diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml index b6a1cdcbf6b..a749d32bb3a 100644 --- a/.github/workflows/conformance.yml +++ b/.github/workflows/conformance.yml @@ -1,5 +1,5 @@ name: Manually run upstream conformance test on Linux -run-name: Run ${{ inputs.test-suite }} test with Antrea ${{ inputs.antrea-version }} and K8s ${{ inputs.k8s-version }} +run-name: Run ${{ inputs.test-suite }} test with Antrea ${{ inputs.antrea-version }} {{ inputs.distro }} image and K8s ${{ inputs.k8s-version }} on: workflow_dispatch: @@ -10,6 +10,13 @@ on: 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 + distro: + description: The Linux distribution to test. Ubuntu will be used if empty. + 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 @@ -56,7 +63,7 @@ jobs: - name: Build Antrea image if required if: ${{ steps.check-release.outputs.released == 'false' }} run: | - ./hack/build-antrea-linux-all.sh --pull + ./hack/build-antrea-linux-all.sh --pull --distro ${{ inputs.distro }} - name: Install Kind run: | KIND_VERSION=$(head -n1 ./ci/kind/version) @@ -67,16 +74,19 @@ jobs: run: | # The command also loads local antrea/antrea-ubuntu:latest into Nodes if it exists. ./ci/kind/kind-setup.sh create kind \ - --k8s-version "${{ inputs.k8s-version }}" + --k8s-version "${{ inputs.k8s-version }}" \ + --images antrea/antrea-"${{ inputs.distro }}":latest - name: Install Antrea run: | if [ ${{ steps.check-release.outputs.released }} == 'true' ]; then helm repo add antrea https://charts.antrea.io helm repo update helm install --namespace kube-system antrea antrea/antrea --version "${{ inputs.antrea-version }}" \ - --set "${{ inputs.antrea-values }}" + --set "${{ inputs.antrea-values }}" \ + --set image.repository=antrea/antrea-"${{ inputs.distro }}" else helm install --namespace kube-system antrea ./build/charts/antrea \ + --set image.repository=antrea/antrea-"${{ inputs.distro }}" \ --set "${{ inputs.antrea-values }}" fi kubectl rollout status -n kube-system ds/antrea-agent --timeout=5m diff --git a/.github/workflows/kind.yml b/.github/workflows/kind.yml index c967fd2ca90..ed54d29e1ed 100644 --- a/.github/workflows/kind.yml +++ b/.github/workflows/kind.yml @@ -49,6 +49,27 @@ jobs: path: antrea-ubuntu.tar retention-days: 1 # minimum value, in case artifact deletion by 'artifact-cleanup' job fails + build-antrea-ubi-image: + name: Build Antrea UBI image to be used for Kind e2e tests + needs: check-changes + if: ${{ needs.check-changes.outputs.has_changes == 'yes' }} + runs-on: [ubuntu-latest] + steps: + - uses: actions/checkout@v4 + with: + show-progress: false + - name: Build Antrea UBI Docker image + run: | + ./hack/build-antrea-linux-all.sh --pull --distro ubi + - name: Save Antrea UBI image to tarball + run: docker save -o antrea-ubi.tar antrea/antrea-ubi:latest + - name: Upload Antrea UBI image for subsequent jobs + uses: actions/upload-artifact@v3 + with: + name: antrea-ubi + path: antrea-ubi.tar + retention-days: 1 # minimum value, in case artifact deletion by 'artifact-cleanup' job fails + build-flow-aggregator-coverage-image: name: Build Flow Aggregator image to be used for Kind e2e tests needs: check-changes @@ -68,6 +89,52 @@ jobs: path: flow-aggregator.tar retention-days: 1 # minimum value, in case artifact deletion by 'artifact-cleanup' job fails + test-e2e-ubi-basic: + name: Basic e2e tests on a Kind cluster for the UBI image + needs: [build-antrea-ubi-image] + runs-on: [ubuntu-latest] + 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: + show-progress: false + - uses: actions/setup-go@v4 + with: + go-version-file: 'go.mod' + - name: Download Antrea image from previous job + uses: actions/download-artifact@v3 + with: + name: antrea-ubi + - name: Load Antrea image + run: | + docker load -i antrea-ubi.tar + - name: Install Kind + run: | + KIND_VERSION=$(head -n1 ./ci/kind/version) + curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64 + chmod +x ./kind + sudo mv kind /usr/local/bin + - name: Run basic e2e tests + run: | + mkdir log + ANTREA_LOG_DIR=$PWD/log ./ci/kind/test-e2e-kind.sh --encap-mode encap \ + --antrea-image-name antrea/antrea-ubi --antrea-image-tag latest \ + --run '^TestBasic$' + - name: Tar log files + if: ${{ failure() }} + run: tar -czf log.tar.gz log + - name: Upload test log + uses: actions/upload-artifact@v3 + if: ${{ failure() }} + with: + name: e2e-kind-ubi-basic.tar.gz + path: log.tar.gz + retention-days: 30 + test-e2e-encap: name: E2e tests on a Kind cluster on Linux needs: [build-antrea-coverage-image] @@ -730,6 +797,7 @@ jobs: needs: - build-antrea-coverage-image - build-flow-aggregator-coverage-image + - build-antrea-ubi-image - test-e2e-encap - test-e2e-encap-non-default - test-e2e-encap-all-features-enabled @@ -742,6 +810,7 @@ jobs: - validate-prometheus-metrics-doc - test-e2e-flow-visibility - test-network-policy-conformance-encap + - test-e2e-ubi-basic runs-on: [ubuntu-latest] steps: - name: Delete antrea-ubuntu-cov diff --git a/ci/kind/test-e2e-kind.sh b/ci/kind/test-e2e-kind.sh index 60bef8dbabe..9221b72a0ab 100755 --- a/ci/kind/test-e2e-kind.sh +++ b/ci/kind/test-e2e-kind.sh @@ -40,6 +40,8 @@ _usage="Usage: $0 [--encap-mode ] [--ip-family ] [--coverage] --setup-only Only perform setting up the cluster and run test. --cleanup-only Only perform cleaning up the cluster. --test-only Only run test on current cluster. Not set up/clean up the cluster. + --antrea-image-name The image name to use for Antrea components. + --antrea-image-tag The image tag to use for Antrea components. --help, -h Print this message and exit. " @@ -47,7 +49,6 @@ function print_usage { echoerr -n "$_usage" } - THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" TESTBED_CMD="$THIS_DIR/kind-setup.sh" YML_CMD="$THIS_DIR/../../hack/generate-manifest.sh" @@ -81,6 +82,8 @@ skiplist="" setup_only=false cleanup_only=false test_only=false +antrea_image_name="antrea/antrea-ubuntu" +antrea_image_tag="latest" run="" while [[ $# -gt 0 ]] do @@ -155,6 +158,14 @@ case $key in test_only=true shift ;; + --antrea-image-name) + antrea_image_name="$2" + shift 2 + ;; + --antrea-image-tag) + antrea_image_tag="$2" + shift 2 + ;; -h|--help) print_usage exit 0 @@ -235,9 +246,9 @@ done # The Antrea images should not be pulled, as we want to use the local build. if $coverage; then manifest_args="$manifest_args --coverage" - COMMON_IMAGES_LIST+=("antrea/antrea-ubuntu-coverage:latest") + COMMON_IMAGES_LIST+=("${antrea_image_name}-coverage:${antrea_image_tag}") else - COMMON_IMAGES_LIST+=("antrea/antrea-ubuntu:latest") + COMMON_IMAGES_LIST+=("${antrea_image_name}:${antrea_image_tag}") fi if $flow_visibility; then if $coverage; then @@ -292,8 +303,11 @@ function run_test { current_mode=$1 coverage_args="" flow_visibility_args="" + export IMG_NAME="${antrea_image_name}" + export IMG_TAG="${antrea_image_tag}" if $coverage; then + export IMG_NAME="${antrea_image_name}-coverage" $YML_CMD --encap-mode $current_mode $manifest_args | docker exec -i kind-control-plane dd of=/root/antrea-coverage.yml $YML_CMD --ipsec $manifest_args | docker exec -i kind-control-plane dd of=/root/antrea-ipsec-coverage.yml timeout="80m" diff --git a/hack/generate-manifest.sh b/hack/generate-manifest.sh index 8a35cfc8ed0..7d4c5278ee4 100755 --- a/hack/generate-manifest.sh +++ b/hack/generate-manifest.sh @@ -283,6 +283,7 @@ if [[ $TUN_TYPE != "geneve" ]]; then fi if $COVERAGE; then + IMG_NAME=${IMG_NAME-coverage} HELM_VALUES+=("testing.coverage=true") fi