Allow builds/tests/publish without docker This change adds support for using buildah, which does not require the docker socket and can thus be used within a container. Change-Id: Idcae27e3dee0fc0d61b4ba527a56745172284114
diff --git a/.gitignore b/.gitignore index 127f652..1628c5f 100644 --- a/.gitignore +++ b/.gitignore
@@ -14,3 +14,5 @@ .project .idea/ + +dist
diff --git a/build b/build index 9202147..50fc8db 100755 --- a/build +++ b/build
@@ -16,10 +16,12 @@ usage() { me=`basename "$0"` - echo >&2 "Usage: $me [--help] [--tag TAG] [--no-cache] [--gerrit-url URL] [--base-image IMAGE] [--platform PLATFORM] [--branch GERRIT_BRANCH] [IMAGE]" + echo >&2 "Usage: $me [--help] [--tag TAG] [--no-cache] [--gerrit-url URL] [--base-image IMAGE] [--platform PLATFORM] [--branch GERRIT_BRANCH] [--buildah] [IMAGE]" exit 1 } +BUILD_TOOL="docker" + while test $# -gt 0 ; do case "$1" in --help) @@ -67,6 +69,11 @@ shift ;; + --buildah) + BUILD_TOOL="buildah" + shift + ;; + *) break esac @@ -79,25 +86,30 @@ PLATFORM=${PLATFORM:-linux/amd64} # Default value if PLATFORM is not set GERRIT_BRANCH=${GERRIT_BRANCH:-master} # Default value if GERRIT_BRANCH is not set DOCKER_BUILD_OPTS="--platform=$PLATFORM" +if [[ $BUILD_TOOL = buildah ]]; then + DOCKER_BUILD_OPTS="$DOCKER_BUILD_OPTS --isolation=chroot" + GERRIT_VER_OPTS="$GERRIT_VER_OPTS --no-docker" +fi test -n "$NO_CACHE" && DOCKER_BUILD_OPTS="$DOCKER_BUILD_OPTS --no-cache" if test -n "$GERRIT_WAR_URL"; then BUILD_ARGS="--build-arg GERRIT_WAR_URL=$GERRIT_WAR_URL" + GERRIT_VER_OPTS="$GERRIT_VER_OPTS --gerrit-url $GERRIT_WAR_URL" fi if test -n "$HEALTHCHECK_JAR_URL"; then BUILD_ARGS="$BUILD_ARGS --build-arg HEALTHCHECK_JAR_URL=$HEALTHCHECK_JAR_URL" fi -export REV="$(./get_version.sh --output K8SGERRIT --platform $PLATFORM)" +export K8SGERRIT_VER="$(./get_version.sh --output K8SGERRIT)" docker_build(){ IMAGE=$1 - docker build \ + $BUILD_TOOL build \ $DOCKER_BUILD_OPTS \ - --build-arg TAG=$REV \ - --build-arg GERRIT_VER="$(./get_version.sh --output GERRIT --platform $PLATFORM)" \ + --build-arg TAG=$K8SGERRIT_VER \ + --build-arg GERRIT_VER="$GERRIT_VER" \ -t k8sgerrit/$IMAGE:$TAG \ ./container-images/$IMAGE @@ -110,19 +122,21 @@ } docker_build_gerrit_base(){ - BUILD_ARGS="$BUILD_ARGS --build-arg TAG=$REV --build-arg GERRIT_BRANCH=$GERRIT_BRANCH" - docker build \ + BUILD_ARGS="$BUILD_ARGS --build-arg TAG=$K8SGERRIT_VER --build-arg GERRIT_BRANCH=$GERRIT_BRANCH" + $BUILD_TOOL build \ $DOCKER_BUILD_OPTS \ $BUILD_ARGS \ - -t gerrit-base:$REV \ + -t gerrit-base:$K8SGERRIT_VER \ ./container-images/gerrit-base if test $? -ne 0; then echo -e "\n\nFailed to build gerrit-base image." exit 1 fi + export GERRIT_VER="$(./get_version.sh --output GERRIT --platform $PLATFORM $GERRIT_VER_OPTS)" + if test -z "$TAG"; then - export TAG="$(./get_version.sh --platform $PLATFORM)" + export TAG="$(./get_version.sh --platform $PLATFORM $GERRIT_VER_OPTS)" fi } @@ -133,7 +147,7 @@ BASE_BUILD_ARGS="--build-arg BASE_IMAGE=$BASE_IMAGE" fi -docker build $DOCKER_BUILD_OPTS $BASE_BUILD_ARGS -t base:$REV ./container-images/base +$BUILD_TOOL build $DOCKER_BUILD_OPTS $BASE_BUILD_ARGS -t base:$K8SGERRIT_VER ./container-images/base if test $? -ne 0; then echo -e "\n\nFailed to build base image." exit 1 @@ -150,7 +164,7 @@ docker_build_gerrit_base else if test -z "$TAG"; then - TAG="$REV-unknown" + TAG="$K8SGERRIT_VER-unknown" fi echo -e "\nNo Image containing Gerrit will be built." \ "The Gerrit-version can thus not be determinded." \
diff --git a/get_version.sh b/get_version.sh index 8647ba8..4920143 100755 --- a/get_version.sh +++ b/get_version.sh
@@ -14,11 +14,12 @@ usage() { me=`basename "$0"` - echo >&2 "Usage: $me [--help] [--output (K8SGERRIT | GERRIT | COMBINED)]" + echo >&2 "Usage: $me [--help] [--output (K8SGERRIT | GERRIT | COMBINED)] [--platform PLATFORM] [--gerrit-war-url GERRIT_WAR_URL] [--no-docker]" exit 1 } OUTPUT="COMBINED" +USE_DOCKER=true while test $# -gt 0 ; do case "$1" in @@ -38,6 +39,17 @@ shift ;; + --no-docker) + USE_DOCKER=false + shift + ;; + + --gerrit-url) + shift + GERRIT_WAR_URL=$1 + shift + ;; + *) break esac @@ -47,7 +59,7 @@ echo "$(git describe --always --dirty --abbrev=10)" } -getGerritVersion() { +getGerritVersionDocker() { PLATFORM=${PLATFORM:-linux/amd64} # Default value if PLATFORM is not set GERRIT_VERSION="$( docker run \ @@ -64,6 +76,41 @@ echo "$GERRIT_VERSION" } +getGerritVersionNoDocker() { + GERRIT_BRANCH=${GERRIT_BRANCH:-main} + GERRIT_WAR_URL=${GERRIT_WAR_URL:-https://gerrit-ci.gerritforge.com/job/Gerrit-bazel-${GERRIT_BRANCH}/lastSuccessfulBuild/artifact/gerrit/bazel-bin/release.war} + + # Create temporary directory for WAR file + TMP_DIR="./dist" + mkdir -p $TMP_DIR + + GERRIT_WAR_FILE="$TMP_DIR/gerrit.war" + + if ! test -f "$GERRIT_WAR_FILE"; then + if ! curl -f -k -s -S -o "$GERRIT_WAR_FILE" "$GERRIT_WAR_URL" 2>&1 >&2; then + echo "Error: Failed to download Gerrit WAR file from $GERRIT_WAR_URL" >&2 + exit 1 + fi + fi + + GERRIT_VERSION="$(java -jar "$GERRIT_WAR_FILE" version | cut -d' ' -f3)" + + if [ -z "$GERRIT_VERSION" ]; then + echo "Error: Could not extract Gerrit version from WAR file" >&2 + exit 1 + fi + + echo "$GERRIT_VERSION" +} + +getGerritVersion() { + if [ "$USE_DOCKER" = "true" ]; then + getGerritVersionDocker + else + getGerritVersionNoDocker + fi +} + case $OUTPUT in K8SGERRIT) echo "$(getK8sVersion)"
diff --git a/operator/pom.xml b/operator/pom.xml index 5ff797e..e8707ee 100644 --- a/operator/pom.xml +++ b/operator/pom.xml
@@ -28,6 +28,7 @@ <platform.architecture>amd64</platform.architecture> <docker.registry>docker.io</docker.registry> <docker.org>k8sgerrit</docker.org> + <skip.docker.build>false</skip.docker.build> <test.docker.registry>docker.io</test.docker.registry> <test.docker.org>k8sgerritdev</test.docker.org> @@ -35,6 +36,50 @@ <profiles> <profile> + <id>tar</id> + <properties> + <skip.docker.build>true</skip.docker.build> + </properties> + <build> + <plugins> + <plugin> + <groupId>com.google.cloud.tools</groupId> + <artifactId>jib-maven-plugin</artifactId> + <executions> + <execution> + <id>build-tar</id> + <phase>package</phase> + <goals> + <goal>buildTar</goal> + </goals> + <configuration> + <container> + <mainClass>com.google.gerrit.k8s.operator.Main</mainClass> + </container> + <containerizingMode>packaged</containerizingMode> + <from> + <image>gcr.io/distroless/java17-debian12</image> + <platforms> + <platform> + <architecture>${platform.architecture}</architecture> + <os>${platform.os}</os> + </platform> + </platforms> + </from> + <to> + <image>gerrit-operator</image> + <tags> + <tag>${project.version}</tag> + </tags> + </to> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <profile> <id>publish</id> <build> <plugins> @@ -314,11 +359,13 @@ <artifactId>jib-maven-plugin</artifactId> <executions> <execution> + <id>docker-build</id> <phase>package</phase> <goals> <goal>dockerBuild</goal> </goals> <configuration> + <skip>${skip.docker.build}</skip> <container> <mainClass>com.google.gerrit.k8s.operator.Main</mainClass> </container>
diff --git a/publish b/publish index 5205375..4ded786 100755 --- a/publish +++ b/publish
@@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -x # Copyright (C) 2018 The Android Open Source Project # @@ -16,13 +16,14 @@ usage() { me=`basename "$0"` - echo >&2 "Usage: $me [--help] [--update-latest] [--registry REGISTRY] [--org ORGANIZATION] [--no-push] [--tag TAG] [IMAGE]" + echo >&2 "Usage: $me [--help] [--buildah] [--update-latest] [--registry REGISTRY] [--org ORGANIZATION] [--no-push] [--tag TAG] [IMAGE]" exit 1 } UPDATE_LATEST=false ORGANIZATION=k8sgerrit PUSH_IMAGES=true +BUILD_TOOL=docker while test $# -gt 0 ; do case "$1" in @@ -52,6 +53,10 @@ TAG=$1 shift ;; + --buildah) + BUILD_TOOL="buildah" + shift + ;; *) break esac @@ -65,20 +70,26 @@ source container-images/publish_list IMAGES=$(get_image_list) +if [[ "$BUILD_TOOL" = "docker" ]]; then + IMG_TAG_CMD="docker image tag" +elif [[ "$BUILD_TOOL" = "buildah" ]]; then + IMG_TAG_CMD="buildah tag" +fi + test -n "$REGISTRY" && [[ "$REGISTRY" != */ ]] && REGISTRY="$REGISTRY/" publish_image(){ IMAGE=$1 if test "$UPDATE_LATEST" = "true" ; then - docker image tag k8sgerrit/$IMAGE:$TAG ${REGISTRY}${ORGANIZATION}/$IMAGE:latest + $IMG_TAG_CMD k8sgerrit/$IMAGE:$TAG ${REGISTRY}${ORGANIZATION}/$IMAGE:latest if test "$PUSH_IMAGES" = "true" ; then - docker push "${REGISTRY}${ORGANIZATION}/$IMAGE:latest" + $BUILD_TOOL push "${REGISTRY}${ORGANIZATION}/$IMAGE:latest" fi fi - docker image tag k8sgerrit/$IMAGE:$TAG ${REGISTRY}${ORGANIZATION}/$IMAGE:$TAG + $IMG_TAG_CMD k8sgerrit/$IMAGE:$TAG ${REGISTRY}${ORGANIZATION}/$IMAGE:$TAG if test "$PUSH_IMAGES" = "true" ; then - docker push "${REGISTRY}${ORGANIZATION}/$IMAGE:$TAG" + $BUILD_TOOL push "${REGISTRY}${ORGANIZATION}/$IMAGE:$TAG" fi }
diff --git a/setup.cfg b/setup.cfg index 7708c62..3fe9480 100644 --- a/setup.cfg +++ b/setup.cfg
@@ -3,6 +3,7 @@ markers = docker: Tests that require to run and interact with a docker container + dockerinspect: Tests that inspect image layers incremental: Test classes containing tests that need to run incrementally integration: Integration tests slow: Tests that run slower than the average test
diff --git a/tests/conftest.py b/tests/conftest.py index ec5dd63..495cbdd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py
@@ -70,6 +70,21 @@ help="If set, the docker cache will be used when building container images.", ) parser.addoption( + "--tag", + action="store", + help="Tag of the images to test. If set, the build will be skipped.", + ) + parser.addoption( + "--repo", + action="store", + help="Repository from where to pull the images. Only used when --tag is set.", + ) + parser.addoption( + "--docker-host", + action="store", + help="Docker host to be used by docker client.", + ) + parser.addoption( "--skip-slow", action="store_true", help="If set, skip slow tests." ) @@ -97,7 +112,11 @@ @pytest.fixture(scope="session") -def docker_client(): +def docker_client(request): + if request.config.getoption("--docker-host"): + return docker.DockerClient( + base_url=request.config.getoption("--docker-host"), + version="1.41") return docker.from_env() @@ -117,6 +136,21 @@ @pytest.fixture(scope="session") +def docker_get(request, docker_client, docker_build): + def docker_get(image, name): + if request.config.getoption("--tag"): + if name in ["base", "gerrit-base"]: + return + return docker_client.images.get( + f"{request.config.getoption('--repo')}/{name}:{request.config.getoption('--tag')}", + ) + + return docker_build(image, name) + + return docker_get + + +@pytest.fixture(scope="session") def docker_build( request, docker_client, @@ -142,7 +176,7 @@ @pytest.fixture(scope="session") -def docker_network(request, docker_client): +def docker_network(docker_client): network = docker_client.networks.create( name="k8sgerrit-test-network", scope="local" ) @@ -153,35 +187,35 @@ @pytest.fixture(scope="session") -def base_image(container_images, docker_build): - return docker_build(container_images["base"], "base") +def base_image(container_images, docker_get): + return docker_get(container_images["base"], "base") @pytest.fixture(scope="session") -def gerrit_base_image(container_images, docker_build, base_image): - return docker_build(container_images["gerrit-base"], "gerrit-base") +def gerrit_base_image(container_images, docker_get, base_image): + return docker_get(container_images["gerrit-base"], "gerrit-base") @pytest.fixture(scope="session") -def gitgc_image(container_images, docker_build, base_image): - return docker_build(container_images["git-gc"], "git-gc") +def gitgc_image(container_images, docker_get, base_image): + return docker_get(container_images["git-gc"], "git-gc") @pytest.fixture(scope="session") -def apache_git_http_backend_image(container_images, docker_build, base_image): - return docker_build( +def apache_git_http_backend_image(container_images, docker_get, base_image): + return docker_get( container_images["apache-git-http-backend"], "apache-git-http-backend" ) @pytest.fixture(scope="session") -def gerrit_image(container_images, docker_build, base_image, gerrit_base_image): - return docker_build(container_images["gerrit"], "gerrit") +def gerrit_image(container_images, docker_get, base_image, gerrit_base_image): + return docker_get(container_images["gerrit"], "gerrit") @pytest.fixture(scope="session") -def gerrit_init_image(container_images, docker_build, base_image, gerrit_base_image): - return docker_build(container_images["gerrit-init"], "gerrit-init") +def gerrit_init_image(container_images, docker_get, base_image, gerrit_base_image): + return docker_get(container_images["gerrit-init"], "gerrit-init") @pytest.fixture(scope="session")
diff --git a/tests/container-images/apache-git-http-backend/test_container_build_apache_git_http_backend.py b/tests/container-images/apache-git-http-backend/test_container_build_apache_git_http_backend.py index 8d17602..fc7faca 100644 --- a/tests/container-images/apache-git-http-backend/test_container_build_apache_git_http_backend.py +++ b/tests/container-images/apache-git-http-backend/test_container_build_apache_git_http_backend.py
@@ -15,6 +15,6 @@ import pytest -@pytest.mark.structure +@pytest.mark.build def test_build_apache_git_http_backend_image(apache_git_http_backend_image): assert apache_git_http_backend_image.id is not None
diff --git a/tests/container-images/apache-git-http-backend/test_container_structure_apache_git_http_backend.py b/tests/container-images/apache-git-http-backend/test_container_structure_apache_git_http_backend.py index baaef0e..78603af 100755 --- a/tests/container-images/apache-git-http-backend/test_container_structure_apache_git_http_backend.py +++ b/tests/container-images/apache-git-http-backend/test_container_structure_apache_git_http_backend.py
@@ -13,15 +13,6 @@ # limitations under the License. import pytest -import utils - - -# pylint: disable=E1101 -@pytest.mark.structure -def test_apache_git_http_backend_inherits_from_base(apache_git_http_backend_image): - assert utils.check_if_ancestor_image_is_inherited( - apache_git_http_backend_image, "base:latest" - ) @pytest.mark.docker @@ -55,6 +46,7 @@ @pytest.mark.structure +@pytest.mark.dockerinspect def test_apache_git_http_backend_has_entrypoint(apache_git_http_backend_image): entrypoint = apache_git_http_backend_image.attrs["Config"]["Entrypoint"] assert len(entrypoint) == 2
diff --git a/tests/container-images/base/test_container_build_base.py b/tests/container-images/base/test_container_build_base.py deleted file mode 100644 index e0a8ff4..0000000 --- a/tests/container-images/base/test_container_build_base.py +++ /dev/null
@@ -1,20 +0,0 @@ -# Copyright (C) 2018 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import pytest - - -@pytest.mark.structure -def test_build_base(base_image): - assert base_image.id is not None
diff --git a/tests/container-images/base/test_container_structure_base.py b/tests/container-images/base/test_container_structure_base.py index 528d2b4..5cad844 100755 --- a/tests/container-images/base/test_container_structure_base.py +++ b/tests/container-images/base/test_container_structure_base.py
@@ -15,9 +15,19 @@ import pytest -@pytest.fixture(scope="module") -def container_run(docker_client, container_endless_run_factory, base_image): - container_run = container_endless_run_factory(docker_client, base_image) +@pytest.fixture( + scope="module", + params=[ + "apache_git_http_backend_image", + "gerrit_image", + "gerrit_init_image", + "gitgc_image", + ], +) +def container_run(request, docker_client, container_endless_run_factory): + container_run = container_endless_run_factory( + docker_client, request.getfixturevalue(request.param) + ) yield container_run container_run.stop(timeout=1)
diff --git a/tests/container-images/gerrit-base/test_container_build_gerrit_base.py b/tests/container-images/gerrit-base/test_container_build_gerrit_base.py deleted file mode 100644 index bd3dd5c..0000000 --- a/tests/container-images/gerrit-base/test_container_build_gerrit_base.py +++ /dev/null
@@ -1,20 +0,0 @@ -# Copyright (C) 2018 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import pytest - - -@pytest.mark.structure -def test_build_gerrit_base(gerrit_base_image): - assert gerrit_base_image.id is not None
diff --git a/tests/container-images/gerrit-base/test_container_structure_gerrit_base.py b/tests/container-images/gerrit-base/test_container_structure_gerrit_base.py index 6ab63ca..0e9171b 100755 --- a/tests/container-images/gerrit-base/test_container_structure_gerrit_base.py +++ b/tests/container-images/gerrit-base/test_container_structure_gerrit_base.py
@@ -16,25 +16,19 @@ import pytest -import utils - JAVA_VER = 25 -@pytest.fixture(scope="module") -def container_run(docker_client, container_endless_run_factory, gerrit_base_image): - container_run = container_endless_run_factory(docker_client, gerrit_base_image) +@pytest.fixture(scope="module", params=["gerrit_image", "gerrit_init_image"]) +def container_run(request, docker_client, container_endless_run_factory): + container_run = container_endless_run_factory( + docker_client, request.getfixturevalue(request.param) + ) yield container_run container_run.stop(timeout=1) -# pylint: disable=E1101 -@pytest.mark.structure -def test_gerrit_base_inherits_from_base(gerrit_base_image): - assert utils.check_if_ancestor_image_is_inherited(gerrit_base_image, "base:latest") - - @pytest.mark.docker @pytest.mark.structure def test_gerrit_base_contains_java(container_run): @@ -92,9 +86,3 @@ def test_gerrit_base_war_dir_permissions(container_run): exit_code, _ = container_run.exec_run("test -O /var/war") assert exit_code == 0 - - -@pytest.mark.structure -def test_gerrit_base_has_entrypoint(gerrit_base_image): - entrypoint = gerrit_base_image.attrs["Config"]["Entrypoint"] - assert "/var/tools/start" in entrypoint
diff --git a/tests/container-images/gerrit-init/test_container_build_gerrit_init.py b/tests/container-images/gerrit-init/test_container_build_gerrit_init.py index 0fe3532..1ab4460 100644 --- a/tests/container-images/gerrit-init/test_container_build_gerrit_init.py +++ b/tests/container-images/gerrit-init/test_container_build_gerrit_init.py
@@ -15,6 +15,6 @@ import pytest -@pytest.mark.structure +@pytest.mark.build def test_build_gerrit_init(gerrit_init_image): assert gerrit_init_image.id is not None
diff --git a/tests/container-images/gerrit-init/test_container_structure_gerrit_init.py b/tests/container-images/gerrit-init/test_container_structure_gerrit_init.py index 21230e9..1ee56aa 100755 --- a/tests/container-images/gerrit-init/test_container_structure_gerrit_init.py +++ b/tests/container-images/gerrit-init/test_container_structure_gerrit_init.py
@@ -45,14 +45,6 @@ return request.param -# pylint: disable=E1101 -@pytest.mark.structure -def test_gerrit_init_inherits_from_gerrit_base(gerrit_init_image): - assert utils.check_if_ancestor_image_is_inherited( - gerrit_init_image, "gerrit-base:latest" - ) - - @pytest.mark.docker @pytest.mark.structure def test_gerrit_init_contains_expected_scripts(container_run, expected_script): @@ -68,6 +60,7 @@ @pytest.mark.structure +@pytest.mark.dockerinspect def test_gerrit_init_has_entrypoint(gerrit_init_image): entrypoint = gerrit_init_image.attrs["Config"]["Entrypoint"] assert len(entrypoint) >= 1
diff --git a/tests/container-images/gerrit/test_container_build_gerrit.py b/tests/container-images/gerrit/test_container_build_gerrit.py index fb94e92..f885c7c 100644 --- a/tests/container-images/gerrit/test_container_build_gerrit.py +++ b/tests/container-images/gerrit/test_container_build_gerrit.py
@@ -15,6 +15,6 @@ import pytest -@pytest.mark.structure +@pytest.mark.build def test_build_gerrit(gerrit_image): assert gerrit_image.id is not None
diff --git a/tests/container-images/gerrit/test_container_structure_gerrit.py b/tests/container-images/gerrit/test_container_structure_gerrit.py index 7ece25e..55f8bf6 100755 --- a/tests/container-images/gerrit/test_container_structure_gerrit.py +++ b/tests/container-images/gerrit/test_container_structure_gerrit.py
@@ -24,16 +24,15 @@ container_run.stop(timeout=1) -# pylint: disable=E1101 -@pytest.mark.structure -def test_gerrit_inherits_from_gerrit_base(gerrit_image): - assert utils.check_if_ancestor_image_is_inherited( - gerrit_image, "gerrit-base:latest" - ) - - @pytest.mark.docker @pytest.mark.structure def test_gerrit_contains_start_script(container_run): exit_code, _ = container_run.exec_run("test -f /var/tools/start") assert exit_code == 0 + + +@pytest.mark.structure +@pytest.mark.dockerinspect +def test_gerrit_base_has_entrypoint(gerrit_image): + entrypoint = gerrit_image.attrs["Config"]["Entrypoint"] + assert "/var/tools/start" in entrypoint
diff --git a/tests/container-images/git-gc/test_container_build_gitgc.py b/tests/container-images/git-gc/test_container_build_gitgc.py index f94078c..3dfe708 100644 --- a/tests/container-images/git-gc/test_container_build_gitgc.py +++ b/tests/container-images/git-gc/test_container_build_gitgc.py
@@ -15,6 +15,6 @@ import pytest -@pytest.mark.structure +@pytest.mark.build def test_build_gitgc(gitgc_image): assert gitgc_image.id is not None
diff --git a/tests/container-images/git-gc/test_container_structure_gitgc.py b/tests/container-images/git-gc/test_container_structure_gitgc.py index 65a3be0..c87ee8a 100644 --- a/tests/container-images/git-gc/test_container_structure_gitgc.py +++ b/tests/container-images/git-gc/test_container_structure_gitgc.py
@@ -24,12 +24,6 @@ container_run.stop(timeout=1) -# pylint: disable=E1101 -@pytest.mark.structure -def test_gitgc_inherits_from_base(gitgc_image): - assert utils.check_if_ancestor_image_is_inherited(gitgc_image, "base:latest") - - @pytest.mark.docker @pytest.mark.structure def test_gitgc_contains_gc_script(container_run): @@ -38,6 +32,7 @@ @pytest.mark.structure +@pytest.mark.dockerinspect def test_gitgc_has_entrypoint(gitgc_image): entrypoint = gitgc_image.attrs["Config"]["Entrypoint"] assert len(entrypoint) == 1