Beispiel #1
0
def test_raise_error_for_missing_ubi_config_version():
    config_path = os.path.join(TEST_DATA_DIR, "ubi8")
    ubipopulate = UbiPopulate(
        "foo.pulp.com", ("foo", "foo"), False, ubiconfig_dir_or_url=config_path
    )
    repo = YumRepository(
        id="repo",
        ubi_config_version="",
    )
    for config in ubipopulate.ubiconfig_list:
        with pytest.raises(ValueError):
            ubipopulate._get_config(repo, config)
Beispiel #2
0
def test_raise_config_missing(caplog):
    config_path = os.path.join(TEST_DATA_DIR, "ubi8")
    ubipopulate = UbiPopulate(
        "foo.pulp.com", ("foo", "foo"), False, ubiconfig_dir_or_url=config_path
    )
    repo = YumRepository(
        id="repo",
        ubi_config_version="9.8",
    )
    for config in ubipopulate.ubiconfig_list:
        with pytest.raises(ConfigMissing):
            ubipopulate._get_config(repo, config)

    assert (
        "Config file ubiconf_golang.yaml missing from 9.8 and default 9 branches"
        in caplog.text
    )
Beispiel #3
0
def test_create_output_file_all_repos(mock_ubipop_runner, mock_get_repo_pairs,
                                      mocked_ubiconfig_load_all,
                                      mock_run_ubi_population):
    # pylint: disable=unused-argument
    path = tempfile.mkdtemp("ubipop")
    try:
        out_file_path = os.path.join(path, 'output.txt')

        ubipop = UbiPopulate("foo.pulp.com", ('foo', 'foo'),
                             False,
                             output_repos=out_file_path)
        ubipop.populate_ubi_repos()

        with open(out_file_path) as f:
            content = f.readlines()

        assert sorted(content) == sorted(
            ["ubi-foo-rpms\n", "ubi-foo-source\n", "ubi-foo-debug\n"])
    finally:
        shutil.rmtree(path)
Beispiel #4
0
def test_load_ubiconfig_by_content_set_labels():
    """Ensure correct config is returned when given a content set label"""
    ubipop = UbiPopulate("foo.pulp.com", ('foo', 'foo'),
                         False,
                         ubiconfig_dir_or_url=TEST_DATA_DIR,
                         content_sets=[
                             "rhel-7-server-rpms",
                         ])
    assert len(ubipop.ubiconfig_list) == 1
    assert ubipop.ubiconfig_list[
        0].content_sets.rpm.output == "ubi-7-server-rpms"
Beispiel #5
0
def test_load_ubiconfig_by_repo_ids(mocked_search_repo_by_id):
    """Ensure correct config is returned when given a repo ID"""
    mocked_search_repo_by_id.return_value = [
        get_test_repo(repo_id="rhel-7-server",
                      content_set="rhel-7-server-rpms"),
    ]
    ubipop = UbiPopulate("foo.pulp.com", ('foo', 'foo'),
                         False,
                         ubiconfig_dir_or_url=TEST_DATA_DIR,
                         repo_ids=[
                             "rhel-7-server",
                         ])
    assert len(ubipop.ubiconfig_list) == 1
    assert ubipop.ubiconfig_list[
        0].content_sets.rpm.output == "ubi-7-server-rpms"
def test_ubipopulate_load_all_ubiconfig(mocked_ubiconfig_load_all):
    ubipop = UbiPopulate("foo.pulp.com", ('foo', 'foo'), False)
    assert len(ubipop.ubiconfig_list) == 1
    assert ubipop.ubiconfig_list[0] == "test"
Beispiel #7
0
def test_ubipopulate_load_all_ubiconfig(mocked_ubiconfig_load_all):
    # pylint: disable=unused-argument
    ubipop = UbiPopulate("foo.pulp.com", ('foo', 'foo'), False)
    assert len(ubipop.ubiconfig_list) == 1
    assert ubipop.ubiconfig_list[0] == "test"
