github.com/pachyderm/pachyderm@v1.13.4/etc/testing/travis.sh (about)

     1  #!/bin/bash
     2  
     3  set -ex
     4  
     5  (
     6      # Stop Travis from timing us out in 10m when we want to get retried after 20m
     7      set +x
     8      while true; do
     9          echo "liveness ping $(date)"
    10          sleep 60
    11      done
    12  ) &
    13  
    14  # Log in to docker, so we don't get rate-limited if we're pulling images
    15  docker login -u pachydermbuildbot -p "${DOCKER_PWD}"
    16  
    17  # Repeatedly restart minikube until it comes up. This corrects for an issue in
    18  # Travis, where minikube will get stuck on startup and never recover
    19  while true; do
    20    # In case minikube delete doesn't work (see minikube#2519)
    21    for C in $(docker ps -aq); do docker rm -f "$C"; done || true
    22  
    23    # Belt and braces
    24    sudo rm -rf \
    25      /etc/kubernetes \
    26      /data/minikube \
    27      /var/lib/minikube \
    28      "${HOME}"/.pachyderm/config.json  # In case we're retrying on a new cluster
    29  
    30    if make launch-kube; then
    31      break
    32    fi
    33  done
    34  
    35  # make launch-kube connects with kubernetes, so it should just be available
    36  minikube status
    37  kubectl version
    38  
    39  echo "Running test suite based on BUCKET=$BUCKET"
    40  
    41  if [[ "$TRAVIS_SECURE_ENV_VARS" == "true" ]]; then
    42      # Pull the pre-built images. This is only done if we have access to the
    43      # secret env vars, because otherwise the build step would've had to be
    44      # skipped.
    45      make install
    46      version=$(pachctl version --client-only)
    47      docker pull "pachyderm/pachd:${version}"
    48      docker tag "pachyderm/pachd:${version}" "pachyderm/pachd:local"
    49      docker pull "pachyderm/worker:${version}"
    50      docker tag "pachyderm/worker:${version}" "pachyderm/worker:local"
    51  else
    52      make docker-build
    53      # push pipeline build images
    54      pushd etc/pipeline-build
    55          make push-to-minikube
    56      popd
    57  fi
    58  
    59  if [[ "${BUCKET}" = "PPS3" ]]; then
    60      make launch-loki
    61  fi
    62  for i in $(seq 3); do
    63      make clean-launch-dev || true # may be nothing to delete
    64      make launch-dev && break
    65      (( i < 3 )) # false if this is the last loop (causes exit)
    66      sleep 10
    67  done
    68  
    69  pachctl config update context "$(pachctl config get active-context)" --pachd-address="$(minikube ip):30650"
    70  
    71  function test_bucket {
    72      set +x
    73      package="${1}"
    74      target="${2}"
    75      bucket_num="${3}"
    76      num_buckets="${4}"
    77      if (( bucket_num == 0 )); then
    78          echo "Error: bucket_num should be > 0, but was 0" >/dev/stderr
    79          exit 1
    80      fi
    81  
    82      echo "Running bucket $bucket_num of $num_buckets"
    83      # shellcheck disable=SC2207
    84      tests=( $(go test -v  "${package}" -list ".*" | grep -v '^ok' | grep -v '^Benchmark') )
    85      total_tests="${#tests[@]}"
    86      # Determine the offset and length of the sub-array of tests we want to run
    87      # The last bucket may have a few extra tests, to accommodate rounding
    88      # errors from bucketing:
    89      let "bucket_size=total_tests/num_buckets" \
    90          "start=bucket_size * (bucket_num-1)" \
    91          "bucket_size+=bucket_num < num_buckets ? 0 : total_tests%num_buckets"
    92      test_regex="$(IFS=\|; echo "${tests[*]:start:bucket_size}")"
    93      echo "Running ${bucket_size} tests of ${total_tests} total tests"
    94      make RUN="-run=\"${test_regex}\"" "${target}"
    95      set -x
    96  }
    97  
    98  # Clean cached test results
    99  go clean -testcache
   100  
   101  case "${BUCKET}" in
   102   MISC)
   103      make lint
   104      make enterprise-code-checkin-test
   105      make test-cmds
   106      make test-libs
   107      make test-proto-static
   108      make test-transaction
   109      make test-deploy-manifests
   110      make test-s3gateway-unit
   111      make test-enterprise
   112      make test-worker
   113      if [[ "$TRAVIS_SECURE_ENV_VARS" == "true" ]]; then
   114          # these tests require secure env vars to run, which aren't available
   115          # when the PR is coming from an outside contributor - so we just
   116          # disable them
   117          make test-tls
   118          make test-vault
   119      fi
   120      ;;
   121   ADMIN)
   122      make test-admin
   123      ;;
   124   EXAMPLES)
   125      echo "Running the example test suite"
   126      ./etc/testing/examples.sh
   127      ;;
   128   PFS)
   129      make test-pfs-server
   130      make test-pfs-storage
   131      ;;
   132   PPS?)
   133      pushd etc/testing/images/ubuntu_with_s3_clients
   134      make push-to-minikube
   135      popd
   136      make docker-build-kafka
   137      bucket_num="${BUCKET#PPS}"
   138      test_bucket "./src/server" test-pps "${bucket_num}" "${PPS_BUCKETS}"
   139      if [[ "${bucket_num}" -eq "${PPS_BUCKETS}" ]]; then
   140        go test -v -count=1 ./src/server/pps/server -timeout 3600s
   141      fi
   142      ;;
   143   AUTH?)
   144      make launch-dex
   145      bucket_num="${BUCKET#AUTH}"
   146      test_bucket "./src/server/auth/server/testing" test-auth "${bucket_num}" "${AUTH_BUCKETS}"
   147      set +x
   148      ;;
   149  OBJECT)
   150      make test-object-clients
   151      ;;
   152   *)
   153      echo "Unknown bucket"
   154      exit 1
   155      ;;
   156  esac