How to use delete_aggregate method in tempest

Best Python code snippet using tempest_python

test_aggregates.py

Source:test_aggregates.py Github

copy

Full Screen

...42 resp, aggregate = self.client.create_aggregate(aggregate_name)43 self.assertEqual(200, resp.status)44 self.assertEqual(aggregate_name, aggregate['name'])45 self.assertEqual(None, aggregate['availability_zone'])46 resp, _ = self.client.delete_aggregate(aggregate['id'])47 self.assertEqual(200, resp.status)48 self.client.wait_for_resource_deletion(aggregate['id'])49 @attr(type='gate')50 def test_aggregate_create_delete_with_az(self):51 # Create and delete an aggregate.52 aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)53 az_name = data_utils.rand_name(self.az_name_prefix)54 resp, aggregate = self.client.create_aggregate(aggregate_name, az_name)55 self.assertEqual(200, resp.status)56 self.assertEqual(aggregate_name, aggregate['name'])57 self.assertEqual(az_name, aggregate['availability_zone'])58 resp, _ = self.client.delete_aggregate(aggregate['id'])59 self.assertEqual(200, resp.status)60 self.client.wait_for_resource_deletion(aggregate['id'])61 @attr(type='gate')62 def test_aggregate_create_verify_entry_in_list(self):63 # Create an aggregate and ensure it is listed.64 aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)65 resp, aggregate = self.client.create_aggregate(aggregate_name)66 self.addCleanup(self.client.delete_aggregate, aggregate['id'])67 resp, aggregates = self.client.list_aggregates()68 self.assertEqual(200, resp.status)69 self.assertIn((aggregate['id'], aggregate['availability_zone']),70 map(lambda x: (x['id'], x['availability_zone']),71 aggregates))72 @attr(type='gate')...

Full Screen

Full Screen

test_aggregates_negative.py

Source:test_aggregates_negative.py Github

copy

Full Screen

