How to use get_service_list method in tempest

Best Python code snippet using tempest_python

test_service.py

Source:test_service.py Github

copy

Full Screen

...57 self.assertRaises(exception.ServiceNotFound,58 self.dbapi.get_service_by_uuid,59 self.context,60 magnum_utils.generate_uuid())61 def test_get_service_list(self):62 uuids = [self.service.uuid]63 for i in range(1, 6):64 service = utils.create_test_service(65 bay_uuid=self.bay.uuid,66 uuid=magnum_utils.generate_uuid())67 uuids.append(six.text_type(service.uuid))68 res = self.dbapi.get_service_list(self.context)69 res_uuids = [r.uuid for r in res]70 self.assertEqual(sorted(uuids), sorted(res_uuids))71 def test_get_service_list_sorted(self):72 uuids = [self.service.uuid]73 for _ in range(5):74 service = utils.create_test_service(75 uuid=magnum_utils.generate_uuid())76 uuids.append(six.text_type(service.uuid))77 res = self.dbapi.get_service_list(self.context, sort_key='uuid')78 res_uuids = [r.uuid for r in res]79 self.assertEqual(sorted(uuids), res_uuids)80 self.assertRaises(exception.InvalidParameterValue,81 self.dbapi.get_service_list,82 self.context,83 sort_key='foo')84 def test_get_service_list_with_filters(self):85 bay1 = utils.get_test_bay(id=11, uuid=magnum_utils.generate_uuid())86 bay2 = utils.get_test_bay(id=12, uuid=magnum_utils.generate_uuid())87 self.dbapi.create_bay(bay1)88 self.dbapi.create_bay(bay2)89 service1 = utils.create_test_service(90 name='service-one',91 uuid=magnum_utils.generate_uuid(),92 bay_uuid=bay1['uuid'],93 ports=[{'port': 8000}])94 service2 = utils.create_test_service(95 name='service-two',96 uuid=magnum_utils.generate_uuid(),97 bay_uuid=bay2['uuid'],98 ports=[{'port': 8001}])99 res = self.dbapi.get_service_list(self.context,100 filters={'bay_uuid': bay1['uuid']})101 self.assertEqual([service1.id], [r.id for r in res])102 res = self.dbapi.get_service_list(self.context,103 filters={'bay_uuid': bay2['uuid']})104 self.assertEqual([service2.id], [r.id for r in res])105 res = self.dbapi.get_service_list(self.context,106 filters={'name': 'service-one'})107 self.assertEqual([service1.id], [r.id for r in res])108 res = self.dbapi.get_service_list(self.context,109 filters={'name': 'bad-service'})110 self.assertEqual([], [r.id for r in res])111 res = self.dbapi.get_service_list(self.context,112 filters={'ports': [{'port': 8000}]})113 self.assertEqual([service1.id], [r.id for r in res])114 res = self.dbapi.get_service_list(self.context,115 filters={'ports': [{'port': 8001}]})116 self.assertEqual([service2.id], [r.id for r in res])117 def test_get_service_list_bay_not_exist(self):118 res = self.dbapi.get_service_list(self.context, filters={119 'bay_uuid': self.bay.uuid})120 self.assertEqual(1, len(res))121 res = self.dbapi.get_service_list(self.context, filters={122 'bay_uuid': magnum_utils.generate_uuid()})123 self.assertEqual(0, len(res))124 def test_get_services_by_bay_uuid(self):125 res = self.dbapi.get_services_by_bay_uuid(self.context,126 self.bay.uuid)127 self.assertEqual(self.service.id, res[0].id)128 def test_get_services_by_bay_uuid_that_does_not_exist(self):129 self.assertRaises(exception.BayNotFound,130 self.dbapi.get_services_by_bay_uuid,131 self.context,132 magnum_utils.generate_uuid())133 def test_destroy_service(self):134 self.dbapi.destroy_service(self.service.id)135 self.assertRaises(exception.ServiceNotFound,...

Full Screen

Full Screen

services.py

Source:services.py Github

copy

Full Screen

...10from datetime import timedelta, datetime11SERVICES_TAG = 'OPS_SERVICES_TAG'12MAX_SERVICES_CACHE_SIZE = 31314def get_service_list(maxage=timedelta(seconds=0), targetID=None, use_volatile=False):15 command = ops.cmd.getDszCommand('services')16 return ops.project.generic_cache_get(command, cache_tag=SERVICES_TAG, cache_size=2, maxage=maxage, targetID=targetID, use_volatile=use_volatile).service1718def get_running_services(maxage=timedelta(seconds=0), targetID=None, use_volatile=False):19 servlist = get_service_list(maxage=maxage, targetID=targetID) ...

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