Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick calico postrelease test fixes [v3.26] #8554

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions hack/postrelease/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ RUN --mount=type=tmpfs,target=/var/cache/apk apk add --no-cache \
python3 \
python3-dev \
py3-pip \
py3-yaml \
py3-pytest \
py3-requests \
py3-rich \
py-setuptools \
openssl-dev \
curl \
jq
jq \
yq

RUN mkdir -p /root/.docker /code
COPY config.json /root/.docker/
COPY requirements.txt /requirements.txt
RUN pip install --no-cache-dir -r /requirements.txt

# The container is used by mounting the code-under-test to /code
WORKDIR /code/
32 changes: 27 additions & 5 deletions hack/postrelease/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
include variables.mk

### Binaries we need

bin/yq:
$(info Downloading YQ from $(YQ4_URL))
@mkdir -p bin
@curl -fsSL $(YQ4_URL) -o $(YQ4)
@chmod +x $(YQ4)

### Utility!

require_var = $(if \
$(filter-out undefined,$(origin $(1))),\
,\
$(error The variable $(1) is required but is not defined) \
)

require-vars-%:
$(foreach var,$(subst -, ,$*),$(call require_var,$(var)))

### Actual rules below here!

.PHONY: create_docker_container clean
Expand All @@ -10,7 +29,7 @@ all: create_docker_container run_pytests_docker clean_docker_container

create_docker_container: .docker_container.stamp

.docker_container.stamp: Dockerfile requirements.txt config.json
.docker_container.stamp: bin/yq Dockerfile config.json
$(info +++ Building docker container with Calico $(CALICO_VERSION), Operator $(OPERATOR_VERSION), Flannel $(FLANNEL_VERSION))
docker buildx build \
-t $(CALICO_POSTRELEASE_TEST_IMAGE) \
Expand All @@ -22,9 +41,9 @@ create_docker_container: .docker_container.stamp

## Execution

run_pytests_docker: create_docker_container
run_pytests_docker: create_docker_container require-vars-QUAY_TOKEN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we should be using a quay token at all.

$(info +++ Running postrelease tests)
@docker run -it --rm \
@docker run -it --rm \
-v .:/code \
-v /run/docker.sock:/run/docker.sock \
-e QUAY_TOKEN \
Expand All @@ -35,12 +54,15 @@ run_pytests_docker: create_docker_container

# `clean` is meant to be run manually, as it also runs clean_xunit, which
# deletes the xunit file. We actually want that file to exist in e.g. semaphore.
clean: clean_docker_container clean_xunit
clean: clean_docker_container clean_xunit clean_bin

clean_xunit:
$(RM) xunit.xml

clean_docker_container:
clean_bin:
$(RM) -r bin

clean_docker_container: bin/yq
$(info +++ Cleaning docker container)
@docker rmi $(CALICO_POSTRELEASE_TEST_IMAGE) 2> /dev/null || true
$(RM) .docker_container.stamp
4 changes: 0 additions & 4 deletions hack/postrelease/requirements.txt

This file was deleted.

16 changes: 10 additions & 6 deletions hack/postrelease/variables.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Paths to override
YQ ?= yq
# Binaries we need

YQ4_VERSION := v4.40.3
YQ4_BINARY := yq_linux_amd64
YQ4_URL := https://github.com/mikefarah/yq/releases/download/$(YQ4_VERSION)/$(YQ4_BINARY)
YQ4 := bin/yq

# Override implicit RM command quietly
RM := @$(RM)
Expand All @@ -9,16 +13,16 @@ CHARTS_TIGERAOPERATOR_VALUES = ../../charts/tigera-operator/values.yaml
CHART_CALICO_VALUES = ../../charts/calico/values.yaml

# Versions (extracted from the charts files)
CALICO_VERSION := $(shell $(YQ) '.calicoctl.tag' < $(CHARTS_TIGERAOPERATOR_VALUES))
OPERATOR_VERSION := $(shell $(YQ) '.tigeraOperator.version' < $(CHARTS_TIGERAOPERATOR_VALUES))
FLANNEL_VERSION := $(shell $(YQ) '.flannel.tag' < $(CHART_CALICO_VALUES))
CALICO_VERSION = $(shell $(YQ4) '.calicoctl.tag' < $(CHARTS_TIGERAOPERATOR_VALUES))
OPERATOR_VERSION = $(shell $(YQ4) '.tigeraOperator.version' < $(CHARTS_TIGERAOPERATOR_VALUES))
FLANNEL_VERSION = $(shell $(YQ4) '.flannel.tag' < $(CHART_CALICO_VALUES))

# The docker image that we build to run the tests in
CALICO_POSTRELEASE_TEST_IMAGE = calico_postrelease_tests:$(CALICO_VERSION)

.PHONY: show-variables

show-variables:
show-variables: bin/yq
$(info # Chart locations)
$(info CHARTS_TIGERAOPERATOR_VALUES = $(CHARTS_TIGERAOPERATOR_VALUES))
$(info CHART_CALICO_VALUES = $(CHART_CALICO_VALUES))
Expand Down