How to use _check_if_allocation_is_possible method in tempest

Best Python code snippet using tempest_python

test_minbw_allocation_placement.py

Source:test_minbw_allocation_placement.py Github

copy

Full Screen

...100 'provider:physical_network': physnet_name,101 'provider:segmentation_id': base_segm102 })103 self._create_qos_policies()104 def _check_if_allocation_is_possible(self):105 alloc_candidates = self.placement_client.list_allocation_candidates(106 resources1='%s:%s' % (self.INGRESS_RESOURCE_CLASS,107 self.SMALLEST_POSSIBLE_BW))108 if len(alloc_candidates['provider_summaries']) == 0:109 self.fail('No allocation candidates are available for %s:%s' %110 (self.INGRESS_RESOURCE_CLASS, self.SMALLEST_POSSIBLE_BW))111 # Just to be sure check with impossible high (placement max_int),112 # allocation113 alloc_candidates = self.placement_client.list_allocation_candidates(114 resources1='%s:%s' % (self.INGRESS_RESOURCE_CLASS,115 self.PLACEMENT_MAX_INT))116 if len(alloc_candidates['provider_summaries']) != 0:117 self.fail('For %s:%s there should be no available candidate!' %118 (self.INGRESS_RESOURCE_CLASS, self.PLACEMENT_MAX_INT))119 @decorators.idempotent_id('78625d92-212c-400e-8695-dd51706858b8')120 @decorators.attr(type='slow')121 @utils.services('compute', 'network')122 def test_qos_min_bw_allocation_basic(self):123 """"Basic scenario with QoS min bw allocation in placement.124 Steps:125 * Create prerequisites:126 ** VLAN type provider network with subnet.127 ** valid QoS policy with minimum bandwidth rule with min_kbps=1128 (This is a simplification to skip the checks in placement for129 detecting the resource provider tree and inventories, as if130 bandwidth resource is available 1 kbs will be available).131 ** invalid QoS policy with minimum bandwidth rule with132 min_kbs=max integer from placement (this is a simplification again133 to avoid detection of RP tress and inventories, as placement will134 reject such big allocation).135 * Create port with valid QoS policy, and boot VM with that, it should136 pass.137 * Create port with invalid QoS policy, and try to boot VM with that,138 it should fail.139 """140 self._check_if_allocation_is_possible()141 self._create_network_and_qos_policies()142 valid_port = self.create_port(143 self.prov_network['id'], qos_policy_id=self.qos_policy_valid['id'])144 server1 = self.create_server(145 networks=[{'port': valid_port['id']}])146 allocations = self.placement_client.list_allocations(server1['id'])147 self.assertGreater(len(allocations['allocations']), 0)148 bw_resource_in_alloc = False149 for rp, resources in allocations['allocations'].items():150 if self.INGRESS_RESOURCE_CLASS in resources['resources']:151 bw_resource_in_alloc = True152 self.assertTrue(bw_resource_in_alloc)153 # boot another vm with max int bandwidth154 not_valid_port = self.create_port(...

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