diff options
Diffstat (limited to 'xci/playbooks/roles')
11 files changed, 188 insertions, 117 deletions
diff --git a/xci/playbooks/roles/create-vm-nodes/tasks/create_vm.yml b/xci/playbooks/roles/create-vm-nodes/tasks/create_vm.yml index 008e5531..700c6c72 100644 --- a/xci/playbooks/roles/create-vm-nodes/tasks/create_vm.yml +++ b/xci/playbooks/roles/create-vm-nodes/tasks/create_vm.yml @@ -1,13 +1,8 @@ --- -# Create a VM and volume for it, save its MAC address -- shell: "sudo virsh list --all | grep 'shut off' | wc -l" - register: num_vms - - name: "Creating VM" block: - # NOTE(pas-ha) item here refers to name of the vm - set_fact: - vm_name: "{{ node_names[num_vms.stdout | int] }}" + vm_name: "{{ node_names[item.0 | int] }}" - set_fact: vm_log_file: "{{ node_logdir }}/{{ vm_name }}_console.log" @@ -41,7 +36,7 @@ register: _vm_volume_prepared - name: Resize opnfv VM image to {{ item.disks[0].disk_capacity }} - command: "qemu-img resize {{ opnfv_image_path }}/opnfv.qcow2 {{ item.disks[0].disk_capacity }}" + command: "qemu-img resize {{ opnfv_image_path }}/opnfv.qcow2 {{ item.1.disks[0].disk_capacity }}" when: - vm_name == 'opnfv' - _vm_volume_prepared.stat.exists @@ -52,7 +47,7 @@ command: > virsh --connect {{ vm_libvirt_uri }} vol-create-as {{ node_storage_pool }} {{ vm_name }}.qcow2 - {{ item.disks[0].disk_capacity }} + {{ item.1.disks[0].disk_capacity }} --format qcow2 {{ prealloc|default("") }} when: - not _vm_volume_prepared.stat.exists @@ -115,7 +110,7 @@ when: vbmc_list.stdout.find(vm_name) != -1 - set_fact: - virtual_ipmi_port: "{{ (vm_ipmi_port_start|default(623) | int ) + (num_vms.stdout | int ) }}" + virtual_ipmi_port: "{{ (vm_ipmi_port_start|default(623) | int ) + (item.0 | int) }}" - name: plug vm into vbmc command: vbmc add {{ vm_name }} --libvirt-uri {{ vm_libvirt_uri }} --port {{ virtual_ipmi_port }} @@ -135,7 +130,7 @@ - name: Fetch the ip set_fact: - vm_ip: "{%- for interface in item.interfaces %}{%- if 'native' in (interface.vlan | string) %}{{ interface.address }}{%- endif %}{%- endfor %}" + vm_ip: "{%- for interface in item.1.interfaces %}{%- if 'native' in (interface.vlan | string) %}{{ interface.address }}{%- endif %}{%- endfor %}" # Assumes there is only a single NIC per VM - name: get MAC from vm XML @@ -155,17 +150,17 @@ power: ipmi_address: "192.168.122.1" ipmi_port: "{{ virtual_ipmi_port }}" - ipmi_username: "{{ item.remote_management.user }}" - ipmi_password: "{{ item.remote_management.pass }}" + ipmi_username: "{{ item.1.remote_management.user }}" + ipmi_password: "{{ item.1.remote_management.pass }}" nics: - mac: "{{ vm_mac }}" ansible_ssh_host: "{{ vm_ip }}" ipv4_address: "{{ vm_ip }}" properties: - cpu_arch: "{{ item.node.arch }}" - ram: "{{ item.node.memory.rstrip('G') }}" - cpus: "{{ item.node.cpus }}" - disk_size: "{{ item.disks[0].disk_capacity.rstrip('G') }}" + cpu_arch: "{{ item.1.node.arch }}" + ram: "{{ item.1.node.memory.rstrip('G') }}" + cpus: "{{ item.1.node.cpus }}" + disk_size: "{{ item.1.disks[0].disk_capacity.rstrip('G') }}" - name: add created vm info set_fact: @@ -177,4 +172,4 @@ opnfv_vm_ip: "{{ vm_ip }}" when: vm_name == 'opnfv' - when: (num_nodes | int) > (num_vms.stdout | int) + when: (num_nodes | int) > (item.0 | int) diff --git a/xci/playbooks/roles/create-vm-nodes/tasks/main.yml b/xci/playbooks/roles/create-vm-nodes/tasks/main.yml index 7e0090e4..c1cee6dc 100644 --- a/xci/playbooks/roles/create-vm-nodes/tasks/main.yml +++ b/xci/playbooks/roles/create-vm-nodes/tasks/main.yml @@ -18,7 +18,7 @@ # First we create the opnfv_vm - include_tasks: create_vm.yml - with_items: "{{ [opnfv_vm] + nodes }}" + with_indexed_items: "{{ [opnfv_vm] + nodes }}" - name: Start the opnfv vm virt: diff --git a/xci/playbooks/roles/create-vm-nodes/templates/vm.xml.j2 b/xci/playbooks/roles/create-vm-nodes/templates/vm.xml.j2 index c44fa6aa..5c235f55 100644 --- a/xci/playbooks/roles/create-vm-nodes/templates/vm.xml.j2 +++ b/xci/playbooks/roles/create-vm-nodes/templates/vm.xml.j2 @@ -1,9 +1,9 @@ <domain type='{{ vm_domain_type }}'> <name>{{ vm_name }}</name> - <memory unit='GiB'>{{ item.node.memory.rstrip('G') }}</memory> - <vcpu>{{ item.node.cpus }}</vcpu> + <memory unit='GiB'>{{ item.1.node.memory.rstrip('G') }}</memory> + <vcpu>{{ item.1.node.cpus }}</vcpu> <os> - <type arch='{{ item.node.arch }}' machine='{{ item.node.model }}'>hvm</type> + <type arch='{{ item.1.node.arch }}' machine='{{ item.1.node.model }}'>hvm</type> {%- if 'opnfv' in vm_name -%} <boot dev='hd'/> {%- else -%} @@ -17,7 +17,7 @@ <apic/> <pae/> </features> - <cpu mode='{{ item.node.cpu_cflags }}'> + <cpu mode='{{ item.1.node.cpu_cflags }}'> <model fallback='allow'/> </cpu> <clock offset='utc'/> @@ -36,7 +36,7 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> {% set native_interfaces = [] %} - {%- for interface in item.interfaces %} + {%- for interface in item.1.interfaces %} {%- if 'native' in (interface.vlan | string) %} {%- set _ = native_interfaces.append(interface) %} {%- endif %} diff --git a/xci/playbooks/roles/prepare-functest/templates/run-functest.sh.j2 b/xci/playbooks/roles/prepare-functest/templates/run-functest.sh.j2 deleted file mode 100644 index 6e62a3bb..00000000 --- a/xci/playbooks/roles/prepare-functest/templates/run-functest.sh.j2 +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash - -# Variables that we need to pass from XCI to functest -XCI_ENV=(INSTALLER_TYPE XCI_FLAVOR OPENSTACK_OSA_VERSION CI_LOOP BUILD_TAG NODE_NAME FUNCTEST_MODE FUNCTEST_SUITE_NAME OPNFV_FUNCTEST_HEALTHCHECK_DOCKER_IMAGE_DIGEST) - -# Create directory to store functest logs -mkdir -p ~/results/ - -# Extract variables from xci.env file -if [[ -e /root/xci.env ]]; then - for x in ${XCI_ENV[@]}; do - grep "^${x}=" /root/xci.env >> /root/env - done - # Parse the XCI's DEPLOY_SCENARIO and XCI_FLAVOR variables and - # set the functest container's DEPLOY_SCENARIO variable in the - # following format <scenario>-<flavor>. But the XCI's mini flavor - # is converted into noha. - DEPLOY_SCENARIO=`grep -Po '(?<=DEPLOY_SCENARIO=).*' /root/xci.env` - XCI_FLAVOR=`grep -Po '(?<=XCI_FLAVOR=).*' /root/xci.env` - XCI_FLAVOR=${XCI_FLAVOR/mini/noha} - echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO-$XCI_FLAVOR" >> /root/env -fi - -# Dump the env file -echo "------------------------------------------------------" -echo "------------- functest environment file --------------" -cat /root/env -echo "------------------------------------------------------" - -# we need to ensure the necessary environment variables are sourced -source /root/env - -{% if 'os-' in deploy_scenario %} -{# stuff needed for OpenStack based scenarios #} -source /root/openrc - -openstack --insecure network create --external \ - --provider-physical-network flat \ - --provider-network-type flat {{ external_network }} - -openstack --insecure subnet create --network {{ external_network }} \ - --allocation-pool {{ allocation_pool }} \ - --subnet-range {{ subnet_cidr }} --gateway {{ gateway_ip }} \ - --no-dhcp {{ subnet_name }} - -# the needed images differ between the suites so avoid downloading unnecessary images -if [[ "$FUNCTEST_SUITE_NAME" =~ "healthcheck" ]]; then - mkdir ~/images && cd ~/images && wget -q http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img && cd ~ -elif [[ "$FUNCTEST_SUITE_NAME" =~ "smoke" ]]; then - mkdir -p images && wget -q -O- https://git.opnfv.org/functest/plain/functest/ci/download_images.sh | bash -s -- images && ls -1 images/* -else - echo "Unsupported test suite for functest" - exit 1 -fi - -# docker image to use will be different for healthcheck and smoke test -DOCKER_IMAGE_NAME="ollivier/functest-${FUNCTEST_SUITE_NAME}" - -sudo docker run --env-file env \ - -v $(pwd)/openrc:/home/opnfv/functest/conf/env_file \ - -v $(pwd)/images:/home/opnfv/functest/images \ - -v $(pwd)/results:/home/opnfv/functest/results \ - ${DOCKER_IMAGE_NAME} -{% else %} -{# stuff needed for Kubernetes based scenarios #} -# Create k8s.creds file for functest -KUBE_MASTER_URL=$(grep -r server ~/.kube/config | awk '{print $2}') -KUBE_MASTER_IP=$(echo $KUBE_MASTER_URL | awk -F "[:/]" '{print $4}') -cat << EOF > ~/k8s.creds -KUBERNETES_PROVIDER=local -KUBE_MASTER_URL=$KUBE_MASTER_URL -KUBE_MASTER_IP=$KUBE_MASTER_IP -EOF - -# docker image to use will be different for healthcheck and smoke test -DOCKER_IMAGE_NAME="opnfv/functest-kubernetes-${FUNCTEST_SUITE_NAME}" - -sudo docker run --env-file env \ - -v $(pwd)/k8s.creds:/home/opnfv/functest/conf/env_file \ - -v $(pwd)/.kube/config:/root/.kube/config \ - -v $(pwd)/results:/home/opnfv/functest/results \ - $DOCKER_IMAGE_NAME -{% endif %} - diff --git a/xci/playbooks/roles/prepare-functest/defaults/main.yml b/xci/playbooks/roles/prepare-tests/defaults/main.yml index a3638302..a3638302 100644 --- a/xci/playbooks/roles/prepare-functest/defaults/main.yml +++ b/xci/playbooks/roles/prepare-tests/defaults/main.yml diff --git a/xci/playbooks/roles/prepare-functest/tasks/main.yml b/xci/playbooks/roles/prepare-tests/tasks/main.yml index c29baca9..1512bbab 100644 --- a/xci/playbooks/roles/prepare-functest/tasks/main.yml +++ b/xci/playbooks/roles/prepare-tests/tasks/main.yml @@ -8,25 +8,25 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -- name: install functest required packages +- name: install required packages package: - name: "{{ functest_required_packages[ansible_pkg_mgr] }}" + name: "{{ required_packages[ansible_pkg_mgr] }}" state: present -# Docker is needed for functest +# Docker is needed for test frameworks - name: Ensure Docker service is started and enabled service: name: docker state: started enabled: yes -- name: install functest required pip packages +- name: install required pip packages pip: - name: "{{ functest_required_pip }}" + name: "{{ required_pip }}" state: present extra_args: '-c https://raw.githubusercontent.com/openstack/requirements/{{ requirements_git_install_branch }}/upper-constraints.txt' -- name: create public network gateway for functest +- name: create public network gateway for testing block: - name: check if the gateway was already set shell: "ip a | grep {{ gateway_ip }}" @@ -40,14 +40,26 @@ when: gateway_ip_result|failed when: deploy_scenario is match("os-.*") -- name: prepare environment file for functest +- name: prepare environment file for tests template: src: env.j2 dest: /root/env mode: 0755 -- name: prepare the script to create networks and run functest +- name: create the script to prepare for testing + template: + src: prepare-tests.sh.j2 + dest: /root/prepare-tests.sh + mode: 0755 + +- name: create the script to run functest template: src: run-functest.sh.j2 dest: /root/run-functest.sh mode: 0755 + +- name: create the script to run yardstick + template: + src: run-yardstick.sh.j2 + dest: /root/run-yardstick.sh + mode: 0755 diff --git a/xci/playbooks/roles/prepare-functest/templates/env.j2 b/xci/playbooks/roles/prepare-tests/templates/env.j2 index d9a3bf32..d9a3bf32 100644 --- a/xci/playbooks/roles/prepare-functest/templates/env.j2 +++ b/xci/playbooks/roles/prepare-tests/templates/env.j2 diff --git a/xci/playbooks/roles/prepare-tests/templates/prepare-tests.sh.j2 b/xci/playbooks/roles/prepare-tests/templates/prepare-tests.sh.j2 new file mode 100644 index 00000000..1b779cb9 --- /dev/null +++ b/xci/playbooks/roles/prepare-tests/templates/prepare-tests.sh.j2 @@ -0,0 +1,46 @@ +#!/bin/bash + +# Variables that we need to pass from XCI to testing +XCI_ENV=(INSTALLER_TYPE XCI_FLAVOR OPENSTACK_OSA_VERSION CI_LOOP BUILD_TAG NODE_NAME FUNCTEST_MODE FUNCTEST_SUITE_NAME FUNCTEST_VERSION) + +# Extract variables from xci.env file +if [[ -e /root/xci.env ]]; then + for x in ${XCI_ENV[@]}; do + grep "^${x}=" /root/xci.env >> /root/env + done + # Parse the XCI's DEPLOY_SCENARIO and XCI_FLAVOR variables and + # set the functest container's DEPLOY_SCENARIO variable in the + # following format <scenario>-<flavor>. But the XCI's mini flavor + # is converted into noha. + DEPLOY_SCENARIO=`grep -Po '(?<=DEPLOY_SCENARIO=).*' /root/xci.env` + XCI_FLAVOR=`grep -Po '(?<=XCI_FLAVOR=).*' /root/xci.env` + XCI_FLAVOR=${XCI_FLAVOR/mini/noha} + echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO-$XCI_FLAVOR" >> /root/env +fi + +# we need to ensure the necessary environment variables are sourced +source /root/env + +{% if 'os-' in deploy_scenario %} +{# stuff needed for OpenStack based scenarios #} +source /root/openrc + +openstack --insecure network create --external \ + --provider-physical-network flat \ + --provider-network-type flat {{ external_network }} + +openstack --insecure subnet create --network {{ external_network }} \ + --allocation-pool {{ allocation_pool }} \ + --subnet-range {{ subnet_cidr }} --gateway {{ gateway_ip }} \ + --no-dhcp {{ subnet_name }} +{% else %} +{# stuff needed for Kubernetes based scenarios #} +# Create k8s.creds file for testing +KUBE_MASTER_URL=$(grep -r server ~/.kube/config | awk '{print $2}') +KUBE_MASTER_IP=$(echo $KUBE_MASTER_URL | awk -F "[:/]" '{print $4}') +cat << EOF > ~/k8s.creds +KUBERNETES_PROVIDER=local +KUBE_MASTER_URL=$KUBE_MASTER_URL +KUBE_MASTER_IP=$KUBE_MASTER_IP +EOF +{% endif %} diff --git a/xci/playbooks/roles/prepare-tests/templates/run-functest.sh.j2 b/xci/playbooks/roles/prepare-tests/templates/run-functest.sh.j2 new file mode 100644 index 00000000..b4cf46d7 --- /dev/null +++ b/xci/playbooks/roles/prepare-tests/templates/run-functest.sh.j2 @@ -0,0 +1,52 @@ +#!/bin/bash + +# Create directory to store functest logs +mkdir -p /root/functest-results/ + +# Dump the env file +echo "------------------------------------------------------" +echo "------------- functest environment file --------------" +cat /root/env +echo "------------------------------------------------------" + +# we need to ensure the necessary environment variables are sourced +source /root/env + +{% if 'os-' in deploy_scenario %} +{# stuff needed for OpenStack based scenarios #} +# the needed images differ between the suites so avoid downloading unnecessary images +echo "Downloading the images needed for functest-$FUNCTEST_SUITE_NAME" +mkdir ~/images && cd ~/images +if [[ "$FUNCTEST_SUITE_NAME" =~ "healthcheck" ]]; then + wget -q http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img +elif [[ "$FUNCTEST_SUITE_NAME" =~ "smoke" ]]; then + wget -q http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img \ + http://testresults.opnfv.org/functest/shaker-image.qcow2 \ + https://cloud-images.ubuntu.com/releases/14.04/release/ubuntu-14.04-server-cloudimg-amd64-disk1.img +else + echo "Unsupported test suite for functest" + exit 1 +fi +echo "------------------------------------------------------" +ls -al . && cd ~ +echo "------------------------------------------------------" + +# docker image to use will be different for healthcheck and smoke test +DOCKER_IMAGE_NAME="opnfv/functest-${FUNCTEST_SUITE_NAME}:${FUNCTEST_VERSION}" + +sudo docker run --env-file env \ + -v $(pwd)/openrc:/home/opnfv/functest/conf/env_file \ + -v $(pwd)/images:/home/opnfv/functest/images \ + -v $(pwd)/functest-results:/home/opnfv/functest/results \ + ${DOCKER_IMAGE_NAME} +{% else %} +{# stuff needed for Kubernetes based scenarios #} +# docker image to use will be different for healthcheck and smoke test +DOCKER_IMAGE_NAME="opnfv/functest-kubernetes-${FUNCTEST_SUITE_NAME}" + +sudo docker run --env-file env \ + -v $(pwd)/k8s.creds:/home/opnfv/functest/conf/env_file \ + -v $(pwd)/.kube/config:/root/.kube/config \ + -v $(pwd)/functest-results:/home/opnfv/functest/results \ + $DOCKER_IMAGE_NAME +{% endif %} diff --git a/xci/playbooks/roles/prepare-tests/templates/run-yardstick.sh.j2 b/xci/playbooks/roles/prepare-tests/templates/run-yardstick.sh.j2 new file mode 100644 index 00000000..6a7fd8be --- /dev/null +++ b/xci/playbooks/roles/prepare-tests/templates/run-yardstick.sh.j2 @@ -0,0 +1,47 @@ +#!/bin/bash + +# Create directory to store yardstick logs +mkdir -p /root/yardstick-results/ + +# Dump the env file +echo "------------------------------------------------------" +echo "------------- yardstick environment file --------------" +cat /root/env +echo "------------------------------------------------------" + +# we need to ensure the necessary environment variables are sourced +source /root/env + +{% if 'os-' in deploy_scenario %} +{# stuff needed for OpenStack based scenarios #} +rc_file_vol="-v /root/openrc:/etc/yardstick/openstack.creds" +{% else %} +{# k8 scenario name is hardcoded for the timebeing until we clarify #} +{# which suite name we should use for the scenarios without yardstick suites #} +DEPLOY_SCENARIO="k8-nosdn-nofeature-noha" +rc_file_vol="-v /root/admin.conf:/etc/yardstick/admin.conf" +{% endif %} + +OS_CACERT="/etc/ssl/certs/haproxy.cert" +DOCKER_IMAGE_NAME="opnfv/yardstick" +YARDSTICK_SCENARIO_SUITE_NAME="opnfv_${DEPLOY_SCENARIO}_daily.yaml" + +# add OS_CACERT to openrc +echo "export OS_CACERT=/etc/yardstick/os_cacert" >> ~/openrc + +opts="--privileged=true --rm" +envs="-e INSTALLER_TYPE=$INSTALLER_TYPE -e INSTALLER_IP=$INSTALLER_IP \ + -e NODE_NAME=$NODE_NAME -e EXTERNAL_NETWORK=$EXTERNAL_NETWORK \ + -e YARDSTICK_BRANCH=master -e BRANCH=master \ + -e DEPLOY_SCENARIO=$DEPLOY_SCENARIO -e CI_DEBUG=true" +cacert_file_vol="-v $OS_CACERT:/etc/yardstick/os_cacert" +map_log_dir="-v /root/yardstick-results:/tmp/yardstick" +sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa" +cmd="sudo docker run ${opts} ${envs} ${rc_file_vol} ${cacert_file_vol} \ + ${map_log_dir} ${sshkey} ${DOCKER_IMAGE_NAME} \ + exec_tests.sh ${YARDSTICK_SCENARIO_SUITE_NAME}" +echo "Running yardstick with the command" +echo "------------------------------------------------------" +echo $cmd +echo "------------------------------------------------------" +$cmd diff --git a/xci/playbooks/roles/prepare-functest/vars/main.yml b/xci/playbooks/roles/prepare-tests/vars/main.yml index 3a6c8a4d..83638466 100644 --- a/xci/playbooks/roles/prepare-functest/vars/main.yml +++ b/xci/playbooks/roles/prepare-tests/vars/main.yml @@ -1,14 +1,17 @@ --- -functest_required_packages: +required_packages: apt: - docker.io - wget + - xz-utils zypper: - docker - wget + - xz yum: - docker - wget + - xz -functest_required_pip: +required_pip: - docker-py |