Exemple #1
0
 def test_scheduledtask_delete(self):
     assert_raises(exceptions.NotFound,
                   self.other_client.scheduledtasks.delete,
                   id=self.test_task.id)
     self.client.scheduledtasks.delete(id=self.test_task.id)
     assert_raises(exceptions.NotFound,
                   self.client.scheduledtasks.get, self.test_task.id)
Exemple #2
0
 def test_node_patch(self):
     """ Testing PATCH:/api/2.0/nodes/:id """
     data = {"name": 'fake_name_test'}
     Api().nodes_get_all()
     nodes = self.__get_data()
     codes = []
     for n in nodes:
         if n.get('name') == 'test_compute_node':
             uuid = n.get('id')
             Api().nodes_patch_by_id(identifier=uuid,body=data)
             rsp = self.__client.last_response
             test_nodes = self.__get_data()
             assert_equal(test_nodes.get('name'), 'fake_name_test', 'Oops patch failed')
             codes.append(rsp)
             LOG.info('Restoring name to "test_compute_node"')
             correct_data = {"name": 'test_compute_node'}
             Api().nodes_patch_by_id(identifier=uuid,body=correct_data)
             rsp = self.__client.last_response
             restored_nodes = self.__get_data()
             assert_equal(restored_nodes.get('name'), 'test_compute_node', 'Oops restoring failed')
             codes.append(rsp)
     assert_not_equal(0, len(codes), message='Failed to find compute node Ids')
     for c in codes:
         assert_equal(200, c.status, message=c.reason)
     assert_raises(rest.ApiException, Api().nodes_patch_by_id, 'fooey', data)
Exemple #3
0
    def test_backup_delete(self):
        """test delete"""

        # Test to make sure that user in other tenant is not able
        # to DELETE this backup
        reqs = Requirements(is_admin=False)
        other_user = CONFIG.users.find_user(
            reqs,
            black_list=[instance_info.user.auth_user])
        other_client = create_dbaas_client(other_user)
        assert_raises(exceptions.NotFound, other_client.backups.delete,
                      backup_info.id)

        instance_info.dbaas.backups.delete(backup_info.id)
        assert_equal(202, instance_info.dbaas.last_http_code)

        def backup_is_gone():
            result = instance_info.dbaas.instances.backups(instance_info.id)
            if len(result) == 0:
                return True
            else:
                return False
        poll_until(backup_is_gone)
        assert_raises(exceptions.NotFound, instance_info.dbaas.backups.get,
                      backup_info.id)
Exemple #4
0
    def test_hostname_ipv4_restriction(self):
        # By default, user hostnames are required to be % or IPv4 addresses.
        user = {"name": "ipv4_nodice", "password": "******",
                "databases": [], "host": "disallowed_host"}

        assert_raises(exceptions.BadRequest, self.dbaas.users.create,
                      instance_info.id, [user])
Exemple #5
0
 def create_too_many_instances(self):
     flavor, flavor_href = get_standby_instance_flavor(self.client1)
     asserts.assert_raises(exceptions.OverLimit,
                           self.client1.instances.create,
                           "too_many_instances",
                           flavor_href, {'size': 1})
     asserts.assert_equal(413, self.client1.last_http_code)
Exemple #6
0
    def test_scheduledtask_create(self):
        now = datetime.now()
        params = {
            "name": "Test Task",
            "instance_id": self.instance.id,
            "description": "Testing",
            "type": self.test_task_type,
            "enabled": True,
            "frequency": "daily",
            "window_start": now,
            "window_end": now + timedelta(hours=1),
            "metadata": {
                "meta": "data",
                "i_am": "so meta!",
            },
        }
        self.test_task = self.client.scheduledtasks.create(**params)
        for key in params:
            assert_equal(getattr(self.test_task, key), params[key])

        assert_is_not_none(self.test_task.id)

        params['frequency'] = 'dodecahourly'
        assert_raises(exceptions.NotFound, self.client.scheduledtasks.create,
                      **params)

        params['type'] = 'nonexistent'
        assert_raises(exceptions.NotFound, self.client.scheduledtasks.create,
                      **params)
    def test_eject_valid_master(self):
        if CONFIG.fake_mode:
            raise SkipTest("eject_replica_source not supported in fake mode")

        assert_raises(exceptions.BadRequest,
                      instance_info.dbaas.instances.eject_replica_source,
                      instance_info.id)
 def test_instance_size_too_big(self):
     if test_config.values['reddwarf_can_have_volume']:
         raise SkipTest("Wrong assertion because we have no volume limit")
         too_big = test_config.values['reddwarf_max_accepted_volume_size']
         assert_raises(nova_exceptions.OverLimit, dbaas.instances.create,
                       "way_too_large", instance_info.dbaas_flavor_href,
                       {'size': too_big + 1}, [])
Exemple #9
0
 def test_cannot_create_taboo_database_names(self):
     for name in self.system_dbs:
         databases = [{"name": name, "charset": "latin2",
                       "collate": "latin2_general_ci"}]
         assert_raises(exceptions.BadRequest, self.dbaas.databases.create,
                       instance_info.id, databases)
         assert_equal(400, self.dbaas.last_http_code)
