How to use _wait_for_cluster method in localstack

Best Python code snippet using localstack_python

test_crush.py

Source:test_crush.py Github

copy

Full Screen

...15 - Create a crush node16 - Add some children to it17 - update it's name, type, and children18 """19 cluster_id = self._wait_for_cluster()20 r = self.api.get("cluster/%s/crush_node" % cluster_id).json()21 real_weights = {}22 rack_id = None23 for node in r:24 if node['id'] in (-2, -3):25 real_weights[node['id']] = node['weight']26 rack_name = str(uuid.uuid1())27 # unique name assuming no collisions28 crush = {'name': rack_name,29 'bucket_type': 'rack',30 'items': [31 {"id": -2,32 "weight": real_weights[-2],33 "pos": 0}34 ]35 }36 r = self.api.post("cluster/%s/crush_node" % cluster_id, crush)37 self._wait_for_completion(r)38 r = self.api.get("cluster/%s/crush_node" % cluster_id).json()39 rack_id = None40 for node in r:41 if node['name'] == rack_name:42 rack_id = node['id']43 # unique name assuming no collisions44 crush = {'name': str(uuid.uuid1()),45 'bucket_type': 'datacenter',46 'items': [{'id': rack_id, 'weight': 0.1, 'pos': 0}],47 }48 r = self.api.post("cluster/%s/crush_node" % cluster_id, crush)49 self._wait_for_completion(r)50 # unique name assuming no collisions51 crush = {'name': rack_name,52 'bucket_type': 'rack',53 'items': [54 {"id": -2,55 "weight": real_weights[-2],56 "pos": 0},57 ]58 }59 r = self.api.patch("cluster/{fsid}/crush_node/{node_id}".format(fsid=cluster_id, node_id=rack_id), crush)60 self._wait_for_completion(r)61 # TODO assert that the shape of the tree is right62 def test_delete_bucket(self):63 cluster_id = self._wait_for_cluster()64 rack_name = str(uuid.uuid1())65 # unique name assuming no collisions66 crush = {'name': rack_name,67 'bucket_type': 'rack',68 'items': []69 }70 r = self.api.post("cluster/%s/crush_node" % cluster_id, crush)71 self._wait_for_completion(r)72 r = self.api.get("cluster/%s/crush_node" % cluster_id).json()73 rack_id = None74 for node in r:75 if node['name'] == rack_name:76 rack_id = node['id']77 r = self.api.delete("cluster/{fsid}/crush_node/{node_id}".format(fsid=cluster_id, node_id=rack_id))78 self._wait_for_completion(r)79 def test_delete_full_bucket_fails(self):80 cluster_id = self._wait_for_cluster()81 rack_name = str(uuid.uuid1())82 # unique name assuming no collisions83 crush = {'name': rack_name,84 'bucket_type': 'rack',85 'items': [86 {"id": -2,87 "weight": 0.0999908447265625,88 "pos": 0}89 ]90 }91 r = self.api.post("cluster/%s/crush_node" % cluster_id, crush)92 self._wait_for_completion(r)93 r = self.api.get("cluster/%s/crush_node" % cluster_id).json()94 rack_id = None95 for node in r:96 if node['name'] == rack_name:97 rack_id = node['id']98 r = self.api.delete("cluster/{fsid}/crush_node/{node_id}".format(fsid=cluster_id, node_id=rack_id))99 assert r.status_code == 409100 def test_adding_non_existing_children_fails(self):101 cluster_id = self._wait_for_cluster()102 rack_name = str(uuid.uuid1())103 # unique name assuming no collisions104 crush = {'name': rack_name,105 'bucket_type': 'rack',106 'items': [107 {"id": -2000,108 "weight": 0.0999908447265625,109 "pos": 0}110 ]111 }112 r = self.api.post("cluster/%s/crush_node" % cluster_id, crush)113 assert r.status_code == 404114 fixed_crush = {'name': rack_name,115 'bucket_type': 'rack',116 'items': []117 }118 r = self.api.post("cluster/%s/crush_node" % cluster_id, fixed_crush)119 self._wait_for_completion(r)120 r = self.api.get("cluster/%s/crush_node" % cluster_id).json()121 rack_id = None122 for node in r:123 if node['name'] == rack_name:124 rack_id = node['id']125 r = self.api.patch("cluster/{fsid}/crush_node/{node_id}".format(fsid=cluster_id, node_id=rack_id), crush)126 assert r.status_code == 404127 @skipIf(True, "needs http://tracker.ceph.com/issues/10844 or admin.keyring on all nodes")128 def test_reparented_osds_survive_osd_restart(self):129 cluster_id = self._wait_for_cluster()130 host_name = str(uuid.uuid1())131 # unique name assuming no collisions132 crush = {'name': host_name,133 'bucket_type': 'host',134 'items': [135 {"id": 1,136 "weight": 0.0999908447265625,137 "pos": 0}138 ]139 }140 r = self.api.post("cluster/%s/crush_node" % cluster_id, crush)141 self._wait_for_completion(r)142 crush_nodes_before = self.api.get('cluster/%s/crush_node' % cluster_id).json()143 log.error('Crush nodes before restart ' + str(crush_nodes_before))144 for server in self.api.get("cluster/%s/server" % cluster_id).json():145 for service in server['services']:146 if service['type'] == 'osd' and service['running'] == 'true':147 self.ceph_ctl.restart_osd(cluster_id, server['fqdn'], service['id'])148 break149 # real clusters won't likely clean up pgs in our wait-timeout interval150 # or we'd just ask for ceph_ctl.configure here151 # TODO perhaps we should explicitly wait for the next OsdMap version152 self.ceph_ctl.wait_till_osds_up_and_in()153 crush_nodes_after = self.api.get('cluster/%s/crush_node' % cluster_id).json()154 log.error('Crush nodes after restart ' + str(crush_nodes_after))155 self.assertEqual(crush_nodes_before, crush_nodes_after)156class TestCrushRuleManagement(RequestTestCase):157 def setUp(self):158 super(TestCrushRuleManagement, self).setUp()159 self.ceph_ctl.configure(2)160 self.calamari_ctl.configure()161 def test_lifecycle(self):162 """163 Test that we can:164 - Create a crush rule165 - Add some children to it166 - update it's name, type, and children167 """168 cluster_id = self._wait_for_cluster()169 r = self.api.get("cluster/%s/crush_rule" % cluster_id).json()170 for x in range(3):171 rule_name = "replicated_ruleset%s" % str(uuid.uuid1())172 crush = {"name": rule_name,173 "min_size": 1,174 "max_size": 1,175 "ruleset": x + 1,176 "steps": [177 {178 "item": -1,179 "item_name": "default",180 "op": "take",181 },182 {183 "num": 0,184 "op": "chooseleaf_firstn",185 "type": "rack"186 },187 {188 "op": "emit",189 }190 ],191 "type": "replicated"}192 r = self.api.post("cluster/%s/crush_rule" % cluster_id, crush)193 self._wait_for_completion(r)194 r = self.api.get("cluster/%s/crush_rule" % cluster_id).json()195 self.assertEqual(len(r), 4)196 rule_id = None197 for rule in r:198 if rule['name'] == rule_name:199 rule_id = rule['id']200 crush = {"name": rule_name,201 "steps": [202 {203 "item": -1,204 "item_name": "default",205 "op": "take",206 },207 {208 "num": 0,209 "op": "chooseleaf_firstn",210 "type": "row"211 },212 {213 "op": "emit",214 }215 ]}216 r = self.api.patch("cluster/%s/crush_rule/%s" % (cluster_id, rule_id), crush)217 self._wait_for_completion(r)218 r = self.api.delete("cluster/%s/crush_rule/%s" % (cluster_id, rule_id))219 self._wait_for_completion(r)220 def test_ruleset(self):221 """222 Test that we can: set ruleset to something else than id223 - Create a crush rule224 - Add some children to it225 - update it's name, type, and children226 """227 cluster_id = self._wait_for_cluster()228 r = self.api.get("cluster/%s/crush_rule" % cluster_id).json()229 rulesets = {} # uuid name to random ruleset id230 for x in range(3):231 rule_name = "replicated_ruleset%s" % str(uuid.uuid1())232 rulesets[rule_name] = random.randint(10, 20)233 crush = {"name": rule_name,234 "min_size": 1,235 "max_size": 1,236 "ruleset": rulesets[rule_name],237 "steps": [238 {239 "item": -1,240 "item_name": "default",241 "op": "take",...

