From 686e4384ce2cf68670e04c0b37201b28a7b61cc0 Mon Sep 17 00:00:00 2001 From: quicksilver Date: Thu, 22 Jul 2021 20:20:12 +0800 Subject: [PATCH] Add skip kind export logs options in e2e test (#6742) Signed-off-by: quicksilver --- build/ci/jenkins/Jenkinsfile | 16 +++++++--------- build/ci/jenkins/NightlyCI.groovy | 28 +++++++++++++--------------- build/kind_provisioner.sh | 4 +++- tests/scripts/e2e-k8s.sh | 6 ++++++ tests/scripts/export_logs.sh | 26 ++++++++++++++++++++++++++ 5 files changed, 55 insertions(+), 25 deletions(-) create mode 100755 tests/scripts/export_logs.sh diff --git a/build/ci/jenkins/Jenkinsfile b/build/ci/jenkins/Jenkinsfile index a144e387ca..cddc483e40 100644 --- a/build/ci/jenkins/Jenkinsfile +++ b/build/ci/jenkins/Jenkinsfile @@ -60,6 +60,8 @@ pipeline { ./e2e-k8s.sh \ --node-image registry.zilliz.com/kindest/node:v1.20.2 \ --kind-config "${env.WORKSPACE}/build/config/topology/trustworthy-jwt-ci.yaml" \ + --skip-export-logs \ + --skip-cleanup \ --test-extra-arg "--tags=smoke" \ --test-timeout ${e2e_timeout_seconds} """ @@ -68,6 +70,8 @@ pipeline { MILVUS_CLUSTER_ENABLED=${clusterEnabled} \ ./e2e-k8s.sh \ --node-image registry.zilliz.com/kindest/node:v1.20.2 \ + --skip-export-logs \ + --skip-cleanup \ --kind-config "${env.WORKSPACE}/build/config/topology/trustworthy-jwt-ci.yaml" \ --test-extra-arg "--tags L0 L1" \ --test-timeout ${e2e_timeout_seconds} @@ -94,24 +98,18 @@ pipeline { } } } - always { + cleanup { container('main') { script { + sh "./tests/scripts/export_logs.sh" dir("${env.ARTIFACTS}") { sh "find ./kind -path '*/history/*' -type f | xargs tar -zcvf artifacts-${PROJECT_NAME}-${MILVUS_SERVER_TYPE}-${SEMVER}-${env.BUILD_NUMBER}-${MILVUS_CLIENT}-e2e-logs.tar.gz --transform='s:^[^/]*/[^/]*/[^/]*/[^/]*/::g' || true" if ("${MILVUS_CLIENT}" == "pymilvus-orm") { sh "tar -zcvf artifacts-${PROJECT_NAME}-${MILVUS_SERVER_TYPE}-${MILVUS_CLIENT}-pytest-logs.tar.gz ./tests/pytest_logs --remove-files || true" } archiveArtifacts artifacts: "**.tar.gz", allowEmptyArchive: true - sh 'docker rm -f \$(docker network inspect -f \'{{ range \$key, \$value := .Containers }}{{ printf "%s " \$key}}{{ end }}\' kind) || true' - sh 'docker network rm kind > /dev/null 2>&1 || true' } - } - } - } - cleanup { - container('main') { - script { + sh "kind delete cluster --name kind -v9 || true" sh 'find . -name . -o -prune -exec rm -rf -- {} +' /* clean up our workspace */ } } diff --git a/build/ci/jenkins/NightlyCI.groovy b/build/ci/jenkins/NightlyCI.groovy index 51b1ab2c28..e63de1e3b3 100644 --- a/build/ci/jenkins/NightlyCI.groovy +++ b/build/ci/jenkins/NightlyCI.groovy @@ -68,6 +68,8 @@ pipeline { ./e2e-k8s.sh \ --kind-config "${env.WORKSPACE}/build/config/topology/trustworthy-jwt-ci.yaml" \ --node-image registry.zilliz.com/kindest/node:v1.20.2 \ + --skip-export-logs \ + --skip-cleanup \ --test-timeout ${e2e_timeout_seconds} """ } else if ("${MILVUS_CLIENT}" == "pymilvus-orm") { @@ -76,6 +78,8 @@ pipeline { ./e2e-k8s.sh \ --kind-config "${env.WORKSPACE}/build/config/topology/trustworthy-jwt-ci.yaml" \ --node-image registry.zilliz.com/kindest/node:v1.20.2 \ + --skip-export-logs \ + --skip-cleanup \ --test-extra-arg "--tags L0 L1 L2" \ --test-timeout ${e2e_timeout_seconds} """ @@ -100,21 +104,6 @@ pipeline { } } } - always { - container('main') { - script { - dir("${env.ARTIFACTS}") { - sh "find ./kind -path '*/history/*' -type f | xargs tar -zcvf artifacts-${PROJECT_NAME}-${MILVUS_SERVER_TYPE}-${SEMVER}-${env.BUILD_NUMBER}-e2e-nightly-logs.tar.gz --transform='s:^[^/]*/[^/]*/[^/]*/[^/]*/::g' || true" - if ("${MILVUS_CLIENT}" == "pymilvus-orm") { - sh "tar -zcvf artifacts-${PROJECT_NAME}-${MILVUS_SERVER_TYPE}-${MILVUS_CLIENT}-pytest-logs.tar.gz ./tests/pytest_logs --remove-files || true" - } - archiveArtifacts artifacts: "**.tar.gz", allowEmptyArchive: true - sh 'docker rm -f \$(docker network inspect -f \'{{ range \$key, \$value := .Containers }}{{ printf "%s " \$key}}{{ end }}\' kind) || true' - sh 'docker network rm kind > /dev/null 2>&1 || true' - } - } - } - } success { container('main') { script { @@ -137,6 +126,15 @@ pipeline { cleanup { container('main') { script { + sh "./tests/scripts/export_logs.sh" + dir("${env.ARTIFACTS}") { + sh "find ./kind -path '*/history/*' -type f | xargs tar -zcvf artifacts-${PROJECT_NAME}-${MILVUS_SERVER_TYPE}-${SEMVER}-${env.BUILD_NUMBER}-e2e-nightly-logs.tar.gz --transform='s:^[^/]*/[^/]*/[^/]*/[^/]*/::g' || true" + if ("${MILVUS_CLIENT}" == "pymilvus-orm") { + sh "tar -zcvf artifacts-${PROJECT_NAME}-${MILVUS_SERVER_TYPE}-${MILVUS_CLIENT}-pytest-logs.tar.gz ./tests/pytest_logs --remove-files || true" + } + archiveArtifacts artifacts: "**.tar.gz", allowEmptyArchive: true + } + sh "kind delete cluster --name kind -v9 || true" sh 'find . -name . -o -prune -exec rm -rf -- {} +' /* clean up our workspace */ } } diff --git a/build/kind_provisioner.sh b/build/kind_provisioner.sh index b85a186dd4..0439fc6566 100755 --- a/build/kind_provisioner.sh +++ b/build/kind_provisioner.sh @@ -124,7 +124,9 @@ function load_cluster_topology() { function cleanup_kind_cluster() { echo "Test exited with exit code $?." NAME="${1}" - kind export logs --name "${NAME}" "${ARTIFACTS}/kind" -v9 || true + if [[ -z "${SKIP_EXPORT_LOGS:-}" ]]; then + kind export logs --name "${NAME}" "${ARTIFACTS}/kind" -v9 || true + fi if [[ -z "${SKIP_CLEANUP:-}" ]]; then echo "Cleaning up kind cluster" kind delete cluster --name "${NAME}" -v9 || true diff --git a/tests/scripts/e2e-k8s.sh b/tests/scripts/e2e-k8s.sh index 2b413b8d51..8cf7f4195f 100755 --- a/tests/scripts/e2e-k8s.sh +++ b/tests/scripts/e2e-k8s.sh @@ -89,6 +89,10 @@ while (( "$#" )); do SKIP_TEST=true shift ;; + --skip-export-logs) + SKIP_EXPORT_LOGS=true + shift + ;; --manual) MANUAL=true shift @@ -150,6 +154,8 @@ Usage: --skip-test Skip e2e test + --skip-export-logs Skip kind export logs + --manual Manual Mode -h or --help Print help information diff --git a/tests/scripts/export_logs.sh b/tests/scripts/export_logs.sh new file mode 100755 index 0000000000..b567d2921c --- /dev/null +++ b/tests/scripts/export_logs.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Copyright (C) 2019-2020 Zilliz. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under the License. + +set -e +set -x + +ARTIFACTS="${ARTIFACTS:-$(mktemp -d)}" + +KIND_NAME="${1:-kind}" + +mkdir -p "${ARTIFACTS}/${KIND_NAME}" + +for node in `kind get nodes --name=kind | tr -s '\n' ' '` +do + docker cp $node:/var/log "${ARTIFACTS}/${KIND_NAME}" +done