Exemple #10
0
 def test_invalid_username(self):
     users = []
     users.append({"name": "user,", "password": self.password,
                   "database": self.db1})
     assert_raises(exceptions.BadRequest, self.dbaas.users.create,
                   instance_info.id, users)
     assert_equal(400, self.dbaas.last_http_code)
 def test_log_disable(self):
     self.instances.log_publish(instance_info.id, 'error', disable=True)
     self.wait_for_log_operation()
     container = 'log-mysql-error-' + instance_info.id
     # Check that the container is actually gone
     assert_raises(swiftclient.exceptions.ClientException,
                   self.swift_client.get_container(container))
Exemple #12
0
 def test_node_patch(self):
     """ Verify PATCH:/nodes/:id """
     data = {"name": "fake_name_test"}
     Nodes().api1_1_nodes_get()
     nodes = loads(self.__client.last_response.data)
     codes = []
     for n in nodes:
         if n.get("name") == "test_compute_node":
             uuid = n.get("id")
             Nodes().api1_1_nodes_identifier_patch(uuid, data)
             rsp = self.__client.last_response
             test_nodes = loads(self.__client.last_response.data)
             assert_equal(test_nodes.get("name"), "fake_name_test", "Oops patch failed")
             codes.append(rsp)
             LOG.info('Restoring name to "test_compute_node"')
             correct_data = {"name": "test_compute_node"}
             Nodes().api1_1_nodes_identifier_patch(uuid, correct_data)
             rsp = self.__client.last_response
             restored_nodes = loads(self.__client.last_response.data)
             assert_equal(restored_nodes.get("name"), "test_compute_node", "Oops restoring failed")
             codes.append(rsp)
     assert_not_equal(0, len(codes), message="Failed to find compute node Ids")
     for c in codes:
         assert_equal(200, c.status, message=c.reason)
     assert_raises(rest.ApiException, Nodes().api1_1_nodes_identifier_patch, "fooey", data)
    def create_list_import_delete_bootstrap_image(self):
        """Validate CRD operations of fuel-bootstrap utility

        Scenario:
            1. Revert snapshot build_default_bootstrap
            2. Build and Ubuntu bootstrap with default settings
            3. Validate it is available in images list
            4. Delete Ubuntu bootstrap image
            5. Validate it is not available and can not be activated
            6. Validate restriction for deleting active image

        Duration 30m
        """
        self.env.revert_snapshot("build_default_bootstrap")

        expected_bootstrap_uuids = \
            self.env.fuel_bootstrap_actions.list_bootstrap_images_uuids()

        uuid, bootstrap_location = \
            self.env.fuel_bootstrap_actions.build_bootstrap_image()
        self.env.fuel_bootstrap_actions.\
            import_bootstrap_image(bootstrap_location)

        bootstrap_uuids = self.env.fuel_bootstrap_actions.\
            list_bootstrap_images_uuids()
        assert_true(uuid in bootstrap_uuids,
                    "Newly built bootstrap image {0} is not in list of "
                    "available images: {1}".format(uuid, bootstrap_uuids))

        assert_equal(
            len(expected_bootstrap_uuids) + 1, len(bootstrap_uuids),
            "Only {0} bootstrap images should be available; current list: "
            "\n{1}".format(bootstrap_uuids, len(expected_bootstrap_uuids) + 1))

        self.env.fuel_bootstrap_actions.delete_bootstrap_image(uuid)

        bootstrap_uuids = self.env.fuel_bootstrap_actions.\
            list_bootstrap_images_uuids()
        assert_true(uuid not in bootstrap_uuids,
                    "Bootstrap {0} was not deleted and still available: {1}"
                    .format(uuid, bootstrap_uuids))

        assert_raises(DevopsCalledProcessError,
                      self.env.fuel_bootstrap_actions.activate_bootstrap_image,
                      uuid)

        assert_equal(
            len(expected_bootstrap_uuids), len(bootstrap_uuids),
            "Only {0} bootstrap images should be available; current list: "
            "\n{1}".format(bootstrap_uuids, len(expected_bootstrap_uuids)))

        uuid = self.env.fuel_bootstrap_actions.get_active_bootstrap_uuid()
        # we need to fail in case uuid is None, otherwise the assert_raises
        # will use: uuid = None
        assert_true(uuid is not None, "No active bootstrap. Possibly centos "
                    "is active or something went wrong.")
        assert_raises(
            DevopsCalledProcessError,
            self.env.fuel_bootstrap_actions.delete_bootstrap_image,
            uuid)
 def test_mgmt_root_history(self):
     """
     A regular user may not view the root access history of
     any instance.
     """
     assert_raises(Unauthorized,
                   self.dbaas.management.root_enabled_history, 0)
