示例#1
0
 def test_shouldnt_create_service_config_when_parameter_is_not_float(
         self, client):
     cluster = steps.create_cluster(client)
     config_w_illegal_param = {
         "ssh-key": "TItbmlzHyNTAAIbmzdHAyNTYAAA",
         "float-key": "blah",
         "zoo.cfg": {
             "autopurge.purgeInterval": 30,
             "dataDir": "/zookeeper",
             "port": 80
         },
         "required-key": "value"
     }
     with allure.step('Create service on the cluster'):
         cluster_svc = client.cluster.service.create(
             cluster_id=cluster['id'],
             prototype_id=get_random_service(client)['id'])
     with allure.step('Try to create config when param is not float'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.service.config.history.create(
                 cluster_id=cluster['id'],
                 service_id=cluster_svc['id'],
                 config=config_w_illegal_param)
     with allure.step('Check error that parameter is not float'):
         err.CONFIG_VALUE_ERROR.equal(e, 'should be float')
     steps.delete_all_data(client)
示例#2
0
 def test_try_to_create_cluster_with_unknown_prototype(self, client):
     with allure.step('Try to create cluster with unknown prototype'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.create(prototype_id=random.randint(100, 500),
                                   name=utils.random_string())
     with allure.step('Check error that cluster doesn\'t exist'):
         err.PROTOTYPE_NOT_FOUND.equal(e, 'prototype doesn\'t exist')
     steps.delete_all_data(client)
示例#3
0
 def test_shouldnt_create_cluster_w_blank_prototype(self, client):
     with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
         client.cluster.create(prototype_id='', name=utils.random_string())
     with allure.step('Check error about valid integer'):
         assert e.value.error.title == '400 Bad Request'
         assert e.value.error['prototype_id'][
             0] == 'A valid integer is required.'
     steps.delete_all_data(client)
示例#4
0
 def test_shouldnt_create_cluster_wo_name(self, client):
     prototype = get_random_cluster_prototype(client)
     with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
         client.cluster.create(prototype_id=prototype['id'], name='')
     with allure.step('Check error about blank field'):
         assert e.value.error.title == '400 Bad Request'
         assert e.value.error['name'] == ['This field may not be blank.']
     steps.delete_all_data(client)
示例#5
0
 def test_validate_host_prototype(self, client):
     host_prototype = json.loads(json.dumps(client.stack.host.list()[0]))
     schema = json.load(
         open(SCHEMAS + '/stack_list_item_schema.json')
     )
     with allure.step('Match prototype with schema'):
         assert validate(host_prototype, schema) is None
     steps.delete_all_data(client)
示例#6
0
 def test_get_nonexistant_cluster_config(self, client):
     # we try to get a nonexistant cluster config, test should raise exception
     with allure.step('Get cluster config from non existant cluster'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.config.list(cluster_id=random.randint(100, 500))
     with allure.step('Check that cluster doesn\'t exist'):
         err.CLUSTER_NOT_FOUND.equal(e, 'cluster doesn\'t exist')
     steps.delete_all_data(client)
示例#7
0
 def test_correct_error_when_user_try_to_get_incorrect_cluster(
         self, client):
     with allure.step('Try to get unknown cluster'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.read(cluster_id=random.randint(500, 999))
     with allure.step('Check error that cluster doesn\'t exist'):
         err.CLUSTER_NOT_FOUND.equal(e, 'cluster doesn\'t exist')
     steps.delete_all_data(client)
示例#8
0
 def test_verify_that_supported_type_is(self, client, datatype, name):
     with allure.step('Create stack'):
         stack = client.stack.cluster.read(
             prototype_id=client.stack.cluster.list()[0]['id'])
     with allure.step('Check stack config'):
         for item in stack['config']:
             if item['name'] == name:
                 assert item['type'] == datatype
     steps.delete_all_data(client)
示例#9
0
 def test_get_config_from_nonexistant_cluster_service(self, client):
     cluster = steps.create_cluster(client)
     with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
         client.cluster.service.config.list(cluster_id=cluster['id'],
                                            service_id=random.randint(
                                                100, 500))
     with allure.step('Check error that service doesn\'t exist'):
         err.SERVICE_NOT_FOUND.equal(e, "service doesn\'t exist")
     steps.delete_all_data(client)
示例#10
0
 def test_add_unknown_host_to_cluster(self, client):
     cluster = steps.create_cluster(client)
     with allure.step('Create mapping between cluster and unknown host'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.host.create(cluster_id=cluster['id'],
                                        host_id=random.randint(900, 950))
     with allure.step('Check error host doesn\'t exist'):
         err.HOST_NOT_FOUND.equal(e, 'host doesn\'t exist')
     steps.delete_all_data(client)
示例#11
0
 def test_read_default_cluster_config(self, client):
     cluster = steps.create_cluster(client)
     config = client.cluster.config.current.list(cluster_id=cluster['id'])
     if config:
         config_json = utils.ordered_dict_to_dict(config)
     with allure.step('Load schema'):
         schema = json.load(open(SCHEMAS + '/config_item_schema.json'))
     with allure.step('Check schema'):
         assert validate(config_json, schema) is None
     steps.delete_all_data(client)
示例#12
0
 def test_should_throws_exception_when_havent_previous_config(self, client):
     cluster = steps.create_cluster(client)
     service = steps.create_random_service(client, cluster['id'])
     with allure.step('Try to get previous version of the service config'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.service.config.previous.list(
                 cluster_id=cluster['id'], service_id=service['id'])
     with allure.step('Check error that config version doesn\'t exist'):
         err.CONFIG_NOT_FOUND.equal(e, 'config version doesn\'t exist')
     steps.delete_all_data(client)
示例#13
0
 def test_shouldnt_create_service_w_id_eq_negative_number(self, client):
     cluster = steps.create_cluster(client)
     with allure.step('Try to create service with id as a negative number'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.service.create(
                 cluster_id=cluster['id'],
                 prototype_id=(get_random_service(client)['id'] * -1))
     with allure.step('Check error prototype doesn\'t exist'):
         err.PROTOTYPE_NOT_FOUND.equal(e, 'prototype doesn\'t exist')
     steps.delete_all_data(client)
示例#14
0
 def test_shouldnt_create_cluster_config_when_config_not_json(self, client):
     cluster = steps.create_cluster(client)
     with allure.step(
             'Try to create the cluster config from non-json string'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.config.history.create(
                 cluster_id=cluster['id'], config=utils.random_string())
     with allure.step('Check that config should not be just one string'):
         err.JSON_ERROR.equal(e, 'config should not be just one string')
     steps.delete_all_data(client)
示例#15
0
 def test_partial_update_cluster_name(self, client):
     name = utils.random_string()
     cluster = steps.create_cluster(client)
     with allure.step('Trying to update cluster'):
         expected = steps.partial_update_cluster(client, cluster, name)
     with allure.step('Take actual data about cluster'):
         actual = steps.read_cluster(client, cluster['id'])
     with allure.step('Check actual and expected result'):
         assert expected == actual
     steps.delete_all_data(client)
示例#16
0
 def test_shouldnt_create_config_with_unknown_key(self, client):
     # config has key that not defined in prototype
     cluster = steps.create_cluster(client)
     config = {"new_key": "value"}
     with allure.step('Try to create config with unknown key'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.config.history.create(cluster_id=cluster['id'],
                                                  config=config)
     with allure.step('Check that unknown key'):
         err.CONFIG_KEY_ERROR.equal(e, 'There is unknown key')
     steps.delete_all_data(client)
示例#17
0
 def test_partial_update_duplicate_cluster_name(self, client):  # ADCM-74
     name = utils.random_string()
     cluster_one = steps.create_cluster(client)
     steps.partial_update_cluster(client, cluster_one, name)
     cluster_two = steps.create_cluster(client)
     with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
         steps.partial_update_cluster(client, cluster_two, name)
     with allure.step('Check error that cluster already exists'):
         err.CLUSTER_CONFLICT.equal(e, 'cluster with name',
                                    'already exists')
     steps.delete_all_data(client)
示例#18
0
 def test_get_cluster_info(self, client):
     actual = steps.create_cluster(client)
     expected = steps.read_cluster(client, actual['id'])
     # status is a variable, so it is no good to compare it
     assert 'status' in actual
     assert 'status' in expected
     del actual['status']
     del expected['status']
     with allure.step('Check cluster info'):
         assert actual == expected
     steps.delete_all_data(client)
示例#19
0
 def test_shouldnt_create_config_when_config_doesnt_have_required_key(
         self, client):
     cluster = steps.create_cluster(client)
     config_wo_required_key = {"str-key": "value"}
     with allure.step('Try to create config wo required key'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.config.history.create(
                 cluster_id=cluster['id'], config=config_wo_required_key)
     with allure.step('Check that no required key'):
         err.CONFIG_KEY_ERROR.equal(e, 'There is no required key')
     steps.delete_all_data(client)
示例#20
0
 def test_shouldnt_create_config_when_key_is_not_in_option_list(
         self, client):
     cluster = steps.create_cluster(client)
     config_key_not_in_list = {"option": "bluh", "required": 10}
     with allure.step('Try to create config has not option in a list'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.config.history.create(
                 cluster_id=cluster['id'], config=config_key_not_in_list)
     with allure.step('Check that not in option list'):
         err.CONFIG_VALUE_ERROR.equal(e, 'Value', 'not in option list')
     steps.delete_all_data(client)
示例#21
0
 def test_create_new_config_version_with_one_req_parameter(self, client):
     cluster = steps.create_cluster(client)
     cfg = {"required": random.randint(0, 9)}
     with allure.step('Create new config'):
         new_config = client.cluster.config.history.create(
             cluster_id=cluster['id'], config=cfg)
     with allure.step('Create config history'):
         expected = client.cluster.config.history.read(
             cluster_id=cluster['id'], version=new_config['id'])
     with allure.step('Check new config'):
         assert new_config == expected
     steps.delete_all_data(client)
示例#22
0
 def test_create_new_config_version_with_other_parameters(self, client):
     cluster = steps.create_cluster(client)
     cfg = {"required": 99, "str-key": utils.random_string()}
     with allure.step('Create new config'):
         new_config = client.cluster.config.history.create(
             cluster_id=cluster['id'], config=cfg)
     with allure.step('Create config history'):
         expected = client.cluster.config.history.read(
             cluster_id=cluster['id'], version=new_config['id'])
     with allure.step('Check new config'):
         assert new_config == expected
     steps.delete_all_data(client)
示例#23
0
 def test_get_default_host_config(self, client):
     # Get a default host config and validate it with json schema
     host = steps.create_host_w_default_provider(client, utils.random_string())
     config_json = {}
     with allure.step('Get default configuration from host'):
         config = client.host.config.current.list(host_id=host['id'])
     if config:
         config_json = json.loads(json.dumps(config))
     schema = json.load(open(SCHEMAS + '/config_item_schema.json'))
     with allure.step('Check config'):
         assert validate(config_json, schema) is None
     steps.delete_all_data(client)
示例#24
0
 def test_souldnt_create_service_w_id_as_string(self, client):
     cluster = steps.create_cluster(client)
     with allure.step('Try to create service with id as a negative number'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.service.create(
                 cluster_id=cluster['id'],
                 prototype_id=utils.random_string())
     with allure.step('Check error about valid integer'):
         assert e.value.error.title == '400 Bad Request'
         assert e.value.error['prototype_id'][
             0] == 'A valid integer is required.'
     steps.delete_all_data(client)
示例#25
0
 def test_get_cluster_service_list(self, client):
     cluster = steps.create_cluster(client)
     expected = []
     with allure.step('Create a list of services in the cluster'):
         for service in client.stack.service.list():
             expected.append(
                 client.cluster.service.create(cluster_id=cluster['id'],
                                               prototype_id=service['id']))
     with allure.step('Get a service list in cluster'):
         actual = client.cluster.service.list(cluster_id=cluster['id'])
     with allure.step('Check expected and actual value'):
         assert expected == actual
     steps.delete_all_data(client)
示例#26
0
 def test_shouldnt_create_service_config_when_config_is_number(
         self, client):  # ADCM-86
     cluster = steps.create_cluster(client)
     with allure.step('Try to create config from number'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.config.history.create(cluster_id=cluster['id'],
                                                  config=random.randint(
                                                      0, 9))
     with allure.step(
             'Check that config should not be just one int or float'):
         err.JSON_ERROR.equal(e,
                              'config should not be just one int or float')
     steps.delete_all_data(client)
示例#27
0
 def test_partial_update_cluster_name_and_desc(self, client):
     name = utils.random_string()
     desc = utils.random_string()
     with allure.step('Create cluster'):
         cluster = steps.create_cluster(client)
     with allure.step('Trying to update cluster name and description'):
         expected = steps.partial_update_cluster(client, cluster, name,
                                                 desc)
     with allure.step('Take actual data about cluster'):
         actual = steps.read_cluster(client, cluster['id'])
     with allure.step('Check actual and expected result'):
         assert expected['name'] == name
         assert expected == actual
     steps.delete_all_data(client)
示例#28
0
 def test_config_history_url_must_point_to_the_host_config(self, client):
     host = steps.create_host_w_default_provider(client, utils.random_string())
     config = {"str-key": "{1bbb}", "required": 158, "option": 8080, "sub": {"sub1": 2},
               "credentials": {"sample_string": "txt", "read_only_initiated": {}}}
     i = 0
     with allure.step('Create host history'):
         while i < random.randint(0, 10):
             client.host.config.history.create(host_id=host['id'],
                                               description=utils.random_string(),
                                               config=config)
             i += 1
         history = client.host.config.history.list(host_id=host['id'])
     with allure.step('Check host history'):
         for conf in history:
             assert ('host/{0}/config/'.format(host['id']) in conf['url']) is True
     steps.delete_all_data(client)
示例#29
0
 def test_shouldnt_create_service_config_when_config_have_unknown_param(
         self, client):
     cluster = steps.create_cluster(client)
     config_w_unknown_param = {"name": "foo"}
     with allure.step('Create service on the cluster'):
         cluster_svc = client.cluster.service.create(
             cluster_id=cluster['id'],
             prototype_id=get_random_service(client)['id'])
     with allure.step('Try to create config with unknown parameter'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.service.config.history.create(
                 cluster_id=cluster['id'],
                 service_id=cluster_svc['id'],
                 config=config_w_unknown_param)
     with allure.step('Check error about unknown key'):
         err.CONFIG_KEY_ERROR.equal(e, 'There is unknown key')
     steps.delete_all_data(client)
示例#30
0
 def test_shouldnt_create_service_config_when_config_doesnt_have_all_req_param(
         self, client):
     cluster = steps.create_cluster(client)
     config_wo_required_param = {
         "ssh-key": "TItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAA"
     }
     with allure.step('Create service on the cluster'):
         cluster_svc = client.cluster.service.create(
             cluster_id=cluster['id'],
             prototype_id=get_random_service(client)['id'])
     with allure.step(
             'Try to create config when config doesnt have all params'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.service.config.history.create(
                 cluster_id=cluster['id'],
                 service_id=cluster_svc['id'],
                 config=config_wo_required_param)
     with allure.step('Check error about params'):
         err.CONFIG_KEY_ERROR.equal(e)
     steps.delete_all_data(client)