def test_cluster_should_be_unlocked_when_ansible_task_killed(client, prepared_cluster): with allure.step('Run cluster action: lock terminate'): task = client.cluster.action.run.create( action_id=get_action_by_name(client, prepared_cluster, 'lock-terminate')['id'], cluster_id=prepared_cluster['id']) with allure.step('Check if cluster is locked and then terminate_failed'): assert client.cluster.read(cluster_id=prepared_cluster['id'])['state'] == 'locked' wait_until(client, task) assert client.cluster.read(cluster_id=prepared_cluster['id'])['state'] == 'terminate_failed'
def test_host_should_be_unlocked_when_ansible_task_killed(client, prepared_cluster, host): with allure.step('Create host'): client.cluster.host.create(cluster_id=prepared_cluster['id'], host_id=host['id']) with allure.step('Run action: lock terminate'): task = client.cluster.action.run.create( action_id=get_action_by_name(client, prepared_cluster, 'lock-terminate')['id'], cluster_id=prepared_cluster['id']) with allure.step('Check if host is locked and then created'): assert client.host.read(host_id=host['id'])['state'] == 'locked' wait_until(client, task) assert client.host.read(host_id=host['id'])['state'] == 'created'
def test_hostprovider_must_be_unlocked_when_his_task_finished(client, hostprovider): with allure.step('Run action: action locker and create hostprovider'): action_id = filter_action_by_name( client.provider.action.list(provider_id=hostprovider['id']), 'action-locker')[0]['id'] task = client.provider.action.run.create( action_id=action_id, provider_id=hostprovider['id'] ) with allure.step('Check if provider is locked and then created'): assert client.provider.read(provider_id=hostprovider['id'])['state'] == 'locked' wait_until(client, task) assert client.provider.read(provider_id=hostprovider['id'])['state'] == 'created'
def test_service_should_be_unlocked_when_ansible_task_killed(client, prepared_cluster): with allure.step('Create service'): service = client.cluster.service.create(cluster_id=prepared_cluster['id'], prototype_id=client.stack.service.list()[0]['id']) with allure.step('Run action: lock-terminate'): task = client.cluster.action.run.create( action_id=get_action_by_name(client, prepared_cluster, 'lock-terminate')['id'], cluster_id=prepared_cluster['id']) with allure.step('Check if service is locked and then created'): assert client.cluster.service.read(cluster_id=prepared_cluster['id'], service_id=service['id'])['state'] == 'locked' wait_until(client, task) assert client.cluster.service.read(cluster_id=prepared_cluster['id'], service_id=service['id'])['state'] == 'created'
def test_check_cluster_state_after_run_action_when_empty(cluster_bundle, state, client): with allure.step(f'Upload cluster bundle: {cluster_bundle}'): bundle = utils.get_data_dir(__file__, "empty_states", cluster_bundle) steps.upload_bundle(client, bundle) with allure.step('Create cluster'): cluster = client.cluster.create(prototype_id=client.stack.cluster.list()[0]['id'], name=utils.random_string()) with allure.step('Run cluster'): action = client.cluster.action.run.create( action_id=filter_action_by_name( client.cluster.action.list(cluster_id=cluster['id']), 'install')[0]['id'], cluster_id=cluster['id']) wait_until(client, action) with allure.step(f'Check if cluster state is {state}'): assert client.cluster.read(cluster_id=cluster['id'])['state'] == state
def test_when_component_hasnt_constraint_then_cluster_doesnt_have_issues(client): with allure.step('Create cluster (component hasnt constraint)'): bundledir = utils.get_data_dir(__file__, "cluster_component_hasnt_constraint") steps.upload_bundle(client, bundledir) cluster = steps.create_cluster(client) with allure.step('Create service'): steps.create_random_service(client, cluster['id']) with allure.step('Run action: lock cluster'): action = get_action_by_name(client, cluster, 'lock-cluster') wait_until( client, task=client.cluster.action.run.create(cluster_id=cluster['id'], action_id=action['id']) ) with allure.step('Check if state is always-locked'): assert client.cluster.read(cluster_id=cluster['id'])['state'] == 'always-locked'
def test_run_parametrized_action_must_be_runned(client): with allure.step('Upload cluster bundle'): bundle = utils.get_data_dir(__file__, "run_parametrized_action") steps.upload_bundle(client, bundle) with allure.step('Create cluster'): cluster = client.cluster.create(prototype_id=client.stack.cluster.list()[0]['id'], name=utils.random_string()) with allure.step('Run cluster'): action = client.cluster.action.run.create( action_id=filter_action_by_name( client.cluster.action.list(cluster_id=cluster['id']), 'install')[0]['id'], cluster_id=cluster['id'], config={"param": "test test test test test"}) wait_until(client, action) with allure.step('Check if state is success'): assert client.job.read(job_id=client.job.list()[0]['id'])['status'] == 'success'
def test_check_host_state_after_run_action_when_empty(host_bundle, state, client): with allure.step(f'Upload cluster bundle: {host_bundle}'): bundle = utils.get_data_dir(__file__, "empty_states", host_bundle) steps.upload_bundle(client, bundle) with allure.step('Create provider and host'): provider = client.provider.create(prototype_id=client.stack.provider.list()[0]['id'], name=utils.random_string()) host = client.host.create(prototype_id=client.stack.host.list()[0]['id'], provider_id=provider['id'], fqdn=utils.random_string()) with allure.step('Run host'): action = client.host.action.run.create( action_id=filter_action_by_name( client.host.action.list(host_id=host['id']), 'init')[0]['id'], host_id=host['id']) wait_until(client, action) with allure.step(f'Check if host state is {state}'): assert client.host.read(host_id=host['id'])['state'] == state
def test_check_that_file_field_put_correct_data_in_file_inside_docker( self, client): cluster = steps.create_cluster(client) test_data = "lorem ipsum" with allure.step('Create config data'): config_data = utils.ordered_dict_to_dict( client.cluster.config.current.list( cluster_id=cluster['id'])['config']) config_data['input_file'] = test_data config_data['required'] = random.randint(0, 99) with allure.step('Create config history'): client.cluster.config.history.create(cluster_id=cluster['id'], config=config_data) with allure.step('Check file type'): action = client.cluster.action.run.create( action_id=get_action_by_name(client, cluster, 'check-file-type')['id'], cluster_id=cluster['id']) wait_until(client, action) with allure.step('Check that state is success'): expected = client.task.read(task_id=action['id']) assert expected['status'] == 'success'