Exemple #15
0
 def test_node_patch(self):
     """ Verify PATCH:/nodes/:id """
     data = {"name": 'fake_name_test'}
     Nodes().nodes_get()
     nodes = loads(self.__client.last_response.data)
     codes = []
     for n in nodes:
         if n.get('name') == 'test_compute_node':
             uuid = n.get('id')
             Nodes().nodes_identifier_patch(uuid, data)
             rsp = self.__client.last_response
             test_nodes = loads(self.__client.last_response.data)
             assert_equal(test_nodes.get('name'), 'fake_name_test', 'Oops patch failed')
             codes.append(rsp)
             LOG.info('Restoring name to "test_compute_node"')
             correct_data = {"name": 'test_compute_node'}
             Nodes().nodes_identifier_patch(uuid, correct_data)
             rsp = self.__client.last_response
             restored_nodes = loads(self.__client.last_response.data)
             assert_equal(restored_nodes.get('name'), 'test_compute_node', 'Oops restoring failed')
             codes.append(rsp)
     assert_not_equal(0, len(codes), message='Failed to find compute node Ids')
     for c in codes:
         assert_equal(200, c.status, message=c.reason)
     assert_raises(rest.ApiException, Nodes().nodes_identifier_patch, 'fooey', data)
Exemple #16
0
    def test_updateduser_newhost_invalid(self):
        # Ensure invalid hostnames/usernames aren't allowed to enter the system
        users = []
        username = "******"
        hostname1 = "192.168.0.1"
        users.append({"name": username, "password": "******", "host": hostname1, "databases": []})
        self.dbaas.users.create(instance_info.id, users)
        hostname1 = hostname1.replace(".", "%2e")
        assert_raises(
            exceptions.BadRequest,
            self.dbaas.users.update_attributes,
            instance_info.id,
            username,
            {"host": "badjuju"},
            hostname1,
        )
        assert_equal(400, self.dbaas.last_http_code)

        assert_raises(
            exceptions.BadRequest,
            self.dbaas.users.update_attributes,
            instance_info.id,
            username,
            {"name": " bad username   "},
            hostname1,
        )
        assert_equal(400, self.dbaas.last_http_code)

        self.dbaas.users.delete(instance_info.id, username, hostname=hostname1)
    def test_compatability_wrapper_should_not_hide_error(self):

        def test_1():
            raise RuntimeError()

        assert_raises(RuntimeError,
                      compatability.capture_type_error, test_1)
Exemple #18
0
 def test_change_password_nonexistent_user(self):
     user = self._pick_a_user()
     user["name"] = "thisuserDNE"
     asserts.assert_raises(exceptions.NotFound,
                           self.dbaas.users.change_passwords,
                           instance_info.id, [user])
     asserts.assert_equal(404, self.dbaas.last_http_code)
Exemple #19
0
 def test_change_password_bogus_user(self):
     user = self._pick_a_user()
     user["name"] = "thisuserhasanamethatstoolong"
     asserts.assert_raises(exceptions.BadRequest,
                           self.dbaas.users.change_passwords,
                           instance_info.id, [user])
     asserts.assert_equal(400, self.dbaas.last_http_code)
Exemple #20
0
 def test_datastore_not_found(self):
     try:
         assert_raises(exceptions.NotFound,
                       self.rd_client.datastores.get, NAME)
     except exceptions.BadRequest as e:
         assert_equal(e.message,
                      "Datastore '%s' cannot be found." % NAME)
    def set_duplicate_hostname(self):
        """Verify that a duplicate hostname is not allowed

        Scenario:
            1. Revert the snapshot
            2. Set a custom hostname for the node
            3. Verify that new hostnames are validated to avoid duplicates

        Duration: 7m
        """
        self.env.revert_snapshot("ready_with_5_slaves")

        # Set a custom hostname for a node for the 1st time
        custom_hostname = 'custom-hostname'
        node = self.fuel_web.client.list_nodes()[0]
        self.fuel_web.client.set_hostname(node['id'], custom_hostname)

        # Try to change the hostname of the provisioned node
        assert_raises(
            HTTPError,
            self.fuel_web.client.set_hostname,
            node,
            custom_hostname)

        self.env.make_snapshot("set_duplicate_hostname")
Exemple #22
0
 def test_assign_configuration_to_instance_with_config(self):
     # test assigning a configuration to an instance that
     # already has an assigned configuration
     config_id = configuration_info.id
     assert_raises(exceptions.BadRequest,
                   instance_info.dbaas.instances.modify, instance_info.id,
                   configuration=config_id)
 def test_instance_size_too_big(self):
     if 'reddwarf_max_accepted_volume_size' in test_config.values:
         too_big = test_config.values['reddwarf_max_accepted_volume_size']
         assert_raises(exceptions.OverLimit, dbaas.instances.create,
                       "way_too_large", instance_info.dbaas_flavor_href,
                       {'size': too_big + 1}, [])
         assert_equal(413, dbaas.last_http_code)
Exemple #24
0
 def test_username_too_long(self):
     users = []
     users.append({"name": "1233asdwer345tyg56", "password": self.password,
                   "database": self.db1})
     assert_raises(exceptions.BadRequest, self.dbaas.users.create,
                   instance_info.id, users)
     assert_equal(400, self.dbaas.last_http_code)
 def delete_user(self):
     if self.test_user is None:
         raise SkipTest("User tests were never run.")
     admin = mymodule.get_admin_client()
     admin.delete_user(self.test_user.id)
     assert_raises(mymodule.UserNotFoundException, mymodule.login,
                 {'username':self.test_user.username, 'password':'******'})
