Example #1
0
    def test_sync_downloaded_content(self):
        """Create two repositories with the same feed, and sync them serially.

        More specifically, this test creates two puppet repositories with
        identical feeds, syncs them serially, and verifies that both have equal
        non-zero content unit counts.
        """
        cfg = config.get_config()
        if selectors.bug_is_untestable(1937, cfg.version):
            self.skipTest('https://pulp.plan.io/issues/1937')
        utils.pulp_admin_login(cfg)

        # Create two repos, schedule them for deletion, and sync them.
        client = cli.Client(cfg)
        repo_ids = [utils.uuid4() for _ in range(2)]
        for repo_id in repo_ids:
            client.run(('pulp-admin puppet repo create '
                        '--repo-id {} --feed {} --queries {}').format(
                            repo_id, PUPPET_FEED, PUPPET_QUERY).split())
            self.addCleanup(client.run,
                            ('pulp-admin puppet repo delete --repo-id {}'
                             ).format(repo_id).split())
            client.run(('pulp-admin puppet repo sync run --repo-id {}'
                        ).format(repo_id).split())

        # Verify the number of puppet modules in each repository.
        unit_counts = [
            get_num_units_in_repo(cfg, repo_id) for repo_id in repo_ids
        ]
        for i, unit_count in enumerate(unit_counts):
            with self.subTest(i=i):
                self.assertGreater(unit_count, 0)
        self.assertEqual(unit_counts[0], unit_counts[1])
def setUpModule():  # pylint:disable=invalid-name
    """Possibly skip tests. Create and sync an RPM repository.

    Skip tests in this module if the RPM plugin is not installed on the target
    Pulp server. Then create an RPM repository with a feed and sync it. Test
    cases may copy data from this repository but should **not** change it.
    """
    set_up_module()
    cfg = config.get_config()
    client = cli.Client(config.get_config())

    # log in, then create repository
    utils.pulp_admin_login(cfg)
    client.run(
        'pulp-admin rpm repo create --repo-id {} --feed {}'
        .format(_REPO_ID, constants.RPM_SIGNED_FEED_URL).split()
    )

    # If setUpModule() fails, tearDownModule() isn't run. In addition, we can't
    # use addCleanup(), as it's an instance method. If this set-up procedure
    # grows, consider implementing a stack of tear-down steps instead.
    try:
        client.run(
            'pulp-admin rpm repo sync run --repo-id {}'
            .format(_REPO_ID).split()
        )
    except subprocess.CalledProcessError:
        client.run(
            'pulp-admin rpm repo delete --repo-id {}'.format(_REPO_ID).split()
        )
        raise
def setUpModule():  # pylint:disable=invalid-name
    """Possibly skip tests. Create and sync an RPM repository.

    Skip tests in this module if the RPM plugin is not installed on the target
    Pulp server. Then create an RPM repository with a feed and sync it. Test
    cases may copy data from this repository but should **not** change it.
    """
    set_up_module()
    cfg = config.get_config()
    client = cli.Client(config.get_config())

    # log in, then create repository
    utils.pulp_admin_login(cfg)
    global _REPO_ID  # pylint:disable=global-statement
    _REPO_ID = utils.uuid4()
    client.run('pulp-admin rpm repo create --repo-id {} --feed {}'.format(
        _REPO_ID, constants.RPM_FEED_URL).split())

    # If setUpModule() fails, tearDownModule() isn't run. In addition, we can't
    # use addCleanup(), as it's an instance method. If this set-up procedure
    # grows, consider implementing a stack of tear-down steps instead.
    try:
        client.run('pulp-admin rpm repo sync run --repo-id {}'.format(
            _REPO_ID).split())
    except subprocess.CalledProcessError:
        client.run(
            'pulp-admin rpm repo delete --repo-id {}'.format(_REPO_ID).split())
        raise
