def test_run_new_action_on_locked_cluster_must_throws_exception(client, prepared_cluster):
    with allure.step('Run first action: lock cluster'):
        cluster = prepared_cluster
        lock_action = get_action_by_name(client, cluster, 'lock-cluster')
        install_action = get_action_by_name(client, cluster, 'install')
        client.cluster.action.run.create(
            action_id=lock_action['id'],
            cluster_id=cluster['id'])
    with allure.step('Run second action: install'):
        with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
            client.cluster.action.run.create(
                action_id=install_action['id'],
                cluster_id=cluster['id'])
    with allure.step('Check error that object is locked'):
        TASK_ERROR.equal(e)
        assert "object is locked" in e.value.error['desc']
def test_cluster_must_be_locked_when_action_running(client, prepared_cluster):
    with allure.step('Run action: lock cluster'):
        cluster = prepared_cluster
        client.cluster.action.run.create(
            action_id=get_action_by_name(client, cluster, 'lock-cluster')['id'],
            cluster_id=cluster['id'])
    with allure.step('Check if cluster is locked'):
        assert client.cluster.read(cluster_id=cluster['id'])['state'] == 'locked'
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_in_cluster_must_be_locked_when_cluster_action_running(client, prepared_cluster, host):
    with allure.step('Create  host and run action: lock cluster'):
        cluster = prepared_cluster
        client.cluster.host.create(cluster_id=cluster['id'], host_id=host['id'])
        client.cluster.action.run.create(
            action_id=get_action_by_name(client, cluster, 'lock-cluster')['id'],
            cluster_id=cluster['id'])
    with allure.step('Check if host is locked'):
        assert client.cluster.host.read(cluster_id=cluster['id'],
                                        host_id=host['id'])['state'] == 'locked'
def test_service_in_cluster_must_be_locked_when_cluster_action_running(client, prepared_cluster):
    with allure.step('Create service and run action: lock cluster'):
        cluster = prepared_cluster
        service = client.cluster.service.create(cluster_id=cluster['id'],
                                                prototype_id=client.stack.service.list()[0]['id'])
        client.cluster.action.run.create(
            action_id=get_action_by_name(client, cluster, 'lock-cluster')['id'],
            cluster_id=cluster['id'])
    with allure.step('Check if service is locked'):
        assert client.cluster.service.read(cluster_id=cluster['id'],
                                           service_id=service['id'])['state'] == 'locked'
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_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'
Exemple #8
0
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'
Exemple #9
0
 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'