1# Copyright 2013 Huawei Technologies Co.,LTD.2# All Rights Reserved.3#4# Licensed under the Apache License, Version 2.0 (the "License"); you may5# not use this file except in compliance with the License. You may obtain6# a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the13# License for the specific language governing permissions and limitations14# under the License.15from tempest_lib import exceptions as lib_exc16from tempest.api.compute import base17from tempest.common import tempest_fixtures as fixtures18from tempest.common.utils import data_utils19from tempest import test20class AggregatesAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):21 """22 Tests Aggregates API that require admin privileges23 """24 @classmethod25 def setup_clients(cls):26 super(AggregatesAdminNegativeTestJSON, cls).setup_clients()27 cls.client = cls.os_adm.aggregates_client28 cls.user_client = cls.aggregates_client29 @classmethod30 def resource_setup(cls):31 super(AggregatesAdminNegativeTestJSON, cls).resource_setup()32 cls.aggregate_name_prefix = 'test_aggregate'33 cls.az_name_prefix = 'test_az'34 hosts_all = cls.os_adm.hosts_client.list_hosts()['hosts']35 hosts = map(lambda x: x['host_name'],36 filter(lambda y: y['service'] == 'compute', hosts_all))37 cls.host = hosts[0]38 @test.attr(type=['negative'])39 @test.idempotent_id('86a1cb14-da37-4a70-b056-903fd56dfe29')40 def test_aggregate_create_as_user(self):41 # Regular user is not allowed to create an aggregate.42 aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)43 self.assertRaises(lib_exc.Forbidden,44 self.user_client.create_aggregate,45 name=aggregate_name)46 @test.attr(type=['negative'])47 @test.idempotent_id('3b8a1929-3793-4e92-bcb4-dfa572ee6c1d')48 def test_aggregate_create_aggregate_name_length_less_than_1(self):49 # the length of aggregate name should >= 1 and <=25550 self.assertRaises(lib_exc.BadRequest,51 self.client.create_aggregate,52 name='')53 @test.attr(type=['negative'])54 @test.idempotent_id('4c194563-543b-4e70-a719-557bbe947fac')55 def test_aggregate_create_aggregate_name_length_exceeds_255(self):56 # the length of aggregate name should >= 1 and <=25557 aggregate_name = 'a' * 25658 self.assertRaises(lib_exc.BadRequest,59 self.client.create_aggregate,60 name=aggregate_name)61 @test.attr(type=['negative'])62 @test.idempotent_id('9c23a291-b0b1-487b-b464-132e061151b3')63 def test_aggregate_create_with_existent_aggregate_name(self):64 # creating an aggregate with existent aggregate name is forbidden65 aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)66 aggregate = self.client.create_aggregate(name=aggregate_name)67 self.addCleanup(self.client.delete_aggregate,68 aggregate['aggregate']['id'])69 self.assertRaises(lib_exc.Conflict,70 self.client.create_aggregate,71 name=aggregate_name)72 @test.attr(type=['negative'])73 @test.idempotent_id('cd6de795-c15d-45f1-8d9e-813c6bb72a3d')74 def test_aggregate_delete_as_user(self):75 # Regular user is not allowed to delete an aggregate.76 aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)77 aggregate = (self.client.create_aggregate(name=aggregate_name)78 ['aggregate'])79 self.addCleanup(self.client.delete_aggregate, aggregate['id'])80 self.assertRaises(lib_exc.Forbidden,81 self.user_client.delete_aggregate,82 aggregate['id'])83 @test.attr(type=['negative'])84 @test.idempotent_id('b7d475a6-5dcd-4ff4-b70a-cd9de66a6672')85 def test_aggregate_list_as_user(self):86 # Regular user is not allowed to list aggregates.87 self.assertRaises(lib_exc.Forbidden,88 self.user_client.list_aggregates)89 @test.attr(type=['negative'])90 @test.idempotent_id('557cad12-34c9-4ff4-95f0-22f0dfbaf7dc')91 def test_aggregate_get_details_as_user(self):92 # Regular user is not allowed to get aggregate details.93 aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)94 aggregate = (self.client.create_aggregate(name=aggregate_name)95 ['aggregate'])96 self.addCleanup(self.client.delete_aggregate, aggregate['id'])97 self.assertRaises(lib_exc.Forbidden,98 self.user_client.show_aggregate,99 aggregate['id'])100 @test.attr(type=['negative'])101 @test.idempotent_id('c74f4bf1-4708-4ff2-95a0-f49eaca951bd')102 def test_aggregate_delete_with_invalid_id(self):103 # Delete an aggregate with invalid id should raise exceptions.104 self.assertRaises(lib_exc.NotFound,105 self.client.delete_aggregate, -1)106 @test.attr(type=['negative'])107 @test.idempotent_id('3c916244-2c46-49a4-9b55-b20bb0ae512c')108 def test_aggregate_get_details_with_invalid_id(self):109 # Get aggregate details with invalid id should raise exceptions.110 self.assertRaises(lib_exc.NotFound,111 self.client.show_aggregate, -1)112 @test.attr(type=['negative'])113 @test.idempotent_id('0ef07828-12b4-45ba-87cc-41425faf5711')114 def test_aggregate_add_non_exist_host(self):115 # Adding a non-exist host to an aggregate should raise exceptions.116 hosts_all = self.os_adm.hosts_client.list_hosts()['hosts']117 hosts = map(lambda x: x['host_name'], hosts_all)118 while True:119 non_exist_host = data_utils.rand_name('nonexist_host')120 if non_exist_host not in hosts:121 break122 aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)123 aggregate = (self.client.create_aggregate(name=aggregate_name)124 ['aggregate'])125 self.addCleanup(self.client.delete_aggregate, aggregate['id'])126 self.assertRaises(lib_exc.NotFound, self.client.add_host,127 aggregate['id'], host=non_exist_host)128 @test.attr(type=['negative'])129 @test.idempotent_id('7324c334-bd13-4c93-8521-5877322c3d51')130 def test_aggregate_add_host_as_user(self):131 # Regular user is not allowed to add a host to an aggregate.132 aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)133 aggregate = (self.client.create_aggregate(name=aggregate_name)134 ['aggregate'])135 self.addCleanup(self.client.delete_aggregate, aggregate['id'])136 self.assertRaises(lib_exc.Forbidden,137 self.user_client.add_host,138 aggregate['id'], host=self.host)139 @test.attr(type=['negative'])140 @test.idempotent_id('19dd44e1-c435-4ee1-a402-88c4f90b5950')141 def test_aggregate_add_existent_host(self):142 self.useFixture(fixtures.LockFixture('availability_zone'))143 aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)144 aggregate = (self.client.create_aggregate(name=aggregate_name)145 ['aggregate'])146 self.addCleanup(self.client.delete_aggregate, aggregate['id'])147 self.client.add_host(aggregate['id'], host=self.host)148 self.addCleanup(self.client.remove_host, aggregate['id'],149 host=self.host)150 self.assertRaises(lib_exc.Conflict, self.client.add_host,151 aggregate['id'], host=self.host)152 @test.attr(type=['negative'])153 @test.idempotent_id('7a53af20-137a-4e44-a4ae-e19260e626d9')154 def test_aggregate_remove_host_as_user(self):155 # Regular user is not allowed to remove a host from an aggregate.156 self.useFixture(fixtures.LockFixture('availability_zone'))157 aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)158 aggregate = (self.client.create_aggregate(name=aggregate_name)159 ['aggregate'])160 self.addCleanup(self.client.delete_aggregate, aggregate['id'])161 self.client.add_host(aggregate['id'], host=self.host)162 self.addCleanup(self.client.remove_host, aggregate['id'],163 host=self.host)164 self.assertRaises(lib_exc.Forbidden,165 self.user_client.remove_host,166 aggregate['id'], host=self.host)167 @test.attr(type=['negative'])168 @test.idempotent_id('95d6a6fa-8da9-4426-84d0-eec0329f2e4d')169 def test_aggregate_remove_nonexistent_host(self):170 non_exist_host = data_utils.rand_name('nonexist_host')171 aggregate_name = data_utils.rand_name(self.aggregate_name_prefix)172 aggregate = (self.client.create_aggregate(name=aggregate_name)173 ['aggregate'])174 self.addCleanup(self.client.delete_aggregate, aggregate['id'])175 self.assertRaises(lib_exc.NotFound, self.client.remove_host,...

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