github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/tests/e2e/scripts/keadm_e2e.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # Copyright 2020 The KubeEdge Authors.
     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  curpath=$PWD
    18  
    19  make all WHAT=keadm
    20  
    21  cd `dirname $0`
    22  workdir=`pwd`
    23  cd $workdir
    24  
    25  cd ../
    26  echo $PWD
    27  
    28  ginkgo build -r keadm/
    29  
    30  kind create cluster --name test
    31  kubectl create clusterrolebinding system:anonymous --clusterrole=cluster-admin --user=system:anonymous
    32  
    33  # edge side don't support kind cni now, delete kind cni plugin for workaround
    34  kubectl delete daemonset kindnet -nkube-system
    35  
    36  export KUBECONFIG=$HOME/.kube/config
    37  sudo mkdir -p /var/lib/kubeedge
    38  sudo ${curpath}/_output/local/bin/keadm init --kube-config=$KUBECONFIG
    39  sudo CHECK_EDGECORE_ENVIRONMENT="false" ${curpath}/_output/local/bin/keadm join --cloudcore-ipport=127.0.0.1:10000 --edgenode-name=edge-node
    40  
    41  export MASTER_IP=`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' test-control-plane`
    42  
    43  
    44  #Pre-configurations required for running the suite.
    45  #Any new config addition required corresponding code changes.
    46  cat >config.json<<END
    47  {
    48          "image_url": ["nginx", "nginx"],
    49          "k8smasterforkubeedge":"https://$MASTER_IP:6443",
    50          "dockerhubusername":"user",
    51          "dockerhubpassword":"password",
    52          "mqttendpoint":"tcp://127.0.0.1:1884",
    53          "kubeconfigpath":"$KUBECONFIG"
    54  }
    55  END
    56  
    57  # TODO: check edgenode running
    58  sleep 10s
    59  
    60  :> /tmp/testcase.log
    61  ./keadm/keadm.test $debugflag 2>&1 | tee -a /tmp/testcase.log
    62  
    63  #stop the edgecore after the test completion
    64  grep  -e "Running Suite" -e "SUCCESS\!" -e "FAIL\!" /tmp/testcase.log | sed -r 's/\x1B\[([0-9];)?([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g' | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g'
    65  echo "Integration Test Final Summary Report"
    66  echo "==============================================="
    67  echo "Total Number of Test cases = `grep "Ran " /tmp/testcase.log | awk '{sum+=$2} END {print sum}'`"
    68  passed=`grep -e "SUCCESS\!" -e "FAIL\!" /tmp/testcase.log | awk '{print $3}' | sed -r "s/\x1B\[([0-9];)?([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" | awk '{sum+=$1} END {print sum}'`
    69  echo "Number of Test cases PASSED = $passed"
    70  fail=`grep -e "SUCCESS\!" -e "FAIL\!" /tmp/testcase.log | awk '{print $6}' | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" | awk '{sum+=$1} END {print sum}'`
    71  echo "Number of Test cases FAILED = $fail"
    72  echo "==================Result Summary======================="
    73  
    74  if [ "$fail" != "0" ];then
    75      echo "Integration suite has failures, Please check !!"
    76      exit 1
    77  else
    78      echo "Integration suite successfully passed all the tests !!"
    79      exit 0
    80  fi