How to use delete_service method in tempest

Best Python code snippet using tempest_python

delete_service_test.py

Source:delete_service_test.py Github

copy

Full Screen

...11TEST_DEFAULT_USERID = '11223344'12TEST_DEFAULT_POSTID = '22334455'13TEST_DEFAULT_THREADID = '22123123'14@pytest.fixture(scope='function')15def delete_service():16 session_user = create_mock_entity_fromattrs(dict(userId=TEST_DEFAULT_USERID))17 mock_repo = mocks.createMockRepo()18 mock_session = mocks.createMockSessionService()19 mock_session.get_user.return_value = session_user20 service = DeleteService(mock_repo, mock_session)21 return service22class TestUserDeleteService:23 def test_deleteUserByIdShouldPassUserIdToRepoAsFilter(self, delete_service):24 mock_repo = delete_service._repo25 expectedFilter = PrimitiveFilter.createFilter(dict(26 operator='eq', field='userId', value=[ TEST_DEFAULT_USERID ],27 ))28 delete_service.deleteUserById(TEST_DEFAULT_USERID)29 mock_repo.deleteUser.assert_called_once()...

Full Screen

Full Screen

test_docker_swarm_client.py

Source:test_docker_swarm_client.py Github

copy

Full Screen

...33 service_names.append(names)34 assert "scheduler1" in service_names35 assert "scheduler2" in service_names36 # Cleaning37 DC.delete_service("scheduler1")38 DC.delete_service("scheduler2")39# def test_containers():40# """Test function for getting list of container ids."""41# # TODO(NJT)42# # Passing in a test compose file43# service_names = []44# config_path = os.path.join(FILE_PATH, '..', 'compose-file',45# 'docker-compose.p3-fluentd.yml')46# with open(config_path, 'r') as compose_str:47# s_ids = DC.create_services(compose_str)48#49# for service_id in s_ids:50# service_details = DC.get_service_details(service_id)51#52# # TODO (NJT) Need a real container to test this53# print("Containers {}".format(DC.containers))54# # service_names.append(service_details['Spec']['Name'])55# # assert "recv" in service_names56# # assert "send" in service_names57# #58# # Cleaning59# DC.delete_service("recv")60# DC.delete_service("send")61def test_nodes():62 """Test function for getting list of node ids."""63 # Number of nodes64 assert len(DC.nodes) == 165def test_create_services():66 """Test function for create services."""67 # Passing in a test compose file68 service_names = []69 config_path = os.path.join(FILE_PATH, '..', 'compose-file',70 'docker-compose-run-local.yml')71 with open(config_path, 'r') as compose_str:72 s_ids = DC.create_services(compose_str)73 for service_id in s_ids:74 service_details = DC.get_service_details(service_id)75 service_names.append(service_details['Spec']['Name'])76 assert "recv" in service_names77 assert "send" in service_names78 # Cleaning79 DC.delete_service("recv")80 DC.delete_service("send")81def test_create_volume():82 """Test function for creating volume."""83 # Create a new volume84 volume_name = 'test_volume'85 DC.create_volume(volume_name, 'local')86 assert "test_volume" in DC.get_volume_details(volume_name)['Name']87 # Cleaning88 DC.delete_volume(volume_name)89 assert "test_volume" not in DC.get_volume_list()90def test_workflow_and_service_state():91 """Test function to to start workflow and check if the service is92 running and shutdown at the right time. """93 config_path = os.path.join(FILE_PATH, '..', 'compose-file',94 'docker-compose.workflow.yml')95 service_names = []96 running_service_ids = []97 test_ids = []98 with open(config_path, 'r') as compose_str:99 s_ids = DC.create_services(compose_str)100 for s_id in s_ids:101 service_details = DC.get_service_details(s_id)102 service_names.append(service_details['Spec']['Name'])103 running_service_ids.append(s_id)104 test_ids.append(s_id)105 assert "start_stage" in service_names106 assert "mock_stage" in service_names107 assert "mock_workflow_stage1" in service_names108 while running_service_ids:109 for service_id in running_service_ids:110 service_state = DC.get_service_state(service_id)111 if service_state == 'shutdown':112 DC.delete_service(service_id)113 running_service_ids.remove(service_id)114 # Get all service ids115 service_list = DC.get_service_list()116 for s_id in test_ids:117 assert s_id not in service_list118def test_get_service_list():119 """Test function for getting service list."""120 # Create new services121 service_names = []122 config_path = os.path.join(FILE_PATH, '..', 'compose-file',123 'docker-compose.shorter.yml')124 with open(config_path, 'r') as compose_str:125 service_ids = DC.create_services(compose_str)126 for service_id in service_ids:127 service_list = DC.get_service_list()128 assert service_id in service_list129 service_list = DC.get_service_list()130 for services in service_list:131 names = DC.get_service_name(services)132 service_names.append(names)133 assert "scheduler1" in service_names134 assert "scheduler2" in service_names135 # Cleaning136 DC.delete_service("scheduler1")137 DC.delete_service("scheduler2")138def test_get_node_list():139 """Test function for getting nodes list."""140 # Number of nodes141 assert len(DC.get_node_list()) == 1142def test_get_volume_list():143 """Test function for getting volume list."""144 # Create a new volume145 volume_name = 'test_volume'146 DC.create_volume(volume_name, 'local')147 assert "test_volume" in DC.get_volume_details(volume_name)['Name']148 # Try with a invalid name149 assert 'invalid_name' not in DC.get_volume_list()150 # Cleaning151 DC.delete_volume(volume_name)152 assert volume_name not in DC.get_volume_list()153def test_delete_service():154 """Test function for deleting a service."""155 # Passing in a test compose file156 config_path = os.path.join(FILE_PATH, '..', 'compose-file',157 'docker-compose.visibility.yml')158 with open(config_path, 'r') as compose_str:159 s_ids = DC.create_services(compose_str)160 for service_id in s_ids:161 DC.delete_service(service_id)162 service_list = DC.get_service_list()163 assert service_id not in service_list164def test_delete_volume():165 """Test function for deleting a volume."""166 # Create a new volume167 DC.create_volume('delete_volume', 'local')168 DC.delete_volume('delete_volume')169 assert "delete_volume" not in DC.get_volume_list()170def test_replication_level():171 """Test function for getting the replication level of a service."""172 config_path = os.path.join(FILE_PATH, '..', 'compose-file',173 'docker-compose-replica.yml')174 with open(config_path, 'r') as compose_str:175 s_ids = DC.create_services(compose_str)176 assert len(s_ids) == 1177 level = 0178 while level < 1:179 for service_id in s_ids:180 level = DC.get_replicas(service_id)181 for s_id in s_ids:182 replicas = DC.get_replicas(s_id)183 assert replicas == 1184 # Cleaning185 DC.delete_service("replica_test")186def test_actual_replica_level():187 """Test function for getting the actual replica level of a service."""188 config_path = os.path.join(FILE_PATH, '..', 'compose-file',189 'docker-compose-replica.yml')190 with open(config_path, 'r') as compose_str:191 s_ids = DC.create_services(compose_str)192 assert len(s_ids) == 1193 for service_id in s_ids:194 level = DC.get_actual_replica(service_id)195 assert level == 1196 # Cleaning197 DC.delete_service("replica_test")198def test_environment():199 """Test function for setting environment variables."""200 config_path = os.path.join(FILE_PATH, '..', 'compose-file',201 'docker-compose-env.yml')202 with open(config_path, 'r') as compose_str:203 s_ids = DC.create_services(compose_str)204 assert len(s_ids) == 1205 level = 0206 while level < 1:207 for service_id in s_ids:208 level = DC.get_replicas(service_id)209 for s_id in s_ids:210 replicas = DC.get_replicas(s_id)211 assert replicas == 1212 # Cleaning...

