Esempio n. 1
0
 def test_shouldnt_create_service_config_when_try_to_put_dictionary_in_flat_key(
         self, client):
     cluster = steps.create_cluster(client)
     config = {
         "ssh-key": "as32fKj14fT88",
         "zoo.cfg": {
             "autopurge.purgeInterval": 24,
             "dataDir": "/zookeeper",
             "port": {
                 "foo": "bar"
             }
         },
         "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 where in flat param we put a dictionary'
     ):
         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)
     with allure.step('Check error about flat param'):
         err.CONFIG_VALUE_ERROR.equal(e, 'should be flat')
     steps.delete_all_data(client)
Esempio n. 2
0
 def test_create_cluster_service_config(self, client):
     cluster = steps.create_cluster(client)
     cfg_json = {
         "ssh-key": "TItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAA",
         "zoo.cfg": {
             "autopurge.purgeInterval": 30,
             "dataDir": "/dev/0",
             "port": 80
         },
         "required-key": "value"
     }
     with allure.step('Create service'):
         cluster_svc = client.cluster.service.create(
             cluster_id=cluster['id'],
             prototype_id=get_random_service(client)['id'])
     with allure.step('Create config'):
         config = client.cluster.service.config.history.create(
             cluster_id=cluster['id'],
             service_id=cluster_svc['id'],
             description='simple desc',
             config=cfg_json)
     with allure.step('Check created config'):
         expected = client.cluster.service.config.history.read(
             cluster_id=cluster['id'],
             service_id=cluster_svc['id'],
             version=config['id'])
         assert config == expected
     steps.delete_all_data(client)
Esempio n. 3
0
 def test_shouldnt_create_service_config_when_float_param_less_than_boundary(
         self, client):
     cluster = steps.create_cluster(client)
     config_float_less_boundary = {
         "ssh-key": "TItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAA",
         "zoo.cfg": {
             "autopurge.purgeInterval": 24,
             "dataDir": "/zookeeper",
             "port": 80
         },
         "float-key": 3.3,
         "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 float less than boundary'):
         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_float_less_boundary)
     with allure.step('Check error that float less than boundary'):
         err.CONFIG_VALUE_ERROR.equal(e, 'Value', 'should be more than')
     steps.delete_all_data(client)
Esempio n. 4
0
 def test_shouldnt_create_service_config_when_key_shouldnt_have_any_subkeys(
         self, client):
     cluster = steps.create_cluster(client)
     config_shouldnt_have_subkeys = {
         "ssh-key": {
             "key": "value"
         },
         "zoo.cfg": {
             "autopurge.purgeInterval": "24",
             "dataDir": "/zookeeper",
             "port": "http"
         }
     }
     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 where param shouldn\'t have any subkeys'
     ):
         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_shouldnt_have_subkeys)
     with allure.step('Check error about unknown subkey'):
         err.CONFIG_KEY_ERROR.equal(
             e, 'input config should not have any subkeys')
     steps.delete_all_data(client)
Esempio n. 5
0
 def test_shouldnt_create_service_config_when_config_have_unknown_subkey(
         self, client):
     cluster = steps.create_cluster(client)
     config_w_unknown_subkey = {
         "ssh-key": "TItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAA",
         "zoo.cfg": {
             "autopurge.purgeInterval": 24,
             "dataDir": "/zookeeper",
             "portium": "http"
         },
         "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 with unknown subkey'):
         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_subkey)
     with allure.step('Check error about unknown subkey'):
         err.CONFIG_KEY_ERROR.equal(e, 'There is unknown subkey')
     steps.delete_all_data(client)
