Set the wait_timeout variable to the deployment script
[releng.git] / prototypes / bifrost / scripts / test-bifrost-deployment.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 Ericsson AB and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 set -eux
12 set -o pipefail
13 export PYTHONUNBUFFERED=1
14 SCRIPT_HOME="$(cd "$(dirname "$0")" && pwd)"
15 BIFROST_HOME=$SCRIPT_HOME/..
16 ANSIBLE_INSTALL_ROOT=${ANSIBLE_INSTALL_ROOT:-/opt/stack}
17 ENABLE_VENV="false"
18 USE_DHCP="false"
19 USE_VENV="false"
20 BUILD_IMAGE=true
21 PROVISION_WAIT_TIMEOUT=${PROVISION_WAIT_TIMEOUT:-2400}
22
23 # Set defaults for ansible command-line options to drive the different
24 # tests.
25
26 # NOTE(TheJulia/cinerama): The variables defined on the command line
27 # for the default and DHCP tests are to drive the use of Cirros as the
28 # deployed operating system, and as such sets the test user to cirros,
29 # and writes a debian style interfaces file out to the configuration
30 # drive as cirros does not support the network_info.json format file
31 # placed in the configuration drive. The "build image" test does not
32 # use cirros.
33
34 TEST_VM_NUM_NODES=3
35 export TEST_VM_NODE_NAMES="jumphost.opnfvlocal controller00.opnfvlocal compute00.opnfvlocal"
36 export VM_DOMAIN_TYPE="kvm"
37 export VM_CPU=4
38 export VM_DISK=100
39 TEST_PLAYBOOK="test-bifrost-infracloud.yaml"
40 USE_INSPECTOR=true
41 USE_CIRROS=false
42 TESTING_USER=root
43 VM_MEMORY_SIZE="8192"
44 DOWNLOAD_IPA=true
45 CREATE_IPA_IMAGE=false
46 INSPECT_NODES=true
47 INVENTORY_DHCP=false
48 INVENTORY_DHCP_STATIC_IP=false
49 WRITE_INTERFACES_FILE=true
50
51 # Set BIFROST_INVENTORY_SOURCE
52 export BIFROST_INVENTORY_SOURCE=/tmp/baremetal.csv
53
54 # DIB custom elements path
55 export ELEMENTS_PATH=/usr/share/diskimage-builder/elements:/opt/puppet-infracloud/files/elements
56
57 # settings for console access
58 export DIB_DEV_USER_PWDLESS_SUDO=yes
59 export DIB_DEV_USER_PASSWORD=devuser
60
61 # settings for distro: trusty/ubuntu-minimal, 7/centos-minimal
62 export DIB_OS_RELEASE=${DIB_OS_RELEASE:-trusty}
63 export DIB_OS_ELEMENT=${DIB_OS_ELEMENT:-ubuntu-minimal}
64
65 # for centos 7: "openssh-server,vim,less,bridge-utils,iputils,rsyslog,curl"
66 export DIB_OS_PACKAGES=${DIB_OS_PACKAGES:-"openssh-server,vlan,vim,less,bridge-utils,language-pack-en,iputils-ping,rsyslog,curl"}
67
68 # Source Ansible
69 # NOTE(TheJulia): Ansible stable-1.9 source method tosses an error deep
70 # under the hood which -x will detect, so for this step, we need to suspend
71 # and then re-enable the feature.
72 set +x +o nounset
73 $SCRIPT_HOME/env-setup.sh
74 source ${ANSIBLE_INSTALL_ROOT}/ansible/hacking/env-setup
75 ANSIBLE=$(which ansible-playbook)
76 set -x -o nounset
77
78 # Change working directory
79 cd $BIFROST_HOME/playbooks
80
81 # Syntax check of dynamic inventory test path
82 for task in syntax-check list-tasks; do
83     ${ANSIBLE} -vvvv \
84            -i inventory/localhost \
85            test-bifrost-create-vm.yaml \
86            --${task}
87     ${ANSIBLE} -vvvv \
88            -i inventory/localhost \
89            ${TEST_PLAYBOOK} \
90            --${task} \
91            -e testing_user=${TESTING_USER}
92 done
93
94 # Create the test VMS
95 ${ANSIBLE} -vvvv \
96        -i inventory/localhost \
97        test-bifrost-create-vm.yaml \
98        -e test_vm_num_nodes=${TEST_VM_NUM_NODES} \
99        -e test_vm_memory_size=${VM_MEMORY_SIZE} \
100        -e enable_venv=${ENABLE_VENV} \
101        -e test_vm_domain_type=${VM_DOMAIN_TYPE}
102
103 # Execute the installation and VM startup test.
104 ${ANSIBLE} -vvvv \
105     -i inventory/bifrost_inventory.py \
106     ${TEST_PLAYBOOK} \
107     -e use_cirros=${USE_CIRROS} \
108     -e testing_user=${TESTING_USER} \
109     -e test_vm_num_nodes=${TEST_VM_NUM_NODES} \
110     -e inventory_dhcp=${INVENTORY_DHCP} \
111     -e inventory_dhcp_static_ip=${INVENTORY_DHCP_STATIC_IP} \
112     -e enable_venv=${ENABLE_VENV} \
113     -e enable_inspector=${USE_INSPECTOR} \
114     -e inspect_nodes=${INSPECT_NODES} \
115     -e download_ipa=${DOWNLOAD_IPA} \
116     -e create_ipa_image=${CREATE_IPA_IMAGE} \
117     -e write_interfaces_file=${WRITE_INTERFACES_FILE} \
118     -e ipv4_gateway=192.168.122.1 \
119     -e wait_timeout=${PROVISION_WAIT_TIMEOUT}
120 EXITCODE=$?
121
122 if [ $EXITCODE != 0 ]; then
123     echo "****************************"
124     echo "Test failed. See logs folder"
125     echo "****************************"
126 fi
127
128 $SCRIPT_HOME/collect-test-info.sh
129
130 exit $EXITCODE