Exemple #26
0
def must_work_with_blank_accept_headers():
    """Test to make sure that trove works without the headers"""
    versions = Versions()
    versions.setUp()
    client = versions.client

    if type(client.client).morph_request != TroveHTTPClient.morph_request:
        raise SkipTest("Not using the JSON client so can't execute this test.")

    original_morph_request = client.client.morph_request

    def morph_content_type_to(content_type):
        @wraps(original_morph_request)
        def _morph_request(kwargs):
            original_morph_request(kwargs)
            kwargs['headers']['Accept'] = content_type
            kwargs['headers']['Content-Type'] = content_type

        client.client.morph_request = _morph_request

    try:
        morph_content_type_to('')
        # run versions to make sure the API still returns JSON even though the
        # header type is blank
        versions.test_list_versions_index()
        # now change headers to XML to make sure the test fails
        morph_content_type_to('application/xml')
        asserts.assert_raises(exceptions.ResponseFormatError,
                              versions.test_list_versions_index)
    finally:
        client.client.morph_request = original_morph_request
Exemple #27
0
    def test_backup_get(self):
        """Test get backup."""
        backup = instance_info.dbaas.backups.get(backup_info.id)
        assert_equal(backup_info.id, backup.id)
        assert_equal(backup_info.name, backup.name)
        assert_equal(backup_info.description, backup.description)
        assert_equal(instance_info.id, backup.instance_id)
        assert_not_equal(0.0, backup.size)
        assert_equal('COMPLETED', backup.status)
        assert_equal(instance_info.dbaas_datastore,
                     backup.datastore['type'])
        assert_equal(instance_info.dbaas_datastore_version,
                     backup.datastore['version'])

        datastore_version = instance_info.dbaas.datastore_versions.get(
            instance_info.dbaas_datastore,
            instance_info.dbaas_datastore_version)
        assert_equal(datastore_version.id, backup.datastore['version_id'])

        # Test to make sure that user in other tenant is not able
        # to GET this backup
        reqs = Requirements(is_admin=False)
        other_user = CONFIG.users.find_user(
            reqs,
            black_list=[instance_info.user.auth_user])
        other_client = create_dbaas_client(other_user)
        assert_raises(exceptions.NotFound, other_client.backups.get,
                      backup_info.id)
Exemple #28
0
 def test_node_tags_del(self):
     """ Testing DELETE:api/2.0/nodes/:id/tags/:tagName """
     get_codes = []
     del_codes = []
     Api().nodes_get_all()
     rsp = self.__client.last_response
     nodes = loads(rsp.data)
     get_codes.append(rsp)
     for n in nodes:
         for t in self.__test_tags.get('tags'):
             Api().nodes_del_tag_by_id(identifier=n.get('id'), tag_name=t)
             rsp = self.__client.last_response
             del_codes.append(rsp)
         Api().nodes_get_by_id(identifier=n.get('id'))
         rsp = self.__client.last_response
         get_codes.append(rsp)
         updated_node = loads(rsp.data)
         for t in self.__test_tags.get('tags'):
             assert_true(t not in updated_node.get('tags'), message= "Tag " + t + " was not deleted" )
     for c in get_codes:
         assert_equal(200, c.status, message=c.reason)
     for c in del_codes:
         assert_equal(204, c.status, message=c.reason)
       
     assert_raises(rest.ApiException, Api().nodes_del_tag_by_id, 'fooey',tag_name=['tag'])
    def test_promote_master(self):
        if CONFIG.fake_mode:
            raise SkipTest("promote_master not supported in fake mode")

        assert_raises(exceptions.BadRequest,
                      instance_info.dbaas.instances.promote_to_replica_source,
                      instance_info.id)
 def test_create_failure_with_no_volume_size(self):
     instance_name = "instance-failure-with-no-volume-size"
     databases = []
     volume = {'size': None}
     assert_raises(nova_exceptions.BadRequest, dbaas.instances.create,
                   instance_name, instance_info.dbaas_flavor_href, volume,
                   databases)
Exemple #31
0
 def test_node_tags_del(self):
     """ Testing DELETE:api/2.0/nodes/:id/tags/:tagName """
     codes = []
     Api().nodes_get_all()
     rsp = self.__client.last_response
     nodes = loads(rsp.data)
     codes.append(rsp)
     for n in nodes:
         for t in self.__test_tags.get('tags'):
             Api().nodes_del_tag_by_id(identifier=n.get('id'), tag_name=t)
             rsp = self.__client.last_response
             codes.append(rsp)
         Api().nodes_get_by_id(identifier=n.get('id'))
         rsp = self.__client.last_response
         codes.append(rsp)
         updated_node = loads(rsp.data)
         for t in self.__test_tags.get('tags'):
             assert_true(t not in updated_node.get('tags'), message= "Tag " + t + " was not deleted" )
     for c in codes:
         assert_equal(200, c.status, message=c.reason)
     assert_raises(rest.ApiException, Api().nodes_del_tag_by_id, 'fooey',tag_name=['tag'])
