2 Documentation General Utils library. This library has broad scope, it can be used by any robot system tests.
8 Library RequestsLibrary
9 Library ./UtilLibrary.py
10 Resource KarafKeywords.robot
11 Resource OpenStackOperations.robot
12 Resource SSHKeywords.robot
13 Resource ../variables/Variables.robot
16 ${default_devstack_prompt_timeout} 10s
17 ${DEVSTACK_SYSTEM_PASSWORD} \ # set to empty, but provide for others to override if desired
18 ${blacklist_file} /tmp/blacklist.txt
19 @{stable/newton_exclusion_regexes} ${EMPTY}
20 @{stable/ocata_exclusion_regexes} ${EMPTY}
21 @{stable/pike_exclusion_regexes} ${EMPTY}
22 @{master_exclusion_regexes} ${EMPTY}
23 ${tempest_dir} /opt/stack/tempest
24 ${tempest_config_file} ${tempest_dir}/etc/tempest.conf
25 ${external_physical_network} physnet1
26 ${external_net_name} external-net
27 ${external_subnet_name} external-subnet
28 # Parameter values below are based on releng/builder - changing them requires updates in releng/builder as well
29 ${external_gateway} 10.10.10.250
30 ${external_subnet_allocation_pool} start=10.10.10.2,end=10.10.10.249
31 ${external_subnet} 10.10.10.0/24
32 ${TEMPEST_TIMEOUT} 420s
33 ${OS_CNTL_CONN_ID} None
34 ${OS_CMP1_CONN_ID} None
35 ${OS_CMP2_CONN_ID} None
36 ${OS_CNTL_IP} ${EMPTY}
37 ${OS_CMP1_IP} ${EMPTY}
38 ${OS_CMP2_IP} ${EMPTY}
39 @{OS_ALL_IPS} @{EMPTY}
40 @{OS_CMP_IPS} @{EMPTY}
44 [Arguments] ${tempest_regex} ${timeout}=${TEMPEST_TIMEOUT} ${debug}=False
45 Run Keyword If "${debug}"=="False" Run Tempest Tests Without Debug ${tempest_regex} timeout=${timeout}
46 Run Keyword If "${debug}"=="True" Run Tempest Tests With Debug ${tempest_regex} timeout=${timeout}
47 Run Keyword If "${debug}"!="True" and "${debug}"!="False" Fail debug argument must be True or False
49 Run Tempest Tests Without Debug
50 [Arguments] ${tempest_regex} ${tempest_directory}=${tempest_dir} ${timeout}=${TEMPEST_TIMEOUT}
51 [Documentation] Using ostestr will allow us to (by default) run tests in paralllel.
52 ... Because of the parallel fashion, we must ensure there is no pause on teardown so that flag in tempest.conf is
53 ... explicitly set to False.
54 Return From Keyword If "skip_if_${OPENSTACK_BRANCH}" in @{TEST_TAGS}
55 Return From Keyword If "skip_if_${SECURITY_GROUP_MODE}" in @{TEST_TAGS}
56 ${tempest_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
57 SSHKeywords.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
58 Write Commands Until Prompt source ${DEVSTACK_DEPLOY_PATH}/openrc admin admin
59 Write Commands Until Prompt cd ${tempest_directory}
61 Tempest Conf Modify Pause On Test Teardown False
62 SSHLibrary.Set Client Configuration timeout=${timeout}
63 # There are tons of deprecation error messages when we use ostestr in our CSIT environment (openstack via devstack)
64 # The robot log files are very large and one culprit is all these deprecation warnings. If we redirect stderr to
65 # /dev/null we should be able to ignore them. We will miss any other errors, however.
66 ${output}= Write Commands Until Prompt ostestr --regex ${tempest_regex} 2>/dev/null timeout=${timeout}
68 SSHLibrary.Close Connection
69 Should Contain ${output} Failed: 0
71 Run Tempest Tests With Debug
72 [Arguments] ${tempest_regex} ${tempest_directory}=${tempest_dir} ${timeout}=${TEMPEST_TIMEOUT}
73 [Documentation] After setting pause_teardown=True in tempest.conf, use the python -m testtools.run module to execute
74 ... a single tempest test case. We need to run only one tempest test case at a time as there will
75 ... be potentional for an unkown number of debug pdb() prompts to catch and continue if we are running multiple
76 ... test cases with a single command. Essentially, this keyword only handles one breakpoint at a single teardown.
77 Return From Keyword If "skip_if_${OPENSTACK_BRANCH}" in @{TEST_TAGS}
78 Return From Keyword If "skip_if_${SECURITY_GROUP_MODE}" in @{TEST_TAGS}
79 ${tempest_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
80 SSHKeywords.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
81 Write Commands Until Prompt source ${DEVSTACK_DEPLOY_PATH}/openrc admin admin
82 Write Commands Until Prompt cd ${tempest_directory}
84 Tempest Conf Modify Pause On Test Teardown True
85 SSHLibrary.Set Client Configuration timeout=${timeout}
86 SSHLibrary.Write python -m testtools.run ${tempest_regex}
87 ${output}= SSHLibrary.Read Until Regexp ${DEFAULT_LINUX_PROMPT_STRICT}|pdb.set_trace()
90 Get Test Teardown Debugs
91 SSHLibrary.Switch Connection ${tempest_conn_id}
92 SSHLibrary.Write continue
93 ${output}= SSHLibrary.Read Until Regexp ${DEFAULT_LINUX_PROMPT_STRICT}|pdb.set_trace()
95 SSHLibrary.Write continue
96 ${output}= SSHLibrary.Read Until Prompt
98 SSHLibrary.Close Connection
99 Should Contain ${output} OK
100 Should Not Contain ${output} FAILED
103 OpenStackOperations.OpenStack Suite Setup
104 Log In To Tempest Executor And Setup Test Environment
106 Log In To Tempest Executor And Setup Test Environment
107 [Documentation] Initialize SetupUtils, open SSH connection to a devstack system and source the openstack
108 ... credentials needed to run the tempest tests. The (sometimes empty) tempest blacklist file will be created
109 ... and pushed to the tempest executor.
110 Create Blacklist File
111 # Tempest tests need an existing external network in order to create routers.
112 Create Network ${external_net_name} --external --default --provider-network-type flat --provider-physical-network ${PUBLIC_PHYSICAL_NETWORK}
113 Create Subnet ${external_net_name} ${external_subnet_name} ${external_subnet} --gateway ${external_gateway} --allocation-pool ${external_subnet_allocation_pool}
115 ${control_node_conn_id}= SSHLibrary.Open Connection ${OS_CONTROL_NODE_IP} prompt=${DEFAULT_LINUX_PROMPT_STRICT}
116 SSHKeywords.Flexible SSH Login ${OS_USER}
117 Write Commands Until Prompt source ${DEVSTACK_DEPLOY_PATH}/openrc admin admin
118 Write Commands Until Prompt sudo rm -rf /opt/stack/tempest/.testrepository
119 ${net_id}= Get Net Id ${external_net_name}
120 Tempest Conf Add External Network And Floating Network Name ${net_id}
122 Tempest Conf Add External Network And Floating Network Name
123 [Arguments] ${external_network_id}
124 [Documentation] Tempest will be run with a config file - this function will add the
125 ... given external network ID to the configuration file.
126 Modify Config In File On Existing SSH Connection ${tempest_config_file} set network public_network_id ${external_network_id}
127 Modify Config In File On Existing SSH Connection ${tempest_config_file} set DEFAULT debug False
128 Modify Config In File On Existing SSH Connection ${tempest_config_file} set DEFAULT log_level INFO
129 Modify Config In File On Existing SSH Connection ${tempest_config_file} set network floating_network_name ${external_net_name}
130 Write Commands Until Prompt sudo cat ${tempest_config_file}
131 Write Commands Until Prompt sudo chmod 777 ${tempest_config_file}
133 Tempest Conf Modify Pause On Test Teardown
134 [Arguments] ${pause_flag}
135 [Documentation] Sets the DEFAULT section flag for pausing the test teardown. If True the tempest test case
136 ... being executed will break to a pdb() debug shell when it hits it's teardown() function.
137 Modify Config In File On Existing SSH Connection ${tempest_config_file} set DEFAULT pause_teardown ${pause_flag}
139 Modify Config In File On Existing SSH Connection
140 [Arguments] ${config_file} ${modifier} ${config_section} ${config_key} ${config_value}=${EMPTY}
141 [Documentation] uses crudini to populate oslo cofg file.
142 # this keyword is only one line so seems like extra overhead, but this may be a good candidate to move
143 # to a library at some point, when/if other suites need to use it, so wanted to make it generic.
144 Write Commands Until Prompt sudo -E crudini --${modifier} ${config_file} ${config_section} ${config_key} ${config_value}
146 Create Blacklist File
147 [Documentation] For each exclusion regex in the required @{${OPENSTACK_BRANCH}_exclusion_regexes} list a new
148 ... line will be created in the required ${blacklist_file} location. This file is pushed to the OS_CONTROL_NODE
149 ... which is assumed to be the tempest executor.
150 OperatingSystem.Create File ${blacklist_file}
151 : FOR ${exclusion} IN @{${OPENSTACK_BRANCH}_exclusion_regexes}
152 \ OperatingSystem.Append To File ${blacklist_file} ${exclusion}\n
153 Log File ${blacklist_file}
154 SSHKeywords.Copy File To Remote System ${OS_CONTROL_NODE_IP} ${blacklist_file} ${blacklist_file}
157 [Arguments] ${name} ${ip}
158 ${conn_id} = SSHLibrary.Open Connection ${ip} prompt=${DEFAULT_LINUX_PROMPT}
159 SSHKeywords.Flexible SSH Login ${OS_USER} ${DEVSTACK_SYSTEM_PASSWORD}
160 BuiltIn.Set Suite Variable \${${name}} ${conn_id}
164 [Arguments] ${odl_ip}=${ODL_SYSTEM_IP}
165 [Documentation] Open connections to the nodes
166 Get DevStack Nodes Data
167 Create Session session http://${odl_ip}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
168 SSHLibrary.Set Default Configuration timeout=${default_devstack_prompt_timeout}
169 Run Keyword If 0 < ${NUM_OS_SYSTEM} Open Connection OS_CNTL_CONN_ID ${OS_CONTROL_NODE_IP}
170 Run Keyword If 1 < ${NUM_OS_SYSTEM} Open Connection OS_CMP1_CONN_ID ${OS_COMPUTE_1_IP}
171 Run Keyword If 2 < ${NUM_OS_SYSTEM} Open Connection OS_CMP2_CONN_ID ${OS_COMPUTE_2_IP}
173 Write Commands Until Prompt
174 [Arguments] ${cmd} ${timeout}=${default_devstack_prompt_timeout}
175 [Documentation] quick wrapper for Write and Read Until Prompt Keywords to make test cases more readable
176 SSHLibrary.Set Client Configuration timeout=${timeout}
178 SSHLibrary.Write ${cmd};echo Command Returns $?
179 ${output}= SSHLibrary.Read Until Prompt
182 Write Commands Until Prompt And Log
183 [Arguments] ${cmd} ${timeout}=${default_devstack_prompt_timeout}
184 [Documentation] quick wrapper for Write and Read Until Prompt Keywords to make test cases more readable
185 ${output} = Write Commands Until Prompt ${cmd} ${timeout}
189 Log Devstack Nodes Data
190 ${output} = BuiltIn.Catenate SEPARATOR=\n OS_CNTL_HOSTNAME: ${OS_CNTL_HOSTNAME} - OS_CNTL_IP: ${OS_CNTL_IP} - OS_CONTROL_NODE_IP: ${OS_CONTROL_NODE_IP} OS_CMP1_HOSTNAME: ${OS_CMP1_HOSTNAME} - OS_CMP1_IP: ${OS_CMP1_IP} - OS_COMPUTE_1_IP: ${OS_COMPUTE_1_IP} OS_CMP2_HOSTNAME: ${OS_CMP2_HOSTNAME} - OS_CMP2_IP: ${OS_CMP2_IP} - OS_COMPUTE_2_IP: ${OS_COMPUTE_2_IP} OS_ALL_IPS: @{OS_ALL_IPS}
191 ... OS_CMP_IPS: @{OS_CMP_IPS}
192 BuiltIn.Log DevStack Nodes Data:\n${output}
194 Get DevStack Hostnames
195 [Documentation] Assign hostname global variables for DevStack nodes
196 ${OS_CNTL_HOSTNAME} = OpenStackOperations.Get Hypervisor Hostname From IP ${OS_CNTL_IP}
197 ${OS_CMP1_HOSTNAME} = OpenStackOperations.Get Hypervisor Hostname From IP ${OS_CMP1_IP}
198 ${OS_CMP2_HOSTNAME} = OpenStackOperations.Get Hypervisor Hostname From IP ${OS_CMP2_IP}
199 BuiltIn.Set Suite Variable ${OS_CNTL_HOSTNAME}
200 BuiltIn.Set Suite Variable ${OS_CMP1_HOSTNAME}
201 BuiltIn.Set Suite Variable ${OS_CMP2_HOSTNAME}
203 Set Node Data For Control And Compute Node Setup
204 [Documentation] Assign global variables for DevStack nodes where the control node is also the compute
205 BuiltIn.Set Suite Variable ${OS_CMP1_IP} ${OS_CNTL_IP}
206 BuiltIn.Set Suite Variable ${OS_CMP2_IP} ${OS_COMPUTE_1_IP}
207 BuiltIn.Set Suite Variable @{OS_ALL_IPS} ${OS_CNTL_IP} ${OS_CMP2_IP}
208 BuiltIn.Set Suite Variable @{OS_CMP_IPS} ${OS_CMP1_IP} ${OS_CMP2_IP}
210 Set Node Data For Control Only Node Setup
211 [Documentation] Assign global variables for DevStack nodes where the control node is different than the compute
212 BuiltIn.Set Suite Variable ${OS_CMP1_IP} ${OS_COMPUTE_1_IP}
213 BuiltIn.Set Suite Variable ${OS_CMP2_IP} ${OS_COMPUTE_2_IP}
214 BuiltIn.Set Suite Variable @{OS_ALL_IPS} ${OS_CNTL_IP} ${OS_CMP1_IP} ${OS_CMP2_IP}
215 BuiltIn.Set Suite Variable @{OS_CMP_IPS} ${OS_CMP1_IP} ${OS_CMP2_IP}
217 Get DevStack Nodes Data
218 [Documentation] Assign global variables for DevStack nodes
219 BuiltIn.Set Suite Variable ${OS_CNTL_IP} ${OS_CONTROL_NODE_IP}
220 Run Keyword If '${OS_COMPUTE_2_IP}' == '${EMPTY}' Set Node Data For Control And Compute Node Setup
221 ... ELSE Set Node Data For Control Only Node Setup
222 Get DevStack Hostnames
223 Log Devstack Nodes Data