github.com/zhouyu0/docker-note@v0.0.0-20190722021225-b8d3825084db/hack/make/test-integration-flaky (about)

     1  #!/usr/bin/env bash
     2  set -e -o pipefail
     3  
     4  source hack/validate/.validate
     5  new_tests=$(
     6      validate_diff --diff-filter=ACMR --unified=0 -- 'integration/*_test.go' |
     7      grep -E '^(\+func )(.*)(\*testing)' || true
     8  )
     9  
    10  if [ -z "$new_tests" ]; then
    11      echo 'No new tests added to integration.'
    12      return
    13  fi
    14  
    15  echo
    16  echo "Found new integrations tests:"
    17  echo "$new_tests"
    18  echo "Running stress test for them."
    19  
    20  (
    21      TESTARRAY=$(echo "$new_tests" | sed 's/+func //' | awk -F'\\(' '{print $1}' | tr '\n' '|')
    22      # Note: TEST_REPEAT will make the test suite run 5 times, restarting the daemon
    23      # whereas testcount will make each test run 5 times in a row under the same daemon.
    24      # This will make a total of 25 runs for each test in TESTARRAY.
    25      export TEST_REPEAT=5
    26      local testcount=5
    27      # However, TIMEOUT needs to take testcount into account, or a premature time out may happen.
    28      # The following ugliness will:
    29      # - remove last character (usually 'm' from '10m')
    30      # - multiply by testcount
    31      # - add last character back
    32      export TIMEOUT=$((${TIMEOUT::-1} * $testcount))${TIMEOUT:$((${#TIMEOUT}-1)):1}
    33  
    34      export TESTFLAGS="-test.count $testcount -test.run ${TESTARRAY%?}"
    35      echo "Using test flags: $TESTFLAGS"
    36      source hack/make/test-integration
    37  )