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
示例#3
0
 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))
示例#4
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)))
示例#5
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)
示例#6
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,
        )
示例#7
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
    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))
示例#9
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())
示例#10
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)
示例#11
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)
示例#12
0
 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)
示例#13
0
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())