From 0f159713d17641176b69666d3e6a9f724559aa8f Mon Sep 17 00:00:00 2001 From: JimmyYang20 Date: Thu, 14 Jul 2022 16:17:40 +0800 Subject: [PATCH] Update e2e test script all-in-one for test env Signed-off-by: JimmyYang20 --- hack/run-e2e.sh | 12 +- scripts/installation/install.sh | 880 ++++++++++++++++---------------- 2 files changed, 451 insertions(+), 441 deletions(-) diff --git a/hack/run-e2e.sh b/hack/run-e2e.sh index 92eed359f..4e85f2675 100755 --- a/hack/run-e2e.sh +++ b/hack/run-e2e.sh @@ -22,13 +22,19 @@ SEDNA_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)" cd "$SEDNA_ROOT" -# source local-up script +# Prepare all-in-one env { __WITH_SOURCE__=true # this will export KUBECONFIG - source hack/local-up.sh - trap cleanup EXIT + echo "Prepare all-in-one env" + cat scripts/installation/all-in-one.sh | KUBEEDGE_VERSION=v1.8.0 NUM_EDGE_NODES=0 bash - } +# Running e2e echo "Running e2e..." go test ./test/e2e -v + + +# Clean all-in-one env +echo "Chean all-in-one env" +cat scripts/installation/all-in-one.sh | bash /dev/stdin clean diff --git a/scripts/installation/install.sh b/scripts/installation/install.sh index 2f4f770da..fe5ecc4cb 100644 --- a/scripts/installation/install.sh +++ b/scripts/installation/install.sh @@ -1,438 +1,442 @@ -#!/bin/bash - -# Copyright 2021 The KubeEdge Authors. -# -# 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. - -# Influential env vars: -# -# SEDNA_ACTION | optional | 'create'/'clean', default is 'create' -# SEDNA_VERSION | optional | The Sedna version to be installed. -# if not specified, it will get latest release version. -# SEDNA_ROOT | optional | The Sedna offline directory - -set -o errexit -set -o nounset -set -o pipefail - -TMP_DIR=$(mktemp -d --suffix=.sedna) -SEDNA_ROOT=${SEDNA_ROOT:-$TMP_DIR} - -DEFAULT_SEDNA_VERSION=v0.4.0 - - -trap "rm -rf '$TMP_DIR'" EXIT - -get_latest_version() { - # get Sedna latest release version - local repo=kubeedge/sedna - # output of this latest page: - # ... - # "tag_name": "v1.0.0", - # ... - { - curl -s https://api.github.com/repos/$repo/releases/latest | - awk '/"tag_name":/&&$0=$2' | - sed 's/[",]//g' - } || echo $DEFAULT_SEDNA_VERSION # fallback -} - -: ${SEDNA_VERSION:=$(get_latest_version)} -SEDNA_VERSION=v${SEDNA_VERSION#v} - -_download_yamls() { - - yaml_dir=$1 - mkdir -p ${SEDNA_ROOT}/$yaml_dir - cd ${SEDNA_ROOT}/$yaml_dir - for yaml in ${yaml_files[@]}; do - # the yaml file already exists, no need to download - [ -e "$yaml" ] && continue - - echo downloading $yaml into ${SEDNA_ROOT}/$yaml_dir - local try_times=30 i=1 timeout=2 - while ! timeout ${timeout}s curl -sSO https://raw.githubusercontent.com/kubeedge/sedna/main/$yaml_dir/$yaml; do - ((++i>try_times)) && { - echo timeout to download $yaml - exit 2 - } - echo -en "retrying to download $yaml after $[i*timeout] seconds...\r" - done - done -} - -download_yamls() { - yaml_files=( - sedna.io_datasets.yaml - sedna.io_federatedlearningjobs.yaml - sedna.io_incrementallearningjobs.yaml - sedna.io_jointinferenceservices.yaml - sedna.io_lifelonglearningjobs.yaml - sedna.io_models.yaml - ) - _download_yamls build/crds - yaml_files=( - gm.yaml - ) - _download_yamls build/gm/rbac -} - -prepare_install(){ - # need to create the namespace first - kubectl create ns sedna -} - -prepare() { - mkdir -p ${SEDNA_ROOT} - - # we only need build directory - # here don't use git clone because of large vendor directory - download_yamls -} - -cleanup(){ - kubectl delete ns sedna -} - -create_crds() { - cd ${SEDNA_ROOT} - kubectl create -f build/crds -} - -delete_crds() { - cd ${SEDNA_ROOT} - kubectl delete -f build/crds --timeout=90s -} - -get_service_address() { - local service=$1 - local port=$(kubectl -n sedna get svc $service -ojsonpath='{.spec.ports[0].port}') - - # .: - echo $service.sedna:$port -} - -create_kb(){ - cd ${SEDNA_ROOT} - - kubectl $action -f - < $config_file << EOF -kubeConfig: "" -master: "" -namespace: "" -websocket: - address: 0.0.0.0 - port: 9000 -localController: - server: http://localhost:${SEDNA_LC_BIND_PORT:-9100} -knowledgeBaseServer: - server: http://$KB_ADDRESS -EOF - fi - - kubectl $action -n sedna configmap $cm_name --from-file=$config_file -} - -create_gm() { - - cd ${SEDNA_ROOT} - - kubectl create -f build/gm/rbac/ - - cm_name=gm-config - config_file_name=gm.yaml - prepare_gm_config_map $cm_name $config_file_name - - - kubectl $action -f - </dev/null -} - -check_action() { - action=${SEDNA_ACTION:-create} - support_action_list="create delete" - if ! echo "$support_action_list" | grep -w -q "$action"; then - echo "\`$action\` not in support action list: create/delete!" >&2 - echo "You need to specify it by setting $(red_text SEDNA_ACTION) environment variable when running this script!" >&2 - exit 2 - fi - -} - -do_check() { - check_kubectl - check_action -} - -show_debug_infos() { - cat - <try_times)) && { + echo timeout to download $yaml + exit 2 + } + echo -en "retrying to download $yaml after $[i*timeout] seconds...\r" + done + done +} + +download_yamls() { + yaml_files=( + sedna.io_datasets.yaml + sedna.io_federatedlearningjobs.yaml + sedna.io_incrementallearningjobs.yaml + sedna.io_jointinferenceservices.yaml + sedna.io_lifelonglearningjobs.yaml + sedna.io_models.yaml + ) + _download_yamls build/crds + yaml_files=( + gm.yaml + ) + _download_yamls build/gm/rbac +} + +prepare_install(){ + # need to create the namespace first + kubectl create ns sedna +} + +prepare() { + mkdir -p ${SEDNA_ROOT} + + # we only need build directory + # here don't use git clone because of large vendor directory + download_yamls +} + +cleanup(){ + kubectl delete ns sedna +} + +create_crds() { + cd ${SEDNA_ROOT} + kubectl create -f build/crds +} + +delete_crds() { + cd ${SEDNA_ROOT} + kubectl delete -f build/crds --timeout=90s +} + +get_service_address() { + local service=$1 + local port=$(kubectl -n sedna get svc $service -ojsonpath='{.spec.ports[0].port}') + + # .: + echo $service.sedna:$port +} + +create_kb(){ + cd ${SEDNA_ROOT} + + kubectl $action -f - < $config_file << EOF +kubeConfig: "" +master: "" +namespace: "" +websocket: + address: 0.0.0.0 + port: 9000 +localController: + server: http://localhost:${SEDNA_LC_BIND_PORT:-9100} +knowledgeBaseServer: + server: http://$KB_ADDRESS +EOF + fi + + kubectl $action -n sedna configmap $cm_name --from-file=$config_file +} + +create_gm() { + + cd ${SEDNA_ROOT} + + kubectl create -f build/gm/rbac/ + + cm_name=gm-config + config_file_name=gm.yaml + prepare_gm_config_map $cm_name $config_file_name + + + kubectl $action -f - </dev/null +} + +check_action() { + action=${SEDNA_ACTION:-create} + support_action_list="create delete" + if ! echo "$support_action_list" | grep -w -q "$action"; then + echo "\`$action\` not in support action list: create/delete!" >&2 + echo "You need to specify it by setting $(red_text SEDNA_ACTION) environment variable when running this script!" >&2 + exit 2 + fi + +} + +do_check() { + check_kubectl + check_action +} + +show_debug_infos() { + cat - <