Skip to content

Commit

Permalink
Add basic e2e tests for UBI image
Browse files Browse the repository at this point in the history
Run basic e2e tests on a Kind cluster for the UBI image to make sure
the UBI image can be deployed as expected. Add a new input parameter
`distro` to the conformance workflow to allow testing of the UBI image.

Fixes: antrea-io#5729

Signed-off-by: Xu Liu <[email protected]>
  • Loading branch information
xliuxu committed Jan 25, 2024
1 parent ca5dc45 commit 5e1abf6
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 7 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 image distro 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
Expand Down Expand Up @@ -56,27 +63,30 @@ 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)
KIND_VERSION=$(head -n1 ./ci/kind/version || echo v0.20.0)
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: Create K8s cluster
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
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
20 changes: 17 additions & 3 deletions ci/kind/test-e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ _usage="Usage: $0 [--encap-mode <mode>] [--ip-family <v4|v6|dual>] [--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.
"

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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions hack/generate-manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ if [[ $TUN_TYPE != "geneve" ]]; then
fi

if $COVERAGE; then
IMG_NAME=${IMG_NAME-coverage}
HELM_VALUES+=("testing.coverage=true")
fi

Expand Down

0 comments on commit 5e1abf6

Please sign in to comment.