Skip to content

Commit

Permalink
tests: run integration test on macos as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 committed Dec 5, 2023
1 parent 925b4a9 commit 040ac9f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,26 @@ jobs:
# XDG_RUNTIME_DIR is set.
# TODO: figure out what exactly podman needs
sudo -E XDG_RUNTIME_DIR= pytest-3 -s -vv
integration-macos:
name: "Integration macos"
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup up python
uses: actions/setup-python@v4
- name: Setup up podman
run: |
brew install podman
podman machine init -v /private/tmp:/private/tmp -v /var/tmp:/var/tmp -v /tmp:/tmp
podman machine start
# debug only
podman info
- name: Install test dependencies
run: |
sudo pip install pytest flake8
- name: Run tests
run: |
sudo pytest -s -vv
28 changes: 20 additions & 8 deletions test/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import pathlib
import subprocess
import tempfile

import pytest

Expand All @@ -10,10 +11,14 @@


@pytest.fixture(name="output_path")
def output_path_fixture(tmp_path):
output_path = tmp_path / "output"
output_path.mkdir(exist_ok=True)
return output_path
def output_path_fixture():
# do not pytest tmp_path because it's under /tmp by default but
# that is often a tmpfs and the image is relatively big (600mb)
with tempfile.TemporaryDirectory(dir="/var/tmp") as tmp_dir:
tmp_path = pathlib.Path(tmp_dir)
output_path = tmp_path / "output"
output_path.mkdir(exist_ok=True)
yield tmp_path


@pytest.fixture(name="config_json")
Expand All @@ -36,16 +41,22 @@ def config_json_fixture(output_path):
return config_json_path


@pytest.fixture(name="journal_cursor")
def journal_cursor_fixture():
if not testutil.has_executable("journalctl"):
return None
return testutil.journal_cursor()


@pytest.mark.skipif(os.getuid() != 0, reason="needs root")
@pytest.mark.skipif(not testutil.has_executable("podman"), reason="need podman")
def test_smoke(output_path, config_json):
def test_smoke(output_path, journal_cursor, config_json):
# build local container
subprocess.check_call([
"podman", "build",
"-f", "Containerfile",
"-t", "osbuild-deploy-container-test",
])
cursor = testutil.journal_cursor()
# and run container to deploy an image into output/disk.qcow2
subprocess.check_call([
"podman", "run", "--rm",
Expand All @@ -59,8 +70,9 @@ def test_smoke(output_path, config_json):
# check that there are no denials
# TODO: actually check this once https://github.com/osbuild/images/pull/287
# is merged
journal_output = testutil.journal_after_cursor(cursor)
assert journal_output != ""
if journal_cursor:
journal_output = testutil.journal_after_cursor(journal_cursor)
assert journal_output != ""
generated_img = pathlib.Path(output_path) / "qcow2/disk.qcow2"
assert generated_img.exists(), f"output file missing, dir content: {os.listdir(os.fspath(output_path))}"
# TODO: boot and do basic checks, see
Expand Down

0 comments on commit 040ac9f

Please sign in to comment.