Example #4
0
    def setUpClass(cls):
        """Create, populate and publish a repository.

        Ensure at least two versions of an RPM are present in the repository.
        """
        cls.cfg = config.get_config()
        if check_issue_3104(cls.cfg):
            raise unittest.SkipTest('https://pulp.plan.io/issues/3104')
        cls.repo_id = None
        cls.relative_url = utils.uuid4() + '/'
        utils.pulp_admin_login(cls.cfg)
        client = cli.Client(cls.cfg)
        repo_id = utils.uuid4()
        client.run((
            'pulp-admin', 'rpm', 'repo', 'create', '--repo-id', repo_id,
            '--feed', RPM_UNSIGNED_FEED_URL, '--relative-url', cls.relative_url
        ))
        cls.repo_id = repo_id
        del repo_id
        try:
            client.run((
                'pulp-admin', 'rpm', 'repo', 'sync', 'run', '--repo-id',
                cls.repo_id
            ))
            cls.content = client.run((
                'pulp-admin', 'rpm', 'repo', 'content', 'rpm', '--repo-id',
                cls.repo_id
            )).stdout
        except:  # noqa:E722
            cls.tearDownClass()
            raise
    def test_sync_downloaded_content(self):
        """Create two repositories with the same feed, and sync them serially.

        More specifically, this test creates two puppet repositories with
        identical feeds, syncs them serially, and verifies that both have equal
        non-zero content unit counts.
        """
        cfg = config.get_config()
        if selectors.bug_is_untestable(1937, cfg.version):
            self.skipTest('https://pulp.plan.io/issues/1937')
        utils.pulp_admin_login(cfg)

        # Create two repos, schedule them for deletion, and sync them.
        client = cli.Client(cfg)
        repo_ids = [utils.uuid4() for _ in range(2)]
        for repo_id in repo_ids:
            client.run((
                'pulp-admin puppet repo create '
                '--repo-id {} --feed {} --queries {}'
            ).format(repo_id, PUPPET_FEED, PUPPET_QUERY).split())
            self.addCleanup(client.run, (
                'pulp-admin puppet repo delete --repo-id {}'
            ).format(repo_id).split())
            client.run((
                'pulp-admin puppet repo sync run --repo-id {}'
            ).format(repo_id).split())

        # Verify the number of puppet modules in each repository.
        unit_counts = [
            get_num_units_in_repo(cfg, repo_id) for repo_id in repo_ids
        ]
        for i, unit_count in enumerate(unit_counts):
            with self.subTest(i=i):
                self.assertGreater(unit_count, 0)
        self.assertEqual(unit_counts[0], unit_counts[1])
 def setUpClass(cls):
     """Create a content source."""
     super(RefreshAndDeleteContentSourcesTestCase, cls).setUpClass()
     cls.cfg = config.get_config()
     if cls.cfg.version < Version('2.8.6'):
         raise unittest.SkipTest('This test requires at least 2.8.6')
     pulp_admin_login(cls.cfg)
     cls.client = cli.Client(cls.cfg)
     cls.content_source_id = uuid4()
     content_source_path = generate_content_source(
         cls.cfg,
         cls.content_source_id,
         enabled='1',
         type='yum',
         base_url=RPM_SIGNED_FEED_URL,
     )
     sudo = '' if is_root(cls.cfg) else 'sudo '
     cls.responses = [
         cls.client.run(
             'pulp-admin content sources refresh'.split()
         ),
         _get_content_source_ids(cls.cfg),
         cls.client.run(
             'pulp-admin content sources refresh --source-id {}'
             .format(cls.content_source_id).split()
         ),
     ]
     cls.client.run(
         '{}rm -f {}'.format(sudo, content_source_path).split())
     cls.responses.append(_get_content_source_ids(cls.cfg))
Example #7
0
    def setUpClass(cls):
        """Perform a variety of set-up tasks.

        Provide a server config, and skip tests if the targeted Pulp system is
        older than version 2.8. Provide a tuple of two repository IDs (See
        :meth:`tearDownClass`.) Log in to the target system.
        """
        cls.cfg = config.get_config()
        if cls.cfg.version < Version('2.8'):
            raise unittest.SkipTest('These tests require Pulp 2.8 or above.')
        utils.pulp_admin_login(cls.cfg)
        cls.repo_ids = tuple((utils.uuid4() for _ in range(2)))
Example #8
0
    def setUpClass(cls):
        """Perform a variety of set-up tasks.

        Provide a server config, and skip tests if the targeted Pulp system is
        older than version 2.8. Provide a tuple of two repository IDs (See
        :meth:`tearDownClass`.) Log in to the target system.
        """
        cls.cfg = config.get_config()
        if cls.cfg.version < Version('2.8'):
            raise unittest.SkipTest('These tests require Pulp 2.8 or above.')
        utils.pulp_admin_login(cls.cfg)
        cls.repo_ids = tuple((utils.uuid4() for _ in range(2)))
Example #9
0
def setUpModule():  # pylint:disable=invalid-name
    """Execute ``pulp-admin login`` and reset Pulp.

    For :class:`RemovedContentTestCase` to function correctly, we require that
    all of the content units on Pulp's filesystem belong to the repository
    created by that test case. Resetting Pulp guarantees that this is so.
    Ideally, all test cases would clean up after themselves so that no resets
    are necessary.
    """
    cfg = config.get_config()
    set_up_module()
    utils.reset_pulp(cfg)
    utils.pulp_admin_login(cfg)
    def setUpClass(cls):
        """Provide a server config and a repository ID."""
        cls.cfg = config.get_config()

        if cls.cfg.version < version.Version('2.8'):
            raise unittest.SkipTest('These tests require Pulp 2.8 or above.')

        utils.pulp_admin_login(cls.cfg)

        cls.repo_id = utils.uuid4()
        docker_utils.repo_create(
            cls.cfg,
            enable_v2='true',
            repo_id=cls.repo_id,
        )
        docker_utils.repo_sync(cls.cfg, repo_id=cls.repo_id)
        cls.delete_cmd = docker_utils.repo_delete(cls.cfg, cls.repo_id)
