Ejemplo n.º 1
0
    def setUp(self):
        """Sets up the client."""

        reqs = Requirements(is_admin=True)
        instance_info.admin_user = CONFIG.users.find_user(reqs)
        instance_info.dbaas_admin = create_dbaas_client(
            instance_info.admin_user)
        global dbaas_admin
        dbaas_admin = instance_info.dbaas_admin

        # Make sure we create the client as the correct user if we're using
        # a pre-built instance.
        if existing_instance():
            mgmt_inst = dbaas_admin.mgmt.instances.show(existing_instance())
            t_id = mgmt_inst.tenant_id
            instance_info.user = CONFIG.users.find_user_by_tenant_id(t_id)
        else:
            reqs = Requirements(is_admin=False)
            instance_info.user = CONFIG.users.find_user(reqs)

        instance_info.dbaas = create_dbaas_client(instance_info.user)
        if CONFIG.white_box:
            instance_info.nova_client = create_nova_client(instance_info.user)
            instance_info.volume_client = create_nova_client(
                instance_info.user,
                service_type=CONFIG.nova_client['volume_service_type'])
        global dbaas
        dbaas = instance_info.dbaas

        if CONFIG.white_box:
            user = instance_info.user.auth_user
            tenant = instance_info.user.tenant
            instance_info.user_context = context.RequestContext(user, tenant)
Ejemplo n.º 2
0
 def setUp(self):
     admin_req = Requirements(is_admin=True)
     self.admin_user = test_config.users.find_user(admin_req)
     self.admin_client = create_dbaas_client(self.admin_user)
     user_req = Requirements(is_admin=False)
     self.users = test_config.users.find_all_users_who_satisfy(user_req)
     self.user_tenant_ids = [user.tenant_id for user in self.users]
     self._create_instances_for_users()
Ejemplo n.º 3
0
    def setUp(self):
        rd_user = test_config.users.find_user(
            Requirements(is_admin=False, services=["reddwarf"]))
        self.rd_client = create_dbaas_client(rd_user)

        if test_config.nova_client is not None:
            nova_user = test_config.users.find_user(
                Requirements(is_admin=False, services=["nova"]))
            self.nova_client = create_nova_client(nova_user)
Ejemplo n.º 4
0
def delete_all():
    """Delete every single one."""
    user = test_config.users.find_user(Requirements(is_admin=False))
    dbaas = create_dbaas_client(user)
    instances = dbaas.instances.list()
    for instance in instances:
        instance.delete()
Ejemplo n.º 5
0
 def setUp(self):
     self.instances = []
     reqs = Requirements(is_admin=True)
     self.user = CONFIG.users.find_user(
         reqs, black_list=[])
     self.client = create_dbaas_client(self.user)
     self.mgmt = self.client.management
Ejemplo n.º 6
0
 def __init__(self, instance_id):
     self.instance_id = instance_id
     req_admin = Requirements(is_admin=True)
     self.user = util.test_config.users.find_user(req_admin)
     self.dbaas_admin = util.create_dbaas_client(self.user)
     self.instance = self.dbaas_admin.management.show(self.instance_id)
     self.instance_local_id = self.instance.server["local_id"]
Ejemplo n.º 7
0
def create_client(*args, **kwargs):
    """
    Using the User Requirements as arguments, finds a user and grabs a new
    DBAAS client.
    """
    reqs = Requirements(*args, **kwargs)
    user = test_config.users.find_user(reqs)
    return create_dbaas_client(user)
Ejemplo n.º 8
0
def login():
    """
    This super simple test just logs in.
    Its useful when running tests in a new environment to troubleshoot
    connection problems.
    """
    reqs = Requirements(is_admin=False)
    user = test_config.users.find_user(reqs)
    dbaas = create_dbaas_client(user)
    dbaas.instances.list()
Ejemplo n.º 9
0
def mgmt_instance_get():
    """ Tests the mgmt instances index method. """
    reqs = Requirements(is_admin=True)
    user = CONFIG.users.find_user(reqs)
    client = create_dbaas_client(user)
    mgmt = client.management
    # Grab the info.id created by the main instance test which is stored in
    # a global.
    id = instance_info.id
    api_instance = mgmt.show(id)

    # Print out all fields for extra info if the test fails.
    for name in dir(api_instance):
        print(str(name) + "=" + str(getattr(api_instance, name)))
    with TypeCheck("instance", api_instance) as instance:
        instance.has_field('created', basestring)
        instance.has_field('deleted', bool)
        # If the instance hasn't been deleted, this should be false... but
        # lets avoid creating more ordering work.
        instance.has_field('deleted_at', (basestring, None))
        instance.has_field('flavor', dict, flavor_check)
        instance.has_field('guest_status', dict, guest_status_check)
        instance.has_field('id', basestring)
        instance.has_field('links', list)
        instance.has_field('name', basestring)
        #instance.has_field('server_status', basestring)
        instance.has_field('status', basestring)
        instance.has_field('tenant_id', basestring)
        instance.has_field('updated', basestring)
        # Can be None if no volume is given on this instance.
        if CONFIG.reddwarf_volume_support:
            instance.has_field('volume', dict, volume_check)
        else:
            instance.has_field('volume', None)
        #TODO: Validate additional fields, assert no extra fields exist.
    with CollectionCheck("server", api_instance.server) as server:
        server.has_element("addresses", dict)
        server.has_element("deleted", bool)
        server.has_element("deleted_at", (basestring, None))
        server.has_element("host", basestring)
        server.has_element("id", basestring)
        server.has_element("local_id", int)
        server.has_element("name", basestring)
        server.has_element("status", basestring)
        server.has_element("tenant_id", basestring)
    if (CONFIG.reddwarf_volume_support
            and CONFIG.reddwarf_main_instance_has_volume):
        with CollectionCheck("volume", api_instance.volume) as volume:
            volume.has_element("attachments", list)
            volume.has_element("availability_zone", basestring)
            volume.has_element("created_at", (basestring, None))
            volume.has_element("id", basestring)
            volume.has_element("size", int)
            volume.has_element("status", basestring)
