def setUp(self):
        """Sets up the client."""
        global dbaas
        global dbaas_admin
        # TODO(rnirmal): We need to better split out the regular client and
        # the admin client
        reqs = Requirements(is_admin=False)
        instance_info.user = test_config.users.find_user(reqs)
        instance_info.dbaas = create_dbaas_client(instance_info.user)
        if WHITE_BOX:
            instance_info.nova_client = create_nova_client(instance_info.user)
            instance_info.volume_client = create_nova_client(instance_info.user,
                                            service_type="volume_service_type")

        dbaas = instance_info.dbaas

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

        if WHITE_BOX:
            user = instance_info.user.auth_user
            tenant = instance_info.user.tenant
            instance_info.user_context = context.RequestContext(user, tenant)
 def setUp(self):
     self.dbaas = util.create_dbaas_client(instance_info.user)
     self.dbaas_admin = util.create_dbaas_client(instance_info.admin_user)
     databases = [{"name": self.db1, "charset": "latin2", "collate": "latin2_general_ci"}, {"name": self.db2}]
     self.dbaas.databases.create(instance_info.id, databases)
     if not FAKE:
         time.sleep(5)
    def setUp(self):
        """Sets up the client."""

        reqs = Requirements(is_admin=True)
        instance_info.admin_user = test_config.users.find_user(reqs)
        instance_info.dbaas_admin = create_dbaas_client(
                                        instance_info.admin_user)
        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_instance = dbaas_admin.mgmt.instances.show(existing_instance())
            t_id = mgmt_instance.tenant_id
            instance_info.user = test_config.users.find_user_by_tenant_id(t_id)
        else:
            reqs = Requirements(is_admin=False)
            instance_info.user = test_config.users.find_user(reqs)

        instance_info.dbaas = create_dbaas_client(instance_info.user)
        if WHITE_BOX:
            instance_info.nova_client = create_nova_client(instance_info.user)
            instance_info.volume_client = create_nova_client(instance_info.user,
                    service_type=test_config.nova_client['volume_service_type'])
        dbaas = instance_info.dbaas

        if WHITE_BOX:
            user = instance_info.user.auth_user
            tenant = instance_info.user.tenant
            instance_info.user_context = context.RequestContext(user, tenant)
    def setUp(self):
        self.admin_user = test_config.users.find_user(Requirements(is_admin=True))
        self.admin_client = create_dbaas_client(self.admin_user)
        self.admin_context = context.RequestContext(self.admin_user.auth_user, self.admin_user.tenant)

        self.user = test_config.users.find_user(Requirements(is_admin=False))
        self.client = create_dbaas_client(self.user)
        self.context = context.RequestContext(self.user.auth_user, self.user.tenant)
 def setUp(self):
     self.dbaas = util.create_dbaas_client(instance_info.user)
     self.dbaas_admin = util.create_dbaas_client(instance_info.admin_user)
     databases = [{"name": self.db1, "charset": "latin2",
                   "collate": "latin2_general_ci"},
                  {"name": self.db2}]
     try:
         self.dbaas.databases.create(instance_info.id, databases)
     except nova_exceptions.BadRequest:
         pass  # If the db already exists that's OK.
     if not FAKE:
         time.sleep(5)
 def setUp(self):
     nova_user = test_config.users.find_user(
         Requirements(is_admin=False, services=["nova"]))
     rd_user = test_config.users.find_user(
         Requirements(is_admin=False, services=["reddwarf"]))
     self.nova_client = create_nova_client(nova_user)
     self.rd_client = create_dbaas_client(rd_user)
def delete_all():
    """Delete every single one."""
    user = test_config.users.find_user(Requirements(is_admin=True))
    dbaas = create_dbaas_client(user)
    instances = dbaas.instances.list()
    for instance in instances:
        instance.delete()
Example #8
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 None:
            raise SkipTest("Skipping this test as no info to communicate with " "Nova was found in the test config.")
        nova_user = test_config.users.find_user(Requirements(is_admin=False, services=["nova"]))
        self.nova_client = create_nova_client(nova_user)
Example #9
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()
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()
Example #11
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()
Example #12
0
def mgmt_instance_get():
    """ Tests the mgmt instances index method. """
    reqs = Requirements(is_admin=True)
    user = test_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 test_config.values['reddwarf_main_instance_has_volume']:
            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)
    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)
    def setUp(self):
        """Sets up the client."""
        global dbaas
        global dbaas_admin
        # TODO(rnirmal): We need to better split out the regular client and
        # the admin client
        instance_info.user = test_config.users.find_user(Requirements(is_admin=False))
        instance_info.dbaas = create_dbaas_client(instance_info.user)

        nova_user = test_config.users.find_user(
            Requirements(is_admin=False, services=["nova"]))
        self.nova_client = create_nova_client(nova_user)

        dbaas = instance_info.dbaas

        instance_info.admin_user = test_config.users.find_user(Requirements(is_admin=True))
        instance_info.dbaas_admin = create_dbaas_client(instance_info.admin_user)
        dbaas_admin = instance_info.dbaas_admin

        if WHITE_BOX:
            instance_info.user_context = context.RequestContext(instance_info.user.auth_user,
                                                                instance_info.user.tenant)
Example #14
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
     assert_equal(self.instance.status, "ERROR",
         "Instance did not drop to error after server prov failure.")
Example #15
0
 def _delete_instances_for_users(self):
     for user in self.users:
         user_client = create_dbaas_client(user)
         while True:
             deleted_count = 0
             user_instances = user_client.instances.list()
             for instance in user_instances:
                 try:
                     instance.delete()
                 except exceptions.NotFound:
                     deleted_count += 1
                 except Exception:
                     print "Failed to delete instance"
             if deleted_count == len(user_instances):
                 break
 def setUp(self):
     """Sets up the client."""
     user = test_config.users.find_user(Requirements(is_admin=False))
     self.client = create_dbaas_client(user)
 def setUp(self):
     self.dbaas = util.create_dbaas_client(instance_info.user)
     self.dbaas_admin = util.create_dbaas_client(instance_info.admin_user)
Example #18
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)
 def setUp(self):
     self.user = test_config.users.find_user(Requirements(is_admin=True))
     self.client = create_dbaas_client(self.user)
 def setUp(self):
     reqs = Requirements(is_admin=False)
     self.other_user = test_config.users.find_user(reqs,
         black_list=[instance_info.user.auth_user])
     self.other_client = create_dbaas_client(self.other_user)
 def test_index_detail_match_for_regular_user(self):
     user = test_config.users.find_user(Requirements(is_admin=False))
     dbaas = create_dbaas_client(user)
     details = [instance.id for instance in dbaas.instances.list()]
     index = [instance.id for instance in dbaas.instances.index()]
     assert_equal(sorted(details), sorted(index))
Example #22
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)
Example #23
0
 def _create_instances_for_users(self):
     for user in self.users:
         user_client = create_dbaas_client(user)
         for index in range(self.max):
             name = "instance-%s-%03d" % (user.auth_user, index)
             user_client.instances.create(name, 1, {'size': 1}, [], [])
 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)
 def setUp(self):
     self.daffy_user = test_config.users.find_user_by_name("daffy")
     self.daffy_client = create_dbaas_client(self.daffy_user)