Example #11
0
    def setUpClass(cls):
        """Provide a server config and a repository ID."""
        cls.cfg = config.get_config()

        if cls.cfg.version < version.Version('2.8'):
            raise unittest2.SkipTest('These tests require Pulp 2.8 or above.')

        utils.pulp_admin_login(cls.cfg)

        cls.repo_id = utils.uuid4()
        docker_utils.repo_create(
            cls.cfg,
            enable_v2='true',
            repo_id=cls.repo_id,
        )
        docker_utils.repo_sync(cls.cfg, repo_id=cls.repo_id)
        cls.delete_cmd = docker_utils.repo_delete(cls.cfg, cls.repo_id)
 def setUpClass(cls):
     """Create and sync a repository."""
     cls.cfg = config.get_config()
     if cls.cfg.pulp_version < Version('2.9'):
         raise unittest.SkipTest('These tests require Pulp 2.9 or above.')
     utils.pulp_admin_login(cls.cfg)
     cls.repo_id = utils.uuid4()
     cls.client = cli.Client(cls.cfg)
     cls.client.run(
         'pulp-admin rpm repo create --repo-id {} --feed {}'.format(
             cls.repo_id, RPM_SIGNED_FEED_URL).split())
     try:
         cls.client.run('pulp-admin rpm repo sync run --repo-id {}'.format(
             cls.repo_id).split())
     except subprocess.CalledProcessError:
         cls.client.run('pulp-admin rpm repo delete --repo-id {}'.format(
             cls.repo_id).split())
         raise
Example #13
0
    def setUpClass(cls):
        """Provide a server config and a repository ID."""
        cls.cfg = config.get_config()
        if cls.cfg.version < version.Version('2.8'):
            raise unittest2.SkipTest('These tests require Pulp 2.8 or above.')
        if selectors.bug_is_untestable(1710, cls.cfg.version):
            raise unittest2.SkipTest('https://pulp.plan.io/issues/1710')

        utils.pulp_admin_login(cls.cfg)

        # Create a repository and update its distributor.
        cls.repo_id = utils.uuid4()
        cls.repo_registry_id = 'test/' + utils.uuid4()
        docker_utils.repo_create(cls.cfg, repo_id=cls.repo_id)
        cls.update_response = docker_utils.repo_update(
            cls.cfg,
            repo_id=cls.repo_id,
            repo_registry_id=cls.repo_registry_id,
        )
    def setUpClass(cls):
        """Provide a server config and a repository ID."""
        cls.cfg = config.get_config()
        if cls.cfg.version < version.Version('2.8'):
            raise unittest.SkipTest('These tests require Pulp 2.8 or above.')
        if selectors.bug_is_untestable(1710, cls.cfg.version):
            raise unittest.SkipTest('https://pulp.plan.io/issues/1710')

        utils.pulp_admin_login(cls.cfg)

        # Create a repository and update its distributor.
        cls.repo_id = utils.uuid4()
        cls.repo_registry_id = 'test/' + utils.uuid4()
        docker_utils.repo_create(cls.cfg, repo_id=cls.repo_id)
        cls.update_response = docker_utils.repo_update(
            cls.cfg,
            repo_id=cls.repo_id,
            repo_registry_id=cls.repo_registry_id,
        )
Example #15
0
 def setUpClass(cls):
     """Create and sync a repository."""
     cls.cfg = config.get_config()
     if cls.cfg.version < Version('2.9'):
         raise unittest.SkipTest('These tests require Pulp 2.9 or above.')
     utils.pulp_admin_login(cls.cfg)
     cls.repo_id = utils.uuid4()
     cls.client = cli.Client(cls.cfg)
     cls.client.run(
         'pulp-admin rpm repo create --repo-id {} --feed {}'
         .format(cls.repo_id, RPM_SIGNED_FEED_URL).split()
     )
     try:
         cls.client.run(
             'pulp-admin rpm repo sync run --repo-id {}'
             .format(cls.repo_id).split()
         )
     except subprocess.CalledProcessError:
         cls.client.run(
             'pulp-admin rpm repo delete --repo-id {}'
             .format(cls.repo_id).split()
         )
         raise
