Пример #1
0
    def test_create_user_req_params(self):
        _user = []
        _user_name = "F343jasdf"
        _user.append({"name": _user_name,
                      "password": "******"})

        self.dbaas.users.create(self.instance_id, _user)

        httpCode = testutil.get_last_response_code(self.dbaas)
        self.assertTrue(httpCode == '202',
                        "Create instance failed with code %s" % httpCode)

        testutil.waitForActive(self.dbaas, instanceId=self.instance_id)

        #print (self.instance_id)
        self.assertTrue(testutil.getInstanceStatus(self.dbaas, instanceId=self.instance_id) == 'ACTIVE',
                        "Instance is not in Active statue")
        #Get the instance and check instance attribs: such as the flavor / volume size
        #TODO: need to verify this list later...
        _users = self.dbaas.users.list(self.dbaas.instances.get(self.instance_id))
        #self.assertTrue(len(_users) == 1, "Expected 1 user: Got: %s " % len(_users))
        #try to find our instance in the list
        self.assertTrue(testutil.found_resource(self.dbaas,
                                                instanceId=self.instance_id,
                                                userName=_user_name),
                        "Did not find our user name: %s in the list." % _user_name)

        self.dbaas.users.delete(self.instance_id, _user_name)
        self.assertFalse(testutil.found_resource(self.dbaas,
                                                 instanceId=self.instance_id,
                                                 userName=_user_name),
                         "Delete error: Found user name: %s in the list." % _user_name)
Пример #2
0
    def test_create_db_singular(self):
        db_name = "1234FiRstdb"
        _databases = [{"name": db_name,
                       "character_set": "latin2",
                       "collate": "latin2_general_ci"}]

        self.dbaas.databases.create(self.instance_id, _databases)
        httpCode = testutil.get_last_response_code(self.dbaas)
        self.assertTrue(httpCode == '202',
                        "Create instance failed with code %s" % httpCode)

        testutil.waitForActive(self.dbaas, instanceId=self.instance_id)

        #print (self.instance_id)
        self.assertTrue(testutil.getInstanceStatus(self.dbaas, instanceId=self.instance_id) == 'ACTIVE',
                        "Instance is not in Active statue")
        #Get the instance and check instance attribs: such as the flavor / volume size
        _databases = self.dbaas.databases.list(self.dbaas.instances.get(self.instance_id))
        self.assertTrue(len(_databases) == 1, "Expected 1 database: Got: %s " % len(_databases))
        #try to find our instance in the list
        self.assertTrue(testutil.found_resource(self.dbaas,
                                                instanceId=self.instance_id,
                                                databaseName=db_name),
                        "Did not find our database name: %s in the list." % db_name)

        self.dbaas.databases.delete(self.instance_id, db_name)
        self.assertFalse(testutil.found_resource(self.dbaas,
                                                 instanceId=self.instance_id,
                                                 databaseName=db_name),
                         "Delete error: Found database name: %s in the list." % db_name)
Пример #3
0
    def test_create_multi_user_with_multi_db(self):
        _db_name1 = "multi_user_with_multi-database"
        _db_name2 = "multi_user_with_multi-db2"
        _databases = [{"name": _db_name1},
                      {"name": _db_name2}]

        _test_users = []
        _test_users.append({"name": "F343jasdf_",
                      "password": "******",
                      "databases": _databases})

        _test_users.append({"name": "403F23F343jasdf",
                      "password": "******",
                      "databases": _databases})

        _test_users.append({"name": "easy_user_name",
                      "password": "******",
                      "databases": _databases})

        self.dbaas.users.create(self.instance_id, _test_users)

        httpCode = testutil.get_last_response_code(self.dbaas)
        self.assertTrue(httpCode == '202',
                        "Create instance failed with code %s" % httpCode)

        testutil.waitForActive(self.dbaas, instanceId=self.instance_id)

        #print (self.instance_id)
        self.assertTrue(testutil.getInstanceStatus(self.dbaas,
                                                   instanceId=self.instance_id) == 'ACTIVE',
                        "Instance is not in Active statue")
        #Get the instance and check user dbs
        _user_list = self.dbaas.users.list(self.dbaas.instances.get(self.instance_id))
        #self.assertTrue(len(_user_list) == len(_test_users), "Expected %s user: Got: %s "
        #                                                     % (len(_test_users), len(_user_list)))

        for _user in _user_list:
            self.assertEqual(_user.databases, _databases)
            #try to find our user in the list
            self.assertTrue(testutil.found_resource(self.dbaas,
                                                    instanceId=self.instance_id,
                                                    userName=_user.name),
                            "Did not find our user name: %s in the list." % _user.name)
            self.dbaas.users.delete(self.instance_id, _user.name)
            self.assertFalse(testutil.found_resource(self.dbaas,
                                                     instanceId=self.instance_id,
                                                     userName=_user.name),
                             "Delete error: Found user name: %s in the list." % _user.name)
