diff --git a/.github/workflows/test-containers-build.yml b/.github/workflows/test-containers-build.yml index 1ae27a3a..87aa5a4b 100644 --- a/.github/workflows/test-containers-build.yml +++ b/.github/workflows/test-containers-build.yml @@ -11,8 +11,9 @@ jobs: name: Determine if tests image needs to be built runs-on: ubuntu-24.04 outputs: - build-image: ${{ (steps.changed.outputs.qa-tag == 'true' || - contains(github.event.pull_request.labels.*.name, 'rebuild-test-container')) }} + build-image: ${{ (github.event_name != 'schedule' && + (steps.changed.outputs.qa-tag == 'true' || + contains(github.event.pull_request.labels.*.name, 'rebuild-test-container'))) }} steps: - uses: actions/checkout@v7 diff --git a/tests/containers/QA_TAG b/tests/containers/QA_TAG index 6e8bf73a..0ea3a944 100644 --- a/tests/containers/QA_TAG +++ b/tests/containers/QA_TAG @@ -1 +1 @@ -0.1.0 +0.2.0 diff --git a/tests/containers/base/Containerfile b/tests/containers/base/Containerfile new file mode 100644 index 00000000..102da78d --- /dev/null +++ b/tests/containers/base/Containerfile @@ -0,0 +1,2 @@ +# CentOS Stream 10 +FROM quay.io/centos/centos@sha256:6f8d618844ed5af4365bad24bea19fb0435fd5ec808201af9aeb19d7a28eb515 diff --git a/tests/containers/fedora/Makefile b/tests/containers/base/Makefile similarity index 71% rename from tests/containers/fedora/Makefile rename to tests/containers/base/Makefile index c3eabd41..f29828ed 100644 --- a/tests/containers/fedora/Makefile +++ b/tests/containers/base/Makefile @@ -1,12 +1,12 @@ include ../constants.mk -FACT_QA_FEDORA_TAG := fact-fedora-$(FACT_QA_TAG) +FACT_QA_BASE_TAG := fact-base-$(FACT_QA_TAG) all: build run: $(DOCKER) buildx build $(BUILD_ARGS) --platform $(PLATFORM) \ - -t quay.io/rhacs-eng/qa-multi-arch:$(FACT_QA_FEDORA_TAG) \ + -t quay.io/rhacs-eng/qa-multi-arch:$(FACT_QA_BASE_TAG) \ -f Containerfile \ $(CURDIR) diff --git a/tests/containers/editors/Containerfile b/tests/containers/editors/Containerfile index 3357f249..0c8529e1 100644 --- a/tests/containers/editors/Containerfile +++ b/tests/containers/editors/Containerfile @@ -1,5 +1,9 @@ -FROM quay.io/fedora/fedora:44 +# CentOS Stream 10 +FROM quay.io/centos/centos@sha256:6f8d618844ed5af4365bad24bea19fb0435fd5ec808201af9aeb19d7a28eb515 -RUN dnf install -y \ - neovim \ - vim +RUN dnf config-manager --set-enabled crb && \ + dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-10.noarch.rpm && \ + dnf install -y \ + neovim-0.10.1-4.el10_0 \ + vim-enhanced-2:9.1.083-25.el10 && \ + dnf clean all diff --git a/tests/containers/fedora/Containerfile b/tests/containers/fedora/Containerfile deleted file mode 100644 index 3ebbf5b2..00000000 --- a/tests/containers/fedora/Containerfile +++ /dev/null @@ -1 +0,0 @@ -FROM quay.io/fedora/fedora:44 diff --git a/tests/test_editors/commons.py b/tests/test_editors/commons.py index 036d4aeb..622891cc 100644 --- a/tests/test_editors/commons.py +++ b/tests/test_editors/commons.py @@ -52,25 +52,25 @@ def run_editor_container( @pytest.fixture(scope='session') -def build_fedora_image( +def build_base_image( request: pytest.FixtureRequest, docker_client: docker.DockerClient ) -> docker.models.images.Image: no_local_builds = bool(request.config.getoption('--no-local-builds')) return pull_or_build( docker_client, - tag='fact-fedora', - path='containers/fedora', + tag='fact-base', + path='containers/base', no_local_builds=no_local_builds, ) @pytest.fixture -def fedora_container( +def base_container( docker_client: docker.DockerClient, - build_fedora_image: docker.models.images.Image, + build_base_image: docker.models.images.Image, ignored_dir: str, ): - image = build_fedora_image.tags[0] + image = build_base_image.tags[0] yield from run_editor_container( image, docker_client, diff --git a/tests/test_editors/test_nvim.py b/tests/test_editors/test_nvim.py index d2217440..69812b1d 100644 --- a/tests/test_editors/test_nvim.py +++ b/tests/test_editors/test_nvim.py @@ -50,8 +50,9 @@ def test_open_file( editor_container.exec_run(cmd) touch = Process.in_container( - exe_path='/usr/bin/touch', - args=f'touch {fut}', + exe_path='/usr/bin/coreutils', + args="/usr/bin/coreutils '--coreutils-prog-shebang=touch' " + + f'/usr/bin/touch {fut}', name='touch', container_id=container_id, ) @@ -166,8 +167,9 @@ def test_open_file_ovfs( editor_container.exec_run(cmd) touch = Process.in_container( - exe_path='/usr/bin/touch', - args=f'touch {fut}', + exe_path='/usr/bin/coreutils', + args="/usr/bin/coreutils '--coreutils-prog-shebang=touch' " + + f'/usr/bin/touch {fut}', name='touch', container_id=container_id, ) diff --git a/tests/test_editors/test_sed.py b/tests/test_editors/test_sed.py index 1af10ca0..9ce033db 100644 --- a/tests/test_editors/test_sed.py +++ b/tests/test_editors/test_sed.py @@ -9,18 +9,18 @@ def test_sed( - fedora_container: docker.models.containers.Container, + base_container: docker.models.containers.Container, server: EventServer, ): - assert fedora_container.id is not None + assert base_container.id is not None # File Under Test fut = '/mounted/test.txt' create_cmd = f'sh -c "echo \'This is a test\' > {fut}"' sed_cmd = rf'sed -i -e "s/a test/not \\0/" {fut}' - container_id = fedora_container.id[:12] + container_id = base_container.id[:12] - fedora_container.exec_run(create_cmd) - fedora_container.exec_run(sed_cmd) + base_container.exec_run(create_cmd) + base_container.exec_run(sed_cmd) shell = Process.in_container( exe_path='/usr/bin/bash', @@ -72,18 +72,18 @@ def test_sed( def test_sed_ovfs( - fedora_container: docker.models.containers.Container, + base_container: docker.models.containers.Container, server: EventServer, ): - assert fedora_container.id is not None + assert base_container.id is not None # File Under Test fut = '/container-dir/test.txt' create_cmd = f'sh -c "echo \'This is a test\' > {fut}"' sed_cmd = rf'sed -i -e "s/a test/not \\0/" {fut}' - container_id = fedora_container.id[:12] + container_id = base_container.id[:12] - fedora_container.exec_run(create_cmd) - fedora_container.exec_run(sed_cmd) + base_container.exec_run(create_cmd) + base_container.exec_run(sed_cmd) shell = Process.in_container( exe_path='/usr/bin/bash', diff --git a/tests/test_editors/test_vi.py b/tests/test_editors/test_vi.py index c8aa55f0..cf6615d2 100644 --- a/tests/test_editors/test_vi.py +++ b/tests/test_editors/test_vi.py @@ -8,10 +8,10 @@ def test_new_file( - fedora_container: docker.models.containers.Container, + base_container: docker.models.containers.Container, server: EventServer, ): - assert fedora_container.id is not None + assert base_container.id is not None fut = '/mounted/test.txt' swap_file = '/mounted/.test.txt.swp' swx_file = '/mounted/.test.txt.swx' @@ -19,13 +19,13 @@ def test_new_file( cmd = f"{exe} {fut} '+:normal iThis is a test' -c x" - fedora_container.exec_run(cmd) + base_container.exec_run(cmd) process = Process.in_container( exe_path=exe, args=cmd, name='vi', - container_id=fedora_container.id[:12], + container_id=base_container.id[:12], ) events = [ @@ -77,10 +77,10 @@ def test_new_file( def test_new_file_ovfs( - fedora_container: docker.models.containers.Container, + base_container: docker.models.containers.Container, server: EventServer, ): - assert fedora_container.id is not None + assert base_container.id is not None fut = '/container-dir/test.txt' swap_file = '/container-dir/.test.txt.swp' swx_file = '/container-dir/.test.txt.swx' @@ -88,13 +88,13 @@ def test_new_file_ovfs( cmd = f"{exe} {fut} '+:normal iThis is a test' -c x" - fedora_container.exec_run(cmd) + base_container.exec_run(cmd) process = Process.in_container( exe_path=exe, args=cmd, name='vi', - container_id=fedora_container.id[:12], + container_id=base_container.id[:12], ) events = [ @@ -146,27 +146,28 @@ def test_new_file_ovfs( def test_open_file( - fedora_container: docker.models.containers.Container, + base_container: docker.models.containers.Container, server: EventServer, ): - assert fedora_container.id is not None + assert base_container.id is not None fut = '/mounted/test.txt' fut_backup = f'{fut}~' swap_file = '/mounted/.test.txt.swp' swx_file = '/mounted/.test.txt.swx' vi_test_file = get_vi_test_file('/mounted') exe = '/usr/bin/vi' - container_id = fedora_container.id[:12] + container_id = base_container.id[:12] cmd = f"{exe} {fut} '+:normal iThis is a test' -c x" # We ensure the file exists before editing. - fedora_container.exec_run(f'touch {fut}') - fedora_container.exec_run(cmd) + base_container.exec_run(f'touch {fut}') + base_container.exec_run(cmd) touch_process = Process.in_container( - exe_path='/usr/bin/touch', - args=f'touch {fut}', + exe_path='/usr/bin/coreutils', + args="/usr/bin/coreutils '--coreutils-prog-shebang=touch' " + + f'/usr/bin/touch {fut}', name='touch', container_id=container_id, ) @@ -287,27 +288,28 @@ def test_open_file( def test_open_file_ovfs( - fedora_container: docker.models.containers.Container, + base_container: docker.models.containers.Container, server: EventServer, ): - assert fedora_container.id is not None + assert base_container.id is not None fut = '/container-dir/test.txt' fut_backup = f'{fut}~' swap_file = '/container-dir/.test.txt.swp' swx_file = '/container-dir/.test.txt.swx' vi_test_file = get_vi_test_file('/container-dir') exe = '/usr/bin/vi' - container_id = fedora_container.id[:12] + container_id = base_container.id[:12] cmd = f"{exe} {fut} '+:normal iThis is a test' -c x" # We ensure the file exists before editing. - fedora_container.exec_run(f'touch {fut}') - fedora_container.exec_run(cmd) + base_container.exec_run(f'touch {fut}') + base_container.exec_run(cmd) touch_process = Process.in_container( - exe_path='/usr/bin/touch', - args=f'touch {fut}', + exe_path='/usr/bin/coreutils', + args="/usr/bin/coreutils '--coreutils-prog-shebang=touch' " + + f'/usr/bin/touch {fut}', name='touch', container_id=container_id, ) diff --git a/tests/test_editors/test_vim.py b/tests/test_editors/test_vim.py index 57408256..5a6cd01c 100644 --- a/tests/test_editors/test_vim.py +++ b/tests/test_editors/test_vim.py @@ -160,8 +160,9 @@ def test_open_file( editor_container.exec_run(cmd) touch_process = Process.in_container( - exe_path='/usr/bin/touch', - args=f'touch {fut}', + exe_path='/usr/bin/coreutils', + args="/usr/bin/coreutils '--coreutils-prog-shebang=touch' " + + f'/usr/bin/touch {fut}', name='touch', container_id=container_id, ) @@ -300,8 +301,9 @@ def test_open_file_ovfs( editor_container.exec_run(cmd) touch_process = Process.in_container( - exe_path='/usr/bin/touch', - args=f'touch {fut}', + exe_path='/usr/bin/coreutils', + args="/usr/bin/coreutils '--coreutils-prog-shebang=touch' " + + f'/usr/bin/touch {fut}', name='touch', container_id=container_id, )