Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 1 | # Copyright 2017 Mirantis, Inc. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
Dmitry Tyzhnenko | 35413c0 | 2018-03-05 14:12:37 +0200 | [diff] [blame] | 14 | import pytest |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 15 | import time |
| 16 | |
| 17 | from collections import Counter |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 18 | |
| 19 | from tcp_tests import logger |
| 20 | from tcp_tests.managers.jenkins.client import JenkinsClient |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 21 | from tcp_tests import settings |
| 22 | |
| 23 | from tcp_tests import managers |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 24 | |
| 25 | LOG = logger.logger |
| 26 | |
| 27 | |
| 28 | class TestOfflineDeployment(object): |
| 29 | """docstring for TestOfflineDeployment""" |
| 30 | |
Dmitry Tyzhnenko | 35413c0 | 2018-03-05 14:12:37 +0200 | [diff] [blame] | 31 | @pytest.mark.day1_underlay |
| 32 | def test_maas_provision(self, show_step, hardware, underlay, |
| 33 | day1_cfg_config): |
| 34 | """Test for deploying an mcp dvr environment and check it |
| 35 | |
| 36 | Scenario: |
| 37 | 1. Prepare salt on hosts |
| 38 | 2. Setup controller nodes |
| 39 | 3. Setup compute nodes |
| 40 | """ |
| 41 | |
| 42 | show_step(1) |
| 43 | show_step(2) |
| 44 | show_step(3) |
| 45 | |
| 46 | cfg_node = 'cfg01.virtual-mcp-pike-dvr.local' |
| 47 | ssh_test_key = day1_cfg_config.config.underlay.ssh_keys[0]['public'] |
| 48 | verbose = True |
| 49 | |
| 50 | cfg_admin_iface = next(i for i in hardware.master_nodes[0].interfaces |
| 51 | if i.network.name == 'admin') |
| 52 | admin_net = cfg_admin_iface.network.address_pool.ip_network |
| 53 | |
| 54 | underlay.check_call( |
| 55 | node_name=cfg_node, verbose=verbose, |
| 56 | cmd='maas logout mirantis && ' |
| 57 | 'maas login mirantis ' |
| 58 | 'http://localhost:5240/MAAS/api/2.0/ ' |
| 59 | 'FTvqwe7ybBp68gPar2:5mcctTAXVL8mns4ef4:zrA9LZwu2tMc8BAZpsPUfwWwTyQnAtDN') # noqa |
| 60 | |
| 61 | underlay.check_call( |
| 62 | node_name=cfg_node, |
| 63 | verbose=verbose, |
| 64 | cmd="maas mirantis package-repository update main_archive " |
| 65 | "disabled_pockets=backports,security") |
| 66 | |
| 67 | underlay.check_call( |
| 68 | node_name=cfg_node, verbose=verbose, |
| 69 | cmd="maas mirantis ipranges create " |
| 70 | "type=dynamic start_ip={start} end_ip={end} " |
| 71 | "subnet=$(maas mirantis subnets read | jq '.[] | select(.name==\"{net}\") | .id')".format( # noqa |
| 72 | start=admin_net[191], |
| 73 | end=admin_net[253], |
| 74 | net=admin_net)) |
| 75 | underlay.check_call(node_name=cfg_node, verbose=verbose, |
| 76 | cmd="maas mirantis vlan update " |
| 77 | "$(maas mirantis subnets read | jq '.[] | select(.name==\"{net}\") | .vlan.fabric_id') " # noqa |
| 78 | "0 dhcp_on=True primary_rack='cfg01'".format(net=admin_net)) |
| 79 | |
| 80 | underlay.check_call( |
| 81 | node_name=cfg_node, verbose=verbose, |
| 82 | cmd="ssh-keygen -y -f ~root/.ssh/id_rsa > ~root/.ssh/id_rsa.pub") |
| 83 | underlay.check_call( |
| 84 | node_name=cfg_node, verbose=verbose, |
| 85 | cmd='maas mirantis sshkeys create ' |
| 86 | 'key="$(cat ~root/.ssh/id_rsa.pub)"') |
| 87 | |
| 88 | r, f = day1_cfg_config.salt.enforce_state('cfg01*', 'maas.machines') |
| 89 | LOG.info(r) |
| 90 | LOG.info(f) |
| 91 | |
| 92 | # show_step(8) |
Dmitry Tyzhnenko | 468564a | 2018-08-23 16:39:06 +0300 | [diff] [blame] | 93 | # nodes_amount = len(hardware.slave_nodes) |
| 94 | # cmd = """ timeout 600s bash -c 'hosts=$(maas mirantis nodes read | jq -r ".[] | select(.node_type_name==\\"Machine\\") | select(.status_name==\\"Ready\\") | .hostname "); while ! [ $(echo "$hosts" | wc -w) -eq {amount} ]; do echo "Ready hosts:\n$hosts"; sleep 30; hosts=$(maas mirantis nodes read | jq -r ".[] | select(.node_type_name==\\"Machine\\") | select(.status_name==\\"Ready\\") | .hostname "); done ' """.format(amount=nodes_amount) # noqa |
| 95 | cmd = """salt-call state.sls maas.machines.wait_for_ready""" |
Dmitry Tyzhnenko | 35413c0 | 2018-03-05 14:12:37 +0200 | [diff] [blame] | 96 | underlay.check_call(node_name=cfg_node, verbose=verbose, cmd=cmd) |
| 97 | underlay.check_call(node_name=cfg_node, verbose=verbose, |
| 98 | cmd='salt-key') |
Dmitry Tyzhnenko | 468564a | 2018-08-23 16:39:06 +0300 | [diff] [blame] | 99 | |
| 100 | r, f = day1_cfg_config.salt.enforce_state( |
| 101 | 'cfg01*', |
| 102 | 'maas.machines.assign_ip') |
| 103 | LOG.info(r) |
| 104 | LOG.info(f) |
| 105 | |
Dmitry Tyzhnenko | 35413c0 | 2018-03-05 14:12:37 +0200 | [diff] [blame] | 106 | # show_step(9) |
| 107 | underlay.check_call( |
| 108 | node_name=cfg_node, verbose=verbose, |
| 109 | cmd='salt-call state.sls maas.machines.deploy') |
| 110 | # show_step(10) |
| 111 | underlay.check_call( |
| 112 | node_name=cfg_node, verbose=verbose, |
| 113 | cmd='salt-call state.sls maas.machines.wait_for_deployed') |
| 114 | underlay.check_call(node_name=cfg_node, verbose=verbose, |
| 115 | cmd='salt-key') |
| 116 | |
| 117 | underlay.check_call( |
| 118 | node_name=cfg_node, |
| 119 | verbose=verbose, |
| 120 | cmd="salt '*' ssh.set_auth_key root '{}'".format(ssh_test_key)) |
| 121 | underlay.check_call( |
| 122 | node_name=cfg_node, |
| 123 | verbose=verbose, |
| 124 | cmd='salt "*" ssh.set_auth_key root ' |
| 125 | '"$(ssh-keygen -y -f ~/.ssh/id_rsa | cut -d " " -f 2)"') |
| 126 | |
| 127 | underlay.check_call( |
| 128 | node_name=cfg_node, |
| 129 | verbose=verbose, |
| 130 | cmd="salt '*' ssh.set_auth_key ubuntu '{}'".format(ssh_test_key)) |
| 131 | underlay.check_call( |
| 132 | node_name=cfg_node, |
| 133 | verbose=verbose, |
| 134 | cmd='salt "*" ssh.set_auth_key ubuntu ' |
| 135 | '"$(ssh-keygen -y -f ~/.ssh/id_rsa | cut -d " " -f 2)"') |
| 136 | |
| 137 | result = \ |
| 138 | day1_cfg_config.salt.get_pillar(cfg_node, |
| 139 | '_param:jenkins_salt_api_url') |
| 140 | result = result[0].get(cfg_node) |
| 141 | |
| 142 | jenkins = JenkinsClient( |
| 143 | host='http://{host}:8081'.format( |
| 144 | host=day1_cfg_config.config.salt.salt_master_host), |
| 145 | username='admin', |
| 146 | password='r00tme') |
| 147 | params = jenkins.make_defults_params('deploy_openstack') |
| 148 | params['SALT_MASTER_URL'] = result |
| 149 | params['STACK_INSTALL'] = "core,openstack,ovs" |
| 150 | build = jenkins.run_build('deploy_openstack', params) |
| 151 | |
| 152 | jenkins.wait_end_of_build( |
| 153 | name=build[0], |
| 154 | build_id=build[1], |
| 155 | timeout=60 * 60 * 2) |
| 156 | |
| 157 | assert \ |
| 158 | jenkins.build_info( |
| 159 | name=build[0], build_id=build[1])['result'] == 'SUCCESS', \ |
| 160 | "Deploy openstack was failed" |
| 161 | |
| 162 | openstack = managers.openstack_manager.OpenstackManager( |
| 163 | day1_cfg_config.config, underlay, hardware, |
| 164 | day1_cfg_config.salt) |
| 165 | |
| 166 | if settings.RUN_TEMPEST: |
| 167 | openstack.run_tempest(pattern=settings.PATTERN) |
| 168 | openstack.download_tempest_report() |
| 169 | |
| 170 | LOG.info("*************** DONE **************") |
| 171 | |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 172 | def test_deploy_day1(self, show_step, config, underlay, hardware, |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 173 | core_deployed, salt_deployed): |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 174 | """Test for deploying an mcp from day01 images |
| 175 | |
| 176 | Scenario: |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 177 | 1. Wait salt master |
| 178 | 2. Addition config of MaaS |
| 179 | 3. Wait dhcpd server |
| 180 | 4. Start comissioning node via MaaS |
| 181 | 5. Wait of comissioning node by MaaS |
| 182 | 6. Start deploing node via MaaS |
| 183 | 7. Wait of deploing node by |
| 184 | 8. Accept all keys |
| 185 | 9. Configure and baremetal nodes after MaaS deployment |
| 186 | 10. Run deploy OS job |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 187 | |
| 188 | """ |
| 189 | # group = hardware._get_default_node_group() |
| 190 | nodes = underlay.node_names() |
| 191 | LOG.info("Nodes - {}".format(nodes)) |
| 192 | cfg_node = 'cfg01.offline-ocata-vxlan.local' |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 193 | tempest_node = 'gtw01.offline-ocata-vxlan.local' |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 194 | verbose = True |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 195 | ssh_test_key = config.underlay.ssh_keys[0]['public'] |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 196 | |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 197 | show_step(1) |
| 198 | underlay.check_call( |
| 199 | node_name=cfg_node, |
| 200 | verbose=verbose, |
| 201 | cmd="""timeout 300s /bin/bash -c """ |
| 202 | """'while ! salt-call test.ping; do """ |
| 203 | """echo "salt master still isnt running"; sleep 10; done'""" |
| 204 | ) # noqa |
| 205 | |
| 206 | show_step(2) |
| 207 | underlay.check_call( |
| 208 | node_name=cfg_node, |
| 209 | verbose=verbose, |
| 210 | cmd='salt-call saltutil.sync_all') |
| 211 | |
| 212 | underlay.check_call( |
| 213 | node_name=cfg_node, |
| 214 | verbose=verbose, |
| 215 | cmd="salt '*' ssh.set_auth_key root '{}'".format(ssh_test_key)) |
| 216 | underlay.check_call( |
| 217 | node_name=cfg_node, |
| 218 | verbose=verbose, |
| 219 | cmd='salt "*" ssh.set_auth_key root ' |
| 220 | '"$(ssh-keygen -y -f ~/.ssh/id_rsa | cut -d " " -f 2)"') |
| 221 | underlay.check_call( |
| 222 | node_name=cfg_node, |
| 223 | verbose=verbose, |
| 224 | cmd="salt '*' ssh.set_auth_key ubuntu '{}'".format(ssh_test_key)) |
| 225 | underlay.check_call( |
| 226 | node_name=cfg_node, |
| 227 | verbose=verbose, |
| 228 | cmd='salt "*" ssh.set_auth_key ubuntu ' |
| 229 | '"$(ssh-keygen -y -f ~/.ssh/id_rsa | cut -d " " -f 2)"') |
| 230 | |
Dmitry Tyzhnenko | 468564a | 2018-08-23 16:39:06 +0300 | [diff] [blame] | 231 | # underlay.check_call( |
| 232 | # node_name=cfg_node, |
| 233 | # verbose=verbose, |
| 234 | # cmd='salt-call state.sls maas.region') |
| 235 | # underlay.check_call( |
| 236 | # node_name=cfg_node, |
| 237 | # verbose=verbose, |
| 238 | # cmd='maas logout mirantis && ' |
| 239 | # 'maas login mirantis ' |
| 240 | # 'http://localhost:5240/MAAS/api/2.0/ ' |
| 241 | # 'FTvqwe7ybBp68gPar2:5mcctTAXVL8mns4ef4:zrA9LZwu2tMc8BAZpsPUfwWwTyQnAtDN' # noqa |
| 242 | # ) |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 243 | |
Dmitry Tyzhnenko | 468564a | 2018-08-23 16:39:06 +0300 | [diff] [blame] | 244 | # underlay.check_call( |
| 245 | # node_name=cfg_node, |
| 246 | # verbose=verbose, |
| 247 | # cmd="maas mirantis maas set-config " |
| 248 | # "name=upstream_dns value='10.10.0.15 8.8.8.8 8.8.4.4'") |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 249 | |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 250 | # underlay.check_call( |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 251 | # node_name=cfg_node, |
| 252 | # verbose=verbose, |
| 253 | # cmd="maas mirantis ipranges create " |
| 254 | # "type=dynamic start_ip=10.10.191.255 end_ip=10.10.255.254 " |
| 255 | # "subnet=$(maas mirantis subnets read | jq '.[] | " |
| 256 | # "select(.name==\"10.10.0.0/16\") | .id')") |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 257 | |
Dmitry Tyzhnenko | 468564a | 2018-08-23 16:39:06 +0300 | [diff] [blame] | 258 | # underlay.check_call( |
| 259 | # node_name=cfg_node, |
| 260 | # verbose=verbose, |
| 261 | # cmd="maas mirantis vlan update " |
| 262 | # "$(maas mirantis subnets read | jq '.[] | " |
| 263 | # "select(.name==\"10.10.0.0/16\") | .vlan.fabric_id') " |
| 264 | # "0 dhcp_on=True primary_rack='cfg01'") |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 265 | |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 266 | underlay.check_call( |
| 267 | node_name=cfg_node, |
| 268 | verbose=verbose, |
| 269 | cmd="ssh-keygen -y -f ~root/.ssh/id_rsa > ~root/.ssh/id_rsa.pub") |
| 270 | underlay.check_call( |
| 271 | node_name=cfg_node, |
| 272 | verbose=verbose, |
| 273 | cmd='maas mirantis sshkeys create ' |
| 274 | 'key="$(cat ~root/.ssh/id_rsa.pub)"') |
| 275 | |
| 276 | show_step(3) |
| 277 | underlay.check_call( |
| 278 | node_name=cfg_node, |
| 279 | verbose=verbose, |
| 280 | cmd="""timeout 90s /bin/bash -c 'while ! pidof dhcpd; do """ |
| 281 | """echo "dhcpd still isnt running"; sleep 10; done'""") |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 282 | |
| 283 | show_step(4) |
| 284 | underlay.check_call( |
| 285 | node_name=cfg_node, |
| 286 | verbose=verbose, |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 287 | cmd='salt-call state.sls maas.machines') |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 288 | show_step(5) |
Dmitry Tyzhnenko | 468564a | 2018-08-23 16:39:06 +0300 | [diff] [blame] | 289 | # cmd = """ timeout 1200s bash -c 'hosts=$(maas mirantis nodes read | jq -r ".[] | select(.node_type_name==\\"Machine\\") | select(.status_name==\\"Ready\\") | .hostname "); while ! [ $(echo "$hosts" | wc -w) -eq 10 ]; do echo "Ready hosts:\n$hosts"; sleep 30; hosts=$(maas mirantis nodes read | jq -r ".[] | select(.node_type_name==\\"Machine\\") | select(.status_name==\\"Ready\\") | .hostname "); done ' """ # noqa |
| 290 | cmd = """salt-call state.sls maas.machines.wait_for_ready""" |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 291 | underlay.check_call(node_name=cfg_node, verbose=verbose, cmd=cmd) |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 292 | underlay.check_call( |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 293 | node_name=cfg_node, verbose=verbose, cmd='salt-key') |
| 294 | underlay.check_call( |
| 295 | node_name=cfg_node, |
| 296 | verbose=verbose, |
| 297 | cmd='salt-call state.sls maas.machines.assign_ip') |
| 298 | show_step(6) |
| 299 | underlay.check_call( |
| 300 | node_name=cfg_node, |
| 301 | verbose=verbose, |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 302 | cmd='salt-call state.sls maas.machines.deploy') |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 303 | show_step(7) |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 304 | underlay.check_call( |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 305 | node_name=cfg_node, |
| 306 | verbose=verbose, |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 307 | cmd='salt-call state.sls maas.machines.wait_for_deployed') |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 308 | underlay.check_call( |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 309 | node_name=cfg_node, verbose=verbose, cmd='salt-key') |
| 310 | |
| 311 | show_step(8) |
| 312 | underlay.check_call( |
| 313 | node_name=cfg_node, |
| 314 | verbose=verbose, |
| 315 | expected=[0, 1], |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 316 | cmd='salt-key -A -y --include-denied --include-rejected') |
| 317 | underlay.check_call( |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 318 | node_name=cfg_node, verbose=verbose, cmd='salt-key') |
| 319 | |
| 320 | show_step(9) |
| 321 | cmd = "salt '*' saltutil.refresh_pillar" |
| 322 | underlay.check_call(node_name=cfg_node, verbose=verbose, cmd=cmd) |
| 323 | cmd = "salt '*' saltutil.sync_all" |
| 324 | underlay.check_call(node_name=cfg_node, verbose=verbose, cmd=cmd) |
| 325 | |
| 326 | underlay.check_call( |
| 327 | node_name=cfg_node, verbose=verbose, cmd="reclass-salt --top") |
| 328 | |
| 329 | cmd = "salt -C " \ |
Dmitry Tyzhnenko | 468564a | 2018-08-23 16:39:06 +0300 | [diff] [blame] | 330 | "'I@salt:control or I@nova:compute or I@ceph:osd' " \ |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 331 | "cmd.run 'touch /run/is_rebooted'" |
| 332 | underlay.check_call(node_name=cfg_node, verbose=verbose, cmd=cmd) |
| 333 | |
| 334 | cmd = "salt --async -C " \ |
| 335 | "'I@salt:control' cmd.run 'salt-call state.sls " \ |
| 336 | "linux.system.user,openssh,linux.network;reboot'" |
| 337 | underlay.check_call(node_name=cfg_node, verbose=verbose, cmd=cmd) |
| 338 | |
| 339 | cmd = "salt --async -C " \ |
| 340 | "'I@nova:compute' cmd.run 'salt-call state.sls " \ |
| 341 | "linux.system.user,openssh,linux.network;reboot'" |
| 342 | underlay.check_call(node_name=cfg_node, verbose=verbose, cmd=cmd) |
| 343 | |
| 344 | cmd = "salt --async -C " \ |
Dmitry Tyzhnenko | 468564a | 2018-08-23 16:39:06 +0300 | [diff] [blame] | 345 | "'I@ceph:osd' cmd.run 'salt-call state.sls " \ |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 346 | "linux.system.user,openssh,linux.network;reboot'" |
| 347 | underlay.check_call(node_name=cfg_node, verbose=verbose, cmd=cmd) |
| 348 | |
| 349 | time.sleep(360) # TODO: Add ssh waiter |
| 350 | |
| 351 | cmd = "salt -C " \ |
Dmitry Tyzhnenko | 468564a | 2018-08-23 16:39:06 +0300 | [diff] [blame] | 352 | "'I@salt:control or I@nova:compute or I@ceph:osd'" \ |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 353 | " test.ping" |
| 354 | underlay.check_call(node_name=cfg_node, verbose=verbose, cmd=cmd) |
| 355 | |
| 356 | cmd = """salt -C """ \ |
Dmitry Tyzhnenko | 468564a | 2018-08-23 16:39:06 +0300 | [diff] [blame] | 357 | """'I@salt:control or I@nova:compute or I@ceph:osd' """ \ |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 358 | """cmd.run '[ -f "/run/is_rebooted" ] && """ \ |
| 359 | """echo "Has not been rebooted!" || echo "Rebooted"' """ |
| 360 | ret = underlay.check_call(node_name=cfg_node, verbose=verbose, cmd=cmd) |
| 361 | count = Counter(ret['stdout_str'].split()) |
| 362 | |
Dmitry Tyzhnenko | 468564a | 2018-08-23 16:39:06 +0300 | [diff] [blame] | 363 | assert count['Rebooted'] == 13, "Should be rebooted 13 baremetal nodes" |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 364 | |
| 365 | underlay.check_call( |
| 366 | node_name=cfg_node, |
| 367 | verbose=verbose, |
| 368 | cmd="salt '*' ssh.set_auth_key root '{}'".format(ssh_test_key)) |
| 369 | underlay.check_call( |
| 370 | node_name=cfg_node, |
| 371 | verbose=verbose, |
| 372 | cmd='salt "*" ssh.set_auth_key root ' |
| 373 | '"$(ssh-keygen -y -f ~/.ssh/id_rsa | cut -d " " -f 2)"') |
| 374 | underlay.check_call( |
| 375 | node_name=cfg_node, |
| 376 | verbose=verbose, |
| 377 | cmd="salt '*' ssh.set_auth_key ubuntu '{}'".format(ssh_test_key)) |
| 378 | underlay.check_call( |
| 379 | node_name=cfg_node, |
| 380 | verbose=verbose, |
| 381 | cmd='salt "*" ssh.set_auth_key ubuntu ' |
| 382 | '"$(ssh-keygen -y -f ~/.ssh/id_rsa | cut -d " " -f 2)"') |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 383 | |
| 384 | salt_api = \ |
| 385 | salt_deployed.get_pillar(cfg_node, '_param:jenkins_salt_api_url') |
| 386 | salt_api = salt_api[0].get(cfg_node) |
| 387 | |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 388 | show_step(10) |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 389 | jenkins = JenkinsClient( |
| 390 | host='http://172.16.44.33:8081', |
| 391 | username='admin', |
| 392 | password='r00tme') |
| 393 | params = jenkins.make_defults_params('deploy_openstack') |
| 394 | params['SALT_MASTER_URL'] = salt_api |
Dmitry Tyzhnenko | 468564a | 2018-08-23 16:39:06 +0300 | [diff] [blame] | 395 | params['STACK_INSTALL'] = \ |
| 396 | 'core,kvm,ceph,cicd,openstack,stacklight,finalize' |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 397 | build = jenkins.run_build('deploy_openstack', params) |
| 398 | |
| 399 | jenkins.wait_end_of_build( |
Dmitry Tyzhnenko | 468564a | 2018-08-23 16:39:06 +0300 | [diff] [blame] | 400 | name=build[0], build_id=build[1], timeout=60 * 60 * 4) |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 401 | |
| 402 | with open("{path}/cfg01_jenkins_deploy_openstack_console.log".format( |
| 403 | path=settings.LOGS_DIR), 'w') as f: |
| 404 | LOG.info("Save jenkins console log") |
| 405 | console_log = \ |
| 406 | jenkins.get_build_output('deploy_openstack', build[1]) |
| 407 | f.write(console_log) |
Dmitry Tyzhnenko | 5a5d8da | 2017-12-14 14:14:42 +0200 | [diff] [blame] | 408 | |
| 409 | assert \ |
| 410 | jenkins.build_info( |
| 411 | name=build[0], build_id=build[1])['result'] == 'SUCCESS', \ |
| 412 | "Deploy openstack was failed" |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 413 | |
| 414 | underlay.check_call( |
| 415 | node_name=cfg_node, |
| 416 | verbose=verbose, |
| 417 | cmd="salt '*' ssh.set_auth_key root '{}'".format(ssh_test_key)) |
| 418 | underlay.check_call( |
| 419 | node_name=cfg_node, |
| 420 | verbose=verbose, |
| 421 | cmd='salt "*" ssh.set_auth_key root ' |
| 422 | '"$(ssh-keygen -y -f ~/.ssh/id_rsa | cut -d " " -f 2)"') |
| 423 | underlay.check_call( |
| 424 | node_name=cfg_node, |
| 425 | verbose=verbose, |
| 426 | cmd="salt '*' ssh.set_auth_key ubuntu '{}'".format(ssh_test_key)) |
| 427 | underlay.check_call( |
| 428 | node_name=cfg_node, |
| 429 | verbose=verbose, |
| 430 | cmd='salt "*" ssh.set_auth_key ubuntu ' |
| 431 | '"$(ssh-keygen -y -f ~/.ssh/id_rsa | cut -d " " -f 2)"') |
| 432 | |
Dennis Dmitriev | 83cc1d5 | 2018-11-09 15:35:30 +0200 | [diff] [blame] | 433 | salt_deployed.update_ssh_data_from_minions() |
Dmitry Tyzhnenko | b610afd | 2018-02-19 15:43:45 +0200 | [diff] [blame] | 434 | |
| 435 | time.sleep(120) # debug sleep |
| 436 | cmd = "salt '*' test.ping" |
| 437 | underlay.check_call(node_name=cfg_node, verbose=verbose, cmd=cmd) |
| 438 | |
| 439 | openstack = managers.openstack_manager.OpenstackManager( |
| 440 | config, underlay, hardware, salt_deployed) |
| 441 | |
| 442 | if settings.RUN_TEMPEST: |
| 443 | openstack.run_tempest( |
| 444 | pattern=settings.PATTERN, |
| 445 | node_name=tempest_node) |
| 446 | openstack.download_tempest_report() |