Run conformance test with Antrea e4aedec275d16e3bd228a86ff70e1336f6cf9300 and K8s #276
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run upstream conformance tests on Linux | |
run-name: Run ${{ inputs.test-suite }} test with Antrea ${{ inputs.antrea-version }} and K8s ${{ inputs.k8s-version }} | |
on: | |
workflow_dispatch: | |
inputs: | |
antrea-version: | |
description: The Antrea version to test. It could be a SHA-1 value, a branch, or a tag (e.g. a7b012b, release-1.12, v1.12.0). The main branch will be used if empty. | |
required: false | |
antrea-values: | |
description: The Antrea Chart values. Multiple values can be separated with commas (e.g. key1=val1,key2=val2). Default configuration will be tested if empty. | |
required: false | |
antrea-image-distro: | |
description: The Antrea image distribution to test. It could be ubuntu or ubi. | |
type: choice | |
options: | |
- ubuntu | |
- ubi | |
default: ubuntu | |
k8s-version: | |
description: The K8s version (e.g. v1.27.1) to test. Kind's default K8s version will be used if empty. | |
required: false | |
test-suite: | |
description: The test suite to run. Check run-k8s-e2e-tests.sh for which test cases these values represent. | |
type: choice | |
options: | |
- whole-conformance | |
- conformance | |
- network-policy | |
- sig-network | |
- all | |
default: whole-conformance | |
required: true | |
always-upload-logs: | |
description: Always upload logs regardless of the test result. | |
type: boolean | |
default: false | |
runner: | |
description: The Github runner to use for the workflow | |
default: ubuntu-latest | |
antrea-image-platform: | |
description: Platform argument to provide when building the Antrea images | |
type: choice | |
options: | |
- "linux/amd64" | |
- "linux/arm64" | |
- "linux/arm/v7" | |
default: "linux/amd64" | |
required: true | |
jobs: | |
test: | |
name: Run tests | |
runs-on: ${{ inputs.runner }} | |
steps: | |
- name: Free disk space | |
# https://github.com/actions/virtual-environments/issues/709 | |
run: | | |
sudo apt-get clean | |
df -h | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.antrea-version }} | |
fetch-depth: 0 | |
show-progress: false | |
- name: Check if it is a released version | |
id: check-release | |
run: | | |
if git show-ref --tags --verify --quiet refs/tags/${{ inputs.antrea-version }}; then | |
echo "released=true" >> $GITHUB_OUTPUT | |
echo "image-tag=${{ inputs.antrea-version }}" >> $GITHUB_OUTPUT | |
else | |
echo "released=false" >> $GITHUB_OUTPUT | |
echo "image-tag=latest" >> $GITHUB_OUTPUT | |
fi | |
- name: Set up Docker Buildx if required | |
if: ${{ steps.check-release.outputs.released == 'false' }} | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver: docker | |
- name: Build Antrea image if required | |
if: ${{ steps.check-release.outputs.released == 'false' }} | |
run: | | |
./hack/build-antrea-linux-all.sh --pull --distro ${{ inputs.antrea-image-distro }} --platform ${{ inputs.antrea-image-platform }} | |
- name: Get Kind version | |
id: get_kind_version | |
run: | | |
KIND_VERSION=$(head -n1 ./ci/kind/version || echo v0.23.0) | |
echo "kind_version=${KIND_VERSION}" >> $GITHUB_OUTPUT | |
- name: Install Kind | |
uses: helm/kind-action@v1 | |
with: | |
version: ${{ steps.get_kind_version.outputs.kind_version }} | |
install_only: true | |
- name: Build local image for conformance test | |
if: ${{ inputs.k8s-version != '' }} | |
run: | | |
image="kindest/node:${{ inputs.k8s-version }}" | |
if docker pull $image 2>&1; then | |
echo "Image $image exists, no need to build it." | |
else | |
echo "Image $image does not exist, preparing to build it." | |
# Building a local Kind Node image with the latest Kubernetes version will consume a lot of disk space. | |
# We need to free up some disk space before building the image. | |
sudo apt-get clean | |
sudo rm -rf /usr/share/dotnet || true | |
sudo rm -rf /opt/ghc || true | |
sudo rm -rf "/usr/local/share/boost" || true | |
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true | |
git clone --depth 1 --branch ${{ inputs.k8s-version }} https://github.com/kubernetes/kubernetes.git /tmp/kubernetes | |
echo "Building Kind Node image with Kubernetes version ${{ inputs.k8s-version }}" | |
kind build node-image --image kindest/node:${{ inputs.k8s-version }} /tmp/kubernetes | |
rm -rf /tmp/kubernetes | |
fi | |
- name: Create K8s cluster | |
run: | | |
# If an image does not exist (unified vs split), a warning will be printed, but the script | |
# execution will not fail. | |
images=() | |
images+=(antrea/antrea-controller-${{ inputs.antrea-image-distro }}:${{ steps.check-release.outputs.image-tag }}) | |
images+=(antrea/antrea-agent-${{ inputs.antrea-image-distro }}:${{ steps.check-release.outputs.image-tag }}) | |
images+=(antrea/antrea-${{ inputs.antrea-image-distro }}:${{ steps.check-release.outputs.image-tag }}) | |
./ci/kind/kind-setup.sh create kind \ | |
--k8s-version "${{ inputs.k8s-version }}" \ | |
--images "${images[*]}" | |
- name: Install Antrea | |
run: | | |
helm_args=() | |
helm_repo="./build/charts/antrea" | |
if [ ${{ steps.check-release.outputs.released }} == 'true' ]; then | |
helm_repo="antrea/antrea" | |
helm_args+=(--version "${{ inputs.antrea-version }}") | |
helm repo add antrea https://charts.antrea.io | |
helm repo update | |
fi | |
if helm show values ${helm_repo} | grep -q '^controllerImage:'; then | |
helm_args+=(--set controllerImage.repository="antrea/antrea-controller-${{ inputs.antrea-image-distro }}") | |
helm_args+=(--set agentImage.repository="antrea/antrea-agent-${{ inputs.antrea-image-distro }}") | |
else | |
helm_args+=(--set image.repository="antrea/antrea-${{ inputs.antrea-image-distro }}") | |
fi | |
helm install --namespace kube-system antrea ${helm_repo} \ | |
--set "${{ inputs.antrea-values }}" \ | |
"${helm_args[@]}" | |
kubectl rollout status -n kube-system ds/antrea-agent --timeout=5m | |
- name: Run e2e tests | |
run: | | |
./ci/run-k8s-e2e-tests.sh "--e2e-${{ inputs.test-suite }}" | |
- name: Upload test log | |
uses: actions/upload-artifact@v4 | |
if: ${{ failure() || inputs.always-upload-logs }} | |
with: | |
name: sonobuoy.tar.gz | |
path: "*_sonobuoy_*.tar.gz" | |
retention-days: 7 |