Skip to content

Commit

Permalink
integration tests: Use single test repository
Browse files Browse the repository at this point in the history
Modify each test module to use a branch (not a git commit) as a
reference inside the new integration test repository that contains all
integration (e2e) tests for cachi2.

Update and improve a few functions inside utils.py

Drop unnecessary lines from each Containerfile that were blindly
duplicated along with the comments. Plus, they were tightly coupled with
our code printing output of specific files inside of directories coming
from pytest.

closes containerbuildsystem#676

Signed-off-by: Michal Šoltis <msoltis@redhat.com>
  • Loading branch information
slimreaper35 committed Jan 20, 2025
1 parent bbd0262 commit f281d5d
Show file tree
Hide file tree
Showing 31 changed files with 283 additions and 511 deletions.
28 changes: 11 additions & 17 deletions tests/integration/test_bundler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
pytest.param(
utils.TestParameters(
repo="https://github.com/cachito-testing/cachi2-bundler.git",
ref="malformed_ruby_missing_gemfile",
ref="bundler/missing-gemfile",
packages=({"path": ".", "type": "bundler"},),
check_output=False,
check_deps_checksums=False,
Expand All @@ -27,7 +27,7 @@
pytest.param(
utils.TestParameters(
repo="https://github.com/cachito-testing/cachi2-bundler.git",
ref="malformed_ruby_missing_gemfile_lock",
ref="bundler/missing-lockfile",
packages=({"path": ".", "type": "bundler"},),
check_output=False,
check_deps_checksums=False,
Expand All @@ -40,7 +40,7 @@
pytest.param(
utils.TestParameters(
repo="https://github.com/cachito-testing/cachi2-bundler.git",
ref="malformed_ruby_missing_git_revision",
ref="bundler/missing-git-revision",
packages=({"path": ".", "type": "bundler"},),
check_output=False,
check_deps_checksums=False,
Expand All @@ -56,18 +56,15 @@ def test_bundler_packages(
test_params: utils.TestParameters,
cachi2_image: utils.ContainerImage,
tmp_path: Path,
test_repo_dir: Path,
test_data_dir: Path,
request: pytest.FixtureRequest,
) -> None:
"""Integration tests for bundler package manager."""
test_case = request.node.callspec.id

source_folder = utils.clone_repository(
test_params.repo, test_params.ref, f"{test_case}-source", tmp_path
)

utils.fetch_deps_and_check_output(
tmp_path, test_case, test_params, source_folder, test_data_dir, cachi2_image
tmp_path, test_case, test_params, test_repo_dir, test_data_dir, cachi2_image
)


Expand All @@ -77,7 +74,7 @@ def test_bundler_packages(
pytest.param(
utils.TestParameters(
repo="https://github.com/cachito-testing/cachi2-bundler.git",
ref="well_formed_ruby_all_features",
ref="bundler/e2e",
packages=({"path": ".", "type": "bundler", "allow_binary": "true"},),
check_output=True,
check_deps_checksums=False,
Expand All @@ -92,7 +89,7 @@ def test_bundler_packages(
pytest.param(
utils.TestParameters(
repo="https://github.com/cachito-testing/cachi2-bundler.git",
ref="well_formed_ruby_without_gemspec",
ref="bundler/e2e-missing-gemspec",
packages=({"path": ".", "type": "bundler", "allow_binary": "true"},),
check_output=True,
check_deps_checksums=False,
Expand All @@ -112,6 +109,7 @@ def test_e2e_bundler(
expected_cmd_output: str,
cachi2_image: utils.ContainerImage,
tmp_path: Path,
test_repo_dir: Path,
test_data_dir: Path,
request: pytest.FixtureRequest,
) -> None:
Expand All @@ -123,17 +121,13 @@ def test_e2e_bundler(
"""
test_case = request.node.callspec.id

source_folder = utils.clone_repository(
test_params.repo, test_params.ref, f"{test_case}-source", tmp_path
)

output_folder = utils.fetch_deps_and_check_output(
tmp_path, test_case, test_params, source_folder, test_data_dir, cachi2_image
utils.fetch_deps_and_check_output(
tmp_path, test_case, test_params, test_repo_dir, test_data_dir, cachi2_image
)

utils.build_image_and_check_cmd(
tmp_path,
output_folder,
test_repo_dir,
test_data_dir,
test_case,
check_cmd,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
FROM docker.io/ruby:3.3

# Test disabled network access
RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi

# Print cachi2 env vars file
RUN cat /tmp/cachi2.env

# Check bundler deps
RUN ls /tmp/bundler_everything_present-output/deps/bundler

# Check content of source repository folder
RUN ls /tmp/bundler_everything_present-source/

# This should be a COPY, but the source code and Containerfile are in different directories
RUN cp -r /tmp/bundler_everything_present-source /src

WORKDIR /src

RUN . /tmp/cachi2.env && bundle install
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
FROM docker.io/ruby:3.3

# Test disabled network access
RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi

# Print cachi2 env vars file
RUN cat /tmp/cachi2.env

# Check bundler deps
RUN ls /tmp/bundler_everything_present_except_gemspec-output/deps/bundler

# Check content of source repository folder
RUN ls /tmp/bundler_everything_present_except_gemspec-source/

# This should be a COPY, but the source code and Containerfile are in different directories
RUN cp -r /tmp/bundler_everything_present_except_gemspec-source /src

WORKDIR /src

RUN . /tmp/cachi2.env && bundle install
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM registry.fedoraproject.org/fedora:40

RUN cp -r /tmp/generic_e2e-output/deps/generic/ /deps
RUN cp -r /tmp/cachi2-output/deps/generic/ /deps

CMD ["ls", "-al", "/deps"]
CMD ["ls", "-al", "/deps"]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM docker.io/ibmjava:11-jdk

RUN cp -r /tmp/generic_maven_e2e-output/deps/generic/ /deps
RUN cp -r /tmp/cachi2-output/deps/generic/ /deps

CMD ["java", "-cp", "/deps/ant.jar:/deps/ant-launcher.jar", "org.apache.tools.ant.Main", "-version"]
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
FROM docker.io/golang:1.18.1 AS build
FROM docker.io/golang:1.18.1

# Test disabled network access
RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi

# Print cachi2 env vars file
RUN cat /tmp/cachi2.env

# Check content of source repository folder
RUN ls /tmp/gomod_1.18_e2e_test-source/

WORKDIR /tmp/gomod_1.18_e2e_test-source
WORKDIR /src
RUN . /tmp/cachi2.env && go build -o /usr/bin/retrodep

CMD retrodep --help
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
FROM docker.io/golang:1.20.0 AS build
FROM docker.io/golang:1.20.0

# Test disabled network access
RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi

# Print cachi2 env vars file
RUN cat /tmp/cachi2.env

# Check content of source repository folder
RUN ls /tmp/gomod_1.20_e2e_dirty_go.mod-source/

WORKDIR /tmp/gomod_1.20_e2e_dirty_go.mod-source/twenty

# Check that repository is clean (go.mod should not be updated)
RUN if [ -n "$(git status --porcelain)" ]; then echo "Repo is dirty. Check go.mod"; exit 1; fi
WORKDIR /src/twenty

RUN . /tmp/cachi2.env && go build -o /usr/bin/twenty

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
FROM docker.io/golang:1.21.5 AS build
FROM docker.io/golang:1.21.5

# Test disabled network access
RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi

# Print cachi2 env vars file
RUN cat /tmp/cachi2.env

# Check content of source repository folder
RUN ls /tmp/gomod_1.21_e2e_test-source/

WORKDIR /tmp/gomod_1.21_e2e_test-source
WORKDIR /src
RUN . /tmp/cachi2.env && go build -o /usr/bin/retrodep

CMD retrodep --help
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
FROM docker.io/golang:1.22.0 AS build
FROM docker.io/golang:1.22.0

# Test disabled network access
RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi

# Print cachi2 env vars file
RUN cat /tmp/cachi2.env

# Check content of source repository folder
RUN ls /tmp/gomod_1.22_e2e_workspace_vendoring-source

WORKDIR /tmp/gomod_1.22_e2e_workspace_vendoring-source/hi/hiii
WORKDIR /src/hi/hiii
RUN . /tmp/cachi2.env && go build -o /usr/bin/hiii

CMD hiii
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
FROM docker.io/golang:1.18.1

# Test disabled network access
RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi

# Print cachi2 env vars file
RUN cat /tmp/cachi2.env

WORKDIR /tmp/gomod_e2e_multiple_modules-source
WORKDIR /src
RUN . /tmp/cachi2.env && \
cd spam-module && go build -o /usr/bin/spam-module && \
cd ../eggs-module && go build -o /usr/bin/eggs-module
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
FROM docker.io/node:18

# Test disabled network access
RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi
WORKDIR /src

# Print cachi2 env vars file
RUN cat /tmp/cachi2.env

# Check npm deps
RUN ls /tmp/npm_lockfile3_aliased_deps-output/deps/npm

# Check content of source repository folder
RUN ls /tmp/npm_lockfile3_aliased_deps-source/

WORKDIR /tmp/npm_lockfile3_aliased_deps-source

# Install packages and list them
RUN . /tmp/cachi2.env && \
npm install && \
npm ll --parseable > /opt/npm-ls-output.txt
RUN . /tmp/cachi2.env && npm install
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
FROM docker.io/node:18

# Test disabled network access
RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi
WORKDIR /src

# Print cachi2 env vars file
RUN cat /tmp/cachi2.env

# Check npm deps
RUN ls /tmp/npm_lockfile3_dev_optional_peer_deps-output/deps/npm

# Check content of source repository folder
RUN ls /tmp/npm_lockfile3_dev_optional_peer_deps-source/

WORKDIR /tmp/npm_lockfile3_dev_optional_peer_deps-source

# Install packages and list them
RUN . /tmp/cachi2.env && \
npm install && \
npm ls -a --parseable > /opt/npm-ls-output.txt
RUN . /tmp/cachi2.env && npm install
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
FROM docker.io/node:18

# Test disabled network access
RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi
WORKDIR /src

# Print cachi2 env vars file
RUN cat /tmp/cachi2.env

# Check npm deps
RUN ls /tmp/npm_lockfile3_multiple_dep_versions-output/deps/npm

# Check content of source repository folder
RUN ls /tmp/npm_lockfile3_multiple_dep_versions-source/

WORKDIR /tmp/npm_lockfile3_multiple_dep_versions-source

# Install packages and list them
RUN . /tmp/cachi2.env && \
npm install && \
npm ll --parseable > /opt/npm-ls-output.txt
RUN . /tmp/cachi2.env && npm install
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
FROM docker.io/node:17

# Test disabled network access
RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi
WORKDIR /src/first_pkg
RUN . /tmp/cachi2.env && npm install && npm ls

# Print cachi2 env vars file
RUN cat /tmp/cachi2.env

# Check npm deps
RUN ls /tmp/npm_multiple_packages_lockfile3-output/deps/npm

# Check content of source repository folder
RUN ls /tmp/npm_multiple_packages_lockfile3-source/

WORKDIR /tmp/npm_multiple_packages_lockfile3-source

# Install packages
RUN cd ./first_pkg && . /tmp/cachi2.env && npm i && npm ls
RUN cd ./second_pkg && . /tmp/cachi2.env && npm i && npm ls
WORKDIR /src/second_pkg
RUN . /tmp/cachi2.env && npm install && npm ls
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
FROM docker.io/node:17

# Test disabled network access
RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi
WORKDIR /src

# Print cachi2 env vars file
RUN cat /tmp/cachi2.env

# Check pip deps
RUN ls /tmp/npm_smoketest_lockfile2-output/deps/npm

# Check content of source repository folder
RUN ls /tmp/npm_smoketest_lockfile2-source/

WORKDIR /tmp/npm_smoketest_lockfile2-source

# Install packages
RUN . /tmp/cachi2.env && npm i && npm ls
RUN . /tmp/cachi2.env && npm install && npm ls
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
FROM docker.io/node:18

# Test disabled network access
RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi
WORKDIR /src

# Print cachi2 env vars file
RUN cat /tmp/cachi2.env

# Check pip deps
RUN ls /tmp/npm_smoketest_lockfile3-output/deps/npm

# Check content of source repository folder
RUN ls /tmp/npm_smoketest_lockfile3-source/

WORKDIR /tmp/npm_smoketest_lockfile3-source

# Install packages
RUN . /tmp/cachi2.env && npm i && npm ls
RUN . /tmp/cachi2.env && npm install && npm ls
Loading

0 comments on commit f281d5d

Please sign in to comment.