Пример #4
0
    def test_create_tiny_instance(self):
        """
        Creating an instance for smoke testing

        """

        #database = self.dbaas_provider.client.reddwarfclient
        NAME = "qe-tiny-instance"
        FLAVOR = 1
        VOLUME = 20
        instance = self.dbaas.instances.create(
            name=NAME,
            flavor_id=FLAVOR,
            volume={"size": VOLUME},
            databases=[{"databases": [{"name": "databaseA"}],
                        "name": "dbuser1",
                        "password": "******"}])
        httpCode = testutil.get_last_response_code(self.dbaas)
        self.assertTrue(httpCode == '200',
                        "Create instance failed with code %s" % httpCode)
        testutil.waitForActive(self.dbaas, instanceId=instance.id)
        self.tiny_instance_id = instance.id

        #print (self.instance_id)
        self.assertTrue(testutil.getInstanceStatus(self.dbaas, instanceId=instance.id) == 'ACTIVE',
                        "Instance is not in Active statue")
        #Get the instance and check instance attribs: such as the flavor / volume size
        instance = self.dbaas.instances.get(instance)
        self.assertTrue(instance.flavor['id'] == str(FLAVOR))
        self.assertTrue(instance.volume['size'] == VOLUME)
        self.assertTrue(instance.name == NAME)
        #try to find our instance in the list
        self.assertTrue(testutil.found_resource(self.dbaas, instanceId=instance.id),
                        "Did not find our instance id: %s in the list." % instance.id)
Пример #5
0
    def test_create_required_params_instance(self):
        """
        Creating an instance for smoke testing

        """
        dbaas = self.dbaas_provider.client.reddwarfclient
        NAME = "qe-req-params-instance"
        FLAVOR = 1
        VOLUME = 10
        instance = dbaas.instances.create(
            name=NAME,
            flavor_id=FLAVOR,
            volume={"size": VOLUME})
        httpCode = testutil.get_last_response_code(dbaas)
        self.req_params_instance_id = instance.id
        self.assertTrue(httpCode == '200',
                        "Create instance failed with code %s" % httpCode)
        testutil.waitForActive(dbaas, instanceId=instance.id)
        self.assertTrue(testutil.getInstanceStatus(dbaas, instanceId=instance.id) == 'ACTIVE',
                        "Instance is not in Active statue")

        #Get the instance and check instance attribs: such as the flavor / volume size
        instance = self.dbaas.instances.get(instance)
        self.assertTrue(instance.flavor['id'] == str(FLAVOR))
        self.assertTrue(instance.volume['size'] == VOLUME)
        self.assertTrue(instance.name == NAME)
        #try to find our instance in the list
        self.assertTrue(testutil.found_resource(self.dbaas, instanceId=instance.id),
                        "Did not find our instance id: %s in the list." % instance.id)
Пример #6
0
    def test_create_2_users_instance(self):
        """
        Creating an instance for smoke testing

        """
        dbaas = self.dbaas_provider.client.reddwarfclient
        NAME = "qe-2users-instance"
        FLAVOR = 1
        VOLUME = 10

        databases = []
        databases.append({"name": "firstdb",
                          "character_set": "latin2",
                          "collate": "latin2_general_ci"})
        users = []
        users.append({"name": "lite",
                      "password": "******",
                      "databases": [{"name": "firstdb"}]})
        users.append({"name": "lite1",
                      "password": "******",
                      "databases": [{"name": "firstdb"}]})

        instance = dbaas.instances.create(
            name=NAME,
            flavor_id=FLAVOR,
            volume={"size": VOLUME},
            databases=databases,
            users=users)
        httpCode = testutil.get_last_response_code(dbaas)
        self.multi_users_instance_id = instance.id
        self.assertTrue(httpCode == '200',
                        "Create instance failed with code %s" % httpCode)
        testutil.waitForActive(dbaas, instanceId=instance.id)
        self.assertTrue(testutil.getInstanceStatus(dbaas, instanceId=instance.id) == 'ACTIVE',
                        "Instance is not in Active statue")

        #Get the instance and check instance attribs: such as the flavor / volume size
        instance = self.dbaas.instances.get(instance)
        self.assertTrue(instance.flavor['id'] == str(FLAVOR))
        self.assertTrue(instance.volume['size'] == VOLUME)
        self.assertTrue(instance.name == NAME)
        #try to find our instance in the list
        self.assertTrue(testutil.found_resource(self.dbaas, instanceId=instance.id),
                        "Did not find our instance id: %s in the list." % instance.id)
