diff --git a/cluster/vagrant/pod-ip-test.sh b/cluster/vagrant/pod-ip-test.sh old mode 100644 new mode 100755 index cf43bcba819..56aba721fd9 --- a/cluster/vagrant/pod-ip-test.sh +++ b/cluster/vagrant/pod-ip-test.sh @@ -14,31 +14,91 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -e +echoOK() { + TC='\e[' + RegB="${TC}0m" + if [ "$1" -eq "0" ]; then + Green="${TC}32m" + echo -e "[${Green}OK${RegB}]" + else + Red="${TC}31m" + echo -e "[${Red}FAIL${RegB}]" + echo "Check log file." + exit 1 + fi +} + +usage() { + echo "Usage options: [--logfile ]" +} + +logfile=/dev/null +while [[ $# > 0 ]]; do + key="$1" + shift + case $key in + -l|--logfile) + logfile="$1" + if [ "$logfile" == "" ]; then + usage + exit 1 + fi + shift + ;; + *) + # unknown option + usage + exit 1 + ;; + esac +done cd $(dirname ${BASH_SOURCE})/../../ -# start the cluster with 2 minions +echo All verbose output will be redirected to $logfile, use --logfile option to change. + +printf "Start the cluster with 2 minions .. " export KUBERNETES_NUM_MINIONS=2 export KUBERNETES_PROVIDER=vagrant -cluster/kube-up.sh -echo "Pull an image that runs a web server" -vagrant ssh minion-1 -- sudo docker pull dockerfile/nginx -vagrant ssh minion-2 -- sudo docker pull dockerfile/nginx +(cluster/kube-up.sh &>> $logfile) || true +echoOK $? -echo "Run the servers" -vagrant ssh minion-1 -- sudo docker run -d dockerfile/nginx -vagrant ssh minion-2 -- sudo docker run -d dockerfile/nginx +printf "Check if minion-1 can reach kubernetes master .. " +vagrant ssh minion-1 -- ping -c 10 kubernetes-master &>> $logfile +echoOK $? +printf "Check if minion-2 can reach kubernetes master .. " +vagrant ssh minion-2 -- ping -c 10 kubernetes-master &>> $logfile +echoOK $? -echo "Run ping from minion-1 to docker bridges and to the containers on both minions" -vagrant ssh minion-1 -- 'ping -c 10 10.244.1.1 && ping -c 10 10.244.2.1 && ping -c 10 10.244.1.3 && ping -c 10 10.244.2.3' -echo "Same pinch from minion-2" -vagrant ssh minion-2 -- 'ping -c 10 10.244.1.1 && ping -c 10 10.244.2.1 && ping -c 10 10.244.1.3 && ping -c 10 10.244.2.3' +printf "Pull an image that runs a web server on minion-1 .. " +vagrant ssh minion-1 -- 'sudo docker pull dockerfile/nginx' &>> $logfile +echoOK $? +printf "Pull an image that runs a web server on minion-2 .. " +vagrant ssh minion-2 -- 'sudo docker pull dockerfile/nginx' &>> $logfile +echoOK $? -echo "tcp check, curl to both the running webservers from both machines" -vagrant ssh minion-1 -- 'curl 10.244.1.3:80 && curl 10.244.2.3:80' -vagrant ssh minion-2 -- 'curl 10.244.1.3:80 && curl 10.244.2.3:80' +printf "Run the server on minion-1 .. " +vagrant ssh minion-1 -- sudo docker run -d dockerfile/nginx &>> $logfile +echoOK $? +printf "Run the server on minion-2 .. " +vagrant ssh minion-2 -- sudo docker run -d dockerfile/nginx &>> $logfile +echoOK $? -echo "All good, destroy the cluster" -vagrant destroy -f +printf "Run ping from minion-1 to docker bridges and to the containers on both minions .. " +vagrant ssh minion-1 -- 'ping -c 20 10.244.1.1 && ping -c 20 10.244.2.1 && ping -c 20 10.244.1.3 && ping -c 20 10.244.2.3' &>> $logfile +echoOK $? +printf "Same pinch from minion-2 .. " +vagrant ssh minion-2 -- 'ping -c 20 10.244.1.1 && ping -c 20 10.244.2.1 && ping -c 20 10.244.1.3 && ping -c 20 10.244.2.3' &>> $logfile +echoOK $? + +printf "tcp check, curl to both the running webservers from minion-1 .. " +vagrant ssh minion-1 -- 'curl 10.244.1.3:80 && curl 10.244.2.3:80' &>> $logfile +echoOK $? +printf "tcp check, curl to both the running webservers from minion-2 .. " +vagrant ssh minion-2 -- 'curl 10.244.1.3:80 && curl 10.244.2.3:80' &>> $logfile +echoOK $? + +printf "All good, destroy the cluster .. " +vagrant destroy -f &>> $logfile +echoOK $?