示例#1
0
 def wait_for_broken_connection(self):
     """Wait until our connection breaks."""
     if not USE_IP:
         return
     poll_until(self.connection.is_connected,
                lambda connected: not connected,
                time_out=TIME_OUT_TIME)
 def wait_for_broken_connection(self):
     """Wait until our connection breaks."""
     if not USE_IP:
         return
     poll_until(self.connection.is_connected,
                lambda connected: not connected,
                time_out=TIME_OUT_TIME)
 def test_get_init_pid(self):
     def get_the_pid():
         out, err = process("pgrep init | vzpid - | awk '/%s/{print $1}'"
                             % str(instance_info.local_id))
         instance_info.pid = out.strip()
         return len(instance_info.pid) > 0
     poll_until(get_the_pid, sleep_time=10, time_out=(60 * 10))
 def wait_for_resize(self):
     def is_finished_resizing():
         instance = self.instance
         if instance.status == "RESIZE":
             return False
         assert_equal("ACTIVE", instance.status)
         return True
     poll_until(is_finished_resizing, time_out=TIME_OUT_TIME)
示例#5
0
 def wait_for_resize(self):
     def is_finished_resizing():
         instance = self.instance
         if instance.status == "RESIZE":
             return False
         assert_equal("ACTIVE", instance.status)
         return True
     poll_until(is_finished_resizing, time_out=TIME_OUT_TIME)
示例#6
0
    def test_get_init_pid(self):
        def get_the_pid():
            out, err = process("pgrep init | vzpid - | awk '/%s/{print $1}'" %
                               str(instance_info.local_id))
            instance_info.pid = out.strip()
            return len(instance_info.pid) > 0

        poll_until(get_the_pid, sleep_time=10, time_out=(60 * 10))
 def test_create_failure_on_server_failure(self):
     # Fake nova will fail a server ending with 'SERVER_ERROR'."
     response = self.dbaas.instances.create("test_SERVER_ERROR", 1, {"size": 1}, [])
     poll_until(
         lambda: self.dbaas.instances.get(response.id), lambda instance: instance.status == "ERROR", time_out=10
     )
     instance = self.dbaas.instances.get(response.id)
     print "Status: %s" % instance.status
     assert_equal(instance.status, "ERROR", "Instance did not drop to error after server prov failure.")
 def test_create_failure_on_volume_prov_failure(self):
     # Fake nova will fail a volume of size 9.
     response = self.dbaas.instances.create("volume_fail", 1, {"size": 9}, [])
     poll_until(
         lambda: self.dbaas.instances.get(response.id), lambda instance: instance.status == "ERROR", time_out=10
     )
     instance = self.dbaas.instances.get(response.id)
     print "Status: %s" % instance.status
     assert_equal(instance.status, "ERROR", "Instance did not drop to error after volume prov failure.")
 def test_create_failure_on_dns_failure(self):
     # TODO(ed-): Throw DNS-specific monkeywrench into works
     response = self.dbaas.instances.create("test_DNS_ERROR", 1, {"size": 1}, [])
     poll_until(
         lambda: self.dbaas.instances.get(response.id), lambda instance: instance.status == "ERROR", time_out=10
     )
     instance = self.dbaas.instances.get(response.id)
     print "Status: %s" % instance.status
     assert_equal(instance.status, "ERROR", "Instance did not drop to error after DNS prov failure.")
 def test_instance_created(self):
     def check_status_of_instance():
         status, err = process("sudo vzctl status %s | awk '{print $5}'"
                               % str(instance_info.local_id))
         if string_in_list(status, ["running"]):
             self.assertEqual("running", status.strip())
             return True
         else:
             return False
     poll_until(check_status_of_instance, sleep_time=5, time_out=(60 * 8))
 def test_get_ip(self):
     # wait for a few seconds for the IP to sync up
     # is there a better way to do this?
     def get_ip_for_instance():
         result = instance_info.dbaas.instances.get(instance_info.id)
         if hasattr(result, 'ip'):
             instance_info.user_ip = result.ip[0]
             return True
         return False
     poll_until(get_ip_for_instance, sleep_time=5, time_out=20)
示例#12
0
    def wait_for_failure_status(self):
        """Wait until status becomes running."""
        def is_finished_rebooting():
            instance = self.instance
            if instance.status == "REBOOT":
                return False
            assert_equal("SHUTDOWN", instance.status)
            return True

        poll_until(is_finished_rebooting, time_out=TIME_OUT_TIME)
