github.com/hernad/nomad@v1.6.112/e2e/ui/run.sh (about)

     1  #!/usr/bin/env bash
     2  # Copyright (c) HashiCorp, Inc.
     3  # SPDX-License-Identifier: MPL-2.0
     4  
     5  set -e
     6  
     7  help() {
     8      cat <<EOF
     9  Usage: run.sh [subcommand] [options] [--help]
    10  
    11    Runs playwright tests in a Docker container against your shell's configured
    12    Nomad target.
    13  
    14    Subcommands:
    15    test   Run the tests (default behavior if no subcommand is provided). Options:
    16           --no-install   Don't run npm install because you've already done so.
    17  
    18    shell  Run a bash shell with the environment already set up. Maybe useful
    19           for debugging.
    20  
    21    proxy  Deploy a reverse proxy. When the cluster is using mTLS, you will need
    22           this so that we don't need to load a CA certificate into the browser.
    23           This reverse proxy uses a self-signed cert. Will print a new NOMAD_ADDR
    24           address for you to use for test runs.
    25  
    26    Environment Variables:
    27    NOMAD_ADDR    Address of Nomad cluster or reverse proxy.
    28    NOMAD_TOKEN   Authentication token.
    29  
    30  EOF
    31  }
    32  
    33  
    34  IMAGE="mcr.microsoft.com/playwright:focal"
    35  pushd $(dirname "${BASH_SOURCE[0]}") > /dev/null
    36  
    37  run_tests() {
    38      run bash script.sh $@
    39  }
    40  
    41  run_shell() {
    42      run bash $@
    43  }
    44  
    45  run() {
    46      exec docker run -it --rm \
    47             -v $(pwd):/src \
    48             -w /src \
    49             -e NOMAD_ADDR=$NOMAD_ADDR \
    50             -e NOMAD_TOKEN=$NOMAD_TOKEN \
    51             --ipc=host \
    52             --net=host \
    53             "$IMAGE" \
    54             $@
    55  }
    56  
    57  run_proxy() {
    58      nomad namespace apply proxy
    59      nomad job run "./input/proxy.nomad"
    60      IP=$(nomad node status -json -verbose \
    61            $(nomad operator api '/v1/allocations?namespace=proxy' | jq -r '.[] | select(.JobID == "nomad-proxy") | .NodeID') \
    62          | jq -r '.Attributes."unique.platform.aws.public-ipv4"')
    63      echo "NOMAD_ADDR=https://$IP:6464"
    64      exit 0
    65  }
    66  
    67  opt="$1"
    68  case $opt in
    69      help|--help|-h) help ;;
    70      proxy|--proxy) run_proxy ;;
    71      test|--test) shift ; run_tests "$@" ;;
    72      shell) shift ; run_shell ;;
    73      *) run_tests "$@" ;;
    74  esac
    75  
    76  run_tests