From eecf16a456e3b1a46a34b6413d6a0ea6d0109c34 Mon Sep 17 00:00:00 2001 From: Yanjun Zhou Date: Tue, 23 Aug 2022 17:58:39 -0700 Subject: [PATCH] Build clickhouse server image in kind test Signed-off-by: Yanjun Zhou --- .github/workflows/kind.yml | 49 ++++++++++++++++++++++++++++++++--- ci/jenkins/test-vmc.sh | 4 ++- ci/kind/test-e2e-kind.sh | 4 +-- ci/kind/test-upgrade-theia.sh | 7 ++--- hack/generate-manifest.sh | 5 +++- 5 files changed, 58 insertions(+), 11 deletions(-) diff --git a/.github/workflows/kind.yml b/.github/workflows/kind.yml index 6e0c78ef..e66dfdb8 100644 --- a/.github/workflows/kind.yml +++ b/.github/workflows/kind.yml @@ -46,9 +46,26 @@ jobs: path: policy-recommendation.tar retention-days: 1 # minimum value, in case artifact deletion by 'artifact-cleanup' job fails + build-clickhouse-server-image: + name: Build ClickHouse server 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@v3 + - run: make clickhouse-server + - name: Save ClickHouse server image to tarball + run: docker save -o clickhouse-server.tar antrea/theia-clickhouse-server + - name: Upload ClickHouse server image for subsequent jobs + uses: actions/upload-artifact@v3 + with: + name: clickhouse-server + path: clickhouse-server.tar + retention-days: 1 # minimum value, in case artifact deletion by 'artifact-cleanup' job fails + test-e2e-encap: name: E2e tests on a Kind cluster on Linux - needs: build-policy-recommendation-image + needs: [build-clickhouse-server-image, build-policy-recommendation-image] runs-on: [ubuntu-latest] steps: - name: Free disk space @@ -60,14 +77,20 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.17 - - name: Download Theia images from previous jobs + - name: Download Policy Recommendation images from previous jobs uses: actions/download-artifact@v3 with: name: policy-recommendation + - name: Download ClickHouse server images from previous jobs + uses: actions/download-artifact@v3 + with: + name: clickhouse-server - name: Load Theia image run: | docker load -i policy-recommendation.tar docker tag antrea/theia-policy-recommendation:latest projects.registry.vmware.com/antrea/theia-policy-recommendation:latest + docker load -i clickhouse-server.tar + docker tag antrea/theia-clickhouse-server:latest projects.registry.vmware.com/antrea/theia-clickhouse-server:latest - name: Install Kind run: | curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64 @@ -90,6 +113,7 @@ jobs: test-upgrade-from-N-1: name: Upgrade from Theia version N-1 + needs: build-clickhouse-server-image runs-on: [ubuntu-latest] steps: - name: Free disk space @@ -101,6 +125,14 @@ jobs: - uses: actions/setup-go@v3 with: go-version: 1.17 + - name: Download ClickHouse server images from previous jobs + uses: actions/download-artifact@v3 + with: + name: clickhouse-server + - name: Load Theia image + run: | + docker load -i clickhouse-server.tar + docker tag antrea/theia-clickhouse-server:latest projects.registry.vmware.com/antrea/theia-clickhouse-server:latest - name: Install Kind run: | curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64 @@ -127,8 +159,12 @@ jobs: # yet. artifact-cleanup: name: Delete uploaded images - needs: [build-policy-recommendation-image, test-e2e-encap] - if: ${{ always() && needs.build-policy-recommendation-image.result == 'success' }} + needs: + - build-policy-recommendation-image + - build-clickhouse-server-image + - test-e2e-encap + - test-upgrade-from-N-1 + if: ${{ always() && (needs.build-policy-recommendation-image.result == 'success' || needs.build-clickhouse-server-image.result == 'success') }} runs-on: [ubuntu-latest] steps: - name: Delete policy-recommendation @@ -136,3 +172,8 @@ jobs: uses: geekyeggo/delete-artifact@v1 with: name: policy-recommendation + - name: Delete clickhouse-server + if: ${{ needs.build-clickhouse-server-image.result == 'success' }} + uses: geekyeggo/delete-artifact@v1 + with: + name: clickhouse-server diff --git a/ci/jenkins/test-vmc.sh b/ci/jenkins/test-vmc.sh index 1ff759ff..d03557db 100644 --- a/ci/jenkins/test-vmc.sh +++ b/ci/jenkins/test-vmc.sh @@ -365,8 +365,9 @@ function deliver_antrea { docker save -o theia-spark-operator.tar projects.registry.vmware.com/antrea/theia-spark-operator:v1beta2-1.3.3-3.1.1 docker save -o theia-zookeeper.tar projects.registry.vmware.com/antrea/theia-zookeeper:3.8.0 - (cd $GIT_CHECKOUT_DIR && make policy-recommendation) + (cd $GIT_CHECKOUT_DIR && make policy-recommendation && make clickhouse-server) docker save -o theia-policy-recommendation.tar projects.registry.vmware.com/antrea/theia-policy-recommendation:latest + docker save -o theia-clickhouse-server.tar projects.registry.vmware.com/antrea/theia-clickhouse-server:latest # not sure the exact image tag, so read from yaml # and we assume the image tag is the same for all images in this yaml @@ -390,6 +391,7 @@ function deliver_antrea { copy_image theia-zookeeper.tar projects.registry.vmware.com/antrea/theia-zookeeper ${IPs[$i]} 3.8.0 true copy_image theia-spark-operator.tar projects.registry.vmware.com/antrea/theia-spark-operator ${IPs[$i]} v1beta2-1.3.3-3.1.1 true copy_image theia-policy-recommendation.tar projects.registry.vmware.com/antrea/theia-policy-recommendation ${IPs[$i]} latest true + copy_image theia-clickhouse-server.tar projects.registry.vmware.com/antrea/theia-clickhouse-server ${IPs[$i]} latest true done } diff --git a/ci/kind/test-e2e-kind.sh b/ci/kind/test-e2e-kind.sh index fbe5133a..03dc539a 100755 --- a/ci/kind/test-e2e-kind.sh +++ b/ci/kind/test-e2e-kind.sh @@ -111,7 +111,6 @@ COMMON_IMAGES_LIST=("k8s.gcr.io/e2e-test-images/agnhost:2.29" \ "antrea/flow-aggregator:latest" \ "projects.registry.vmware.com/antrea/theia-clickhouse-operator:0.18.2" \ "projects.registry.vmware.com/antrea/theia-metrics-exporter:0.18.2" \ - "projects.registry.vmware.com/antrea/theia-clickhouse-server:latest" \ "projects.registry.vmware.com/antrea/theia-clickhouse-monitor:latest" \ "projects.registry.vmware.com/antrea/theia-zookeeper:3.8.0" \ "projects.registry.vmware.com/antrea/theia-grafana:8.3.3" \ @@ -124,7 +123,8 @@ for image in "${COMMON_IMAGES_LIST[@]}"; do done done -COMMON_IMAGES_LIST+=("projects.registry.vmware.com/antrea/theia-policy-recommendation:latest") +COMMON_IMAGES_LIST+=("projects.registry.vmware.com/antrea/theia-policy-recommendation:latest"\ + "projects.registry.vmware.com/antrea/theia-clickhouse-server:latest") printf -v COMMON_IMAGES "%s " "${COMMON_IMAGES_LIST[@]}" function setup_cluster { diff --git a/ci/kind/test-upgrade-theia.sh b/ci/kind/test-upgrade-theia.sh index c5188ae2..c8a6d3dc 100755 --- a/ci/kind/test-upgrade-theia.sh +++ b/ci/kind/test-upgrade-theia.sh @@ -144,7 +144,7 @@ echo "Running upgrade test for tag $THEIA_FROM_TAG" ANTREA_FROM_TAG=$(grep "$THEIA_FROM_TAG" < $ROOT_DIR/VERSION_MAP | awk '{print $2}') # From v0.3.0, ClickHouse Image is labeled with Theia version -if version_lt $THEIA_FROM_TAG "v0.3.0"; then +if [[ $THEIA_FROM_TAG == "v0.2.0" || $THEIA_FROM_TAG == "v0.1.0" ]]; then CLICKHOUSE_FROM_TAG="21.11" else CLICKHOUSE_FROM_TAG=$THEIA_FROM_TAG @@ -162,8 +162,7 @@ DOCKER_IMAGES=("k8s.gcr.io/e2e-test-images/agnhost:2.29" \ "projects.registry.vmware.com/antrea/theia-clickhouse-monitor:$THEIA_FROM_TAG" \ "projects.registry.vmware.com/antrea/theia-clickhouse-server:$CLICKHOUSE_FROM_TAG" \ "antrea/antrea-ubuntu:latest" \ - "projects.registry.vmware.com/antrea/theia-clickhouse-monitor:latest"\ - "projects.registry.vmware.com/antrea/theia-clickhouse-server:latest") + "projects.registry.vmware.com/antrea/theia-clickhouse-monitor:latest") for img in "${DOCKER_IMAGES[@]}"; do echo "Pulling $img" @@ -173,6 +172,8 @@ for img in "${DOCKER_IMAGES[@]}"; do done done +DOCKER_IMAGES+=("projects.registry.vmware.com/antrea/theia-clickhouse-server:latest") + echo "Creating Kind cluster" IMAGES="${DOCKER_IMAGES[@]}" $THIS_DIR/kind-setup.sh create kind --images "$IMAGES" diff --git a/hack/generate-manifest.sh b/hack/generate-manifest.sh index ee8926ee..6695c9c4 100755 --- a/hack/generate-manifest.sh +++ b/hack/generate-manifest.sh @@ -136,7 +136,10 @@ if [ "$MODE" == "dev" ] && [ -n "$IMG_NAME" ]; then HELM_VALUES+=("clickhouse.monitor.image.repository=$IMG_NAME") fi if [ "$MODE" == "release" ]; then - HELM_VALUES+=("clickhouse.monitor.image.repository=$IMG_NAME" "clickhouse.monitor.image.tag=$IMG_TAG" "clickhouse.image.tag=$IMG_TAG") + HELM_VALUES+=("clickhouse.monitor.image.repository=$IMG_NAME" "clickhouse.monitor.image.tag=$IMG_TAG") + if [ $IMG_TAG != "v0.1.0" && $IMG_TAG != "v0.2.0" ]; then + HELM_VALUES+=("clickhouse.image.tag=$IMG_TAG") + fi fi if [ "$MODE" == "antrea-e2e" ]; then HELM_VALUES+=("grafana.enable=false" "clickhouse.monitor.enable=false")