Full Screen

Full Screen

test_master_controller_healthcheck.py

Source:test_master_controller_healthcheck.py Github

copy

Full Screen

...24 s_heath = MHC.services_health25 assert s_heath['service_health'] == "Healthy"26 assert s_heath['service_health_error'] == "Unhealthy"27 # Cleaning28 DC.delete_service("service_health")29 DC.delete_service("service_health_error")30def test_get_service_health():31 """Test the service health by service id."""32 config_path = os.path.join(FILE_PATH, 'compose-file',33 'docker-compose-service.yml')34 with open(config_path, 'r') as compose_str:35 s_id = DC.create_services(compose_str)36 assert len(s_id) == 137 time.sleep(10)38 assert MHC.get_service_health(s_id[0]) == "Healthy"39 # Cleaning40 DC.delete_service("service_health")41def test_get_overall_services_health():42 """Test the overall service health function. """43 config_path = os.path.join(FILE_PATH, 'compose-file',44 'docker-compose-overall.yml')45 with open(config_path, 'r') as compose_str:46 s_id = DC.create_services(compose_str)47 assert len(s_id) == 248 time.sleep(10)49 assert MHC.overall_health == "Healthy"50 # Cleaning51 DC.delete_service("service_health_1")52 DC.delete_service("service_health_2")53 config_path = os.path.join(FILE_PATH, 'compose-file',54 'docker-compose-services.yml')55 with open(config_path, 'r') as compose_str:56 s_id = DC.create_services(compose_str)57 assert len(s_id) == 258 time.sleep(5)59 assert MHC.overall_health == "Unhealthy"60 # Cleaning61 DC.delete_service("service_health")...

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