Example #1
0
 def test_sync_ami_image_with_dependent_images(self):
     ari_create_params = {
         "container_format": CONF.image.container_formats[1],
         "disk_format": CONF.image.disk_formats[1],
         "visibility": 'private',
     }
     ari_image = self.create_and_upload_image(**ari_create_params)
     aki_create_params = {
         "container_format": CONF.image.container_formats[2],
         "disk_format": CONF.image.disk_formats[2],
         "visibility": 'private',
     }
     aki_image = self.create_and_upload_image(**aki_create_params)
     ami_create_params = {
         "container_format": CONF.image.container_formats[0],
         "disk_format": CONF.image.disk_formats[0],
         "visibility": 'private',
         "ramdisk_id": ari_image['id'],
         "kernel_id": aki_image['id']
     }
     ami_image = self.create_and_upload_image(**ami_create_params)
     job_details = self._sync_ami_image(DEFAULT_FORCE, ami_image['id'])
     # Clean_up the database entries
     utils.wait_until_true(
         lambda: self._check_job_status(),
         exception=RuntimeError("Timed out waiting for job %s " %
                                job_details['job_id']))
     # Check for resources in target_regions.
     self._check_and_delete_dependent_images_target_region(
         job_details['admin'], job_details['target'], ami_image,
         DEFAULT_FORCE, **ami_create_params)
     self.delete_db_entries(job_details['job_id'])
 def test_keypair_sync_with_force_false(self):
     job_details_1 = self._keypair_sync_job_create(DEFAULT_FORCE)
     job_id_1 = job_details_1['job_id']
     utils.wait_until_true(lambda: self._check_job_status(),
                           exception=RuntimeError(
                               "Timed out waiting for job %s " % job_id_1))
     self.delete_db_entries(job_id_1)
     job_details_2 = self._keypair_sync_job_create(DEFAULT_FORCE,
                                                   job_details_1['keys'])
     job_id_2 = job_details_2['job_id']
     utils.wait_until_true(lambda: self._check_job_status(),
                           exception=RuntimeError(
                               "Timed out waiting for job %s " % job_id_2))
     job_list_resp = self.get_sync_job_detail(job_id_2)
     # This job fail because resoruce is already created.
     # We can use force to recreate that resource.
     self.assertEqual(
         job_list_resp.get('job_set')[0].get('sync_status'),
         consts.JOB_FAILURE)
     self.assertEqual(
         job_list_resp.get('job_set')[1].get('sync_status'),
         consts.JOB_FAILURE)
     # Clean_up the database entries
     self.delete_db_entries(job_id_2)
     self._cleanup_resources(job_details_2['keys'], job_details_2['target'],
                             self.client.user_id)
Example #3
0
 def test_get_image_sync_job_details(self):
     create_params = {
         "container_format": CONF.image.container_formats[3],
         "disk_format": CONF.image.disk_formats[6],
         "visibility": 'private',
     }
     job_details = self._image_sync_job_create(DEFAULT_FORCE,
                                               **create_params)
     utils.wait_until_true(
         lambda: self._check_job_status(),
         exception=RuntimeError("Timed out waiting for job %s " %
                                job_details['job_id']))
     job_list_resp = self.get_sync_job_detail(job_details['job_id'])
     for image_id in job_details['images']:
         for j in range(len(job_list_resp.get('job_set'))):
             if image_id in job_list_resp.get('job_set')[j].values():
                 self.assertEqual(
                     job_list_resp.get('job_set')[j].get('resource'),
                     image_id)
     self.assertEqual(
         job_list_resp.get('job_set')[0].get('resource_type'),
         consts.IMAGE_RESOURCE_TYPE)
     self._check_images_delete_target_region(job_details['admin'],
                                             job_details['target'],
                                             job_details['images'],
                                             DEFAULT_FORCE, **create_params)
     # Clean_up the database entries and resources.
     self.delete_db_entries(job_details['job_id'])
 def test_kb_quota_class_delete_method(self):
     new_quota = {"instances": 15, "cores": 15}
     self.update_quota_for_class(self.class_name, new_quota)
     self.delete_quota_for_class(self.class_name)
     utils.wait_until_true(
         lambda: self._delete_quota_values(self.class_name),
         exception=RuntimeError("Timed out "))
     quota_after_delete = self.get_quota_for_class(self.class_name)
     self.assertNotEqual(quota_after_delete['cores'], 15)
     self.assertNotEqual(quota_after_delete['instances'], 15)
 def test_kb_quota_class_put_method(self):
     new_quota = {"instances": 15, "cores": 10}
     actual_value = self.update_quota_for_class(self.class_name, new_quota)
     expected_value = QUOTA_CLASS_FORMAT
     expected_value['cores'] = 10
     expected_value['instances'] = 15
     expected_value['class_name'] = self.class_name
     self.assertEqual(expected_value, actual_value)
     self.delete_quota_for_class(self.class_name)
     utils.wait_until_true(
         lambda: self._delete_quota_values(self.class_name),
         exception=RuntimeError("Timed out "))
 def test_get_active_jobs(self):
     job_details = self._keypair_sync_job_create(FORCE)
     active_job = self.get_sync_job_list(consts.JOB_ACTIVE)
     status = active_job.get('job_set')[0].get('sync_status')
     self.assertEqual(status, consts.JOB_PROGRESS)
     utils.wait_until_true(
         lambda: self._check_job_status(),
         exception=RuntimeError("Timed out waiting for job %s " %
                                job_details['job_id']))
     # Clean_up the database entries
     self.delete_db_entries(job_details['job_id'])
     self._cleanup_resources(job_details['keys'], job_details['target'],
                             self.client.user_id)
 def test_get_kingbird_sync_list(self):
     job_details = self._keypair_sync_job_create(FORCE)
     utils.wait_until_true(
         lambda: self._check_job_status(),
         exception=RuntimeError("Timed out waiting for job %s " %
                                job_details['job_id']))
     job_list_resp = self.get_sync_job_list()
     self.assertEqual(job_list_resp['job_set'][0]['id'],
                      job_details['job_id'])
     # Clean_up the database entries and resources
     self.delete_db_entries(job_details['job_id'])
     self._cleanup_resources(job_details['keys'], job_details['target'],
                             self.client.user_id)
 def test_delete_already_deleted_job(self):
     job_details = self._keypair_sync_job_create(FORCE)
     # Clean_up the database entries
     utils.wait_until_true(
         lambda: self._check_job_status(),
         exception=RuntimeError("Timed out waiting for job %s " %
                                job_details['job_id']))
     self.delete_db_entries(job_details['job_id'])
     self.assertRaisesRegexp(kingbirdclient.exceptions.APIException,
                             "404 *", self.delete_db_entries,
                             job_details['job_id'])
     self._cleanup_resources(job_details['keys'], job_details['target'],
                             self.client.user_id)
 def test_kingbird_keypair_sync(self):
     # Keypairs created should be available in the response list
     # Create 2 keypairs:
     job_details = self._keypair_sync_job_create(FORCE)
     utils.wait_until_true(
         lambda: self._check_job_status(),
         exception=RuntimeError("Timed out waiting for job %s " %
                                job_details['job_id']))
     # Check for resources in target_regions
     self._check_keypairs_in_target_region(job_details['target'],
                                           job_details['keys'])
     # Clean_up the database entries and resources
     self.delete_db_entries(job_details['job_id'])
     self._cleanup_resources(job_details['keys'], job_details['target'],
                             self.client.user_id)
 def test_keypair_sync_with_force_true(self):
     job_details_1 = self._keypair_sync_job_create(FORCE)
     job_id_1 = job_details_1['job_id']
     utils.wait_until_true(lambda: self._check_job_status(),
                           exception=RuntimeError(
                               "Timed out waiting for job %s " % job_id_1))
     self.delete_db_entries(job_id_1)
     job_details_2 = self._keypair_sync_job_create(FORCE)
     job_id_2 = job_details_2['job_id']
     utils.wait_until_true(lambda: self._check_job_status(),
                           exception=RuntimeError(
                               "Timed out waiting for job %s " % job_id_2))
     # Clean_up the database entries
     self.delete_db_entries(job_id_2)
     self._cleanup_resources(job_details_2['keys'], job_details_2['target'],
                             self.client.user_id)
Example #11
0
 def test_qcow2_force_image_sync_with_extra_specs(self):
     create_params = {
         "container_format": CONF.image.container_formats[3],
         "disk_format": CONF.image.disk_formats[6],
         "visibility": 'private',
         "architecture": 'arm',
         "hypervisor_type": 'qemu'
     }
     job_details = self._image_sync_job_create(FORCE, **create_params)
     utils.wait_until_true(
         lambda: self._check_job_status(),
         exception=RuntimeError("Timed out waiting for job %s " %
                                job_details['job_id']))
     # Check for resources in target_regions.
     self._check_images_delete_target_region(job_details['admin'],
                                             job_details['target'],
                                             job_details['images'], FORCE,
                                             **create_params)
     # Clean_up the database entries and resources
     self.delete_db_entries(job_details['job_id'])
 def test_get_sync_job_details(self):
     job_details = self._keypair_sync_job_create(FORCE)
     utils.wait_until_true(
         lambda: self._check_job_status(),
         exception=RuntimeError("Timed out waiting for job %s " %
                                job_details['job_id']))
     job_list_resp = self.get_sync_job_detail(job_details['job_id'])
     key_list = job_details['keys']
     for i in range(len(key_list)):
         for j in range(len(job_list_resp.get('job_set'))):
             if key_list[i] in job_list_resp.get('job_set')[j].values():
                 self.assertEqual(
                     job_list_resp.get('job_set')[j].get('resource'),
                     key_list[i])
     self.assertEqual(
         job_list_resp.get('job_set')[0].get('resource_type'),
         consts.KEYPAIR_RESOURCE_TYPE)
     # Clean_up the database entries
     self.delete_db_entries(job_details['job_id'])
     self._cleanup_resources(job_details['keys'], job_details['target'],
                             self.client.user_id)
Example #13
0
 def test_delete_already_deleted_job(self):
     create_params = {
         "container_format": CONF.image.container_formats[3],
         "disk_format": CONF.image.disk_formats[6],
         "visibility": 'private',
     }
     job_details = self._image_sync_job_create(DEFAULT_FORCE,
                                               **create_params)
     utils.wait_until_true(
         lambda: self._check_job_status(),
         exception=RuntimeError("Timed out waiting for job %s " %
                                job_details['job_id']))
     # Clean_up the database entries
     self.delete_db_entries(job_details['job_id'])
     self.assertRaisesRegexp(kingbirdclient.exceptions.APIException,
                             "404 *", self.delete_db_entries,
                             job_details['job_id'])
     # Check for resources in target_regions.
     self._check_images_delete_target_region(job_details['admin'],
                                             job_details['target'],
                                             job_details['images'],
                                             DEFAULT_FORCE, **create_params)
Example #14
0
 def test_get_active_jobs_image_sync(self):
     create_params = {
         "container_format": CONF.image.container_formats[3],
         "disk_format": CONF.image.disk_formats[6],
         "visibility": 'private',
     }
     job_details = self._image_sync_job_create(DEFAULT_FORCE,
                                               **create_params)
     active_job = self.get_sync_job_list(consts.JOB_ACTIVE)
     status = active_job.get('job_set')[0].get('sync_status')
     self.assertEqual(status, consts.JOB_PROGRESS)
     utils.wait_until_true(
         lambda: self._check_job_status(),
         exception=RuntimeError("Timed out waiting for job %s " %
                                job_details['job_id']))
     # Check for resources in target_regions.
     self._check_images_delete_target_region(job_details['admin'],
                                             job_details['target'],
                                             job_details['images'],
                                             DEFAULT_FORCE, **create_params)
     # Clean_up the database entries
     self.delete_db_entries(job_details['job_id'])
Example #15
0
 def test_get_kingbird_image_sync_list(self):
     create_params = {
         "container_format": CONF.image.container_formats[3],
         "disk_format": CONF.image.disk_formats[6],
         "visibility": 'private',
     }
     job_details = self._image_sync_job_create(DEFAULT_FORCE,
                                               **create_params)
     utils.wait_until_true(
         lambda: self._check_job_status(),
         exception=RuntimeError("Timed out waiting for job %s " %
                                job_details['job_id']))
     # Check for resources in target_regions.
     job_list_resp = self.get_sync_job_list()
     self.assertEqual(job_list_resp['job_set'][0]['id'],
                      job_details['job_id'])
     self._check_images_delete_target_region(job_details['admin'],
                                             job_details['target'],
                                             job_details['images'],
                                             DEFAULT_FORCE, **create_params)
     # Clean_up the database entries and resources.
     self.delete_db_entries(job_details['job_id'])
Example #16
0
    def test_qcow2_force_image_sync(self):
        """Here we test these functionalities.

        Register image, upload the image file, get image and check
        if image is created in target regions.
        """
        create_params = {
            "container_format": CONF.image.container_formats[3],
            "disk_format": CONF.image.disk_formats[6],
            "visibility": 'private'
        }
        job_details = self._image_sync_job_create(FORCE, **create_params)
        utils.wait_until_true(
            lambda: self._check_job_status(),
            exception=RuntimeError("Timed out waiting for job %s " %
                                   job_details['job_id']))
        # Check for resources in target_regions.
        self._check_images_delete_target_region(job_details['admin'],
                                                job_details['target'],
                                                job_details['images'], FORCE,
                                                **create_params)
        # Clean_up the database entries and resources
        self.delete_db_entries(job_details['job_id'])