Full Screen

Full Screen

test_osd_management.py

Source:test_osd_management.py Github

copy

Full Screen

...15 'up': False,16 'reweight': 0.517 }18 osd_id = 019 fsid = self._wait_for_cluster()20 for k, v in updates.items():21 log.debug("Updating %s=%s" % (k, v))22 osd_url = "cluster/%s/osd/%s" % (fsid, osd_id)23 # Check that the modification really is a modification and24 # not the status quo25 osd = self.api.get(osd_url).json()26 self.assertNotEqual(osd[k], v)27 # Apply the modification28 response = self.api.patch(osd_url, {k: v})29 self._wait_for_completion(response)30 # After completion the update should be visible31 # NB this is slightly racy on a real cluster because when we mark something32 # down it will at some point get marked up again, hopefully not so quickly33 # that we fail this check. But if this is mysteriously failing, yeah. That.34 osd = self.api.get(osd_url).json()35 self.assertEqual(osd[k], v)36 def test_no_op_updates(self):37 """38 That no-op updates get a 304 response39 """40 no_op_updates = {41 'in': True,42 'up': True,43 'reweight': 1.044 }45 osd_id = 046 fsid = self._wait_for_cluster()47 for k, v in no_op_updates.items():48 osd_url = "cluster/%s/osd/%s" % (fsid, osd_id)49 osd = self.api.get(osd_url).json()50 self.assertEqual(osd[k], v)51 response = self.api.patch(osd_url, {k: v})52 self.assertEqual(response.status_code, 304)53 osd = self.api.get(osd_url).json()54 self.assertEqual(osd[k], v)55 def test_apply(self):56 """57 That we can apply ceph commands to an OSD58 """59 commands = ['scrub', 'deep_scrub', 'repair']60 osd_id = 061 fsid = self._wait_for_cluster()62 osd_url = "cluster/%s/osd/%s" % (fsid, osd_id)63 osd = self.api.get(osd_url).json()64 self.assertEqual(osd['up'], True)65 osd_url = "cluster/%s/osd/%s/command" % (fsid, osd_id)66 response = self.api.get(osd_url)67 self.assertEqual(response.status_code, 200, 'HTTP status not 200 for %s' % osd_url)68 osd = response.json()69 for x in commands:70 self.assertIn(x, osd.get(str(osd_id)).get('valid_commands'))71 osd_url = "cluster/%s/osd/%s/command/%s" % (fsid, osd_id, x)72 response = self.api.post(osd_url)73 self.assertEqual(response.status_code, 202, 'HTTP status not 202 for %s' % osd_url)74 def test_osd_config_change(self):75 """76 That we can change the flags on an OsdMap77 """78 fsid = self._wait_for_cluster()79 url = "cluster/%s/osd_config" % (fsid)80 config = self.api.get(url).json()81 self.assertEqual(False, config['pause'])82 response = self.api.patch(url, data={"pause": True})83 self._wait_for_completion(response)84 config = self.api.get(url).json()...

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 localstack 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