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.28] #8660

Open
wants to merge 11 commits into
base: release-v3.28
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions hack/postrelease/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.*.stamp
xunit.xml
37 changes: 30 additions & 7 deletions hack/postrelease/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
FROM docker:18.09
# hadolint global ignore=DL3018
FROM docker:24

RUN apk add --update bash python python-dev py2-pip py-setuptools openssl-dev curl jq && \
rm -rf /var/cache/apk/*
ARG VERSION
ARG FLANNEL_VERSION
ARG OPERATOR_VERSION
ARG UID

RUN mkdir -p /root/.docker
ENV VERSION ${VERSION}
ENV FLANNEL_VERSION ${FLANNEL_VERSION}
ENV NOSE_PROCESSES ${NOSE_PROCESSES}
ENV OPERATOR_VERSION ${OPERATOR_VERSION}

RUN --mount=type=tmpfs,target=/var/cache/apk apk add --no-cache \
bash \
python3 \
python3-dev \
py3-pip \
py3-yaml \
py3-pytest \
py3-pytest-xdist\
py3-requests \
py3-rich \
py-setuptools \
openssl-dev \
curl \
jq \
yq

RUN mkdir -p /root/.docker /code
COPY config.json /root/.docker/
COPY requirements.txt /requirements.txt
COPY *.py /code/
RUN pip install -r /requirements.txt
RUN adduser -D -u ${UID} test_user
USER test_user

# The container is used by mounting the code-under-test to /code
WORKDIR /code/
68 changes: 68 additions & 0 deletions hack/postrelease/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
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

all: create_docker_container run_pytests_docker clean_docker_container

## Setting up

create_docker_container: .docker_container.stamp

.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) \
--build-arg UID=$(shell id -u) \
--build-arg VERSION=$(CALICO_VERSION) \
--build-arg FLANNEL_VERSION=$(FLANNEL_VERSION) \
--build-arg OPERATOR_VERSION=$(OPERATOR_VERSION) \
.
@touch .docker_container.stamp

## Execution

run_pytests_docker: create_docker_container
$(info +++ Running postrelease tests)
@docker run -it --rm \
-v .:/code \
-v /run/docker.sock:/run/docker.sock \
$(CALICO_POSTRELEASE_TEST_IMAGE) \
pytest -n$(shell nproc) --junitxml=xunit.xml tests

## Cleanup

# `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_bin

clean_xunit:
$(RM) xunit.xml

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
7 changes: 7 additions & 0 deletions hack/postrelease/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[pytest]
markers =
slow: marks tests as slow
windows: a windows-related test
helm: tests relating to the helm chart
github: tests which access github to validate files
openstack: tests which validate our openstack releases
6 changes: 0 additions & 6 deletions hack/postrelease/requirements.txt

This file was deleted.

33 changes: 0 additions & 33 deletions hack/postrelease/test_helm_artifacts.py

This file was deleted.

162 changes: 0 additions & 162 deletions hack/postrelease/test_images.py

This file was deleted.

52 changes: 0 additions & 52 deletions hack/postrelease/test_manifests_archives.py

This file was deleted.

Loading