Skip to content

Commit 54a2f5d

Browse files
committed
metadata download test
1 parent 7dbbe20 commit 54a2f5d

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

tests/github/test_release_page.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
11
import os
2+
import shutil
23
from pathlib import Path
34

5+
import pytest
46
import requests_mock
57
from git import Repo
68

79
from gardenlinux.apt.debsource import DebsrcFile
8-
from gardenlinux.github.__main__ import _get_package_list
10+
from gardenlinux.features import CName
11+
from gardenlinux.github.__main__ import (
12+
GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME, _get_package_list,
13+
download_metadata_file, get_variant_from_flavor)
14+
from gardenlinux.s3 import S3Artifacts
915

1016
GARDENLINUX_RELEASE = "1877.3"
1117
GARDENLINUX_COMMIT = "75df9f401a842914563f312899ec3ce34b24515c"
18+
GARDENLINUX_COMMIT_SHORT = GARDENLINUX_COMMIT[:8]
19+
1220
GLVD_BASE_URL = "https://glvd.ingress.glvd.gardnlinux.shoot.canary.k8s-hana.ondemand.com/v1"
1321
GL_REPO_BASE_URL = "https://packages.gardenlinux.io/gardenlinux"
1422

1523
TEST_DATA_DIR = Path(os.path.dirname(__file__)) / ".." / ".." / "test-data" / "release_notes"
24+
S3_DOWNLOADS_DIR = Path(os.path.dirname(__file__)) / ".." / ".." / "s3_downloads"
25+
26+
TEST_FLAVORS = [("foo_bar_baz", "legacy"),
27+
("aws-gardener_prod_trustedboot_tpm2-amd64", "legacy"),
28+
("openstack-gardener_prod_tpm2_trustedboot-arm64", "tpm2_trustedboot"),
29+
("azure-gardener_prod_usi-amd64", "usi"),
30+
("", "legacy")]
1631

1732

1833
class SubmoduleAsRepo(Repo):
@@ -37,6 +52,18 @@ def __new__(cls, *args, **kwargs):
3752
return sr
3853

3954

55+
@pytest.fixture
56+
def downloads_dir():
57+
os.makedirs(S3_DOWNLOADS_DIR, exist_ok=True)
58+
yield
59+
shutil.rmtree(S3_DOWNLOADS_DIR)
60+
61+
62+
@pytest.mark.parametrize("flavor", TEST_FLAVORS)
63+
def test_get_variant_from_flavor(flavor):
64+
assert get_variant_from_flavor(flavor[0]) == flavor[1]
65+
66+
4067
def test_get_package_list():
4168
gl_packages_gz = TEST_DATA_DIR / "Packages.gz"
4269

@@ -50,6 +77,17 @@ def test_get_package_list():
5077
assert isinstance(_get_package_list(GARDENLINUX_RELEASE), DebsrcFile)
5178

5279

80+
def test_download_metadata_file(downloads_dir):
81+
s3_artifacts = S3Artifacts(GARDENLINUX_GITHUB_RELEASE_BUCKET_NAME)
82+
cname = CName("aws-gardener_prod", "amd64", "{0}-{1}".format(GARDENLINUX_RELEASE, GARDENLINUX_COMMIT_SHORT))
83+
download_metadata_file(s3_artifacts,
84+
cname.cname,
85+
GARDENLINUX_RELEASE,
86+
GARDENLINUX_COMMIT_SHORT,
87+
S3_DOWNLOADS_DIR)
88+
os.path.isfile(S3_DOWNLOADS_DIR / "aws-gardener_prod-amd64.s3_metadata.yaml")
89+
90+
5391
def test_github_release_page(monkeypatch):
5492
monkeypatch.setattr("gardenlinux.github.__main__.Repo", SubmoduleAsRepo)
5593
import gardenlinux.github

0 commit comments

Comments
 (0)