Example #16
0
 def test_run(self):
     """Assert the function executes ``cli.Client.run``."""
     with mock.patch.object(cli, 'Client') as client:
         cfg = config.PulpSmashConfig(
             pulp_auth=['u', 'p'],
             systems=[
                 config.PulpSystem(
                     hostname='example.com',
                     roles={'pulp cli': {}}
                 )
             ]
         )
         response = utils.pulp_admin_login(cfg)
         self.assertIs(response, client.return_value.run.return_value)
Example #17
0
    def test_sync_puppet_forge(self):
        """Create a Puppet repository and trigger a sync."""
        cfg = config.get_config()
        utils.pulp_admin_login(cfg)

        # Create a repository and schedule it for deletion.
        repo_id = utils.uuid4()
        client = cli.Client(cfg)
        cmd = (
            'pulp-admin puppet repo create --repo-id {} --feed {} --queries {}'
        ).format(repo_id, PUPPET_FEED, PUPPET_QUERY)
        client.run(cmd.split())
        cmd = 'pulp-admin puppet repo delete --repo-id {}'.format(repo_id)
        self.addCleanup(client.run, cmd.split())

        # Sync the repository.
        cmd = 'pulp-admin puppet repo sync run --repo-id {}'.format(repo_id)
        completed_proc = client.run(cmd.split())

        # Verify no errors were reported.
        phrase = 'Invalid properties:'
        for stream in ('stdout', 'stderr'):
            with self.subTest(stream=stream):
                self.assertNotIn(phrase, getattr(completed_proc, stream))
    def test_sync_puppet_forge(self):
        """Create a Puppet repository and trigger a sync."""
        cfg = config.get_config()
        utils.pulp_admin_login(cfg)

        # Create a repository and schedule it for deletion.
        repo_id = utils.uuid4()
        client = cli.Client(cfg)
        cmd = (
            'pulp-admin puppet repo create --repo-id {} --feed {} --queries {}'
        ).format(repo_id, PUPPET_FEED, PUPPET_QUERY)
        client.run(cmd.split())
        cmd = 'pulp-admin puppet repo delete --repo-id {}'.format(repo_id)
        self.addCleanup(client.run, cmd.split())

        # Sync the repository.
        cmd = 'pulp-admin puppet repo sync run --repo-id {}'.format(repo_id)
        completed_proc = client.run(cmd.split())

        # Verify no errors were reported.
        phrase = 'Invalid properties:'
        for stream in ('stdout', 'stderr'):
            with self.subTest(stream=stream):
                self.assertNotIn(phrase, getattr(completed_proc, stream))
def setUpModule():  # pylint:disable=invalid-name
    """Log in."""
    set_up_module()
    utils.pulp_admin_login(config.get_config())
 def setUpClass(cls):
     """Provide a server config and a repository ID."""
     cls.cfg = config.get_config()
     cls.repo_id = utils.uuid4()
     utils.pulp_admin_login(cls.cfg)
Example #21
0
 def test_run(self):
     """Assert the function executes ``cli.Client.run``."""
     with mock.patch.object(cli, 'Client') as client:
         cfg = config.ServerConfig('http://example.com', auth=['u', 'p'])
         response = utils.pulp_admin_login(cfg)
         self.assertIs(response, client.return_value.run.return_value)
 def setUp(self):
     """Provide a server config and a repository ID."""
     self.cfg = config.get_config()
     self.repo_id = utils.uuid4()
     utils.pulp_admin_login(self.cfg)
 def test_run(self):
     """Assert the function executes ``cli.Client.run``."""
     with mock.patch.object(cli, 'Client') as client:
         cfg = config.ServerConfig('http://example.com', auth=['u', 'p'])
         response = utils.pulp_admin_login(cfg)
         self.assertIs(response, client.return_value.run.return_value)
Example #24
0
def setUpModule():  # pylint:disable=invalid-name
    """Execute ``pulp-admin login`` on the target Pulp system."""
    set_up_module()
    utils.pulp_admin_login(config.get_config())
Example #25
0
 def setUp(self):
     """Provide a server config and a repository ID."""
     self.cfg = config.get_config()
     self.repo_id = utils.uuid4()
     utils.pulp_admin_login(self.cfg)
Example #26
0
def setUpModule():  # pylint:disable=invalid-name
    """Execute ``pulp-admin login`` on the target Pulp system."""
    set_up_module()
    utils.pulp_admin_login(config.get_config())
def setUpModule():  # pylint:disable=invalid-name
    """Conditionally skip this module, and execute ``pulp-admin login``."""
    set_up_module()
    utils.pulp_admin_login(config.get_config())