How to use nova_show method in tempest

Best Python code snippet using tempest_python

test_minimum_basic.py

Source:test_minimum_basic.py Github

copy

Full Screen

...41 def nova_list(self):42 servers = self.servers_client.list_servers()43 # The list servers in the compute client is inconsistent...44 return servers['servers']45 def nova_show(self, server):46 got_server = (self.servers_client.show_server(server['id'])47 ['server'])48 excluded_keys = ['OS-EXT-AZ:availability_zone']49 # Exclude these keys because of LP:#148647550 excluded_keys.extend(['OS-EXT-STS:power_state', 'updated'])51 self.assertThat(52 server, custom_matchers.MatchesDictExceptForKeys(53 got_server, excluded_keys=excluded_keys))54 def cinder_create(self):55 return self.create_volume()56 def cinder_list(self):57 return self.volumes_client.list_volumes()['volumes']58 def cinder_show(self, volume):59 got_volume = self.volumes_client.show_volume(volume['id'])['volume']60 self.assertEqual(volume, got_volume)61 def nova_reboot(self, server):62 self.servers_client.reboot_server(server['id'], type='SOFT')63 waiters.wait_for_server_status(self.servers_client,64 server['id'], 'ACTIVE')65 def check_partitions(self):66 # NOTE(andreaf) The device name may be different on different guest OS67 partitions = self.linux_client.get_partitions()68 self.assertEqual(1, partitions.count(CONF.compute.volume_device_name))69 def create_and_add_security_group_to_server(self, server):70 secgroup = self._create_security_group()71 self.servers_client.add_security_group(server['id'],72 name=secgroup['name'])73 self.addCleanup(self.servers_client.remove_security_group,74 server['id'], name=secgroup['name'])75 def wait_for_secgroup_add():76 body = (self.servers_client.show_server(server['id'])77 ['server'])78 return {'name': secgroup['name']} in body['security_groups']79 if not test.call_until_true(wait_for_secgroup_add,80 CONF.compute.build_timeout,81 CONF.compute.build_interval):82 msg = ('Timed out waiting for adding security group %s to server '83 '%s' % (secgroup['id'], server['id']))84 raise exceptions.TimeoutException(msg)85 @test.idempotent_id('bdbb5441-9204-419d-a225-b4fdbfb1a1a8')86 @test.services('compute', 'volume', 'image', 'network')87 def test_minimum_basic_scenario(self):88 image = self.glance_image_create()89 keypair = self.create_keypair()90 server = self.create_server(image_id=image,91 key_name=keypair['name'],92 wait_until='ACTIVE')93 servers = self.nova_list()94 self.assertIn(server['id'], [x['id'] for x in servers])95 self.nova_show(server)96 volume = self.cinder_create()97 volumes = self.cinder_list()98 self.assertIn(volume['id'], [x['id'] for x in volumes])99 self.cinder_show(volume)100 volume = self.nova_volume_attach(server, volume)101 self.addCleanup(self.nova_volume_detach, server, volume)102 self.cinder_show(volume)103 floating_ip = self.create_floating_ip(server)104 self.create_and_add_security_group_to_server(server)105 # check that we can SSH to the server before reboot106 self.linux_client = self.get_remote_client(107 floating_ip['ip'], private_key=keypair['private_key'])108 self.nova_reboot(server)109 # check that we can SSH to the server after reboot...

Full Screen

Full Screen

test_nova.py

Source:test_nova.py Github

copy

Full Screen

1#!/usr/bin/env python2#3# Copyright (c) 2017 Hewlett Packard Enterprise, L.P.4# Copyright (c) 2013 OpenStack Foundation5#6# Licensed under the Apache License, Version 2.0 (the "License");7# you may not use this file except in compliance with the License.8# You may obtain a copy of the License at9#10# http://www.apache.org/licenses/LICENSE-2.011#12# Unless required by applicable law or agreed to in writing, software13# distributed under the License is distributed on an "AS IS" BASIS,14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or15# implied.16# See the License for the specific language governing permissions and17# limitations under the License.18import libvirt19import os20import time21from tests import data22from tests import utils23def verify_private_key(stdout):24 line = [l for l in stdout.split('\n') if l != '']25 if ((line[0] == '-----BEGIN PRIVATE KEY-----' and26 line[-1] == '-----END PRIVATE KEY-----')):27 return stdout28 return ''29def cwd(filename):30 return os.path.join(os.path.dirname(__file__), 'data', filename)31server1 = data.server['11111111-2222-3333-4444-555555555555']32server1_image = data.image[server1['image_id']]33class DwarfTestCase(utils.TestCase):34 def setUp(self):35 super(DwarfTestCase, self).setUp()36 self.start_dwarf()37 def tearDown(self):38 self.stop_dwarf()39 super(DwarfTestCase, self).tearDown()40 def test_nova_flavors(self):41 self.exec_verify(['nova', 'flavor-list'],42 filename=cwd('nova_flavor-list'))43 self.exec_verify(['nova', 'flavor-show', '100'],44 filename=cwd('nova_flavor-show'))45 self.exec_verify(['nova', 'flavor-delete', '100'],46 filename=cwd('nova_flavor-delete'))47 self.exec_verify(['nova', 'flavor-create', 'test.flavor', '999',48 '1024', '15', '2'],49 filename=cwd('nova_flavor-create'))50 def test_nova_keypairs(self):51 self.exec_verify(['nova', 'keypair-add', 'test key', '--pub-key',52 cwd('nova_keypair-add.pub')],53 stdout='')54 self.exec_verify(['nova', 'keypair-list'],55 filename=cwd('nova_keypair-list'))56 self.exec_verify(['nova', 'keypair-show', 'test key'],57 filename=cwd('nova_keypair-show'))58 self.exec_verify(['nova', 'keypair-delete', 'test key'],59 stdout='')60 self.exec_verify(['nova', 'keypair-add', 'test key'],61 callback=verify_private_key)62 def test_nova_servers(self):63 # Preload an image64 self.create_image(server1_image)65 self.exec_verify(['nova', 'boot', '--flavor', server1['flavor_id'],66 '--image', server1['image_id'], server1['name']],67 filename=cwd('nova_boot'))68 self.exec_verify(['nova', 'list'],69 filename=cwd('nova_list.building'))70 libvirt.DOMAIN_STATE = libvirt.VIR_DOMAIN_RUNNING71 libvirt.IP_ADDRESS = server1['ip']72 time.sleep(3)73 # Should show the IP and status 'active'74 self.exec_verify(['nova', 'list'],75 filename=cwd('nova_list'))76 self.exec_verify(['nova', 'show', server1['id']],77 filename=cwd('nova_show'))78 self.exec_verify(['nova', 'console-log', server1['id']],79 stdout='Test server console log\n')80 self.exec_verify(['nova', 'stop', server1['id']],81 stdout='Request to stop server %s has been '82 'accepted.\n' % server1['id'])83 # Should show status 'stopped'84 self.exec_verify(['nova', 'show', server1['id']],85 filename=cwd('nova_show.stopped'))86 self.exec_verify(['nova', 'start', server1['id']],87 stdout='Request to start server %s has been '88 'accepted.\n' % server1['id'])89 # Should show status 'active'90 self.exec_verify(['nova', 'show', server1['id']],91 filename=cwd('nova_show'))92 self.exec_verify(['nova', 'reboot', server1['id']],93 stdout='Request to reboot server <Server: %s> has '...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful