예제 #1
0
    def test_post_user_scenario_capsule_sync_yum_repo(self, request,
                                                      default_sat,
                                                      default_org):
        """Post-upgrade scenario that creates and sync repository with
        rpm, sync capsule with satellite and verifies if the repo/rpm in
        satellite is synced to capsule.

        :id: postupgrade-7c1d3441-3e8d-4ac2-8102-30e18274658c

        :steps:
            1. Post Upgrade , Sync a repo/rpm in satellite.
            2. Run capsule sync.
            3. Check if the repo/rpm is been synced to capsule.

        :expectedresults:
            1. The repo/rpm should be synced to satellite
            2. Capsule sync should be successful
            3. The repo/rpm from satellite should be synced to capsule

        """
        request.addfinalizer(lambda: cleanup(content_view, repo, product))
        repo_name = gen_string('alpha')
        rpm_name = rpm2.split('/')[-1]
        activation_key = (
            settings.upgrade.capsule_ak[settings.upgrade.os]
            or settings.upgrade.custom_capsule_ak[settings.upgrade.os])
        cap_host = settings.upgrade.capsule_hostname
        ak = default_sat.api.ActivationKey(organization=default_org.id).search(
            query={'search': f'name={activation_key}'})[0]
        ak_env = ak.environment.read()
        repo_url = f'http://{default_sat.hostname}/pub/{repo_name}/'
        product = default_sat.api.Product(organization=default_org.id).create()
        repo_path = f'/var/www/html/pub/{repo_name}/'
        create_repo(rpm2, repo_path)

        repo = default_sat.api.Repository(product=product.id,
                                          name=f'{repo_name}',
                                          url=repo_url).create()
        repo.sync()
        content_view = default_sat.api.ContentView(
            organization=default_org.id).create()
        content_view.repository = [repo]
        content_view = content_view.update(['repository'])
        content_view.publish()
        promote(content_view.read().version[0], ak_env.id)
        content_view_env = [env.id for env in content_view.read().environment]
        assert ak_env.id in content_view_env

        wait_untill_capsule_sync(cap_host)
        result = execute(
            lambda: run(
                f'[ -f /var/lib/pulp/published/yum/http/repos/{default_org.label}/{ak_env.name}/'
                f'{content_view.name}/custom/{product.name}/{repo_name}/Packages/c/{rpm_name} ];'
                f' echo $?'),
            host=cap_host,
        )[cap_host]
        assert '0' == result
예제 #2
0
 def setUpClass(cls):
     cls.cls_name = 'Scenario_capsule_sync_2'
     cls.sat_host = settings.server.hostname
     cls.cap_host = settings.upgrade.rhev_cap_host or settings.upgrade.capsule_hostname
     cls.repo_name = 'capsulesync_TestRepo_' + cls.cls_name
     cls.repo_path = '/var/www/html/pub/postupgradeCapSync_repo/'
     cls.rpm_name = rpm2.split('/')[-1]
     cls.prod_name = 'Scenario_postUpgradeCapSync_' + cls.cls_name
     cls.activation_key = settings.upgrade.rhev_capsule_ak or settings.upgrade.capsule_ak
     cls.cv_name = 'Scenario_postcapSync_' + cls.cls_name
     cls.org_id = '1'
     cls.repo_url = 'http://{0}{1}'.format(cls.sat_host,
                                           '/pub/postupgradeCapSync_repo/')
예제 #3
0
 def setUpClass(cls):
     cls.cls_name = 'Scenario_capsule_sync_2'
     cls.sat_host = settings.server.hostname
     cls.cap_host = os.environ.get('RHEV_CAP_HOST',
                                   os.environ.get('CAPSULE_HOSTNAME'))
     cls.repo_name = 'capsulesync_TestRepo_' + cls.cls_name
     cls.repo_path = '/var/www/html/pub/postupgradeCapSync_repo/'
     cls.rpm_name = rpm2.split('/')[-1]
     cls.prod_name = 'Scenario_postUpgradeCapSync_' + cls.cls_name
     cls.activation_key = os.environ.get('CAPSULE_AK',
                                         os.environ.get('RHEV_CAPSULE_AK'))
     cls.cv_name = 'Scenario_postcapSync_' + cls.cls_name
     cls.org_id = '1'
     cls.repo_url = 'http://{0}{1}'.format(cls.sat_host,
                                           '/pub/postupgradeCapSync_repo/')
예제 #4
0
 def setUpClass(cls):
     cls.cls_name = 'Scenario_capsule_sync_2'
     cls.sat_host = settings.server.hostname
     cls.cap_host = os.environ.get(
         'RHEV_CAP_HOST', os.environ.get('CAPSULE_HOSTNAME'))
     cls.repo_name = 'capsulesync_TestRepo_' + cls.cls_name
     cls.repo_path = '/var/www/html/pub/postupgradeCapSync_repo/'
     cls.rpm_name = rpm2.split('/')[-1]
     cls.prod_name = 'Scenario_postUpgradeCapSync_' + cls.cls_name
     cls.activation_key = os.environ.get(
         'CAPSULE_AK', os.environ.get('RHEV_CAPSULE_AK'))
     cls.cv_name = 'Scenario_postcapSync_' + cls.cls_name
     cls.org_id = '1'
     cls.repo_url = 'http://{0}{1}'.format(
         cls.sat_host, '/pub/postupgradeCapSync_repo/')
