From 4c28678c2fd998c1533329d3eb502d8574d33706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=ABl=20Bardelot?= Date: Mon, 26 Jan 2026 17:59:52 +0100 Subject: [PATCH 1/6] Improve running end-to-end locally * Allow users to run end-to-end tests with a fully-qualified and/or private alpine image * Allow users to run end-to-end tests behind a proxy * Sort .gitgnore for convenience for future diffs * Add .idea/ to .gitignore --- .gitignore | 9 +++--- CONTRIBUTING.md | 56 ++++++++++++++++++++++++++++++++++++ Makefile | 18 +++++++++++- _test_tools/httpd/Dockerfile | 3 +- _test_tools/ncsvr/Dockerfile | 3 +- _test_tools/sshd/Dockerfile | 3 +- test_e2e.sh | 6 ++++ 7 files changed, 90 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index bd3243142..0b06302fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ -/bin -/.go -/.push-* +/.buildx-initialized /.container-* /.dockerfile-* -/.buildx-initialized +/.go +/.idea /.licenses +/.push-* +/bin diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 570c6bd6e..f017c2cb4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,3 +38,59 @@ make all-container \ BUILD_IMAGE=$BUILD_IMAGE_IN_PRIVATE_REGISTRY \ BASEIMAGE=$BASEIMAGE_IN_PRIVATE_REGISTRY ``` + +## Running end-to-end tests using fully-qualified base images + +By default the `_test_tools/*/Dockerfile` images used by the end-to-end tests are built in the `Makefile`'s `.container-test_tool.%` goals +using an unqualified `alpine` image. + +In order to pull the `alpine` image from a private registry and/or with a fully-qualified name, and run the tests, you can +use for example: + +```sh +docker login $YOUR_PRIVATE_REGISTRY +ALPINE_REGISTRY_PREFIX=$YOUR_PRIVATE_REGISTRY/$YOUR_ALPINE_NAMESPACE_PREFIX/ # Please note the final '/' +docker pull ${ALPINE_REGISTRY_PREFIX}alpine +make test ALPINE_REGISTRY_PREFIX=$ALPINE_REGISTRY_PREFIX +``` + +## Running end-to-end tests locally with docker configured behind a proxy + +If you are using proxy configurations in your `~/.docker/config` file, you must add the `docker0` subnet (created by the +*bridge* network) as an exception in order for the containers executed by the tests to be able to call each other. + +For example to get the subnets associated with the *bridge* network in a default Docker configuration you can run: + +```bash +docker network ls # you can verify that a network called bridge is present +docker network inspect bridge --format '{{ range .IPAM.Config }}{{ .Subnet }}{{ end }}' +``` + +If for example your *bridge* subnet is `172.16.0.0/12`, then you'd want your `~/.docker/config.json` to look like this: + +```json +{ + "proxies": { + "default": { + "httpProxy": "...", + "httpsProxy": "...", + "noProxy": "...,172.16.0.0/12" + } + } +} +``` + +And you'd want to run the tests like this: + +```bash +make test HTTP_PROXY="..." HTTPS_PROXY="..." NO_PROXY"...,172.16.0.0/12" +``` + +Or manually: + +```bash +export HTTP_PROXY="..." +export HTTPS_PROXY="..." +export NO_PROXY"...,172.16.0.0/12" +VERBOSE=1 ./test_e2e.sh +``` \ No newline at end of file diff --git a/Makefile b/Makefile index 5bd8624a2..ee513b6e9 100644 --- a/Makefile +++ b/Makefile @@ -34,11 +34,15 @@ DBG ?= # These are passed to docker when building and testing. HTTP_PROXY ?= HTTPS_PROXY ?= +NO_PROXY ?= # Allow some buildx adaptation for local builds BUILDX_BUILDER_NAME := git-sync BUILDX_BUILDER_SKIP_CREATION ?= +# Allow alpine to be pulled from a private registry when building the end-to-end tests images +ALPINE_REGISTRY_PREFIX ?= + ### ### These variables should not need tweaking. ### @@ -134,6 +138,7 @@ $(OUTBIN): .go/$(OUTBIN).stamp -v $$(pwd)/.go/cache:/.cache \ --env HTTP_PROXY=$(HTTP_PROXY) \ --env HTTPS_PROXY=$(HTTPS_PROXY) \ + --env NO_PROXY=$(NO_PROXY) \ $(BUILD_IMAGE) \ /bin/sh -c " \ ARCH=$(ARCH) \ @@ -190,6 +195,7 @@ container: .container-$(DOTFILE_IMAGE) container-name --platform "$(OS)/$(ARCH)" \ --build-arg HTTP_PROXY=$(HTTP_PROXY) \ --build-arg HTTPS_PROXY=$(HTTPS_PROXY) \ + --build-arg NO_PROXY=$(NO_PROXY) \ -t $(IMAGE):$(OS_ARCH_TAG) \ -f .dockerfile-$(OS)_$(ARCH) \ . @@ -248,17 +254,27 @@ test: $(BUILD_DIRS) -v $$(pwd)/.go/cache:/.cache \ --env HTTP_PROXY=$(HTTP_PROXY) \ --env HTTPS_PROXY=$(HTTPS_PROXY) \ + --env NO_PROXY=$(NO_PROXY) \ $(BUILD_IMAGE) \ /bin/sh -c " \ ./build/test.sh ./... \ " + @if [ -n "$(HTTP_PROXY)" ]; then \ + export HTTP_PROXY="$(HTTP_PROXY)"; \ + fi + @if [ -n "$(HTTPS_PROXY)" ]; then \ + export HTTPS_PROXY="$(HTTPS_PROXY)"; \ + fi + @if [ -n "$(NO_PROXY)" ]; then \ + export NO_PROXY="$(NO_PROXY)"; \ + fi VERBOSE=1 ./test_e2e.sh TEST_TOOLS := $(shell find _test_tools/* -type d -printf "%f ") test-tools: $(foreach tool, $(TEST_TOOLS), .container-test_tool.$(tool)) .container-test_tool.%: _test_tools/% _test_tools/%/* - docker build -t $(REGISTRY)/test/$$(basename $<) $< + docker build --build-arg ALPINE_REGISTRY_PREFIX="$(ALPINE_REGISTRY_PREFIX)" -t $(REGISTRY)/test/$$(basename $<) $< docker images -q $(REGISTRY)/test/$$(basename $<) > $@ # Help set up multi-arch build tools. This assumes you have the tools diff --git a/_test_tools/httpd/Dockerfile b/_test_tools/httpd/Dockerfile index f0473331d..a44895530 100644 --- a/_test_tools/httpd/Dockerfile +++ b/_test_tools/httpd/Dockerfile @@ -14,7 +14,8 @@ # Stolen from https://github.com/linuxkit/linuxkit/tree/master/pkg/sshd/ -FROM alpine AS base +ARG ALPINE_REGISTRY_PREFIX="" +FROM ${ALPINE_REGISTRY_PREFIX}alpine AS base RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ RUN apk add --no-cache --initdb -p /out \ diff --git a/_test_tools/ncsvr/Dockerfile b/_test_tools/ncsvr/Dockerfile index ef3e23af3..6f4b5004e 100644 --- a/_test_tools/ncsvr/Dockerfile +++ b/_test_tools/ncsvr/Dockerfile @@ -14,7 +14,8 @@ # Stolen from https://github.com/linuxkit/linuxkit/tree/master/pkg/sshd/ -FROM alpine AS base +ARG ALPINE_REGISTRY_PREFIX="" +FROM ${ALPINE_REGISTRY_PREFIX}alpine AS base RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ RUN apk add --no-cache --initdb -p /out \ diff --git a/_test_tools/sshd/Dockerfile b/_test_tools/sshd/Dockerfile index c8caa682c..92a5f9842 100644 --- a/_test_tools/sshd/Dockerfile +++ b/_test_tools/sshd/Dockerfile @@ -14,7 +14,8 @@ # Stolen from https://github.com/linuxkit/linuxkit/tree/master/pkg/sshd/ -FROM alpine AS base +ARG ALPINE_REGISTRY_PREFIX="" +FROM ${ALPINE_REGISTRY_PREFIX}alpine AS base RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ RUN apk add --no-cache --initdb -p /out \ diff --git a/test_e2e.sh b/test_e2e.sh index a65f381fa..5caeb5dd8 100755 --- a/test_e2e.sh +++ b/test_e2e.sh @@ -18,6 +18,12 @@ set -o errexit set -o nounset set -o pipefail +# If the Makefile and/or the user do set up the upper-case flavor of a proxy variable, +# then let us also set up the lower-case flavor that is used by tools like the git CLI. +[ -n "${HTTP_PROXY:-}" ] && export http_proxy="$HTTP_PROXY" +[ -n "${HTTPS_PROXY:-}" ] && export https_proxy="$HTTPS_PROXY" +[ -n "${NO_PROXY:-}" ] && export no_proxy="$NO_PROXY" + # shellcheck disable=SC2120 function caller() { local stack_skip=${1:-0} From f81403a0fb76bb1b9a7dc002320dcee70de1b5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=ABl=20Bardelot?= Date: Tue, 27 Jan 2026 10:45:30 +0100 Subject: [PATCH 2/6] Overriding the git-sync repo URL in e2e tests Allow the user running end-to-end tests to override the repository's URL in order to use a mirror if need be. --- test_e2e.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_e2e.sh b/test_e2e.sh index 5caeb5dd8..045b4b025 100755 --- a/test_e2e.sh +++ b/test_e2e.sh @@ -3451,7 +3451,7 @@ function e2e::touch_file_abs_path() { function e2e::github_https() { GIT_SYNC \ --one-time \ - --repo="https://github.com/kubernetes/git-sync" \ + --repo="${GIT_SYNC_REPOSITORY_URL:-https://github.com/kubernetes/git-sync}" \ --root="$ROOT" \ --link="link" assert_file_exists "$ROOT/link/LICENSE" From d9181a7fbcc5f06c7a6554d637147cc63bbc2710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=ABl=20Bardelot?= Date: Tue, 27 Jan 2026 12:05:02 +0100 Subject: [PATCH 3/6] End-to-end tests selection in the Makefile Introduces a new LIST_OF_E2E_TESTS option in order to select end-to-end tests that will be executed when calling `make test`. It uses the tests script's arguments parsing that already exists. --- test_e2e.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test_e2e.sh b/test_e2e.sh index 045b4b025..18e51fd49 100755 --- a/test_e2e.sh +++ b/test_e2e.sh @@ -3676,6 +3676,9 @@ if [[ "$#" == 0 ]]; then fi # Build it +# NOTE: If you want to run the end-to-end tests locally and you need specific Makefile arguments +# you might want to run `make test` once first with those arguments, in order to pre-build this image. +# Otherwise this call to the Makefile will made without customization. $build_container && make container REGISTRY=e2e VERSION="${E2E_TAG}" ALLOW_STALE_APT=1 make test-tools REGISTRY=e2e From 3f7b8007356677fa2ac68a73ae91847c68aefe5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=ABl=20Bardelot?= Date: Tue, 27 Jan 2026 12:15:03 +0100 Subject: [PATCH 4/6] Revert "Clarify end-to-end tests script" This reverts commit 560274698e3b42eaad01648a1afa81bc8e91ea0a. --- test_e2e.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/test_e2e.sh b/test_e2e.sh index 18e51fd49..045b4b025 100755 --- a/test_e2e.sh +++ b/test_e2e.sh @@ -3676,9 +3676,6 @@ if [[ "$#" == 0 ]]; then fi # Build it -# NOTE: If you want to run the end-to-end tests locally and you need specific Makefile arguments -# you might want to run `make test` once first with those arguments, in order to pre-build this image. -# Otherwise this call to the Makefile will made without customization. $build_container && make container REGISTRY=e2e VERSION="${E2E_TAG}" ALLOW_STALE_APT=1 make test-tools REGISTRY=e2e From 8354e914ec08a258b9c0d03424d63f741baf3c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=ABl=20Bardelot?= Date: Tue, 27 Jan 2026 12:17:23 +0100 Subject: [PATCH 5/6] Clarify end-to-end script usage --- test_e2e.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test_e2e.sh b/test_e2e.sh index 045b4b025..18e51fd49 100755 --- a/test_e2e.sh +++ b/test_e2e.sh @@ -3676,6 +3676,9 @@ if [[ "$#" == 0 ]]; then fi # Build it +# NOTE: If you want to run the end-to-end tests locally and you need specific Makefile arguments +# you might want to run `make test` once first with those arguments, in order to pre-build this image. +# Otherwise this call to the Makefile will made without customization. $build_container && make container REGISTRY=e2e VERSION="${E2E_TAG}" ALLOW_STALE_APT=1 make test-tools REGISTRY=e2e From 5b9e7f58c825e0cdb9bf276b50f48540c6b3f494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=ABl=20Bardelot?= Date: Tue, 27 Jan 2026 12:17:36 +0100 Subject: [PATCH 6/6] End-to-end tests selection in the Makefile Introduces a new LIST_OF_E2E_TESTS option in order to select end-to-end tests that will be executed when calling `make test`. It uses the tests script's arguments parsing that already exists. --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ee513b6e9..c5b03a6a0 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,9 @@ BUILDX_BUILDER_SKIP_CREATION ?= # Allow alpine to be pulled from a private registry when building the end-to-end tests images ALPINE_REGISTRY_PREFIX ?= +# By default all end-to-end tests are executed, but this allows for a manual selection +LIST_OF_E2E_TESTS ?= + ### ### These variables should not need tweaking. ### @@ -268,7 +271,7 @@ test: $(BUILD_DIRS) @if [ -n "$(NO_PROXY)" ]; then \ export NO_PROXY="$(NO_PROXY)"; \ fi - VERBOSE=1 ./test_e2e.sh + VERBOSE=1 ./test_e2e.sh $(LIST_OF_E2E_TESTS) TEST_TOOLS := $(shell find _test_tools/* -type d -printf "%f ") test-tools: $(foreach tool, $(TEST_TOOLS), .container-test_tool.$(tool))