Beispiel #8
0
def test_skip_outdated_dot_repos(mocked_search_repo_by_cs,
                                 mocked_ubipop_runner, caplog):
    # Don't actually query Pulp for repos
    mocked_search_repo_by_cs.side_effect = [
        # Input repos - rhel-8-for-x86_64-appstream
        [
            get_test_repo(
                repo_id="rhel-8-for-x86_64-appstream-rpms",
                content_set="rhel-8-for-x86_64-appstream-rpms",
            ),
        ],
        [
            get_test_repo(
                repo_id="rhel-8-for-x86_64-appstream-source-rpms",
                content_set="rhel-8-for-x86_64-appstream-source-rpms",
            ),
        ],
        [
            get_test_repo(
                repo_id="rhel-8-for-x86_64-appstream-debug-rpms",
                content_set="rhel-8-for-x86_64-appstream-debug-rpms",
            ),
        ],

        # Output repos - rhel-8-for-x86_64-appstream
        [
            get_test_repo(repo_id="ubi-8-for-x86_64-appstream-rpms",
                          content_set="ubi-8-for-x86_64-appstream-rpms",
                          ubi_population=True),
        ],
        [
            get_test_repo(repo_id="ubi-8-for-x86_64-appstream-source-rpms",
                          content_set="ubi-8-for-x86_64-appstream-source-rpms",
                          ubi_population=True),
        ],
        [
            get_test_repo(repo_id="ubi-8-for-x86_64-appstream-debug-rpms",
                          content_set="ubi-8-for-x86_64-appstream-debug-rpms",
                          ubi_population=True),
        ],

        # Input repos - rhel-7-server
        [
            get_test_repo(
                repo_id="rhel-7-server-rpms__7_DOT_2__x86_64",
                content_set="rhel-7-server-rpms",
            ),
        ],
        [
            get_test_repo(
                repo_id="rhel-7-server-source-rpms__7_DOT_2__x86_64",
                content_set="rhel-7-server-source-rpms",
            ),
        ],
        [
            get_test_repo(
                repo_id="rhel-7-server-debuginfo-rpms__7_DOT_2__x86_64",
                content_set="rhel-7-server-debuginfo-rpms",
            ),
        ],

        # Output repos - rhel-7-server
        [
            get_test_repo(repo_id="ubi-7-server-rpms__7_DOT_2__x86_64",
                          content_set="ubi-7-server-rpms",
                          ubi_population=True),
        ],
        [
            get_test_repo(repo_id="ubi-7-server-source-rpms__7_DOT_2__x86_64",
                          content_set="ubi-7-server-source-rpms",
                          ubi_population=False),
        ],
        [
            get_test_repo(
                repo_id="ubi-7-server-debuginfo-rpms__7_DOT_2__x86_64",
                content_set="ubi-7-server-debuginfo-rpms",
                ubi_population=False),
        ],
    ]

    # Attempt to populate both invalid and valid repo sets
    ubipop = UbiPopulate("foo.pulp.com", ("foo", "foo"),
                         False,
                         ubiconfig_dir_or_url=TEST_DATA_DIR)
    ubipop.populate_ubi_repos()

    # Should've only run once
    assert mocked_ubipop_runner.call_count == 1
    # For rhel-8-for-x86_64-appstream
    assert "Skipping rhel-8-for-x86_64-appstream" not in caplog.text
    # Not for rhel-7-server
    assert "Skipping rhel-7-server-rpms" in caplog.text
Beispiel #9
0
def test_ubipopulate_load_ubiconfig(mocked_ubiconfig_load):
    # pylint: disable=unused-argument
    ubipop = UbiPopulate("foo.pulp.com", ("foo", "foo"), False, ["cfg.yaml"])
    assert len(ubipop.ubiconfig_list) == 1
    assert ubipop.ubiconfig_list[0].file_name == "test"