Exemple #32
0
    def test_node_id_obm(self):
        """ Testing GET:/api/2.0/nodes/:id/obm """
        Api().nodes_get_all()
        nodes = self.__get_data()
        LOG.debug(nodes, json=True)
        codes = []
        for n in nodes:
            if n.get('name') == 'test_compute_node':
                uuid = n.get('id')
                Api().nodes_get_obm_by_id(identifier=uuid)
                rsp = self.__client.last_response
                LOG.info('OBM setting for node ID {0} is {1}'.format(
                    uuid, rsp.data))
                codes.append(rsp)

        assert_not_equal(0,
                         len(codes),
                         message='Failed to find compute node Ids')
        for c in codes:
            assert_equal(200, c.status, message=c.reason)
        assert_raises(rest.ApiException, Api().nodes_get_obm_by_id, 'fooey')
Exemple #33
0
 def test_workflows_action(self):
     """ Testing PUT:/api/2.0/nodes/:id/workflows/action """
     Api().nodes_get_all()
     nodes = self.__get_data()
     for n in nodes:
         if n.get('type') == 'compute':
             id = n.get('id')
             timeout = 5
             done = False
             while timeout > 0 and done == False:
                 if 0 == self.__post_workflow(id,'Graph.Discovery'):
                     fail('Timed out waiting for graph to start!')
                 try:
                     Api().nodes_workflow_action_by_id(id, {'command': 'cancel'})
                     done = True
                 except rest.ApiException as e:
                     if e.status != 404:
                         raise e
                     timeout -= 1
             assert_not_equal(timeout, 0, message='Failed to delete an active workflow')
     assert_raises(rest.ApiException, Api().nodes_workflow_action_by_id, 'fooey', {'command': 'test'})
Exemple #34
0
 def test_fails_when_creating_user_twice(self):
     users = []
     users.append({
         "name": self.username,
         "password": self.password,
         "databases": [{
             "name": self.db1
         }]
     })
     users.append({
         "name": self.username1,
         "password": self.password1,
         "databases": [{
             "name": self.db1
         }, {
             "name": self.db2
         }]
     })
     assert_raises(exceptions.BadRequest, self.dbaas.users.create,
                   instance_info.id, users)
     assert_equal(400, self.dbaas.last_http_code)
Exemple #35
0
 def test_node_tags_patch(self):
     """ Testing PATCH:/api/2.0/nodes/:id/tags """
     codes = []
     Api().nodes_get_all()
     rsp = self.__client.last_response
     nodes = loads(rsp.data)
     codes.append(rsp)
     for n in nodes:
         LOG.info(n, json=True)
         Api().nodes_patch_tag_by_id(identifier=n.get('id'),
                                     body=self.__test_tags)
         LOG.info('Creating tag (name={0})'.format(self.__test_tags))
         rsp = self.__client.last_response
         codes.append(rsp)
         LOG.info(n.get('id'))
     for c in codes:
         assert_equal(200, c.status, message=c.reason)
     assert_raises(rest.ApiException,
                   Api().nodes_patch_tag_by_id,
                   'fooey',
                   body=self.__test_tags)
Exemple #36
0
    def set_custom_hostname_for_provisioned_node(self):
        """Verify that it is not allowed to change a hostname of a
        provisioned node

        Scenario:
            1. Revert the snapshot
            2. Create a cluster
            3. Add a node with controller role
            4. Set a custom hostname for the node
            5. Provision the node
            6. Verify that updating node hostname of the provisioned node
               is not allowed

        Duration: 20m
        """
        self.env.revert_snapshot("ready_with_5_slaves")

        cluster_id = self.fuel_web.create_cluster(
            name=self.__class__.__name__,
            mode=settings.DEPLOYMENT_MODE,
            settings={
                'net_provider': 'neutron',
                'net_segment_type': settings.NEUTRON_SEGMENT_TYPE
            })

        self.fuel_web.update_nodes(cluster_id, {'slave-01': ['controller']})

        # Set a custom hostname for a node for the 1st time
        # and provision the node
        node = self.fuel_web.client.list_cluster_nodes(cluster_id)[0]
        self.fuel_web.client.set_hostname(node['id'], 'custom-hostname')
        self.fuel_web.provisioning_cluster_wait(cluster_id)

        # Try to change the hostname of the provisioned node
        # TODO(dkruglov): LP#1476722
        assert_raises(HTTPError, self.fuel_web.client.set_hostname, node['id'],
                      'new-custom-hostname')

        self.env.make_snapshot("set_custom_hostname_for_provisioned_node")
Exemple #37
0
 def test_create_failure_with_datastore_notfound(self):
     if VOLUME_SUPPORT:
         volume = {'size': CONFIG.get('trove_volume_size', 1)}
     else:
         volume = None
     instance_name = "datastore_notfound"
     databases = []
     users = []
     datastore = "nonexistent"
     try:
         assert_raises(exceptions.NotFound,
                       dbaas.instances.create,
                       instance_name,
                       instance_info.dbaas_flavor_href,
                       volume,
                       databases,
                       users,
                       datastore=datastore,
                       nics=instance_info.nics)
     except exceptions.BadRequest as e:
         assert_equal(e.message,
                      "Datastore '%s' cannot be found." % datastore)
