Skip to content
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
5 changes: 3 additions & 2 deletions .github/workflows/test-containers-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/containers/QA_TAG
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.2.0
2 changes: 2 additions & 0 deletions tests/containers/base/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# CentOS Stream 10
FROM quay.io/centos/centos@sha256:6f8d618844ed5af4365bad24bea19fb0435fd5ec808201af9aeb19d7a28eb515
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
12 changes: 8 additions & 4 deletions tests/containers/editors/Containerfile
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion tests/containers/fedora/Containerfile

This file was deleted.

12 changes: 6 additions & 6 deletions tests/test_editors/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions tests/test_editors/test_nvim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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,
)
Expand Down
20 changes: 10 additions & 10 deletions tests/test_editors/test_sed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
46 changes: 24 additions & 22 deletions tests/test_editors/test_vi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@


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'
exe = '/usr/bin/vi'

cmd = f"{exe} {fut} '+:normal iThis is a test<CR>' -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 = [
Expand Down Expand Up @@ -77,24 +77,24 @@ 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'
exe = '/usr/bin/vi'

cmd = f"{exe} {fut} '+:normal iThis is a test<CR>' -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 = [
Expand Down Expand Up @@ -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<CR>' -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,
)
Expand Down Expand Up @@ -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<CR>' -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,
)
Expand Down
10 changes: 6 additions & 4 deletions tests/test_editors/test_vim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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,
)
Expand Down
Loading