This repository was archived by the owner on Nov 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 356
TR Ultimate Test Harness GHA workflow #6588
Merged
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
8a1577d
compose file version 3.8
zrhoffman 8217732
Enable IPv6
zrhoffman dd8f218
TR Ultimate Test Harness GHA workflow
zrhoffman 9135060
Set TO API version in API_VERSION
zrhoffman a99bba4
Use nonzero exit code on failure
zrhoffman 35e703f
Make API_VERSION read-only
zrhoffman 15de193
No pull
zrhoffman 03ccc09
Build with buildkit
zrhoffman e42e21a
Store logs and fail if Traffic Ops does not start within 10 minutes
zrhoffman 4aa6f1a
Vendor go dependencies
zrhoffman 3634612
Build docker-compose services in a separate step
zrhoffman 7855dce
Validate service IP addresses
zrhoffman fbd682f
Write logs in a separate step
zrhoffman 2ee2383
Cache local Maven repository
zrhoffman 47d41f0
Cache Node modules
zrhoffman b481149
Use user ID to chown
zrhoffman 57704b2
Use the GHA runner UID for trafficrouter image user
zrhoffman bc3cec4
Do not run tests until the Delivery Service is available
zrhoffman 9ca8687
Revert "Make API_VERSION read-only"
zrhoffman 2a9c893
Increase root logger threshold to WARN
zrhoffman aa644ca
Reuse to-access.sh functions for requests to Traffic Ops
zrhoffman ae2127c
Revert "Set TO API version in API_VERSION"
zrhoffman e55484c
Wait for Traffic Monitor's snapshot before waiting for the Delivery S…
zrhoffman 3dd4725
CDN in a Box: Quote data strings
zrhoffman aa169f6
Increase timeouts, just in case
zrhoffman 5fde13e
Adjust thresholds for GitHub Actions performance
zrhoffman cb4e898
Fetch environment variables in advance
zrhoffman d445a48
Remove commented lines
zrhoffman 793c6cc
Start the Dev CDN in a Box in a separate step
zrhoffman d871b27
Set interface IP addresses in a separate step
zrhoffman 6a92e30
Wait for Traffic Monitor to serve a snapshot in a separate step
zrhoffman 6e5d696
Wait for Delivery Service to become available in a separate step
zrhoffman c07b58a
Compile the tests in a separate step
zrhoffman bc3ad73
Run Traffic Router Ultimate Test Harness directly from workflow file
zrhoffman 36bc346
Wait until Traffic Ops is ready to accept requests in separate step
zrhoffman bb4257a
Run HTTP and DNS tests in separate steps
zrhoffman 5b309cc
Change flag to --delivery-service
zrhoffman 6ecdfc3
Print usage message from here document
zrhoffman 1bcd688
Print flag descriptions on next line
zrhoffman bd03b8f
One environment variable or port per line
zrhoffman 986fe2b
Set UID and GID from file ownership at runtime
zrhoffman ab21073
/root/go -> /go in parameters
zrhoffman b3f63db
Only indent once
zrhoffman a5b246f
Remove unused USER and UID exports
zrhoffman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,212 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # https://apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| name: TR Ultimate Test Harness | ||
|
|
||
| env: | ||
| DOCKER_BUILDKIT: '1' | ||
| COMPOSE_DOCKER_CLI_BUILD: '1' | ||
|
|
||
| on: | ||
| push: | ||
| paths: | ||
| - .github/actions/tr-ultimate-test-harness/** | ||
| - .github/workflows/tr-ultimate-test-harness.yml | ||
| - dev/traffic_router/** | ||
| - traffic_router/** | ||
| create: | ||
| pull_request: | ||
| paths: | ||
| - .github/actions/tr-ultimate-test-harness/** | ||
| - .github/workflows/tr-ultimate-test-harness.yml | ||
| - dev/traffic_router/** | ||
| - traffic_router/** | ||
| types: [ opened, reopened, ready_for_review, synchronize ] | ||
|
|
||
| jobs: | ||
| tests: | ||
| if: github.event.pull_request.draft == false | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@master | ||
| - name: Fetch environment variables | ||
| run: | | ||
| source dev/atc.dev.sh && | ||
| env | grep -e^TO_ -e^UID= >> .env | ||
| - name: Load environment | ||
| run: | | ||
| set -o pipefail && | ||
| cat infrastructure/cdn-in-a-box/variables.env .env | | ||
| sed /^#/d | | ||
| tee --append "${{ github.env }}" | ||
| - name: Install Go | ||
| uses: actions/setup-go@v2 | ||
| with: | ||
| go-version: ${{ env.GO_VERSION }} | ||
| - name: Vendor dependencies | ||
| run: go mod vendor | ||
| - name: Build docker-compose services | ||
| run: | | ||
| docker-compose build --parallel && | ||
| docker-compose pull db | ||
| - name: Cache local Maven repository | ||
| uses: actions/cache@v2 | ||
| with: | ||
| path: ${{ github.workspace }}/.m2/repository | ||
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-maven- | ||
| - name: Cache node modules | ||
| uses: actions/cache@v2 | ||
| with: | ||
| path: ${{ github.workspace }}/.npm | ||
| key: ${{ runner.os }}-node-modules-${{ hashFiles('traffic_portal/**/package*.json') }}- | ||
| restore-keys: | | ||
| ${{ runner.os }}-node-modules- | ||
| - name: Start the Dev CDN in a Box | ||
| run: docker-compose up -d | ||
| - name: Wait until Traffic Ops is ready to accept requests | ||
| run: | | ||
| trap 'echo "Error on line ${LINENO} of setting interface IP addresses"; exit 1' ERR | ||
| set -o errexit -o nounset -o pipefail | ||
|
|
||
| # Get atc-ready function | ||
| source dev/atc.dev.sh | ||
| export -f atc-ready | ||
|
|
||
| echo 'Waiting until Traffic Ops is ready to accept requests...' | ||
| if ! timeout 10m bash -c 'atc-ready -w'; then | ||
| echo 'Traffic Ops was not available within 10 minutes!' | ||
| trap - ERR | ||
| echo 'Exiting...' | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Set interface IP addresses | ||
| run: |2 | ||
| trap 'echo "Error on line ${LINENO} of setting interface IP addresses"; exit 1' ERR | ||
| # set -o xtrace | ||
| # uncomment this line ^ to check interface data | ||
| set -o errexit -o nounset -o pipefail | ||
|
|
||
| source infrastructure/cdn-in-a-box/traffic_ops/to-access.sh | ||
|
|
||
| declare -A service_by_hostname | ||
| service_by_hostname[trafficrouter]=trafficrouter | ||
| service_by_hostname[edge]=t3c | ||
|
|
||
| for hostname in trafficrouter edge; do | ||
| container_id="$(docker-compose ps -q "${service_by_hostname[$hostname]}")" | ||
| interface="$(<<'JSON' jq | ||
| { | ||
| "mtu": 1500, | ||
| "monitor": true, | ||
| "ipAddresses": [], | ||
| "name": "eth0" | ||
| } | ||
| JSON | ||
| )" | ||
| docker_network="$(docker network inspect dev.ciab.test)" | ||
| for ip_address_field in IPv4Address IPv6Address; do | ||
| ip_address="$(<<<"$docker_network" jq -r --arg CONTAINER_ID "$container_id" --arg IP_ADDRESS_FIELD "$ip_address_field" '.[0].Containers[$CONTAINER_ID][$IP_ADDRESS_FIELD]')" | ||
| if [[ "$ip_address" == null ]]; then | ||
| echo "Could not find ${ip_address_field} for ${hostname} service!" | ||
| exit 1 | ||
| fi | ||
| interface="$(<<<"$interface" jq --arg IP_ADDRESS "$ip_address" '.ipAddresses += [{} | .address = $IP_ADDRESS | .serviceAddress = true]')" | ||
| done | ||
|
|
||
| # Get server JSON | ||
| server="$(to-get "api/$TO_API_VERSION/servers?hostName=${hostname}" | jq '.response[0]')" | ||
| if [[ -z "$server" ]]; then | ||
| echo "Could not get JSON for server ${hostname}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Update server's interface with its IP addresses | ||
| server="$(<<<"$server" jq ".interfaces = [${interface}]")" | ||
| server_id="$(<<<"$server" jq .id)" | ||
| if ! to-put "api/$TO_API_VERSION/servers/${server_id}" "$server"; then | ||
| echo "Could not update server ${hostname} with ${server}" | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| # Snapshot | ||
| cdn_id="$(<<<"$server" jq .cdnId)" | ||
| to-put "api/$TO_API_VERSION/snapshot?cdnID=${cdn_id}" | ||
|
|
||
| - name: Wait for Traffic Monitor to serve a snapshot | ||
| run: | | ||
| echo "Waiting for Traffic Monitor to serve a snapshot..." | ||
| if ! timeout 10m curl \ | ||
| --retry 99999 \ | ||
| --retry-delay 5 \ | ||
| --show-error \ | ||
| -fIso/dev/null \ | ||
| http://localhost/publish/CrConfig | ||
| then | ||
| echo "CrConfig was not available from Traffic Monitor within 10 minutes!" | ||
| trap - ERR | ||
| echo 'Exiting...' | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Compile the tests | ||
| run: go test -c ./traffic_router/ultimate-test-harness | ||
|
|
||
| - name: Wait for Delivery Service to become available | ||
| id: wait-for-ds | ||
| run: | | ||
| trap 'echo "Error on line ${LINENO} of waiting for the Delivery Service to become available"; exit 1' ERR | ||
| set -o errexit -o nounset -o pipefail | ||
|
|
||
| # Get atc-ready function | ||
| source dev/atc.dev.sh | ||
| export -f atc-ready | ||
|
|
||
| deliveryservice=cdn.dev-ds.ciab.test | ||
| echo "Waiting for Delivery Service ${deliveryservice} to become available..." | ||
| if ! timeout 10m bash -c 'atc-ready -d'; then | ||
| echo "Delivery Service ${deliveryservice} was not available within 10 minutes!" | ||
| trap - ERR | ||
| echo 'Exiting...' | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Run Traffic Router Ultimate Test Harness HTTP tests | ||
| run: ./ultimate-test-harness.test -test.v -test.run=^TestHTTPLoad$ -http_requests_threshold=1200 | ||
|
|
||
| - name: Run Traffic Router Ultimate Test Harness DNS tests | ||
| run: ./ultimate-test-harness.test -test.v -test.run=^TestDNSLoad$ -dns_requests_threshold=2500 | ||
| if: ${{ steps.wait-for-ds.outcome == 'success' && always() }} | ||
|
|
||
| - name: Write Dev CDN-in-a-Box logs to files | ||
| run: | | ||
| set -o errexit -o nounset | ||
| mkdir -p dev/logs | ||
| for service in $(docker-compose ps --services); do | ||
| docker-compose logs --no-color --timestamps "$service" >"dev/logs/${service}.log" | ||
| done | ||
| if: ${{ failure() }} | ||
| - name: Upload Dev CDN-in-a-Box logs | ||
| uses: actions/upload-artifact@v2 | ||
| with: | ||
| name: dev-ciab-logs | ||
| path: dev/logs/*.log | ||
| if: ${{ failure() }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,25 +28,38 @@ function atc-restart { | |
| } | ||
|
|
||
| function atc-ready { | ||
| local url="https://localhost:6443/api/4.0/ping"; | ||
| local usage url="https://localhost:6443/api/4.0/ping"; | ||
| usage="$(<<-USAGE cat | ||
| Usage: ${0} [-h] [-w] | ||
|
|
||
| -h, --help | ||
| print usage information and exit | ||
| -w, --wait | ||
| wait for ATC to be ready, instead of just checking if it is ready | ||
| -d, --delivery-service | ||
| wait for the ATC delivery service to be ready | ||
| USAGE | ||
| )" | ||
| if [[ $# -gt 0 ]]; then | ||
| case "$1" in | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just to make a note, now that we have mutually exclusive arguments we might want to consider using |
||
| -w|--wait) | ||
| while ! curl -skL "$url" >/dev/null 2>&1; do | ||
| until curl -skL "$url" >/dev/null 2>&1; do | ||
| sleep 1; | ||
| done | ||
| return 0;; | ||
| -d|--delivery-service) | ||
| local deliveryservice=cdn.dev-ds.ciab.test | ||
| until curl -4sfH "Host: ${deliveryservice}" localhost:3080 && | ||
| <<<"$(dig +short -4 @localhost -p 3053 "$deliveryservice")" grep -q '^[0-9.]\+$'; | ||
| do | ||
| sleep 1; | ||
| done | ||
| return 0;; | ||
| -h|--help) | ||
| echo "Usage: $0 [-h] [-w]"; | ||
| echo ""; | ||
| echo "-h, --help print usage information and exit"; | ||
| echo "-w, --wait wait for ATC to be ready, instead of just checking if it is ready"; | ||
| echo "$usage"; | ||
| return 0;; | ||
| *) | ||
| echo "Usage: $0 [-h] [-w]" >&2; | ||
| echo "" >&2; | ||
| echo "-h, --help print usage information and exit" >&2; | ||
| echo "-w, --wait wait for ATC to be ready, instead of just checking if it is ready" >&2; | ||
| echo "$usage" >&2; | ||
| return 1;; | ||
| esac | ||
| fi | ||
|
|
@@ -165,20 +178,3 @@ function tm-health-client { | |
| export TO_URL="https://localhost:6443" | ||
| export TO_USER="admin" | ||
| export TO_PASSWORD="twelve12" | ||
|
|
||
|
|
||
| # On some shell/system combinations, either or both of these are available as | ||
| # shell variables but aren't exported to the execution environment. In others, | ||
| # they may just not be set. In any case, trying to set one or both of these to | ||
| # certain values - or even at all, on some systems - will fail, so we hope this | ||
| # isn't necessary. | ||
| if [[ -z "$USER" ]]; then | ||
| USER="$(id -un)"; | ||
| fi | ||
| export USER; | ||
|
|
||
| if [[ -z "$UID" ]]; then | ||
| UID="$(id -u)"; | ||
| fi | ||
| export UID; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.