Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 37 additions & 17 deletions inventory/local_test/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,48 @@
ansible_python_interpreter: /usr/bin/python3

validation:
# Check if OpenNebula services are running
core_services: true
# List of services to check enabled, stop and restart
service_list:
- name: opennebula.service
desc: OpenNebula core (oned)
- name: opennebula-gate.service
desc: OpenNebula gate
- name: opennebula-flow.service
desc: OpenNebula flow
check_fireedge_ui: false
run_core_services: true
core_services:
# List of services to check enabled, stop and restart
service_list:
- name: opennebula.service
desc: OpenNebula core (oned)
- name: opennebula-gate.service
desc: OpenNebula gate
- name: opennebula-flow.service
desc: OpenNebula flow
check_fireedge_ui: false
run_storage_benchmark: false
run_fe_ha: false
run_network_benchmark: true
create_vnet: false

run_test_vm: true
test_vm:
create_vnet: true
vnet:
name: 'test-vnet'
desc: 'A test network for post-deployment cloud verification'
bridge: 'br-test'
vn_mad: 'dummy'
phydev: 'eth1'
network_address: '192.168.150.100'
network_mask: '255.255.255.0'
dns: '8.8.8.8'
gateway: '192.168.150.1'
ar:
- type: "IP4"
ip: '192.168.150.100'
size: '10'
vm:
check_connection: false
market_name: 'Alpine Linux 3.21'
# template_extra: |
# MEMORY="512"

conn_matrix:
bridge_name: br0
vnet_name: public
vm:
check_connection: false
market_name: 'Alpine Linux 3.21'
# template_extra: |
# MEMORY="512"

run_vm_ha: true
vm_ha:
produce_error_method: 'if_down'
Expand Down
84 changes: 47 additions & 37 deletions inventory/reference/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,64 @@
ansible_python_interpreter: /usr/bin/python3

validation:
# Check if OpenNebula services are running
core_services: true
run_ha_verifications: true
# List of services to check enabled, stop and restart
service_list:
- name: opennebula.service
desc: OpenNebula core (oned)
- name: opennebula-gate.service
desc: OpenNebula gate
- name: opennebula-flow.service
desc: OpenNebula flow
# NOTE: Scheduler service is always checked in earlier than 6.99 versions
# - name: opennebula-scheduler.service
# desc: OpenNebula Scheduler
- name: opennebula-fireedge.service
desc: OpenNebula Fireedge GUI
check_fireedge_ui: true

run_fe_ha: false

run_core_services: true
core_services:
# List of services to check enabled, stop and restart
service_list:
- name: opennebula.service
desc: OpenNebula core (oned)
- name: opennebula-gate.service
desc: OpenNebula gate
- name: opennebula-flow.service
desc: OpenNebula flow
# NOTE: Scheduler service is always checked in earlier than 6.99 versions
# - name: opennebula-scheduler.service
# desc: OpenNebula Scheduler
- name: opennebula-fireedge.service
desc: OpenNebula Fireedge GUI
# Add other services if more should be checked.
check_fireedge_ui: true

run_storage_benchmark: true
storage_benchmark:
vnet_name: vxlan

run_network_benchmark: true
network_benchmark:
iperf_port: 5201
iperf_test_time: 10
create_vnet: true

conn_matrix:
bridge_name: br-test
ping_count: 10
vnet_name: VLAN_580
vm:
check_connection: true
market_name: 'Alpine Linux 3.21'
template_extra: |
MEMORY="512"
vnet:
name: 'VLAN_580'
desc: 'A test network for post-deployment cloud verification'
bridge: 'br-test'
vn_mad: 'dummy'
phydev: ''
network_address: '10.0.0.0'
network_mask: '255.255.255.0'
dns: '8.8.8.8'
gateway: '10.0.0.1'
ar:
- type: "IP4"
ip: '10.0.0.10'
size: '10'

run_test_vm: true
test_vm:
vm:
check_connection: true
market_name: 'Alpine Linux 3.21'
template_extra: |
MEMORY="512"
create_vnet: true
vnet:
name: 'tes-vnet'
desc: 'A test network for post-deployment cloud verification'
bridge: 'br-test'
vn_mad: 'dummy'
phydev: 'eth1'
network_address: '192.168.150.100'
network_mask: '255.255.255.0'
dns: '8.8.8.8'
gateway: '192.168.150.1'
ar:
- type: "IP4"
ip: '192.168.150.100'
size: '10'

