Esempio n. 1
0
def test_get_latest_revision(monkeypatch):
    """Test that the latest revision is found for 1.19"""
    monkeypatch.setattr(
        SnapKubeletRepoModel, "_get_revision_output", mock_get_revision_output
    )
    repo_model = SnapKubeletRepoModel()
    revisions = repo_model.revisions
    assert repo_model.latest_revision(revisions, "1.19/stable", "amd64") == int(1629)
    assert repo_model.latest_revision(revisions, "1.19/stable", "arm64") == int(1552)
Esempio n. 2
0
def test_get_proper_tracks():
    """Test that proper tracks are associated with known versions"""
    repo_model = SnapKubeletRepoModel()
    repo_model.version = "1.23"
    assert repo_model.tracks == [
        "1.23/stable",
        "1.23/candidate",
        "1.23/beta",
        "1.23/edge",
    ]
Esempio n. 3
0
def snaps(dry_run):
    """Syncs the snap branches, keeps snap builds in sync, and makes sure the latest snaps are published into snap store"""
    dryrun(dry_run)
    snaps_to_process = [
        SnapKubeApiServerRepoModel(),
        SnapKubeControllerManagerRepoModel(),
        SnapKubeProxyRepoModel(),
        SnapKubeSchedulerRepoModel(),
        SnapKubectlRepoModel(),
        SnapKubeadmRepoModel(),
        SnapKubeletRepoModel(),
        SnapKubernetesTestRepoModel(),
    ]

    kubernetes_repo = InternalKubernetesRepoModel()

    # Sync all snap branches
    for _snap in snaps_to_process:
        snap_service_obj = SnapService(_snap, kubernetes_repo)
        snap_service_obj.sync_from_upstream()
        snap_service_obj.sync_all_track_snaps()
        snap_service_obj.sync_stable_track_snaps()

    # Handle cdk-addons sync separetely
    cdk_addons = SnapCdkAddonsRepoModel()
    cdk_addons_service_obj = SnapService(cdk_addons, kubernetes_repo)
    cdk_addons_service_obj.sync_stable_track_snaps()
Esempio n. 4
0
def test_rev_1618_promoted(monkeypatch):
    """Test that rev 1618 is promoted in all channels"""
    monkeypatch.setattr(
        SnapKubeletRepoModel, "_get_revision_output", mock_get_revision_output
    )
    repo_model = SnapKubeletRepoModel()
    revisions = repo_model.revisions
    channels = revisions["1618"]["channels"]
    assert all([channel["promoted"] is True for channel in channels]) == True
Esempio n. 5
0
def test_get_revisions(monkeypatch):
    """Test that revisions are being mapped properly"""
    monkeypatch.setattr(
        SnapKubeletRepoModel, "_get_revision_output", mock_get_revision_output
    )
    repo_model = SnapKubeletRepoModel()
    revisions = repo_model.revisions
    assert str(revisions["1609"]["version"]) == "1.17.12"
    assert semver.compare(str(revisions["1629"]["version"]), "1.19.3") == 0
Esempio n. 6
0
def test_latest_branch_from_major_minor(monkeypatch):
    """Test getting latest branch version from a major.minor release"""

    monkeypatch.setattr(
        "cilib.models.repos.snaps.BaseRepoModel.branches",
        ["v1.19.0", "v1.19.1", "v1.19.3"],
    )
    kubelet_repo = SnapKubeletRepoModel()
    max_branch = kubelet_repo.base.latest_branch_from_major_minor("1.19")
    assert semver.VersionInfo.parse(max_branch).compare("1.19.3") == 0
Esempio n. 7
0
def test_latest_patched_branch_from_major_minor(monkeypatch):
    """Test getting latest branch with a patch applied from a major.minor release"""

    monkeypatch.setattr(
        "cilib.models.repos.snaps.BaseRepoModel.branches",
        [
            "v1.19.0",
            "v1.19.1+patch.2",
            "v1.19.3",
            "v1.19.3+patch.1",
            "v1.19.3+patch.4",
            "v1.19.3+patch.12",
        ],
    )
    kubelet_repo = SnapKubeletRepoModel()
    max_branch = kubelet_repo.base.latest_branch_from_major_minor("1.19")
    assert semver.compare(max_branch, "1.19.3+patch.12") == 0
Esempio n. 8
0
def snap_from_branch(branch, dry_run):
    """Syncs the snap branches, keeps snap builds in sync, and makes sure the latest snaps are published into snap store"""
    dryrun(dry_run)
    snaps_to_process = [
        SnapKubeApiServerRepoModel(),
        SnapKubeControllerManagerRepoModel(),
        SnapKubeProxyRepoModel(),
        SnapKubeSchedulerRepoModel(),
        SnapKubectlRepoModel(),
        SnapKubeadmRepoModel(),
        SnapKubeletRepoModel(),
        SnapKubernetesTestRepoModel(),
    ]

    kubernetes_repo = InternalKubernetesRepoModel()

    # Sync all snap branches
    for _snap in snaps_to_process:
        snap_service_obj = SnapService(_snap, kubernetes_repo)
        snap_service_obj.build_snap_from_branch(branch)
Esempio n. 9
0
def test_repo_matches_model():
    """Test that repo model matches the upstream repo"""
    repo_model = SnapKubeletRepoModel()
    assert repo_model.repo == "git+ssh://[email protected]/snap-kubelet"