Exemple #38
0
    def set_duplicate_hostname(self):
        """Verify that a duplicate hostname is not allowed

        Scenario:
            1. Revert the snapshot
            2. Set a custom hostname for the node
            3. Verify that new hostnames are validated to avoid duplicates

        Duration: 7m
        """
        self.env.revert_snapshot("ready_with_5_slaves")

        # Set a custom hostname for a node for the 1st time
        custom_hostname = 'custom-hostname'
        node = self.fuel_web.client.list_nodes()[0]
        self.fuel_web.client.set_hostname(node['id'], custom_hostname)

        # Try to change the hostname of the provisioned node
        assert_raises(HTTPError, self.fuel_web.client.set_hostname, node,
                      custom_hostname)

        self.env.make_snapshot("set_duplicate_hostname")
Exemple #39
0
    def test_create_cluster_with_different_volumes(self):
        invalid_request_body_with_different_volumes = [{
            "flavorRef": 2,
            "volume": {
                "size": 2
            }
        }, {
            "flavorRef": 2,
            "volume": {
                "size": 3
            }
        }]

        asserts.assert_raises(
            exceptions.BadRequest,
            self.rd_client.clusters.create,
            "test_cluster",
            self.instance.dbaas_datastore,
            self.instance.dbaas_datastore_version,
            instances=invalid_request_body_with_different_volumes)

        asserts.assert_equal(400, self.rd_client.last_http_code)
Exemple #40
0
    def test_create_too_many_instances(self):
        instance_quota = 0
        quota_dict = {'instances': instance_quota}
        new_quotas = dbaas_admin.quota.update(self.test_info.user.tenant_id,
                                              quota_dict)

        verify_quota = dbaas_admin.quota.show(self.test_info.user.tenant_id)

        assert_equal(new_quotas['instances'], quota_dict['instances'])
        assert_equal(0, verify_quota['instances'])
        assert_equal(CONFIG.reddwarf_max_volumes_per_user,
                     verify_quota['volumes'])

        self.test_info.volume = {'size': 1}
        self.test_info.name = "too_many_instances"
        assert_raises(exceptions.OverLimit,
                      dbaas.instances.create,
                      self.test_info.name,
                      self.test_info.dbaas_flavor_href,
                      self.test_info.volume)

        assert_equal(413, dbaas.last_http_code)
Exemple #41
0
 def test_node_workflows_post(self):
     """Testing node POST:id/workflows"""
     resps = []
     Nodes().nodes_get()
     nodes = self.__get_data()
     for n in nodes:
         if n.get('type') == 'compute':
             id = n.get('id')
             timeout = self.__post_workflow(id, 'Graph.Discovery', {})
             if timeout > 0:
                 data = self.__get_data()
             resps.append({'data': data, 'id': id})
     for resp in resps:
         assert_not_equal(0,
                          len(resp['data']),
                          message='No Workflows found for Node {0}'.format(
                              resp['id']))
     assert_raises(rest.ApiException,
                   Nodes().nodes_identifier_workflows_post,
                   'fooey',
                   'Graph.Discovery',
                   body={})
Exemple #42
0
 def test_node_workflows_del_active(self):
     """Testing node DELETE:id/workflows/active"""
     Nodes().nodes_get()
     nodes = self.__get_data()
     for n in nodes:
         if n.get('type') == 'compute':
             id = n.get('id')
             timeout = 5
             done = False
             while timeout > 0 and done == False:
                 if 0 == self.__post_workflow(id, 'Graph.Discovery', {}):
                     fail('Timed out waiting for graph to start!')
                 try:
                     Nodes().nodes_identifier_workflows_active_delete(id)
                     done = True
                 except rest.ApiException as e:
                     if e.status != 404:
                         raise e
                     timeout -= 1
     assert_raises(rest.ApiException,
                   Nodes().nodes_identifier_workflows_active_delete,
                   'fooey')
Exemple #43
0
    def check_can_not_enable_dpdk_with_tun(self):
        """Check can not enable DPDK on tun network

        Scenario:
            1. Create new environment with VXLAN segmentation for Neutron
            2. Set KVM as Hypervisor
            3. Add controller and compute nodes
            4. Configure HugePages for compute nodes
            5. Try configure private network in DPDK mode
        """
        self.env.revert_snapshot("ready_with_3_slaves")

        self.show_step(1)
        self.show_step(2)
        cluster_id = self.fuel_web.create_cluster(
            name=self.__class__.__name__,
            mode=settings.DEPLOYMENT_MODE,
            settings={
                "net_provider": 'neutron',
                "net_segment_type": "tun"
            })

        self.show_step(3)
        self.fuel_web.update_nodes(
            cluster_id, {
                'slave-01': ['controller'],
                'slave-02': ['compute'],
                'slave-03': ['cinder']
            })

        compute = self.fuel_web.get_nailgun_cluster_nodes_by_roles(
            cluster_id, ['compute'], role_status='pending_roles')[0]

        self.show_step(4)
        self.setup_hugepages(compute, hp_2mb=256, hp_dpdk_mb=128)

        self.show_step(5)
        assert_raises(HTTPError, self.enable_dpdk, compute, forceEnable=True)