Пример #7
0
    def test_change_user_pw(self):
        """
        Changes the password of a user
        Issue: You cannot verify the new password since that is
        never returned from the server.
        @return:
        """
        _db_name1 = "test_change_user_pw"
        _db_name2 = "test_change_user_pw2"
        _databases = [{"name": _db_name1},
                      {"name": _db_name2}]

        _test_user = []
        _user_name = "F343jasdf1234"
        _test_user.append({"name": _user_name,
                      "password": "******",
                      "databases": _databases})

        self.dbaas.users.create(self.instance_id, _test_user)

        httpCode = testutil.get_last_response_code(self.dbaas)
        self.assertTrue(httpCode == '202',
                        "Create instance failed with code %s" % httpCode)

        testutil.waitForActive(self.dbaas, instanceId=self.instance_id)

        _test_user[0]['password'] = "******"
        self.dbaas.users.change_passwords(self.instance_id, _test_user)

        httpCode = testutil.get_last_response_code(self.dbaas)
        self.assertTrue(httpCode == '202',
                        "Create instance failed with code %s" % httpCode)

        self.dbaas.users.delete(self.instance_id, _user_name)
        self.assertFalse(testutil.found_resource(self.dbaas,
                                                 instanceId=self.instance_id,
                                                 userName=_user_name),
                         "Delete error: Found user name: %s in the list." % _user_name)
Пример #8
0
    def test_user_access(self):
        _db_name1 = "test_user_access-database"
        _db_name2 = "test_user_access-db2"
        _databases = [{"name": _db_name1},
                      {"name": _db_name2}]

        _test_users = []
        _user_name = "F343jasdfasdf"
        _test_users.append({"name": _user_name,
                           "password": "******",
                           "databases": _databases})

        self.dbaas.users.create(self.instance_id, _test_users)

        httpCode = testutil.get_last_response_code(self.dbaas)
        self.assertTrue(httpCode == '202',
                        "Create instance failed with code %s" % httpCode)

        testutil.waitForActive(self.dbaas, instanceId=self.instance_id)

        #Validate access to the databases just created
        for _test_user in _test_users:
            _username = _test_user['name']
            _db_access_list = self.dbaas.users.list_access(self.instance_id, _username)
            #create a dict to compare with
            _db_actual_list = []
            for db_list in _db_access_list:
                _db_actual = {'name': db_list.name}
                _db_actual_list.append(_db_actual)
            self.assertEqual(_databases, _db_actual_list,
                             "Expected %s | Actual %s"
                             % (_databases, _db_actual_list))

        #Revoke access to the dbs
        db_count = 2
        for _test_user in _test_users:
            _username = _test_user['name']
            for _db in _databases:
                self.dbaas.users.revoke(self.instance_id, _username, _db['name'])
                httpCode = testutil.get_last_response_code(self.dbaas)
                self.assertTrue(httpCode == '202',
                                "Create instance failed with code %s" % httpCode)
                db_count -= 1
                _db_access_list = self.dbaas.users.list_access(self.instance_id, _username)
                self.assertEqual(len(_db_access_list), db_count)
                _db_actual_list = []
                for db_list in _db_access_list:
                    _db_actual = {'name': db_list.name}
                    _db_actual_list.append(_db_actual)
                self.assertNotEqual(_databases, _db_actual_list,
                                    "Expected %s | Actual %s"
                                    % (_databases, _db_actual_list))
        #Grant access to the dbs
        db_count = 0
        for _test_user in _test_users:
            _username = _test_user['name']
            for _db in _databases:
                _db_list = [_db['name']]
                self.dbaas.users.grant(self.instance_id, _username, _db_list)
                httpCode = testutil.get_last_response_code(self.dbaas)
                self.assertTrue(httpCode == '202',
                                "Create instance failed with code %s" % httpCode)
                db_count += 1
                _db_access_list = self.dbaas.users.list_access(self.instance_id, _username)
                self.assertEqual(len(_db_access_list), db_count,
                                 "Expected database count %s, Actual DBs found %s"
                                 % (db_count, _db_access_list))
                _db_actual_list = []
                for db_list in _db_access_list:
                    _db_actual = {'name': db_list.name}
                    _db_actual_list.append(_db_actual)
                if db_count != 2:
                    self.assertNotEqual(_databases, _db_actual_list,
                                        "Expected %s | Actual %s"
                                        % (_databases, _db_actual_list))
                else:
                    self.assertEqual(_databases, _db_actual_list,
                                     "Expected %s | Actual %s"
                                     % (_databases, _db_actual_list))

        self.dbaas.users.delete(self.instance_id, _user_name)
        self.assertFalse(testutil.found_resource(self.dbaas,
                                                     instanceId=self.instance_id,
                                                     userName=_user_name),
                             "Delete error: Found user name: %s in the list." % _user_name)