github.com/deemoprobe/k8s-first-commit@v0.0.0-20230430165612-a541f1982be3/src/scripts/e2e-test.sh (about) 1 #!/bin/bash 2 3 # Copyright 2014 Google Inc. All rights reserved. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 # Starts a Kubernetes cluster, verifies it can do basic things, and shuts it 18 # down. 19 20 # Exit on error 21 set -e 22 23 # Use testing config 24 export KUBE_CONFIG_FILE="config-test.sh" 25 source $(dirname $0)/util.sh 26 27 # Build a release 28 $(dirname $0)/../release/release.sh 29 30 # Now bring a test cluster up with that release. 31 $(dirname $0)/kube-up.sh 32 33 # Auto shutdown cluster when we exit 34 function shutdown-test-cluster () { 35 echo "Shutting down test cluster in background." 36 $(dirname $0)/kube-down.sh > /dev/null & 37 } 38 trap shutdown-test-cluster EXIT 39 40 # Launch a container 41 $(dirname $0)/cloudcfg.sh -p 8080:80 run dockerfile/nginx 2 myNginx 42 43 # Get minion IP addresses 44 detect-minions 45 46 # Verify that something is listening (nginx should give us a 404) 47 for (( i=0; i<${#KUBE_MINION_IP_ADDRESSES[@]}; i++)); do 48 IP_ADDRESS=${KUBE_MINION_IP_ADDRESSES[$i]} 49 echo "Trying to reach nginx instance that should be running at ${IP_ADDRESS}:8080..." 50 curl "http://${IP_ADDRESS}:8080" 51 done 52