run_vm_ha: false
vm_ha:
produce_error_method: 'if_down'
Expand Down
4 changes: 2 additions & 2 deletions playbooks/cleanup-test-vm-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- hosts: "{{ frontend_group | d('frontend') }}"
tasks:
# Only execute these steps on a single frontend host
- when: hostvars[groups[frontend_group | d('frontend')][0]]['ansible_host'] == ansible_host
- when: validation.run_test_vm | default(true) and hostvars[groups[frontend_group | d('frontend')][0]]['ansible_host'] == ansible_host
block:
- name: Cleanup test template
ansible.builtin.shell: |
Expand All @@ -22,4 +22,4 @@
ansible.builtin.file:
path: /tmp/test_vm_template_extra.txt
state: absent
when: validation.vm.template_extra is defined
when: validation.test_vm.vm.template_extra is defined
2 changes: 1 addition & 1 deletion playbooks/fe-ha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
- hosts: "{{ frontend_group | d('frontend') }}"
roles:
- role: fe_ha
when: validation.run_ha_verifications == true
when: validation.run_fe_ha == true

9 changes: 5 additions & 4 deletions playbooks/prepare-test-vm-template.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- hosts: "{{ frontend_group | d('frontend') }}"
tasks:
# Only execute these steps on a single frontend host
- when: hostvars[groups[frontend_group | d('frontend')][0]]['ansible_host'] == ansible_host
- when: validation.run_test_vm | default(true) and hostvars[groups[frontend_group | d('frontend')][0]]['ansible_host'] == ansible_host
block:
- name: Download test VM template and image from the Marketplace
ansible.builtin.shell: |
Expand Down Expand Up @@ -32,16 +32,16 @@

- name: Write extra template variables to a temporary file on the remote host
ansible.builtin.copy:
content: "{{ validation.vm.template_extra }}"
content: "{{ validation.test_vm.vm.template_extra }}"
dest: "/tmp/test_vm_template_extra.txt"
when: validation.vm.template_extra is defined
when: validation.test_vm.vm.template_extra is defined

- name: Update VM template with extra data
ansible.builtin.shell: >
onetemplate update --append {{ vm_template_id.stdout }} /tmp/test_vm_template_extra.txt
register: update_vm_template_extra
failed_when: update_vm_template_extra.rc != 0
when: validation.vm.template_extra is defined
when: validation.test_vm.vm.template_extra is defined

- name: Get VM template as JSON
ansible.builtin.shell: >
Expand All @@ -59,3 +59,4 @@
ansible.builtin.set_fact:
test_vm_template_id: "{{ hostvars[groups[frontend_group | d('frontend')][0]]['vm_template_id'].stdout }}"
test_vm_template_image_id: "{{ hostvars[groups[frontend_group | d('frontend')][0]]['vm_template_image_id'] }}"
when: validation.run_test_vm | default(true)
2 changes: 1 addition & 1 deletion playbooks/tasks/conn_matrix_per_host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
onetemplate instantiate {{ test_vm_template_id }} --nic {{ _conn_matrix_vnet_name }} \
--name conn-mtx-vm-on-host-{{ host_id }} --raw '{{
(extra_template_content_raw.content | b64decode) +
(validation.vm.template_extra if validation.vm.template_extra is defined else "")
(validation.test_vm.vm.template_extra if validation.test_vm.vm.template_extra is defined else "")
}}'
register: vm_id
failed_when: "vm_id.rc != 0"
Expand Down
20 changes: 11 additions & 9 deletions playbooks/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@

- name: Set playbook variables for test VM
set_fact:
_test_vm_name: "{{ validation.vm.market_name | d('Alpine Linux 3.21') }}"
_test_vm_name: "{{ validation.test_vm.vm.market_name | d('Alpine Linux 3.21') }}"
# NOTE: Optional parameters, can be overridden in the inventory file
# validation.vm.template_extra: |
# validation.test_vm.vm.template_extra: |
# MEMORY=256
when: validation.run_test_vm | default(true)

- name: Save the output of the hostname command to the hostname variable
ansible.builtin.shell: hostname
Expand All @@ -29,6 +30,7 @@
- hosts: "{{ frontend_group | d('frontend') }}"
roles:
- role: test_vm
when: validation.run_test_vm | default(true)
- role: storage-benchmark
tasks:
# Only execute these steps on a single frontend host
Expand Down Expand Up @@ -58,6 +60,11 @@

- ansible.builtin.import_playbook: ./conn-matrix.yml

# Run network tests on the hypervisor hosts
- hosts: "{{ node_group | d('node') }}"
roles:
- role: network-benchmark