Esempio n. 6
0
 def test_shouldnt_create_service_config_when_parameter_is_not_in_option_list(
         self, client):
     cluster = steps.create_cluster(client)
     config_w_illegal_param = {
         "ssh-key": "TItbmlzdHAyNTYAIbmlzdHAyNTYAAA",
         "float-key": 4.5,
         "zoo.cfg": {
             "autopurge.purgeInterval": 30,
             "dataDir": "/zookeeper",
             "port": 500
         },
         "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 has not option in a list'):
         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 CONFIG_VALUE_ERROR'):
         assert e.value.error.title == '400 Bad Request'
         assert e.value.error['code'] == 'CONFIG_VALUE_ERROR'
         assert ('not in option list' in e.value.error['desc']) is True
     steps.delete_all_data(client)
Esempio n. 7
0
 def test_shouldnt_create_service_config_when_parameter_is_not_string(
         self, client):
     cluster = steps.create_cluster(client)
     config_w_illegal_param = {
         "ssh-key": "TItbmlzdHAyNTYAAAAIbmlzdHAyNTY",
         "float-key": 5.7,
         "zoo.cfg": {
             "autopurge.purgeInterval": 30,
             "dataDir": "/zookeeper",
             "port": 80
         },
         "required-key": 500
     }
     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 string'):
         err.CONFIG_VALUE_ERROR.equal(e, 'should be string')
     steps.delete_all_data(client)
Esempio n. 8
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)
Esempio n. 9
0
 def test_shouldnt_create_service_config_when_config_not_json(self, client):
     cluster = steps.create_cluster(client)
     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 from non-json string'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.service.config.history.create(
                 cluster_id=cluster['id'],
                 service_id=cluster_svc['id'],
                 config=utils.random_string())
     with allure.step(
             'Check error 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)
Esempio n. 10
0
 def test_shouldnt_create_service_config_when_config_is_number(
         self, client):  # ADCM-86
     cluster = steps.create_cluster(client)
     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 from a number'):
         with pytest.raises(coreapi.exceptions.ErrorMessage) as e:
             client.cluster.service.config.history.create(
                 cluster_id=cluster['id'],
                 service_id=cluster_svc['id'],
                 config=random.randint(0, 9))
     with allure.step(
             'Check error that config should not be just one int or float'):
         err.JSON_ERROR.equal(e, 'should not be just one int or float')
     steps.delete_all_data(client)
Esempio n. 11
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)
Esempio n. 12
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)
Esempio n. 13
0
 def test_get_hostcomponent_list(self, client):  # invalid case, random component takes in circle
     cluster = steps.create_cluster(client)
     service = steps.read_service(client, get_random_service(client)['id'])
     cluster_svc = client.cluster.service.create(cluster_id=cluster['id'],
                                                 prototype_id=service['id'])
     components = client.cluster.service.component.list(cluster_id=cluster['id'],
                                                        service_id=cluster_svc['id'])
     # create mapping between cluster and hosts, then create hostcomponent on host
     hostcomponent_list = []
     for fqdn in utils.random_string_list():
         host = steps.create_host_w_default_provider(client, fqdn)
         steps.add_host_to_cluster(client, host, cluster)
         component = random.choice(components)['id']
         hostcomponent_list.append({"host_id": host['id'], "service_id": cluster_svc['id'],
                                    "component_id": component})
     expected_hostcomponent_list = client.cluster.hostcomponent.create(
         cluster_id=cluster['id'], hc=hostcomponent_list)
     actual_hs_list = client.cluster.hostcomponent.list(cluster_id=cluster['id'])
     with allure.step('Check created data with data from API'):
         assert actual_hs_list == expected_hostcomponent_list
Esempio n. 14
0
 def test_shouldnt_create_service_config_when_config_doesnt_have_one_req_sub(
         self, client):
     cluster = steps.create_cluster(client)
     config_wo_required_sub = {
         "ssh-key": "TItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAA",
         "zoo.cfg": {
             "autopurge.purgeInterval": 34
         },
         "required-key": "110"
     }
     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 doesn\'t have required'):
         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_sub)
     with allure.step('Check error about no required subkey'):
         err.CONFIG_KEY_ERROR.equal(e, 'There is no required subkey')
     steps.delete_all_data(client)