Ejemplo n.º 10
0
def setUp():
    """Set up vars needed by this story."""
    user = test_config.users.find_user(Requirements(is_admin=True))
    global client
    client = create_dbaas_client(user)
    flavors = client.find_flavors_by_ram(ram=8192)
    assert_true(len(flavors) >= 1, "No flavor found!")
    flavor = flavors[0]
    global flavor_href
    flavor_href = client.find_flavor_self_href(flavor)
    global original_notification_count
    original_notification_count = out_of_instance_memory_nofication_count()
Ejemplo n.º 11
0
 def test_all_non_admin_users_are_found(self):
     normals = set()
     for x in range(self.NUMBER_OF_USER_TESTS):
         user = self.users.find_user(Requirements(is_admin=False))
         if user not in normals:
             normals.add(user)
     self.assertEqual(NUMBER_OF_NORMALS, len(normals))
     normal_names = list(user.auth_user for user in normals)
     self.assertTrue("mike" in normal_names)
     self.assertTrue("tim" in normal_names)
     expected_test_count = self.NUMBER_OF_USER_TESTS / NUMBER_OF_NORMALS
     for user in normals:
         self.assertFalse(user.requirements.is_admin)
         self.assertEqual(expected_test_count, user.test_count)
Ejemplo n.º 12
0
 def setUp(self):
     self.user = test_config.users.find_user(Requirements(is_admin=True))
     self.client = create_dbaas_client(self.user)
     self.name = 'test_SERVER_ERROR'
     # Create an instance with a broken compute instance.
     self.response = self.client.instances.create(self.name, 1, {'size': 1},
                                                  [])
     poll_until(lambda: self.client.instances.get(self.response.id),
                lambda instance: instance.status == 'ERROR',
                time_out=10)
     self.instance = self.client.instances.get(self.response.id)
     print "Status: %s" % self.instance.status
     msg = "Instance did not drop to error after server prov failure."
     assert_equal(self.instance.status, "ERROR", msg)
Ejemplo n.º 13
0
 def setUp(self):
     self.reqs = Requirements(is_admin=False)
     self.user = CONFIG.users.find_user(self.reqs)
     self.dbaas = create_dbaas_client(self.user)
     self.instance = self.dbaas.instances.create(name="qe_instance",
                                                 flavor_id=1,
                                                 volume={"size": 1},
                                                 databases=[{
                                                     "name":
                                                     "firstdb",
                                                     "character_set":
                                                     "latin2",
                                                     "collate":
                                                     "latin2_general_ci"
                                                 }])
Ejemplo n.º 14
0
 def test_all_admin_users_are_found(self):
     admins = set()
     for x in range(self.NUMBER_OF_USER_TESTS):
         user = self.users.find_user(Requirements(is_admin=True))
         if user not in admins:
             admins.add(user)
     self.assertEqual(NUMBER_OF_ADMINS, len(admins))
     admin_names = list(user.auth_user for user in admins)
     self.assertTrue("admin" in admin_names)
     self.assertTrue("anne" in admin_names)
     self.assertTrue("dan" in admin_names)
     expected_test_count = self.NUMBER_OF_USER_TESTS / NUMBER_OF_ADMINS
     for user in admins:
         self.assertTrue(user.requirements.is_admin)
         self.assertEqual(expected_test_count, user.test_count)
Ejemplo n.º 15
0
 def setUp(self):
     reqs = Requirements(is_admin=False)
     self.other_user = CONFIG.users.find_user(
         reqs,
         black_list=[instance_info.user.auth_user])
     self.other_client = create_dbaas_client(self.other_user)
Ejemplo n.º 16
0
 def set_up(self):
     reqs = Requirements(is_admin=True)
     self.user = test_config.users.find_user(reqs)
     self.dbaas = create_dbaas_client(self.user)
Ejemplo n.º 17
0
 def set_up(self):
     """Create a ton of instances."""
     reqs = Requirements(is_admin=False)
     self.user = test_config.users.find_user(reqs)
     self.dbaas = create_dbaas_client(self.user)
Ejemplo n.º 18
0
 def setUp(self):
     """Create client for mgmt instance test."""
     reqs = Requirements(is_admin=True)
     self.user = CONFIG.users.find_user(reqs)
     self.client = create_dbaas_client(self.user)
Ejemplo n.º 19
0
 def setUp(self):
     """ Create the user and client for use in the subsequent tests."""
     self.user = test_config.users.find_user(Requirements(is_admin=False))
     self.dbaas = create_dbaas_client(self.user)
Ejemplo n.º 20
0
 def setUp(self):
     self.user = test_config.users.find_user(Requirements(is_admin=True))
     self.client = create_dbaas_client(self.user)
     self.host = None
Ejemplo n.º 21
0
 def setUp(self):
     """Sets up the client."""
     user = test_config.users.find_user(Requirements(is_admin=False))
     self.client = create_dbaas_client(user)