github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/edge/test/integration/scripts/execute.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2019 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  echo $PWD
    19  
    20  VAR_EDGED_DIR="/var/lib/kubeedge"
    21  if [ ! -d ${VAR_EDGED_DIR} ]; then
    22    sudo mkdir -p ${VAR_EDGED_DIR} && sudo chown $USER:$USER ${VAR_EDGED_DIR}
    23  fi
    24  
    25  go get github.com/onsi/ginkgo/ginkgo
    26  sudo cp $GOPATH/bin/ginkgo /usr/bin/
    27  
    28  sudo pkill edgecore
    29  #kill the edgecore process if it exists, wait 2s delay before start the edgecore process.
    30  sleep 2s
    31  
    32  PWD=${curpath}/edge/test/integration
    33  
    34  # create cert files
    35  $PWD/scripts/generate_cert.sh
    36  sudo rm -rf $PWD/appdeployment/appdeployment.test
    37  sudo rm -rf $PWD/device/device.test
    38  # Specify the module name to compile in below command
    39  bash -x $PWD/scripts/compile.sh $1
    40  export MQTT_SERVER=127.0.0.1
    41  :> /tmp/testcase.log
    42  bash -x ${PWD}/scripts/fast_test.sh $1
    43  #stop the edgecore after the test completion
    44  sudo pkill edgecore
    45  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'
    46  echo "Integration Test Final Summary Report"
    47  echo "==============================================="
    48  echo "Total Number of Test cases = `grep "Ran " /tmp/testcase.log | awk '{sum+=$2} END {print sum}'`"
    49  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}'`
    50  echo "Number of Test cases PASSED = $passed"
    51  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}'`
    52  echo "Number of Test cases FAILED = $fail"
    53  echo "==================Result Summary======================="
    54  if [ "$fail" != "0" ];then
    55      echo "Integration suite has failures, Please check !!"
    56      exit 1
    57  else
    58      echo "Integration suite successfully passed all the tests !!"
    59      exit 0
    60  fi