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

     1  #!/usr/bin/env bash
     2  # Copyright 2019 The KubeEdge Authors.
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #    http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  if [ "${1}" == "--help" ]; then
    17    cat <<EOF
    18  Usage: $(basename $0) <tests>
    19  
    20    <tests>        the performance tests will be performed, it could be one of [loadtest, nodedensity, hubtest],
    21                   empty means all the performance tests will be performed.
    22  Examples:
    23    $(basename $0)
    24    $(basename $0) loadtest
    25    $(basename $0) nodedensity
    26    $(basename $0) hubtest
    27  
    28  EOF
    29    exit 0
    30  fi
    31  
    32  echo $PWD
    33  curpath=$PWD
    34  PWD=${curpath}/tests/performance
    35  sudo rm -rf $PWD/loadtest/loadtest.test
    36  sudo rm -rf $PWD/nodedensity/nodedensity.test
    37  sudo rm -rf $PWD/hubtest/hubtest.test
    38  
    39  go get github.com/onsi/ginkgo/ginkgo
    40  sudo cp $GOPATH/bin/ginkgo /usr/bin/
    41  # Specify the module name to compile in below command
    42  bash -x $PWD/scripts/compileperf.sh $1
    43  
    44  :> /tmp/testcase.log
    45  bash -x ${PWD}/scripts/runperf.sh $1
    46  #stop the edgecore after the test completion
    47  grep  -e "Running Suite" -e "SUCCESS\!" -e "FAIL\!" /tmp/performace_test.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'
    48  echo "Performance Test Final Summary Report"
    49  echo "==============================================="
    50  echo "Total Number of Test cases = `grep "Ran " /tmp/loadtest_perf.log | awk '{sum+=$2} END {print sum}'`"
    51  passed=`grep -e "SUCCESS\!" -e "FAIL\!" /tmp/performace_test.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}'`
    52  echo "Number of Test cases PASSED = $passed"
    53  fail=`grep -e "SUCCESS\!" -e "FAIL\!" /tmp/performace_test.log | awk '{print $6}' | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" | awk '{sum+=$1} END {print sum}'`
    54  echo "Number of Test cases FAILED = $fail"
    55  echo "==================Result Summary======================="
    56  
    57  if [ "$fail" != "0" ];then
    58      echo "Performance tests has failures, Please check !!"
    59      exit 1
    60  else
    61      echo "Performance tests successfully passed all the tests !!"
    62      exit 0
    63  fi