Exemple #44
0
 def test_re_create_user(self):
     user_list = ["re_create_user"]
     # create, grant, then check a new user
     self._add_users(user_list)
     self._test_access(user_list, [])
     self._grant_access_singular(user_list[0], self.databases)
     self._test_access(user_list, self.databases)
     # drop the user temporarily
     self.dbaas.users.delete(instance_info.id, user_list[0])
     # check his access - user should not be found
     asserts.assert_raises(exceptions.NotFound,
                           self.dbaas.users.list_access, instance_info.id,
                           user_list[0])
     # re-create the user
     self._add_users(user_list)
     # check his access - should not exist
     self._test_access(user_list, [])
     # grant user access to all database.
     self._grant_access_singular(user_list[0], self.databases)
     # check his access - user should exist
     self._test_access(user_list, self.databases)
     # revoke users access
     self._revoke_access_plural(user_list, self.databases)
Exemple #45
0
    def test_updateduser_newhost_invalid(self):
        # Ensure invalid hostnames/usernames aren't allowed to enter the system
        users = []
        username = "******"
        hostname1 = "192.168.0.1"
        users.append({
            "name": username,
            "password": "******",
            "host": hostname1,
            "databases": []
        })
        self.dbaas.users.create(instance_info.id, users)
        hostname1 = hostname1.replace('.', '%2e')
        assert_raises(exceptions.BadRequest,
                      self.dbaas.users.update_attributes, instance_info.id,
                      username, {"host": "badjuju"}, hostname1)
        assert_equal(400, self.dbaas.last_http_code)

        assert_raises(exceptions.BadRequest,
                      self.dbaas.users.update_attributes, instance_info.id,
                      username, {"name": " bad username   "}, hostname1)
        assert_equal(400, self.dbaas.last_http_code)

        self.dbaas.users.delete(instance_info.id, username, hostname=hostname1)
Exemple #46
0
 def assert_raises(self, expected_exception, expected_http_code, client,
                   client_cmd, *cmd_args, **cmd_kwargs):
     if client:
         # Make sure that the client_cmd comes from the same client that
         # was passed in, otherwise asserting the client code may fail.
         cmd_clz = client_cmd.im_self
         cmd_clz_name = cmd_clz.__class__.__name__
         client_attrs = [
             attr[0] for attr in inspect.getmembers(client.real_client)
             if '__' not in attr[0]
         ]
         match = [
             getattr(client, a) for a in client_attrs
             if getattr(client, a).__class__.__name__ == cmd_clz_name
         ]
         self.assert_true(
             any(match),
             "Could not find method class in client: %s" % client_attrs)
         self.assert_equal(
             match[0], cmd_clz,
             "Test error: client_cmd must be from client obj")
     asserts.assert_raises(expected_exception, client_cmd, *cmd_args,
                           **cmd_kwargs)
     self.assert_client_code(client, expected_http_code)
Exemple #47
0
    def set_custom_hostname_for_provisioned_node(self):
        """Verify that it is not allowed to change a hostname of a
        provisioned node

        Scenario:
            1. Revert the snapshot
            2. Create a cluster
            3. Add a node with controller role
            4. Set a custom hostname for the node
            5. Provision the node
            6. Verify that updating node hostname of the provisioned node
               is not allowed

        Duration: 20m
        """
        self.env.revert_snapshot("ready_with_5_slaves")

        cluster_id = self.fuel_web.create_cluster(
            name=self.__class__.__name__,
            mode=settings.DEPLOYMENT_MODE,
        )

        self.fuel_web.update_nodes(cluster_id, {'slave-01': ['controller']})

        # Set a custom hostname for a node for the 1st time
        # and provision the node
        node = self.fuel_web.client.list_cluster_nodes(cluster_id)[0]
        self.fuel_web.client.set_hostname(node['id'], 'custom-hostname')
        self.fuel_web.provisioning_cluster_wait(cluster_id)

        # Try to change the hostname of the provisioned node
        assert_raises(http_exceptions.Forbidden,
                      self.fuel_web.client.set_hostname, node['id'],
                      'new-custom-hostname')

        self.env.make_snapshot("set_custom_hostname_for_provisioned_node")
Exemple #48
0
 def test_instance_resize_to_non_ephemeral_flavor_should_fail(self):
     flavor_name = CONFIG.values.get('instance_bigger_flavor_name',
                                     'm1-small')
     flavors = self.dbaas.find_flavors_by_name(flavor_name)
     asserts.assert_raises(BadRequest, self.dbaas.instances.resize_instance,
                           self.instance_id, flavors[0].id)