- ansible.builtin.import_playbook: ./vm-ha.yml

- ansible.builtin.import_playbook: ./cleanup-test-vm-template.yml
Expand All @@ -68,14 +75,9 @@
- role: validation


# Run FE HA verfification only when variable run_ha_verifications is set to true
# Run FE HA verfification only when variable run_fe_ha is set to true
- hosts: "{{ frontend_group | d('frontend') }}"
roles:
- role: fe_ha
when: validation.run_ha_verifications == true
when: validation.run_fe_ha == true


# Run network tests on the hypervisor hosts
- hosts: "{{ node_group | d('node') }}"
roles:
- role: network-benchmark
43 changes: 22 additions & 21 deletions roles/test_vm/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
---
# Vars for the test network
validation:
# Should we create a test network or reuse existing net? Existin network defined in {{validation.vnet.name}} var
create_vnet: true
vm:
check_connection: true
market_name: 'Alpine Linux 3.21'
template_extra: |
MEMORY="512"
vnet:
name: 'VLAN_580'
desc: 'A test network for post-deployment cloud verification'
bridge: 'br-test'
vn_mad: 'dummy'
phydev: ''
network_address: '10.0.0.0'
network_mask: '255.255.255.0'
dns: '8.8.8.8'
gateway: '10.0.0.1'
ar:
- type: "IP4"
ip: '10.0.0.10'
size: '10'
test_vm:
# Should we create a test network or reuse existing net? Existin network defined in {{validation.test_vm.vnet.name}} var
create_vnet: true
vm:
check_connection: true
market_name: 'Alpine Linux 3.21'
template_extra: |
MEMORY="512"
vnet:
name: 'VLAN_580'
desc: 'A test network for post-deployment cloud verification'
bridge: 'br-test'
vn_mad: 'dummy'
phydev: ''
network_address: '10.0.0.0'
network_mask: '255.255.255.0'
dns: '8.8.8.8'
gateway: '10.0.0.1'
ar:
- type: "IP4"
ip: '10.0.0.10'
size: '10'

20 changes: 10 additions & 10 deletions roles/test_vm/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
---

- name: Create vnet
when: validation.create_vnet
when: validation.test_vm.create_vnet
block:
- name: Verify connection to the VNET default gateway
ansible.builtin.shell: >
ping -c 2 {{ validation.vnet.gateway }}
ping -c 2 {{ validation.test_vm.vnet.gateway }}
register: gw_ping_result
until: gw_ping_result.rc == 0
retries: 10
delay: 10
when: validation.vm.check_connection
when: validation.test_vm.vm.check_connection

- name: Render vnet config
template:
src: test_vnet.j2
dest: /var/tmp/vnet_{{ validation.vnet.name }}.template
dest: /var/tmp/vnet_{{ validation.test_vm.vnet.name }}.template

- name: Create network
ansible.builtin.shell: >
onevnet create /var/tmp/vnet_{{ validation.vnet.name }}.template
onevnet create /var/tmp/vnet_{{ validation.test_vm.vnet.name }}.template
register: test_network
failed_when: "test_network.rc != 0"

- name: Delete vnet definition
file:
path: /var/tmp/vnet_{{ validation.vnet.name }}.template
path: /var/tmp/vnet_{{ validation.test_vm.vnet.name }}.template
state: absent

- name: Verify test network creation
Expand Down Expand Up @@ -65,11 +65,11 @@
verification_result: "{{ verification_result | combine({'Test VM instantiation' : 'ok' }) }}"

- name: Check connection to VM
when: validation.vm.check_connection
when: validation.test_vm.vm.check_connection
block:
- name: Attach NIC to test VM
ansible.builtin.shell: >
onevm nic-attach -n '{{ validation.vnet.name }}' {{ vm_id.stdout.split(':')[1] | trim }}
onevm nic-attach -n '{{ validation.test_vm.vnet.name }}' {{ vm_id.stdout.split(':')[1] | trim }}

- name: Wait until NIC is attached
ansible.builtin.shell: >
Expand Down Expand Up @@ -115,7 +115,7 @@
#
- name: Cleanup created test network
ansible.builtin.shell: |
onevnet delete "{{ validation.vnet.name }}"
onevnet delete "{{ validation.test_vm.vnet.name }}"
register: cleanup_result
failed_when: "cleanup_result.rc != 0"
when: validation.create_vnet and not validation.vm.check_connection
when: validation.test_vm.create_vnet and not validation.test_vm.vm.check_connection
Loading