示例#13
0
    def wait_for_successful_restart(self):
        """Wait until status becomes running."""
        def is_finished_rebooting():
            instance = self.instance
            if instance.status == "REBOOT":
                return False
            assert_equal("ACTIVE", instance.status)
            return True

        poll_until(is_finished_rebooting, time_out=TIME_OUT_TIME)
    def wait_for_failure_status(self):
        """Wait until status becomes running."""
        def is_finished_rebooting():
            instance = self.instance
            if instance.status == "REBOOT":
                return False
            assert_equal("SHUTDOWN", instance.status)
            return True

        poll_until(is_finished_rebooting, time_out=TIME_OUT_TIME)
 def update_and_wait_to_finish(self):
     instance_info.dbaas_admin.management.update(instance_info.id)
     def finished():
         current_version = self.get_version()
         if current_version == self.next_version:
             return True
         # The only valid thing for it to be aside from next_version is
         # old version.
         assert_equal(current_version, self.old_version)
     poll_until(finished, sleep_time=1, time_out=3 * 60)
    def wait_for_successful_restart(self):
        """Wait until status becomes running."""
        def is_finished_rebooting():
            instance = self.instance
            if instance.status == "REBOOT":
                return False
            assert_equal("ACTIVE", instance.status)
            return True

        poll_until(is_finished_rebooting, time_out=TIME_OUT_TIME)
 def test_create_failure_on_dns_failure(self):
     #TODO(ed-): Throw DNS-specific monkeywrench into works
     response = self.dbaas.instances.create('test_DNS_ERROR', 1,
                                            {'size': 1}, [])
     poll_until(lambda: self.dbaas.instances.get(response.id),
                lambda instance: instance.status == 'ERROR',
                time_out=10)
     instance = self.dbaas.instances.get(response.id)
     print "Status: %s" % instance.status
     assert_equal(instance.status, "ERROR",
                  "Instance did not drop to error after DNS prov failure.")
示例#18
0
    def test_instance_created(self):
        def check_status_of_instance():
            status, err = process("sudo vzctl status %s | awk '{print $5}'" %
                                  str(instance_info.local_id))
            if string_in_list(status, ["running"]):
                self.assertEqual("running", status.strip())
                return True
            else:
                return False

        poll_until(check_status_of_instance, sleep_time=5, time_out=(60 * 8))
 def test_create_failure_on_volume_prov_failure(self):
     # Fake nova will fail a volume of size 9.
     response = self.dbaas.instances.create('volume_fail', 1,
         {'size': 9}, [])
     poll_until(lambda: self.dbaas.instances.get(response.id),
                lambda instance: instance.status == 'ERROR',
                time_out=10)
     instance = self.dbaas.instances.get(response.id)
     print "Status: %s" % instance.status
     assert_equal(instance.status, "ERROR",
         "Instance did not drop to error after volume prov failure.")
示例#20
0
    def update_and_wait_to_finish(self):
        instance_info.dbaas_admin.management.update(instance_info.id)

        def finished():
            current_version = self.get_version()
            if current_version == self.next_version:
                return True
            # The only valid thing for it to be aside from next_version is
            # old version.
            assert_equal(current_version, self.old_version)
        poll_until(finished, sleep_time=1, time_out=3 * 60)
 def test_create_failure_on_server_failure(self):
     # Fake nova will fail a server ending with 'SERVER_ERROR'."
     response = self.dbaas.instances.create('test_SERVER_ERROR', 1,
         {'size': 1}, [])
     poll_until(lambda: self.dbaas.instances.get(response.id),
                lambda instance: instance.status == 'ERROR',
                time_out=10)
     instance = self.dbaas.instances.get(response.id)
     print "Status: %s" % instance.status
     assert_equal(instance.status, "ERROR",
         "Instance did not drop to error after server prov failure.")
示例#22
0
    def test_get_ip(self):
        # wait for a few seconds for the IP to sync up
        # is there a better way to do this?
        def get_ip_for_instance():
            result = instance_info.dbaas.instances.get(instance_info.id)
            if hasattr(result, 'ip'):
                instance_info.user_ip = result.ip[0]
                return True
            return False

        poll_until(get_ip_for_instance, sleep_time=5, time_out=20)
示例#23
0
 def set_up(self):
     if not FAKE_MODE:
         raise SkipTest("This test only works in fake mode.")
     self.client = create_client(is_admin=True)
     self.mgmt = self.client.management
     # Fake nova will fail a server ending with 'test_SERVER_ERROR'."
     response = self.client.instances.create('test_SERVER_ERROR', 1,
                                             {'size': 1}, [])
     poll_until(lambda: self.client.instances.get(response.id),
                lambda instance: instance.status == 'ERROR',
                time_out=10)
     self.id = response.id
示例#24
0
    def create_user(self):
        """Create a MySQL user we can use for this test."""

        users = [{"name": MYSQL_USERNAME, "password": MYSQL_PASSWORD,
                  "database": MYSQL_USERNAME}]
        self.dbaas.users.create(instance_info.id, users)

        def has_user():
            users = self.dbaas.users.list(instance_info.id)
            return any([user.name == MYSQL_USERNAME for user in users])

        poll_until(has_user, time_out=30)
        if not FAKE_MODE:
            time.sleep(5)
示例#25
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.")
 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.")
