Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable regular CI for OS_VERSION=tumbleweed as well #269

Merged
merged 7 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ jobs:
- PODMAN
os_version:
- 15.5
- "tumbleweed"
include:
- toxenv: repository
container_runtime: PODMAN
Expand Down
15 changes: 12 additions & 3 deletions bci_tester/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
OS_CONTAINER_TAG = "latest"
APP_CONTAINER_PREFIX = "opensuse"
BCI_CONTAINER_PREFIX = "bci"
OS_VERSION_ID = None

#: The Tumbleweed pretty name (from /etc/os-release)
OS_PRETTY_NAME = os.getenv(
Expand Down Expand Up @@ -368,18 +369,26 @@ def create_BCI(
bci_type=ImageType.OS,
)

# The very last container in this list needs to be available for all
# tested OSes
GOLANG_CONTAINERS = [
create_BCI(
build_tag=f"{BCI_CONTAINER_PREFIX}/golang:{golang_version}",
extra_marks=[pytest.mark.__getattr__(f"golang_{stability}")],
available_versions=["15.5", "15.6"],
)
for golang_version, stability in (
("1.20", "oldstable"),
("oldstable-openssl", "oldstable"),
("stable-openssl", "stable"),
)
] + [
create_BCI(
build_tag=f"{BCI_CONTAINER_PREFIX}/golang:{golang_version}",
extra_marks=[pytest.mark.__getattr__(f"golang_{stability}")],
)
for golang_version, stability in (
("1.20", "oldstable"),
("1.21", "stable"),
# does not exist yet (as of 2023/08/15)
# ("1.21-openssl", "stable"),
)
]

Expand Down
21 changes: 14 additions & 7 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def test_base_size(auto_container, container_runtime):
#: size limits of the base container per arch in MiB
if OS_VERSION in ("basalt", "tumbleweed"):
BASE_CONTAINER_MAX_SIZE: Dict[str, int] = {
"x86_64": 126,
"aarch64": 146,
"ppc64le": 166,
"s390x": 131,
"x86_64": 135,
"aarch64": 135,
"ppc64le": 175,
"s390x": 140,
}
else:
BASE_CONTAINER_MAX_SIZE: Dict[str, int] = {
Expand All @@ -46,9 +46,16 @@ def test_base_size(auto_container, container_runtime):
"ppc64le": 160,
"s390x": 125,
}
assert (
container_runtime.get_image_size(auto_container.image_url_or_id)
< BASE_CONTAINER_MAX_SIZE[LOCALHOST.system_info.arch] * 1024 * 1024
container_size = container_runtime.get_image_size(
auto_container.image_url_or_id
) // (1024 * 1024)
max_container_size = BASE_CONTAINER_MAX_SIZE[LOCALHOST.system_info.arch]
min_container_size = (
BASE_CONTAINER_MAX_SIZE[LOCALHOST.system_info.arch] - 5
)
assert container_size <= max_container_size, (
f"Base container size is {container_size} MiB for {LOCALHOST.system_info.arch} "
f"(expected {min_container_size}..{BASE_CONTAINER_MAX_SIZE[LOCALHOST.system_info.arch]} MiB)"
)


Expand Down
19 changes: 12 additions & 7 deletions tests/test_busybox.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ def test_busybox_provides_sh(auto_container):

#: size limits of the micro image per architecture in MiB
BUSYBOX_IMAGE_MAX_SIZE: Dict[str, int] = {
"x86_64": 16 if OS_VERSION == "tumbleweed" else 14,
"aarch64": 16 if OS_VERSION == "tumbleweed" else 14,
"s390x": 16 if OS_VERSION == "tumbleweed" else 14,
"ppc64le": 16 if OS_VERSION == "tumbleweed" else 14,
"x86_64": 16 if OS_VERSION == "tumbleweed" else 13,
"aarch64": 16 if OS_VERSION == "tumbleweed" else 13,
"s390x": 16 if OS_VERSION == "tumbleweed" else 13,
"ppc64le": 16 if OS_VERSION == "tumbleweed" else 13,
}


Expand All @@ -43,9 +43,14 @@ def test_busybox_image_size(
specified in :py:const:`BUSYBOX_IMAGE_MAX_SIZE`.

"""
assert (
container_runtime.get_image_size(container.image_url_or_id)
< size[LOCALHOST.system_info.arch] * 1024 * 1024
container_size = container_runtime.get_image_size(
container.image_url_or_id
) // (1024 * 1024)
min_container_size = size[LOCALHOST.system_info.arch] - 5
max_container_size = size[LOCALHOST.system_info.arch]
assert container_size <= max_container_size, (
f"Base container size is {container_size} MiB for {LOCALHOST.system_info.arch} "
f"(expected {min_container_size}..{max_container_size} MiB)"
)


Expand Down
8 changes: 4 additions & 4 deletions tests/test_minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
}

TW_MICRO_IMAGE_MAX_SIZE: Dict[str, int] = {
"x86_64": 32,
"aarch64": 34,
"s390x": 32,
"ppc64le": 39,
"x86_64": 34,
"aarch64": 36,
"s390x": 34,
"ppc64le": 41,
}


Expand Down
12 changes: 7 additions & 5 deletions tests/test_php.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from bci_tester.data import PHP_8_APACHE
from bci_tester.data import PHP_8_CLI
from bci_tester.data import PHP_8_FPM
from bci_tester.data import OS_VERSION


CONTAINER_IMAGES = [PHP_8_CLI, PHP_8_APACHE, PHP_8_FPM]
Expand Down Expand Up @@ -271,11 +272,12 @@ def get_env_var(env_var: str) -> str:
f"{apache_confdir}/httpd.conf"
).is_file

apache_envvars = get_env_var("APACHE_ENVVARS")
assert container_per_test.connection.file(apache_envvars).is_file
assert container_per_test.connection.run_expect(
[0], f"source {apache_envvars}"
)
if OS_VERSION not in ("basalt", "tumbleweed"):
apache_envvars = get_env_var("APACHE_ENVVARS")
assert container_per_test.connection.file(apache_envvars).is_file
assert container_per_test.connection.run_expect(
[0], f"source {apache_envvars}"
)


@pytest.mark.parametrize("container_image", [PHP_8_CLI])
Expand Down
22 changes: 21 additions & 1 deletion tests/test_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pytest_container.runtime import LOCALHOST
from pytest_container.runtime import Version

from bci_tester.data import OS_VERSION
from bci_tester.data import PYTHON_CONTAINERS
from bci_tester.runtime_choice import PODMAN_SELECTED

Expand Down Expand Up @@ -100,11 +101,19 @@ def test_pip(auto_container):
assert f"pip {version_from_env}" in reported_version


@pytest.mark.skipif(
OS_VERSION == "tumbleweed",
reason="pip --user not working due to PEP 668",
)
def test_tox(auto_container):
"""Ensure we can use :command:`pip` to install :command:`tox`."""
auto_container.connection.run_expect([0], "pip install --user tox")


@pytest.mark.skipif(
OS_VERSION == "tumbleweed",
reason="pip --user not working due to PEP 668",
)
def test_pip_install_source_cryptography(auto_container_per_test):
"""Check that cryptography python module can be installed from source so that
it is built against the SLE BCI FIPS enabled libopenssl."""
Expand Down Expand Up @@ -193,6 +202,10 @@ def test_python_webserver_1(
)


@pytest.mark.skipif(
OS_VERSION == "tumbleweed",
reason="pip --user not working due to PEP 668",
)
@pytest.mark.parametrize(
"container_per_test", CONTAINER_IMAGES_T2, indirect=["container_per_test"]
)
Expand Down Expand Up @@ -249,6 +262,10 @@ def test_python_webserver_2(
assert container_per_test.connection.file(destdir + xfilename).exists


@pytest.mark.skipif(
OS_VERSION == "tumbleweed",
reason="pip --user not working due to PEP 668",
)
@pytest.mark.skipif(
# skip test if architecture is not x86.
LOCALHOST.system_info.arch != "x86_64",
Expand All @@ -272,7 +289,10 @@ def test_tensorf(container_per_test):
assert "sse4" in cpuflg

# install TF module for python
if container_per_test.connection.run("pip install tensorflow").rc != 0:
if (
container_per_test.connection.run("pip install --user tensorflow").rc
!= 0
):
pytest.xfail(
"pip install failure: check tensorflow requirements or update pip"
)
Expand Down
12 changes: 7 additions & 5 deletions tests/test_ruby.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_rails_hello_world(auto_container_per_test):

# Rails asset pipeline needs Node.js and yarn
auto_container_per_test.connection.run_expect(
[0], "zypper -n in nodejs-default yarn"
[0], "zypper -n in nodejs-default yarn libyaml-devel"
)
auto_container_per_test.connection.run_expect(
[0], "rails new /hello/ --minimal"
Expand All @@ -90,6 +90,11 @@ def test_rails_hello_world(auto_container_per_test):

@pytest.mark.skipif(OS_VERSION != "tumbleweed", reason="no rails for ruby 2.5")
def test_rails_template(auto_container_per_test):
# Rails asset pipeline needs Node.js and yarn
auto_container_per_test.connection.run_expect(
[0], "zypper -n in nodejs-default yarn libyaml-devel"
dcermak marked this conversation as resolved.
Show resolved Hide resolved
)

auto_container_per_test.connection.run_expect(
[0], "gem install 'rails:~> 7.0'"
)
Expand All @@ -111,9 +116,6 @@ def test_rails_template(auto_container_per_test):
):
pytest.xfail("timezone data are not in the container")

curl_localhost = auto_container_per_test.connection.run_expect(
[0],
assert "Ruby on Rails" in auto_container_per_test.connection.check_output(
"cd /hello/ && (rails server > /dev/null &) && curl -sf --retry 5 --retry-connrefused http://localhost:3000",
)

assert "Ruby on Rails" in curl_localhost.stdout.strip()