Exemple #49
0
 def test_instance_resize_same_size_should_fail(self):
     asserts.assert_raises(BadRequest, self.dbaas.instances.resize_instance,
                           self.instance_id, self.flavor_id)
Exemple #50
0
 def test_root_cannot_be_deleted(self):
     """Even if root was enabled, the user root cannot be deleted."""
     assert_raises(exceptions.BadRequest, self.dbaas.users.delete, self.id,
                   "root")
Exemple #51
0
 def test_root_disable_when_root_not_enabled(self):
     reh = self.dbaas_admin.management.root_enabled_history
     self.root_enabled_timestamp = reh(self.id).enabled
     assert_raises(exceptions.NotFound, self.dbaas.root.delete, self.id)
     self._verify_root_timestamp(self.id)
Exemple #52
0
 def test_delete_user_os_admin_failure(self):
     assert_raises(exceptions.BadRequest, self.dbaas.users.delete, self.id,
                   "os_admin")
Exemple #53
0
 def test_create_user_os_admin_failure(self):
     users = [{"name": "os_admin", "password": "******"}]
     assert_raises(exceptions.BadRequest, self.dbaas.users.create, self.id,
                   users)
Exemple #54
0
 def test_backup_create_instance_not_found(self):
     """Test create backup with unknown instance."""
     assert_raises(exceptions.NotFound, instance_info.dbaas.backups.create,
                   BACKUP_NAME, generate_uuid(), BACKUP_DESC)
Exemple #55
0
 def test_flavor_not_found(self):
     assert_raises(exceptions.NotFound, self.rd_client.flavors.get, "foo")
Exemple #56
0
    def assert_raises(self, expected_exception, expected_http_code,
                      client_cmd, *cmd_args, **cmd_kwargs):
        asserts.assert_raises(expected_exception, client_cmd,
                              *cmd_args, **cmd_kwargs)

        self.assert_client_code(expected_http_code)
Exemple #57
0
 def test_assign_in_wrong_state(self):
     # test assigning a config to an instance in RESTART state
     assert_raises(exceptions.BadRequest,
                   instance_info.dbaas.instances.modify,
                   configuration_instance.id,
                   configuration=configuration_info.id)
Exemple #58
0
 def test_unable_delete_instance_configurations(self):
     # test deleting a configuration that is assigned to
     # an instance is not allowed.
     assert_raises(exceptions.BadRequest,
                   instance_info.dbaas.configurations.delete,
                   configuration_info.id)
Exemple #59
0
 def test_delete_invalid_configuration_not_found(self):
     # test deleting a configuration that does not exist throws exception
     invalid_configuration_id = "invalid-config-id"
     assert_raises(exceptions.NotFound,
                   instance_info.dbaas.configurations.delete,
                   invalid_configuration_id)
Exemple #60
0
    def test_configurations_get(self):
        # test that the instance shows up on the assigned configuration
        result = instance_info.dbaas.configurations.get(configuration_info.id)
        assert_equal(configuration_info.id, result.id)
        assert_equal(configuration_info.name, result.name)
        assert_equal(configuration_info.description, result.description)

        # check the result field types
        with TypeCheck("configuration", result) as check:
            check.has_field("id", six.string_types)
            check.has_field("name", six.string_types)
            check.has_field("description", six.string_types)
            check.has_field("values", dict)
            check.has_field("created", six.string_types)
            check.has_field("updated", six.string_types)
            check.has_field("instance_count", int)

        print(result.values)

        # check for valid timestamps
        assert_true(_is_valid_timestamp(result.created))
        assert_true(_is_valid_timestamp(result.updated))

        # check that created and updated timestamps differ, since
        # test_appending_to_existing_configuration should have changed the
        # updated timestamp
        if not CONFIG.fake_mode:
            assert_not_equal(result.created, result.updated)

        assert_equal(result.instance_count, 1)

        with CollectionCheck("configuration_values", result.values) as check:
            # check each item has the correct type according to the rules
            for (item_key, item_val) in result.values.items():
                print("item_key: %s" % item_key)
                print("item_val: %s" % item_val)
                dbaas = instance_info.dbaas
                param = dbaas.configuration_parameters.get_parameter(
                    instance_info.dbaas_datastore,
                    instance_info.dbaas_datastore_version, item_key)
                if param.type == 'integer':
                    check.has_element(item_key, int)
                if param.type == 'string':
                    check.has_element(item_key, six.string_types)
                if param.type == 'boolean':
                    check.has_element(item_key, bool)

        # Test to make sure that another user is not able to GET this config
        reqs = Requirements(is_admin=False)
        test_auth_user = instance_info.user.auth_user
        other_user = CONFIG.users.find_user(reqs, black_list=[test_auth_user])
        other_user_tenant_id = other_user.tenant_id
        client_tenant_id = instance_info.user.tenant_id
        if other_user_tenant_id == client_tenant_id:
            other_user = CONFIG.users.find_user(
                reqs, black_list=[instance_info.user.auth_user, other_user])
        print(other_user)
        print(other_user.__dict__)
        other_client = create_dbaas_client(other_user)
        assert_raises(exceptions.NotFound, other_client.configurations.get,
                      configuration_info.id)