Add skip kind export logs options in e2e test (#6742)

Signed-off-by: quicksilver <zhifeng.zhang@zilliz.com>
This commit is contained in:
quicksilver 2021-07-22 20:20:12 +08:00 committed by GitHub
parent b8e2b3666c
commit 686e4384ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 25 deletions

View File

@ -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 */
}
}

View File

@ -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 */
}
}

View File

@ -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

View File

@ -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

26
tests/scripts/export_logs.sh Executable file
View File

@ -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