示例#27
0
    def test_volume_resize_success(self):
        def check_resize_status():
            instance = instance_info.dbaas.instances.get(instance_info.id)
            if instance.status == "ACTIVE":
                return True
            elif instance.status == "RESIZE":
                return False
            else:
                fail("Status should not be %s" % instance.status)

        poll_until(check_resize_status, sleep_time=2, time_out=300)
        volumes = db.volume_get(context.get_admin_context(),
                                instance_info.volume_id)
        assert_equal(volumes.status, 'in-use')
        assert_equal(volumes.size, self.new_volume_size)
        assert_equal(volumes.attach_status, 'attached')
    def test_volume_resize_success(self):

        def check_resize_status():
            instance = instance_info.dbaas.instances.get(instance_info.id)
            if instance.status == "ACTIVE":
                return True
            elif instance.status == "RESIZE":
                return False
            else:
                fail("Status should not be %s" % instance.status)

        poll_until(check_resize_status, sleep_time=2, time_out=300)
        volumes = db.volume_get(context.get_admin_context(),
                                instance_info.volume_id)
        assert_equal(volumes.status, 'in-use')
        assert_equal(volumes.size, self.new_volume_size)
        assert_equal(volumes.attach_status, 'attached')
    def test_instance_created(self):
        if WHITE_BOX:
            # Checks the db status as well as the REST API status.
            while True:
                guest_status = dbapi.guest_status_get(instance_info.local_id)
                if guest_status.state != power_state.RUNNING:
                    result = dbaas.instances.get(instance_info.id)
                    # I think there's a small race condition which can occur
                    # between the time you grab "guest_status" and "result," so
                    # RUNNING is allowed in addition to BUILDING.
                    self.assertTrue(
                        result.status == dbaas_mapping[power_state.BUILDING] or
                        result.status == dbaas_mapping[power_state.RUNNING],
                        "Result status was %s" % result.status)
                    time.sleep(5)
                else:
                    break
            report.log("Local id = %d" % instance_info.get_local_id())
        else:
            # This version just checks the REST API status.
            def result_is_active():
                instance = dbaas.instances.get(instance_info.id)
                if instance.status == "ACTIVE":
                    return True
                else:
                    # If its not ACTIVE, anything but BUILD must be
                    # an error.
                    assert_equal("BUILD", instance.status)
                    assert_equal(instance.volume.get('used', None), None)
                    return False

            poll_until(result_is_active)
            result = dbaas.instances.get(instance_info.id)
        report.log("Created an instance, ID = %s." % instance_info.id)
        report.log("TIP:")
        report.log("Rerun the tests with TESTS_USE_INSTANCE_ID=%s to skip "
                   "ahead to this point." % instance_info.id)
        report.log("Add TESTS_DO_NOT_DELETE_INSTANCE=True to avoid deleting "
                   "the instance at the end of the tests.")
示例#30
0
    def test_instance_created(self):
        if WHITE_BOX:
            # Checks the db status as well as the REST API status.
            while True:
                guest_status = dbapi.guest_status_get(instance_info.local_id)
                if guest_status.state != power_state.RUNNING:
                    result = dbaas.instances.get(instance_info.id)
                    # I think there's a small race condition which can occur
                    # between the time you grab "guest_status" and "result," so
                    # RUNNING is allowed in addition to BUILDING.
                    self.assertTrue(
                        result.status == dbaas_mapping[power_state.BUILDING]
                        or result.status == dbaas_mapping[power_state.RUNNING],
                        "Result status was %s" % result.status)
                    time.sleep(5)
                else:
                    break
            report.log("Local id = %d" % instance_info.get_local_id())
        else:
            # This version just checks the REST API status.
            def result_is_active():
                instance = dbaas.instances.get(instance_info.id)
                if instance.status == "ACTIVE":
                    return True
                else:
                    # If its not ACTIVE, anything but BUILD must be
                    # an error.
                    assert_equal("BUILD", instance.status)
                    assert_equal(instance.volume.get('used', None), None)
                    return False

            poll_until(result_is_active)
            result = dbaas.instances.get(instance_info.id)
        report.log("Created an instance, ID = %s." % instance_info.id)
        report.log("TIP:")
        report.log("Rerun the tests with TESTS_USE_INSTANCE_ID=%s to skip "
                   "ahead to this point." % instance_info.id)
        report.log("Add TESTS_DO_NOT_DELETE_INSTANCE=True to avoid deleting "
                   "the instance at the end of the tests.")
 def wait_for_instance_status(self, instance_id, status="ACTIVE"):
     poll_until(lambda: self.dbaas.instances.get(instance_id),
                lambda instance: instance.status == status,
                time_out=10)
 def wait_for_instance_task_status(self, instance_id, description):
     poll_until(lambda: self.dbaas.management.show(instance_id),
                lambda instance: instance.task_description == description,
                time_out=10)
示例#33
0
 def _wait_for_active(self):
     poll_until(lambda: self.client.instances.get(self.id),
                lambda instance: instance.status == "ACTIVE",
                time_out=(60 * 8))
 def _wait_for_new_volume_size(self, new_size):
     poll_until(lambda : self.client.instances.get(self.id),
                lambda instance : instance.volume['size'] == new_size,
                time_out=(60 * 8))
示例#35
0
 def _wait_for_new_volume_size(self, new_size):
     poll_until(lambda: self.client.instances.get(self.id),
                lambda instance: instance.volume['size'] == new_size,
                time_out=(60 * 8))
 def _wait_for_active(self):
     poll_until(lambda : self.client.instances.get(self.id),
                lambda instance : instance.status == "ACTIVE",
                time_out=(60 * 8))