class Scenario_capsule_sync_2(TestCase):
    """
    The test class contains pre-upgrade and post-upgrade scenarios to test if
    package added postupgrade in satellite is snyced to capsule post upgrade.

    Test Steps:

    1. Upgrade Satellite and Capsule.
    2. Sync a repo/rpm in satellite.
    3. Run capsule sync.
    4. Check if the repo/rpm is been synced to capsule.

    """
    cls_name = 'Scenario_capsule_sync_2'
    sat_host = get_satellite_host()
    env.host_string = sat_host
    cap_host = os.environ.get('RHEV_CAP_HOST',
                              os.environ.get('CAPSULE_HOSTNAME'))
    repo_name = 'capsulesync_TestRepo_' + cls_name
    repo_path = '/var/www/html/pub/postupgradeCapSync_repo/'
    rpm_name = rpm2.split('/')[-1]
    prod_name = 'Scenario_postUpgradeCapSync_' + cls_name
    activation_key = os.environ.get('CAPSULE_AK',
                                    os.environ.get('RHEV_CAPSULE_AK'))
    cv_name = 'Scenario_postcapSync_' + cls_name
    _, env_name = hammer.hammer_determine_cv_and_env_from_ak(
        activation_key, '1')
    org_id = '1'
    repo_url = 'http://' + sat_host + '/pub/postupgradeCapSync_repo/'

    def create_repo(self):
        """ Creates a custom yum repository, that will be synced to satellite
        and later to capsule from satellite
        """
        run('rm -rf {}'.format(self.repo_path))
        run('mkdir {}'.format(self.repo_path))
        run('wget {0} -P {1}'.format(rpm2, self.repo_path))
        # Renaming custom rpm to preRepoSync.rpm
        run('createrepo --database {0}'.format(self.repo_path))

    @post_upgrade
    def test_post_user_scenario_capsule_sync_2(self):
        """Post-upgrade scenario that creates and sync repository with
        rpm, sync capsule with satellite and verifies if the repo/rpm in
        satellite is synced to capsule.


        :id: postupgrade-7c1d3441-3e8d-4ac2-8102-30e18274658c

        :steps:
            1. Post Upgrade , Sync a repo/rpm in satellite.
            2. Run capsule sync.
            3. Check if the repo/rpm is been synced to capsule.

        :expectedresults:
            1. The repo/rpm should be synced to satellite
            2. Capsule sync should be successful
            3. The repo/rpm from satellite should be synced to capsule

        """
        self.create_repo()
        print hammer.hammer_product_create(self.prod_name, self.org_id)
        prod_list = hammer.hammer('product list --organization-id {}'.format(
            self.org_id))
        self.assertEqual(
            self.prod_name,
            hammer.get_attribute_value(prod_list, self.prod_name, 'name'))
        print hammer.hammer_repository_create(self.repo_name, self.org_id,
                                              self.prod_name, self.repo_url)
        repo_list = hammer.hammer(
            'repository list --product {0} --organization-id {1}'.format(
                self.prod_name, self.org_id))
        self.assertEqual(
            self.repo_name,
            hammer.get_attribute_value(repo_list, self.repo_name, 'name'))
        print hammer.hammer_repository_synchronize(self.repo_name, self.org_id,
                                                   self.prod_name)
        print hammer.hammer_content_view_create(self.cv_name, self.org_id)
        print hammer.hammer_content_view_add_repository(
            self.cv_name, self.org_id, self.prod_name, self.repo_name)
        print hammer.hammer_content_view_publish(self.cv_name, self.org_id)
        cv_ver = hammer.get_latest_cv_version(self.cv_name)
        env_data = hammer.hammer(
            'lifecycle-environment list --organization-id {0} '
            '--name {1}'.format(self.org_id, self.env_name))
        env_id = hammer.get_attribute_value(env_data, self.env_name, 'id')
        print hammer.hammer_content_view_promote_version(
            self.cv_name, cv_ver, env_id, self.org_id)
        cap_data = hammer.hammer('capsule list')
        cap_id = hammer.get_attribute_value(cap_data, self.cap_host, 'id')
        org_data = hammer.hammer('organization list')
        org_name = hammer.get_attribute_value(org_data, int(self.org_id),
                                              'name')
        print hammer.hammer(
            'capsule content synchronize --id {0}'.format(cap_id))
        result = execute(lambda: run(
            '[ -f /var/lib/pulp/published/yum/http/repos/'
            '{0}/{1}/{2}/custom/{3}/{4}/Packages/c/{5} ]; '
            'echo $?'.format(org_name, self.env_name, self.cv_name, self.
                             prod_name, self.repo_name, self.rpm_name)),
                         host=self.cap_host)[self.cap_host]
        self.assertEqual('0', result)