From 8a1577de0f440a913cce9a5b58674b6133d4764a Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Feb 2022 05:01:39 -0700 Subject: [PATCH 01/44] compose file version 3.8 --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 639f7307c7..f0e4506142 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ # under the License. --- -version: '3.5' +version: '3.8' services: trafficops: From 8217732d7ee62c33bc8ed6b0e73fba4ddf07f0a1 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Feb 2022 05:02:02 -0700 Subject: [PATCH 02/44] Enable IPv6 --- docker-compose.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index f0e4506142..2f82862c8e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -135,3 +135,8 @@ networks: ciab: name: dev.ciab.test driver: bridge + enable_ipv6: true + ipam: + driver: default + config: + - subnet: 2001:3984:3989::/64 From dd8f2186da4b732498da57d50e2a4a6ac774e53d Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Feb 2022 09:11:14 -0700 Subject: [PATCH 03/44] TR Ultimate Test Harness GHA workflow --- .../tr-ultimate-test-harness.sh | 104 ++++++++++++++++++ .../workflows/tr-ultimate-test-harness.yml | 48 ++++++++ 2 files changed, 152 insertions(+) create mode 100755 .github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh create mode 100644 .github/workflows/tr-ultimate-test-harness.yml diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh new file mode 100755 index 0000000000..2db2b6319f --- /dev/null +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +# 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 +# +# http://www.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. + +trap 'echo "Error on line ${LINENO} of ${0}"; exit 1' ERR; +set -o xtrace +set -o errexit -o nounset -o pipefail +docker-compose pull +docker-compose build --parallel +docker-compose up -d + +# Constants +declare -r cookie_name=dev-ciab-cookie + +# Set TO_USER, TO_PASSWORD, and TO_URL environment variables and get atc-ready function +source dev/atc.dev.sh + +until atc-ready; do + echo 'Waiting until Traffic Ops is ready to accept requests...' + sleep 3 +done +echo 'Traffic Ops is ready to accept requests!' + +to-req() { + endpoint="$1" + shift + local curl_command=(curl --insecure --silent --cookie-jar "$cookie_name" --cookie "$cookie_name" "${TO_URL}/api/${API_VERSION}") + "${curl_command[@]}${endpoint}" "$@" | jq +} + +# Log in +login_body="$(<<<{} jq --arg TO_USER "$TO_USER" --arg TO_PASSWORD "$TO_PASSWORD" '.u = $TO_USER | .p = $TO_PASSWORD')" +to-req /user/login --data "$login_body" + +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 + )" + for ip_address_field in IPv4Address IPv6Address; do + ip_address="$(docker network inspect dev.ciab.test | + jq -r --arg TR_CONTAINER_ID "$container_id" --arg IP_ADDRESS_FIELD "$ip_address_field" '.[0].Containers[$TR_CONTAINER_ID][$IP_ADDRESS_FIELD]')" + interface="$(<<<"$interface" jq --arg IP_ADDRESS "$ip_address" '.ipAddresses += [{} | .address = $IP_ADDRESS | .serviceAddress = true]')" + done + + + # Get Traffic Router server JSON + server="$(to-req "/servers?hostName=${hostname}" | jq '.response[0]')" + if [[ -z "$server" ]]; then + echo "Could not get JSON for server ${hostname}" + exit 1 + fi + + # Update Traffic Router's interface with its IP addresses + server="$(<<<"$server" jq ".interfaces = [${interface}]")" + server_id="$(<<<"$server" jq .id)" + if ! to-req "/servers/${server_id}" --request PUT --data "$server"; then + echo "Could not update server ${hostname} with ${server}" + fi +done + +# Snapshot +cdn_id="$(<<<"$server" jq .cdnId)" +to-req "/snapshot?cdnID=${cdn_id}" --request PUT + +http_result=0 dns_result=0 +# Compile the tests +go test -c ./traffic_router/ultimate-test-harness +if ! ./ultimate-test-harness.test -test.v -test.run=^TestHTTPLoad$ -http_requests_threshold=5000; then + http_result=1 +fi + +if ! ./ultimate-test-harness.test -test.v -test.run=^TestDNSLoad$ -dns_requests_threshold=20500; then + dns_result=1 +fi +if [[ $http_result -eq 0 && $dns_result -eq 0 ]]; then echo + echo Tests passed! +else + echo Tests failed! +fi diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml new file mode 100644 index 0000000000..e65cf1e211 --- /dev/null +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -0,0 +1,48 @@ +# 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: Run Traffic Router Ultimate Test Harness + run: ./.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh From 913506002739e1d8b0bc96e348e8749e68565779 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Feb 2022 09:49:18 -0700 Subject: [PATCH 04/44] Set TO API version in API_VERSION --- dev/atc.dev.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/atc.dev.sh b/dev/atc.dev.sh index 88b0575971..5c7345cb5b 100644 --- a/dev/atc.dev.sh +++ b/dev/atc.dev.sh @@ -28,7 +28,7 @@ function atc-restart { } function atc-ready { - local url="https://localhost:6443/api/4.0/ping"; + local url="https://localhost:6443/api/${API_VERSION}/ping"; if [[ $# -gt 0 ]]; then case "$1" in -w|--wait) @@ -162,6 +162,7 @@ function tm-health-client { return $?; } +export API_VERSION=4.0 export TO_URL="https://localhost:6443" export TO_USER="admin" export TO_PASSWORD="twelve12" From a99bba4ffb0f9978af495e7880363775f8e4c004 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Feb 2022 13:58:13 -0700 Subject: [PATCH 05/44] Use nonzero exit code on failure --- .../tr-ultimate-test-harness/tr-ultimate-test-harness.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index 2db2b6319f..56a7a7ffc8 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -100,5 +100,7 @@ fi if [[ $http_result -eq 0 && $dns_result -eq 0 ]]; then echo echo Tests passed! else + exit_code=$? echo Tests failed! + exit $exit_code fi From 35e703fd52780c6cd5dfbbe76ae599d1027b65b2 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Feb 2022 14:02:18 -0700 Subject: [PATCH 06/44] Make API_VERSION read-only --- dev/atc.dev.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/atc.dev.sh b/dev/atc.dev.sh index 5c7345cb5b..3bac609126 100644 --- a/dev/atc.dev.sh +++ b/dev/atc.dev.sh @@ -162,7 +162,8 @@ function tm-health-client { return $?; } -export API_VERSION=4.0 +declare -r API_VERSION=4.0 +export API_VERSION export TO_URL="https://localhost:6443" export TO_USER="admin" export TO_PASSWORD="twelve12" From 15de1937760bb574f3e1f9ffc328c023b73992bb Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Mar 2022 00:40:32 -0600 Subject: [PATCH 07/44] No pull --- .../actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index 56a7a7ffc8..08c83706f4 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -19,7 +19,6 @@ trap 'echo "Error on line ${LINENO} of ${0}"; exit 1' ERR; set -o xtrace set -o errexit -o nounset -o pipefail -docker-compose pull docker-compose build --parallel docker-compose up -d From 03ccc092711f5ad3a9db71aa3af9e94cdc0f9c2d Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Mar 2022 00:40:41 -0600 Subject: [PATCH 08/44] Build with buildkit --- .../tr-ultimate-test-harness/tr-ultimate-test-harness.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index 08c83706f4..53e27daa9c 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -16,6 +16,8 @@ # specific language governing permissions and limitations # under the License. +export DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 # build Docker images faster + trap 'echo "Error on line ${LINENO} of ${0}"; exit 1' ERR; set -o xtrace set -o errexit -o nounset -o pipefail From e42e21ac352bbd146298bbca198e83aca53aadfb Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Mar 2022 00:46:01 -0600 Subject: [PATCH 09/44] Store logs and fail if Traffic Ops does not start within 10 minutes --- .../tr-ultimate-test-harness.sh | 18 ++++++++++++++++++ .github/workflows/tr-ultimate-test-harness.yml | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index 53e27daa9c..0c1f1f2d36 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -30,11 +30,29 @@ declare -r cookie_name=dev-ciab-cookie # Set TO_USER, TO_PASSWORD, and TO_URL environment variables and get atc-ready function source dev/atc.dev.sh +store_dev_ciab_logs() { + echo 'Storing Dev CDN-in-a-Box logs...'; + mkdir -p dev/logs; + for service in $(docker-compose ps --services); do + docker-compose logs --no-color --timestamps "$service" >"dev/logs/${service}.log"; + done; +} + +export -f atc-ready +if ! timeout 10m <<'BASH_COMMANDS' bash; then +set -o errexit -o nounset until atc-ready; do echo 'Waiting until Traffic Ops is ready to accept requests...' sleep 3 done echo 'Traffic Ops is ready to accept requests!' +BASH_COMMANDS + echo 'Traffic Ops was not available within 10 minutes!' + store_dev_ciab_logs + trap - ERR + echo 'Exiting...' + exit 1 +fi to-req() { endpoint="$1" diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index e65cf1e211..50ac48d1be 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -46,3 +46,9 @@ jobs: uses: actions/checkout@master - name: Run Traffic Router Ultimate Test Harness run: ./.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh + - name: Upload Dev CDN-in-a-Box logs + uses: actions/upload-artifact@v2 + with: + name: dev-ciab-logs + path: dev/logs/*.log + if: ${{ failure() }} From 4aa6f1ab5f779f38e81c2f13c4c59830040e3e08 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Mar 2022 02:51:48 -0600 Subject: [PATCH 10/44] Vendor go dependencies --- .github/workflows/tr-ultimate-test-harness.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index 50ac48d1be..514367f165 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -44,6 +44,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@master + - name: Check Go version + run: echo "::set-output name=value::$(cat GO_VERSION)" + id: go-version + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ steps.go-version.outputs.value }} + - name: Vendor dependencies + run: go mod vendor - name: Run Traffic Router Ultimate Test Harness run: ./.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh - name: Upload Dev CDN-in-a-Box logs From 363461226fbee436c04cda4dbc12e20f85e06ac9 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Mar 2022 02:54:20 -0600 Subject: [PATCH 11/44] Build docker-compose services in a separate step --- .../tr-ultimate-test-harness/tr-ultimate-test-harness.sh | 1 - .github/workflows/tr-ultimate-test-harness.yml | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index 0c1f1f2d36..78468f7c2d 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -21,7 +21,6 @@ export DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 # build Docker images faster trap 'echo "Error on line ${LINENO} of ${0}"; exit 1' ERR; set -o xtrace set -o errexit -o nounset -o pipefail -docker-compose build --parallel docker-compose up -d # Constants diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index 514367f165..c26890f84c 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -53,6 +53,8 @@ jobs: go-version: ${{ steps.go-version.outputs.value }} - name: Vendor dependencies run: go mod vendor + - name: Build docker-compose services + run: docker-compose build --parallel - name: Run Traffic Router Ultimate Test Harness run: ./.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh - name: Upload Dev CDN-in-a-Box logs From 7855dce8b7b361d35575fcc54a7127434a55b130 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Mar 2022 03:20:54 -0600 Subject: [PATCH 12/44] Validate service IP addresses --- .../tr-ultimate-test-harness/tr-ultimate-test-harness.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index 78468f7c2d..a47c2039f0 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -79,9 +79,13 @@ for hostname in trafficrouter edge; do } JSON )" + docker_network="$(docker network inspect dev.ciab.test)" for ip_address_field in IPv4Address IPv6Address; do - ip_address="$(docker network inspect dev.ciab.test | - jq -r --arg TR_CONTAINER_ID "$container_id" --arg IP_ADDRESS_FIELD "$ip_address_field" '.[0].Containers[$TR_CONTAINER_ID][$IP_ADDRESS_FIELD]')" + 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} container!" + exit 1 + fi interface="$(<<<"$interface" jq --arg IP_ADDRESS "$ip_address" '.ipAddresses += [{} | .address = $IP_ADDRESS | .serviceAddress = true]')" done From fbd682f13e609feb307e5751af3c1cb057dc13d1 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Mar 2022 03:50:05 -0600 Subject: [PATCH 13/44] Write logs in a separate step --- .../tr-ultimate-test-harness.sh | 11 +---------- .github/workflows/tr-ultimate-test-harness.yml | 8 ++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index a47c2039f0..eace6ea309 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -29,14 +29,6 @@ declare -r cookie_name=dev-ciab-cookie # Set TO_USER, TO_PASSWORD, and TO_URL environment variables and get atc-ready function source dev/atc.dev.sh -store_dev_ciab_logs() { - echo 'Storing Dev CDN-in-a-Box logs...'; - mkdir -p dev/logs; - for service in $(docker-compose ps --services); do - docker-compose logs --no-color --timestamps "$service" >"dev/logs/${service}.log"; - done; -} - export -f atc-ready if ! timeout 10m <<'BASH_COMMANDS' bash; then set -o errexit -o nounset @@ -47,7 +39,6 @@ done echo 'Traffic Ops is ready to accept requests!' BASH_COMMANDS echo 'Traffic Ops was not available within 10 minutes!' - store_dev_ciab_logs trap - ERR echo 'Exiting...' exit 1 @@ -83,7 +74,7 @@ JSON 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} container!" + 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]')" diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index c26890f84c..2f3e3e30fe 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -57,6 +57,14 @@ jobs: run: docker-compose build --parallel - name: Run Traffic Router Ultimate Test Harness run: ./.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh + - 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: From 2ee2383e0c69bdad0f6fd8144743a6c8c922573f Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Mar 2022 04:27:40 -0600 Subject: [PATCH 14/44] Cache local Maven repository --- .github/workflows/tr-ultimate-test-harness.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index 2f3e3e30fe..634d708942 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -55,6 +55,13 @@ jobs: run: go mod vendor - name: Build docker-compose services run: docker-compose build --parallel + - 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: Run Traffic Router Ultimate Test Harness run: ./.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh - name: Write Dev CDN-in-a-Box logs to files From 47d41f09d58b1cffe7946bb55acb5ccd17fa72c7 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Mar 2022 04:27:57 -0600 Subject: [PATCH 15/44] Cache Node modules --- .github/workflows/tr-ultimate-test-harness.yml | 7 +++++++ docker-compose.yml | 1 + 2 files changed, 8 insertions(+) diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index 634d708942..1153da96b5 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -62,6 +62,13 @@ jobs: 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: Run Traffic Router Ultimate Test Harness run: ./.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh - name: Write Dev CDN-in-a-Box logs to files diff --git a/docker-compose.yml b/docker-compose.yml index 2f82862c8e..8a92865ed3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,6 +59,7 @@ services: - 444:443 volumes: - .:/root/go/src/github.com/apache/trafficcontrol + - ./.npm:/root/.npm tpv2: build: From b4811492bbd7f34fc8a8221f7c720ef42d343b5f Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Mar 2022 04:48:39 -0600 Subject: [PATCH 16/44] Use user ID to chown --- dev/traffic_router/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/traffic_router/Dockerfile b/dev/traffic_router/Dockerfile index 1423202ede..62ba1a05c2 100644 --- a/dev/traffic_router/Dockerfile +++ b/dev/traffic_router/Dockerfile @@ -25,7 +25,7 @@ ADD https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.43/bin/apache-tomcat-9. ARG USER ARG UID RUN adduser -H -D ${USER} -u ${UID} -RUN chown -R ${USER} /opt /usr/share/java/ /root +RUN chown -R ${UID}:${UID} /opt /usr/share/java/ /root USER ${USER} RUN cd /opt && \ tar -xf tomcat.tgz && \ From 57704b29c4ed371d055e79d5659bfafccb10e3e4 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 28 Mar 2022 04:51:40 -0600 Subject: [PATCH 17/44] Use the GHA runner UID for trafficrouter image user --- .github/workflows/tr-ultimate-test-harness.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index 1153da96b5..993992293a 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -54,7 +54,9 @@ jobs: - name: Vendor dependencies run: go mod vendor - name: Build docker-compose services - run: docker-compose build --parallel + run: | + source dev/atc.dev.sh && + docker-compose build --parallel - name: Cache local Maven repository uses: actions/cache@v2 with: From bc3cec4e8a9974079828eea02b5ad1abfec5058b Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Wed, 30 Mar 2022 13:51:47 -0600 Subject: [PATCH 18/44] Do not run tests until the Delivery Service is available --- .../tr-ultimate-test-harness.sh | 19 +++++++++++-------- dev/atc.dev.sh | 12 +++++++++++- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index eace6ea309..e1f273ed31 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -30,14 +30,8 @@ declare -r cookie_name=dev-ciab-cookie source dev/atc.dev.sh export -f atc-ready -if ! timeout 10m <<'BASH_COMMANDS' bash; then -set -o errexit -o nounset -until atc-ready; do - echo 'Waiting until Traffic Ops is ready to accept requests...' - sleep 3 -done -echo 'Traffic Ops is ready to accept requests!' -BASH_COMMANDS +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...' @@ -100,6 +94,15 @@ done cdn_id="$(<<<"$server" jq .cdnId)" to-req "/snapshot?cdnID=${cdn_id}" --request PUT +deliveryservice=cdn.dev-ds.ciab.test +echo "Waiting for Delivery Service ${deliveryservice} to be available..." +if ! timeout 2m bash -c 'atc-ready -d'; then + echo "Delivery Service ${deliveryservice} was not available within 2 minutes!" + trap - ERR + echo 'Exiting...' + exit 1 +fi + http_result=0 dns_result=0 # Compile the tests go test -c ./traffic_router/ultimate-test-harness diff --git a/dev/atc.dev.sh b/dev/atc.dev.sh index 3bac609126..45519e9dc4 100644 --- a/dev/atc.dev.sh +++ b/dev/atc.dev.sh @@ -32,7 +32,15 @@ function atc-ready { if [[ $# -gt 0 ]]; then case "$1" in -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|--deliveryservice) + 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;; @@ -41,12 +49,14 @@ function atc-ready { 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 "-d, --wait wait for the ATC delivery service to be ready"; 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 "-d, --wait wait for the ATC delivery service to be ready" >&2; return 1;; esac fi From 9ca8687819103aea1c17dbd59757751c7435b94f Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Wed, 30 Mar 2022 14:22:39 -0600 Subject: [PATCH 19/44] Revert "Make API_VERSION read-only" --- dev/atc.dev.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dev/atc.dev.sh b/dev/atc.dev.sh index 45519e9dc4..b89089a375 100644 --- a/dev/atc.dev.sh +++ b/dev/atc.dev.sh @@ -172,8 +172,7 @@ function tm-health-client { return $?; } -declare -r API_VERSION=4.0 -export API_VERSION +export API_VERSION=4.0 export TO_URL="https://localhost:6443" export TO_USER="admin" export TO_PASSWORD="twelve12" From 2a9c893e148e3f16fd48c9e55f7849be4ce3e906 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Wed, 30 Mar 2022 14:33:00 -0600 Subject: [PATCH 20/44] Increase root logger threshold to WARN --- dev/traffic_router/conf/log4j2.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/traffic_router/conf/log4j2.xml b/dev/traffic_router/conf/log4j2.xml index 0b3e097975..17cbf2d899 100644 --- a/dev/traffic_router/conf/log4j2.xml +++ b/dev/traffic_router/conf/log4j2.xml @@ -27,7 +27,7 @@ - + From aa644ca34df21c035d8322e6b37d0c18ecb4b7b7 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Fri, 1 Apr 2022 12:06:21 -0600 Subject: [PATCH 21/44] Reuse to-access.sh functions for requests to Traffic Ops --- .../tr-ultimate-test-harness.sh | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index e1f273ed31..3ce9685467 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -38,16 +38,14 @@ if ! timeout 10m bash -c 'atc-ready -w'; then exit 1 fi -to-req() { - endpoint="$1" - shift - local curl_command=(curl --insecure --silent --cookie-jar "$cookie_name" --cookie "$cookie_name" "${TO_URL}/api/${API_VERSION}") - "${curl_command[@]}${endpoint}" "$@" | jq -} +while IFS= read -r line; do + export "$line"; +done < <( Date: Fri, 1 Apr 2022 12:12:57 -0600 Subject: [PATCH 22/44] Revert "Set TO API version in API_VERSION" --- dev/atc.dev.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dev/atc.dev.sh b/dev/atc.dev.sh index b89089a375..98a8b9d3f2 100644 --- a/dev/atc.dev.sh +++ b/dev/atc.dev.sh @@ -28,7 +28,7 @@ function atc-restart { } function atc-ready { - local url="https://localhost:6443/api/${API_VERSION}/ping"; + local url="https://localhost:6443/api/4.0/ping"; if [[ $# -gt 0 ]]; then case "$1" in -w|--wait) @@ -172,7 +172,6 @@ function tm-health-client { return $?; } -export API_VERSION=4.0 export TO_URL="https://localhost:6443" export TO_USER="admin" export TO_PASSWORD="twelve12" From e55484c90cfe678c8b4a9c3a286d063ea4968b52 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Thu, 7 Apr 2022 17:49:35 -0600 Subject: [PATCH 23/44] Wait for Traffic Monitor's snapshot before waiting for the Delivery Service --- .../tr-ultimate-test-harness/tr-ultimate-test-harness.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index 3ce9685467..ad65cbabb7 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -92,6 +92,14 @@ done cdn_id="$(<<<"$server" jq .cdnId)" to-put "api/$TO_API_VERSION/snapshot?cdnID=${cdn_id}" +echo "Waiting for Traffic Monitor to serve a snapshot..." +timeout 5m curl \ + --retry 99999 \ + --retry-delay 5 \ + --show-error \ + -fIso/dev/null \ + http://localhost/publish/CrConfig; + deliveryservice=cdn.dev-ds.ciab.test echo "Waiting for Delivery Service ${deliveryservice} to be available..." if ! timeout 2m bash -c 'atc-ready -d'; then From 3dd4725954906b40e6ebb02235cfb35c67598ec5 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Thu, 7 Apr 2022 18:09:24 -0600 Subject: [PATCH 24/44] CDN in a Box: Quote data strings --- .../cdn-in-a-box/traffic_ops/to-access.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/infrastructure/cdn-in-a-box/traffic_ops/to-access.sh b/infrastructure/cdn-in-a-box/traffic_ops/to-access.sh index cfd539dbf3..1863b2d58e 100755 --- a/infrastructure/cdn-in-a-box/traffic_ops/to-access.sh +++ b/infrastructure/cdn-in-a-box/traffic_ops/to-access.sh @@ -109,29 +109,29 @@ to-post() { local t local data if [[ -z "$2" ]]; then - data="" + data=() elif [[ -f "$2" ]]; then - data="--data @$2" + data=(--data "@${2}") else t=$(mktemp) - echo $2 >$t - data="--data @$t" + echo "$2" >$t + data=(--data "@${t}") fi to-auth && \ - curl $CURLAUTH $CURLOPTS -H 'Content-Type: application/json;charset=UTF-8' --cookie "$COOKIEJAR" -X POST $data "$TO_URL/$1" + curl $CURLAUTH $CURLOPTS -H 'Content-Type: application/json;charset=UTF-8' --cookie "$COOKIEJAR" -X POST "${data[@]}" "$TO_URL/$1" [[ -n $t ]] && rm -f "$t" } to-put() { if [[ $# -lt 2 || -z "$2" ]]; then - data="" + data=() elif [[ -f "$2" ]]; then - data="--data @$2" + data=(--data "@${2}") else - data="--data $2" + data=(--data "${2}") fi to-auth && \ - curl $CURLAUTH $CURLOPTS --cookie "$COOKIEJAR" -X PUT $data "$TO_URL/$1" + curl $CURLAUTH $CURLOPTS --cookie "$COOKIEJAR" -X PUT "${data[@]}" "$TO_URL/$1" } to-delete() { From aa169f65adce25e6df0a4a917544b3e0e2ec73dd Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Thu, 7 Apr 2022 18:10:50 -0600 Subject: [PATCH 25/44] Increase timeouts, just in case --- .../tr-ultimate-test-harness.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index ad65cbabb7..a2974821bd 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -93,17 +93,23 @@ cdn_id="$(<<<"$server" jq .cdnId)" to-put "api/$TO_API_VERSION/snapshot?cdnID=${cdn_id}" echo "Waiting for Traffic Monitor to serve a snapshot..." -timeout 5m curl \ +if ! timeout 10m curl \ --retry 99999 \ --retry-delay 5 \ --show-error \ -fIso/dev/null \ - http://localhost/publish/CrConfig; + http://localhost/publish/CrConfig; then + echo "CrConfig was not available from Traffic Monitor within 10 minutes!" + trap - ERR + echo 'Exiting...' + exit 1 +fi + deliveryservice=cdn.dev-ds.ciab.test echo "Waiting for Delivery Service ${deliveryservice} to be available..." -if ! timeout 2m bash -c 'atc-ready -d'; then - echo "Delivery Service ${deliveryservice} was not available within 2 minutes!" +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 From 5fde13e0e57464ee8d96b4bf21d2965f76f270fe Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Thu, 7 Apr 2022 18:25:09 -0600 Subject: [PATCH 26/44] Adjust thresholds for GitHub Actions performance --- .../tr-ultimate-test-harness/tr-ultimate-test-harness.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index a2974821bd..979a4d0628 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -116,13 +116,16 @@ if ! timeout 10m bash -c 'atc-ready -d'; then fi http_result=0 dns_result=0 + +http_requests_threshold=1200 +dns_requests_threshold=2500 # Compile the tests go test -c ./traffic_router/ultimate-test-harness -if ! ./ultimate-test-harness.test -test.v -test.run=^TestHTTPLoad$ -http_requests_threshold=5000; then +if ! ./ultimate-test-harness.test -test.v -test.run=^TestHTTPLoad$ -http_requests_threshold "$http_requests_threshold"; then http_result=1 fi -if ! ./ultimate-test-harness.test -test.v -test.run=^TestDNSLoad$ -dns_requests_threshold=20500; then +if ! ./ultimate-test-harness.test -test.v -test.run=^TestDNSLoad$ -dns_requests_threshold "$dns_requests_threshold"; then dns_result=1 fi if [[ $http_result -eq 0 && $dns_result -eq 0 ]]; then echo From cb4e898f73681ad59b629d52752b2fd9b657769d Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 00:03:59 -0600 Subject: [PATCH 27/44] Fetch environment variables in advance --- .../tr-ultimate-test-harness.sh | 7 +------ .../workflows/tr-ultimate-test-harness.yml | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index 979a4d0628..917697eb52 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -16,8 +16,6 @@ # specific language governing permissions and limitations # under the License. -export DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 # build Docker images faster - trap 'echo "Error on line ${LINENO} of ${0}"; exit 1' ERR; set -o xtrace set -o errexit -o nounset -o pipefail @@ -26,7 +24,7 @@ docker-compose up -d # Constants declare -r cookie_name=dev-ciab-cookie -# Set TO_USER, TO_PASSWORD, and TO_URL environment variables and get atc-ready function +# Get atc-ready function source dev/atc.dev.sh export -f atc-ready @@ -38,9 +36,6 @@ if ! timeout 10m bash -c 'atc-ready -w'; then exit 1 fi -while IFS= read -r line; do - export "$line"; -done < <(> .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: ${{ steps.go-version.outputs.value }} + go-version: ${{ env.GO_VERSION }} - name: Vendor dependencies run: go mod vendor - name: Build docker-compose services run: | - source dev/atc.dev.sh && - docker-compose build --parallel + docker-compose build --parallel && + docker-compose pull db - name: Cache local Maven repository uses: actions/cache@v2 with: From d445a4852859245759da990af966809f1ba85cb0 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 00:05:39 -0600 Subject: [PATCH 28/44] Remove commented lines --- .../tr-ultimate-test-harness/tr-ultimate-test-harness.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index 917697eb52..92d84291d4 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -38,10 +38,6 @@ fi source infrastructure/cdn-in-a-box/traffic_ops/to-access.sh -# Log in -#login_body="$(<<<{} jq --arg TO_USER "$TO_USER" --arg TO_PASSWORD "$TO_PASSWORD" '.u = $TO_USER | .p = $TO_PASSWORD')" -#to-post user/login "$login_body" - declare -A service_by_hostname service_by_hostname[trafficrouter]=trafficrouter service_by_hostname[edge]=t3c From 793c6cce6f5deb577315bffe559541c4a29c88a6 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 00:33:53 -0600 Subject: [PATCH 29/44] Start the Dev CDN in a Box in a separate step --- .../tr-ultimate-test-harness/tr-ultimate-test-harness.sh | 2 -- .github/workflows/tr-ultimate-test-harness.yml | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index 92d84291d4..7b7d4cfc74 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -19,8 +19,6 @@ trap 'echo "Error on line ${LINENO} of ${0}"; exit 1' ERR; set -o xtrace set -o errexit -o nounset -o pipefail -docker-compose up -d - # Constants declare -r cookie_name=dev-ciab-cookie diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index eea33ae4a8..58f598c18d 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -78,6 +78,8 @@ jobs: 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: Run Traffic Router Ultimate Test Harness run: ./.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh - name: Write Dev CDN-in-a-Box logs to files From d871b27d65fe90bac8e4769df37ea3a55dd362a3 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 00:34:30 -0600 Subject: [PATCH 30/44] Set interface IP addresses in a separate step --- .../tr-ultimate-test-harness.sh | 53 --------------- .../workflows/tr-ultimate-test-harness.yml | 66 +++++++++++++++++++ 2 files changed, 66 insertions(+), 53 deletions(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index 7b7d4cfc74..7a51c163cc 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -19,63 +19,10 @@ trap 'echo "Error on line ${LINENO} of ${0}"; exit 1' ERR; set -o xtrace set -o errexit -o nounset -o pipefail -# Constants -declare -r cookie_name=dev-ciab-cookie # 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 - -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 Traffic Router 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 Traffic Router'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}" - fi -done # Snapshot cdn_id="$(<<<"$server" jq .cdnId)" diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index 58f598c18d..e0fe3a38e6 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -80,6 +80,72 @@ jobs: ${{ runner.os }}-node-modules- - name: Start the Dev CDN in a Box run: docker-compose up -d + - 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 + + # 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 + + 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: Run Traffic Router Ultimate Test Harness run: ./.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh - name: Write Dev CDN-in-a-Box logs to files From 6a92e30dc0e2ca15abeaa145317bdc12e30f782b Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 01:01:44 -0600 Subject: [PATCH 31/44] Wait for Traffic Monitor to serve a snapshot in a separate step --- .../tr-ultimate-test-harness.sh | 18 ------------------ .github/workflows/tr-ultimate-test-harness.yml | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index 7a51c163cc..19b3381e4b 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -24,24 +24,6 @@ set -o errexit -o nounset -o pipefail source dev/atc.dev.sh export -f atc-ready -# Snapshot -cdn_id="$(<<<"$server" jq .cdnId)" -to-put "api/$TO_API_VERSION/snapshot?cdnID=${cdn_id}" - -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 - - deliveryservice=cdn.dev-ds.ciab.test echo "Waiting for Delivery Service ${deliveryservice} to be available..." if ! timeout 10m bash -c 'atc-ready -d'; then diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index e0fe3a38e6..b0466686f1 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -146,6 +146,22 @@ jobs: 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: Run Traffic Router Ultimate Test Harness run: ./.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh - name: Write Dev CDN-in-a-Box logs to files From 6e5d6962f6ac62b0962366e789d729e434bbaa32 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 01:05:04 -0600 Subject: [PATCH 32/44] Wait for Delivery Service to become available in a separate step --- .../tr-ultimate-test-harness.sh | 14 -------------- .github/workflows/tr-ultimate-test-harness.yml | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index 19b3381e4b..307728a6e0 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -17,22 +17,8 @@ # under the License. trap 'echo "Error on line ${LINENO} of ${0}"; exit 1' ERR; -set -o xtrace 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 be 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 - http_result=0 dns_result=0 http_requests_threshold=1200 diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index b0466686f1..fa7873eaf9 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -162,6 +162,24 @@ jobs: exit 1 fi + - name: Wait for Delivery Service to become available + 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 run: ./.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh - name: Write Dev CDN-in-a-Box logs to files From c07b58a6b9c0102499238b597acefcbbc024234a Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 01:06:01 -0600 Subject: [PATCH 33/44] Compile the tests in a separate step --- .../tr-ultimate-test-harness/tr-ultimate-test-harness.sh | 2 -- .github/workflows/tr-ultimate-test-harness.yml | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh index 307728a6e0..db84ce35f8 100755 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh @@ -23,8 +23,6 @@ http_result=0 dns_result=0 http_requests_threshold=1200 dns_requests_threshold=2500 -# Compile the tests -go test -c ./traffic_router/ultimate-test-harness if ! ./ultimate-test-harness.test -test.v -test.run=^TestHTTPLoad$ -http_requests_threshold "$http_requests_threshold"; then http_result=1 fi diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index fa7873eaf9..39bcf0cd7c 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -162,6 +162,9 @@ jobs: exit 1 fi + - name: Compile the tests + run: go test -c ./traffic_router/ultimate-test-harness + - name: Wait for Delivery Service to become available run: | trap 'echo "Error on line ${LINENO} of waiting for the Delivery Service to become available"; exit 1' ERR From bc3ad73e119073748578be5747c06aef8f4fd4bb Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 01:09:04 -0600 Subject: [PATCH 34/44] Run Traffic Router Ultimate Test Harness directly from workflow file --- .../tr-ultimate-test-harness.sh | 39 ------------------- .../workflows/tr-ultimate-test-harness.yml | 20 +++++++++- 2 files changed, 19 insertions(+), 40 deletions(-) delete mode 100755 .github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh diff --git a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh b/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh deleted file mode 100755 index db84ce35f8..0000000000 --- a/.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash -# 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 -# -# http://www.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. - -trap 'echo "Error on line ${LINENO} of ${0}"; exit 1' ERR; -set -o errexit -o nounset -o pipefail - -http_result=0 dns_result=0 - -http_requests_threshold=1200 -dns_requests_threshold=2500 -if ! ./ultimate-test-harness.test -test.v -test.run=^TestHTTPLoad$ -http_requests_threshold "$http_requests_threshold"; then - http_result=1 -fi - -if ! ./ultimate-test-harness.test -test.v -test.run=^TestDNSLoad$ -dns_requests_threshold "$dns_requests_threshold"; then - dns_result=1 -fi -if [[ $http_result -eq 0 && $dns_result -eq 0 ]]; then echo - echo Tests passed! -else - exit_code=$? - echo Tests failed! - exit $exit_code -fi diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index 39bcf0cd7c..333199fcd8 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -184,7 +184,25 @@ jobs: fi - name: Run Traffic Router Ultimate Test Harness - run: ./.github/actions/tr-ultimate-test-harness/tr-ultimate-test-harness.sh + run: | + trap 'echo "Error on line ${LINENO} of ${0}"; exit 1' ERR + set -o errexit -o nounset -o pipefail + + http_result=0 dns_result=0 + http_requests_threshold=1200 + dns_requests_threshold=2500 + if ! ./ultimate-test-harness.test -test.v -test.run=^TestHTTPLoad$ -http_requests_threshold "$http_requests_threshold"; then + http_result=1 + fi + if ! ./ultimate-test-harness.test -test.v -test.run=^TestDNSLoad$ -dns_requests_threshold "$dns_requests_threshold"; then + dns_result=1 + fi + if [[ $http_result -eq 0 && $dns_result -eq 0 ]]; then echo + echo Tests passed! + else + echo Tests failed! + exit 1 + fi - name: Write Dev CDN-in-a-Box logs to files run: | set -o errexit -o nounset From 36bc346bb5ce4357d5674634582e02a2964fa9bc Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 01:13:18 -0600 Subject: [PATCH 35/44] Wait until Traffic Ops is ready to accept requests in separate step --- .github/workflows/tr-ultimate-test-harness.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index 333199fcd8..19d87d5664 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -80,11 +80,9 @@ jobs: ${{ runner.os }}-node-modules- - name: Start the Dev CDN in a Box run: docker-compose up -d - - name: Set interface IP addresses - run: |2 + - 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 xtrace - # uncomment this line ^ to check interface data set -o errexit -o nounset -o pipefail # Get atc-ready function @@ -99,6 +97,13 @@ jobs: 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 @@ -185,7 +190,7 @@ jobs: - name: Run Traffic Router Ultimate Test Harness run: | - trap 'echo "Error on line ${LINENO} of ${0}"; exit 1' ERR + trap 'echo "Error on line ${LINENO} of running the Trafic Router Ultimate Test Harness"; exit 1' ERR set -o errexit -o nounset -o pipefail http_result=0 dns_result=0 From bb4257a86d0fee0e0fbec64a667b570d1ff667f0 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 01:29:03 -0600 Subject: [PATCH 36/44] Run HTTP and DNS tests in separate steps --- .../workflows/tr-ultimate-test-harness.yml | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/.github/workflows/tr-ultimate-test-harness.yml b/.github/workflows/tr-ultimate-test-harness.yml index 19d87d5664..3a106a17b7 100644 --- a/.github/workflows/tr-ultimate-test-harness.yml +++ b/.github/workflows/tr-ultimate-test-harness.yml @@ -171,6 +171,7 @@ jobs: 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 @@ -188,26 +189,13 @@ jobs: exit 1 fi - - name: Run Traffic Router Ultimate Test Harness - run: | - trap 'echo "Error on line ${LINENO} of running the Trafic Router Ultimate Test Harness"; exit 1' ERR - set -o errexit -o nounset -o pipefail + - 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() }} - http_result=0 dns_result=0 - http_requests_threshold=1200 - dns_requests_threshold=2500 - if ! ./ultimate-test-harness.test -test.v -test.run=^TestHTTPLoad$ -http_requests_threshold "$http_requests_threshold"; then - http_result=1 - fi - if ! ./ultimate-test-harness.test -test.v -test.run=^TestDNSLoad$ -dns_requests_threshold "$dns_requests_threshold"; then - dns_result=1 - fi - if [[ $http_result -eq 0 && $dns_result -eq 0 ]]; then echo - echo Tests passed! - else - echo Tests failed! - exit 1 - fi - name: Write Dev CDN-in-a-Box logs to files run: | set -o errexit -o nounset From 5b309cc9c7c35e6e7a40aab2d8ae08c086e392a9 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 15:57:44 -0600 Subject: [PATCH 37/44] Change flag to --delivery-service --- dev/atc.dev.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/atc.dev.sh b/dev/atc.dev.sh index 98a8b9d3f2..cc2ffb9c0c 100644 --- a/dev/atc.dev.sh +++ b/dev/atc.dev.sh @@ -36,7 +36,7 @@ function atc-ready { sleep 1; done return 0;; - -d|--deliveryservice) + -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.]\+$'; From 6ecdfc3e576ec46ef7f2ca92146b2d3703cc5543 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 16:05:43 -0600 Subject: [PATCH 38/44] Print usage message from here document --- dev/atc.dev.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/dev/atc.dev.sh b/dev/atc.dev.sh index cc2ffb9c0c..549e7f930c 100644 --- a/dev/atc.dev.sh +++ b/dev/atc.dev.sh @@ -28,7 +28,15 @@ 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 -w|--wait) @@ -45,18 +53,10 @@ function atc-ready { 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 "-d, --wait wait for the ATC delivery service to be 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 "-d, --wait wait for the ATC delivery service to be ready" >&2; + echo "$usage" >&2; return 1;; esac fi From 1bcd68855725895303223a48605763fc73aaa295 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 16:10:32 -0600 Subject: [PATCH 39/44] Print flag descriptions on next line --- dev/atc.dev.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dev/atc.dev.sh b/dev/atc.dev.sh index 549e7f930c..4c1370461c 100644 --- a/dev/atc.dev.sh +++ b/dev/atc.dev.sh @@ -32,9 +32,12 @@ function atc-ready { 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 + -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 From bd03b8f826f65e4e6747bb0d5eeb0b00e357a4e6 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 17:20:36 -0600 Subject: [PATCH 40/44] One environment variable or port per line --- dev/traffic_router/Dockerfile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/dev/traffic_router/Dockerfile b/dev/traffic_router/Dockerfile index 62ba1a05c2..f0568c1eb2 100644 --- a/dev/traffic_router/Dockerfile +++ b/dev/traffic_router/Dockerfile @@ -14,9 +14,19 @@ FROM alpine:latest AS trafficrouter-dev ENV TC=/root/go/src/github.com/apache/trafficcontrol -VOLUME /root/go/src/github.com/apache/trafficcontrol -ENV JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n" JAVA_HOME=/usr/lib/jvm/java-11-openjdk M2_HOME=/root/go/src/github.com/apache/trafficcontrol/.m2 CATALINA_BASE=/opt/traffic_router TRAFFIC_MONITOR_HOSTS=trafficmonitor CATALINA_OPTS=-Dlog4j.configurationFile=/opt/traffic_router/conf/log4j2.xml -EXPOSE 3053:53/tcp 3053:53/udp 3080:80 3443:443 3333:3333 2222:3443 5005:5005 +VOLUME "$TC" +ENV JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n" \ + JAVA_HOME=/usr/lib/jvm/java-11-openjdk M2_HOME=${TC}/trafficcontrol/.m2 \ + CATALINA_BASE=/opt/traffic_router \ + TRAFFIC_MONITOR_HOSTS=trafficmonitor \ + CATALINA_OPTS=-Dlog4j.configurationFile=/opt/traffic_router/conf/log4j2.xml +EXPOSE 3053:53/tcp \ + 3053:53/udp \ + 3080:80 \ + 3443:443 \ + 3333:3333 \ + 2222:3443 \ + 5005:5005 RUN apk add --no-cache openjdk11 inotify-tools maven tomcat-native openssl && ln -s /usr/lib/jvm/java-11-openjdk/bin/jdb /bin/jdb From 986fe2b9e9aafff52bc78b5f501abdbf71ea0924 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 17:23:24 -0600 Subject: [PATCH 41/44] Set UID and GID from file ownership at runtime --- dev/traffic_router/Dockerfile | 11 +++-------- dev/traffic_router/run.sh | 15 +++++++++++---- dev/traffic_router/settings.xml | 2 +- docker-compose.yml | 5 +---- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/dev/traffic_router/Dockerfile b/dev/traffic_router/Dockerfile index f0568c1eb2..cc8eec7543 100644 --- a/dev/traffic_router/Dockerfile +++ b/dev/traffic_router/Dockerfile @@ -13,7 +13,7 @@ # FROM alpine:latest AS trafficrouter-dev -ENV TC=/root/go/src/github.com/apache/trafficcontrol +ENV TC=/go/src/github.com/apache/trafficcontrol VOLUME "$TC" ENV JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n" \ JAVA_HOME=/usr/lib/jvm/java-11-openjdk M2_HOME=${TC}/trafficcontrol/.m2 \ @@ -32,17 +32,12 @@ RUN apk add --no-cache openjdk11 inotify-tools maven tomcat-native openssl && ln ADD https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.43/bin/apache-tomcat-9.0.43.tar.gz /opt/tomcat.tgz -ARG USER -ARG UID -RUN adduser -H -D ${USER} -u ${UID} -RUN chown -R ${UID}:${UID} /opt /usr/share/java/ /root -USER ${USER} RUN cd /opt && \ tar -xf tomcat.tgz && \ mv apache-tomcat-* tomcat && \ rm -r tomcat.tgz tomcat/webapps/* /usr/share/java/maven-3/conf/settings.xml && \ - ln -s /root/go/src/github.com/apache/trafficcontrol/dev/traffic_router /opt/traffic_router + ln -s "${TC}/dev/traffic_router" /opt/traffic_router COPY settings.xml /usr/share/java/maven-3/conf/settings.xml -CMD /root/go/src/github.com/apache/trafficcontrol/dev/traffic_router/run.sh +CMD "${TC}/dev/traffic_router/run.sh" diff --git a/dev/traffic_router/run.sh b/dev/traffic_router/run.sh index 3b40c2f9e7..9ec211f188 100755 --- a/dev/traffic_router/run.sh +++ b/dev/traffic_router/run.sh @@ -18,11 +18,18 @@ set -o errexit + + + cd "$TC/traffic_router" +user=trafficrouter +uid="$(stat -c%u .)" +gid="$(stat -c%g .)" +adduser -Du"$uid" "$user" +sed -Ei "s/^(${user}:.*:)[0-9]+(:)$/\1${gid}\2/" /etc/group +chown -R "${uid}:${gid}" /opt -mvn -Dmaven.test.skip=true compile package -P \!rpm-build -chmod -R a+rw "$TC/dev/traffic_router/" +su "$user" -- /usr/bin/mvn -Dmaven.test.skip=true compile package -P \!rpm-build cd "$TC/dev/traffic_router" - -/opt/tomcat/bin/catalina.sh jpda run +exec su "$user" -- /opt/tomcat/bin/catalina.sh jpda run diff --git a/dev/traffic_router/settings.xml b/dev/traffic_router/settings.xml index ad86e7e4b9..3784210481 100644 --- a/dev/traffic_router/settings.xml +++ b/dev/traffic_router/settings.xml @@ -17,5 +17,5 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" > - /root/go/src/github.com/apache/trafficcontrol/.m2/repository/ + /go/src/github.com/apache/trafficcontrol/.m2/repository/ diff --git a/docker-compose.yml b/docker-compose.yml index 8a92865ed3..cb5ce192c2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -113,9 +113,6 @@ services: trafficrouter: build: context: dev/traffic_router - args: - - USER=${USER:-atc} - - UID=${UID:-1000} depends_on: - trafficmonitor hostname: trafficrouter @@ -131,7 +128,7 @@ services: - 2222:3443 - 5005:5005 volumes: - - .:/root/go/src/github.com/apache/trafficcontrol + - .:/go/src/github.com/apache/trafficcontrol networks: ciab: name: dev.ciab.test From ab210732fce0b8f767b650bef361a99918deb28d Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 17:47:08 -0600 Subject: [PATCH 42/44] /root/go -> /go in parameters --- dev/traffic_ops/seed.psql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/traffic_ops/seed.psql b/dev/traffic_ops/seed.psql index 548f584231..7fb5faaf73 100644 --- a/dev/traffic_ops/seed.psql +++ b/dev/traffic_ops/seed.psql @@ -46,7 +46,7 @@ INSERT INTO snapshot ( monitoring ) VALUES ( 'dev', - '{"config":{"coveragezone.polling.url":"file:///root/go/src/github.com/apache/trafficcontrol/dev/traffic_router/czf.json","dnssec.enabled":"false","domain_name":"ciab.test","geolocation.polling.url":"file:///root/go/src/github.com/apache/trafficcontrol/traffic_router/core/src/test/resources/geo/GeoLite2-City.mmdb.gz"},"contentServers":{"edge":{"cacheGroup":"dev","fqdn":"edge.dev.ciab.test","hashCount":999,"hashId":"edge","httpsPort":443,"interfaceName":"eth0","ip":"129.0.0.2","ip6":"","locationId":"dev","port":80,"profile":"EDGE_dev","status":"REPORTED","type":"EDGE","deliveryServices":{"dev-ds":["edge.dev-ds.ciab.test"]},"routingDisabled":0}},"contentRouters":{"trafficrouter":{"fqdn":"trafficrouter.dev.ciab.test","httpsPort":443,"ip":"","ip6":"","location":"tr-cg","port":80,"profile":"CCR_dev","status":"ONLINE"}},"deliveryServices":{"dev-ds":{"anonymousBlockingEnabled":"false","coverageZoneOnly":"false","deepCachingType":"NEVER","dispersion":{"limit":1,"shuffled":"true"},"domains":["dev-ds.ciab.test"],"ecsEnabled":"false","geolocationProvider":"maxmindGeolocationService","ip6RoutingEnabled":"false","matchsets":[{"protocol":"HTTP","matchlist":[{"regex":".*\\.dev-ds\\..*","match-type":"HOST"}]}],"missLocation":{"lat":1,"long":1},"protocol":{"acceptHttps":"false","redirectToHttps":"false"},"regionalGeoBlocking":"false","routingName":"cdn","soa":{"admin":"traffic_ops","expire":"604800","minimum":"30","refresh":"28800","retry":"7200"},"sslEnabled":"false","ttls":{"A":"","AAAA":"","NS":"3600","SOA":"86400"}}},"edgeLocations":{"dev":{"latitude":1,"longitude":1,"backupLocations":{"fallbackToClosest":"true"},"localizationMethods":["GEO","CZ","DEEP_CZ"]}},"trafficRouterLocations":{"tr-cg":{"latitude":1,"longitude":1,"backupLocations":{"fallbackToClosest":"false"},"localizationMethods":["GEO","CZ","DEEP_CZ"]}},"monitors":{"trafficmonitor":{"fqdn":"trafficmonitor.dev.ciab.test","httpsPort":null,"ip":"129.0.0.1","ip6":"","location":"dev","port":80,"profile":"RASCAL_TM_dev","status":"ONLINE"}},"stats":{"CDN_name":"dev","date":1649361181,"tm_host":"trafficops","tm_user":"admin","tm_version":"development"}}', + '{"config":{"coveragezone.polling.url":"file:///go/src/github.com/apache/trafficcontrol/dev/traffic_router/czf.json","dnssec.enabled":"false","domain_name":"ciab.test","geolocation.polling.url":"file:///go/src/github.com/apache/trafficcontrol/traffic_router/core/src/test/resources/geo/GeoLite2-City.mmdb.gz"},"contentServers":{"edge":{"cacheGroup":"dev","fqdn":"edge.dev.ciab.test","hashCount":999,"hashId":"edge","httpsPort":443,"interfaceName":"eth0","ip":"129.0.0.2","ip6":"","locationId":"dev","port":80,"profile":"EDGE_dev","status":"REPORTED","type":"EDGE","deliveryServices":{"dev-ds":["edge.dev-ds.ciab.test"]},"routingDisabled":0}},"contentRouters":{"trafficrouter":{"fqdn":"trafficrouter.dev.ciab.test","httpsPort":443,"ip":"","ip6":"","location":"tr-cg","port":80,"profile":"CCR_dev","status":"ONLINE"}},"deliveryServices":{"dev-ds":{"anonymousBlockingEnabled":"false","coverageZoneOnly":"false","deepCachingType":"NEVER","dispersion":{"limit":1,"shuffled":"true"},"domains":["dev-ds.ciab.test"],"ecsEnabled":"false","geolocationProvider":"maxmindGeolocationService","ip6RoutingEnabled":"false","matchsets":[{"protocol":"HTTP","matchlist":[{"regex":".*\\.dev-ds\\..*","match-type":"HOST"}]}],"missLocation":{"lat":1,"long":1},"protocol":{"acceptHttps":"false","redirectToHttps":"false"},"regionalGeoBlocking":"false","routingName":"cdn","soa":{"admin":"traffic_ops","expire":"604800","minimum":"30","refresh":"28800","retry":"7200"},"sslEnabled":"false","ttls":{"A":"","AAAA":"","NS":"3600","SOA":"86400"}}},"edgeLocations":{"dev":{"latitude":1,"longitude":1,"backupLocations":{"fallbackToClosest":"true"},"localizationMethods":["GEO","CZ","DEEP_CZ"]}},"trafficRouterLocations":{"tr-cg":{"latitude":1,"longitude":1,"backupLocations":{"fallbackToClosest":"false"},"localizationMethods":["GEO","CZ","DEEP_CZ"]}},"monitors":{"trafficmonitor":{"fqdn":"trafficmonitor.dev.ciab.test","httpsPort":null,"ip":"129.0.0.1","ip6":"","location":"dev","port":80,"profile":"RASCAL_TM_dev","status":"ONLINE"}},"stats":{"CDN_name":"dev","date":1649361181,"tm_host":"trafficops","tm_user":"admin","tm_version":"development"}}', '{"trafficServers":[{"profile":"EDGE_dev","status":"REPORTED","port":80,"cachegroup":"dev","hostname":"edge","fqdn":"edge.dev.ciab.test","interfaces":[{"ipAddresses":[{"address":"129.0.0.2","gateway":null,"serviceAddress":true}],"maxBandwidth":null,"monitor":true,"mtu":1500,"name":"eth0"}],"type":"EDGE","hashid":"","deliveryServices":[{"xmlId":"dev-ds"}]}],"trafficMonitors":[{"profile":"RASCAL_TM_dev","status":"ONLINE","port":80,"cachegroup":"dev","hostname":"trafficmonitor","fqdn":"trafficmonitor.dev.ciab.test","ip":"129.0.0.1","ip6":""}],"cacheGroups":[{"name":"dev","coordinates":{"latitude":1,"longitude":1}},{"name":"tr-cg","coordinates":{"latitude":1,"longitude":1}}],"profiles":[{"name":"CCR_dev","type":"CCR","parameters":null},{"name":"EDGE_dev","type":"EDGE","parameters":{"health.polling.format":"stats_over_http","health.polling.url":"http://edge:8080/_stats?application=\\u0026inf.name=${interface_name}"}}],"deliveryServices":[{"xmlId":"dev-ds","totalTpsThreshold":0,"status":"REPORTED","totalKbpsThreshold":0,"type":"HTTP","topology":"","hostRegexes":[".*\\.dev-ds\\..*"]}],"config":{"health.polling.interval":6000,"heartbeat.polling.interval":3000,"peers.polling.interval":3000,"tm.polling.interval":2000},"topologies":{}}' ) ON CONFLICT DO NOTHING; @@ -105,11 +105,11 @@ INSERT INTO parameter ( ), ( 'CRConfig.json', 'geolocation.polling.url', - 'file:///root/go/src/github.com/apache/trafficcontrol/traffic_router/core/src/test/resources/geo/GeoLite2-City.mmdb.gz' + 'file:///go/src/github.com/apache/trafficcontrol/traffic_router/core/src/test/resources/geo/GeoLite2-City.mmdb.gz' ), ( 'CRConfig.json', 'coveragezone.polling.url', - 'file:///root/go/src/github.com/apache/trafficcontrol/dev/traffic_router/czf.json' + 'file:///go/src/github.com/apache/trafficcontrol/dev/traffic_router/czf.json' ), ( 'global', 'tm.url', From b3f63db3954e4db4f002f92c6b9d7246d25e9484 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 17:53:09 -0600 Subject: [PATCH 43/44] Only indent once --- dev/traffic_router/Dockerfile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/dev/traffic_router/Dockerfile b/dev/traffic_router/Dockerfile index cc8eec7543..c30c9bf2cc 100644 --- a/dev/traffic_router/Dockerfile +++ b/dev/traffic_router/Dockerfile @@ -16,17 +16,17 @@ FROM alpine:latest AS trafficrouter-dev ENV TC=/go/src/github.com/apache/trafficcontrol VOLUME "$TC" ENV JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n" \ - JAVA_HOME=/usr/lib/jvm/java-11-openjdk M2_HOME=${TC}/trafficcontrol/.m2 \ - CATALINA_BASE=/opt/traffic_router \ - TRAFFIC_MONITOR_HOSTS=trafficmonitor \ - CATALINA_OPTS=-Dlog4j.configurationFile=/opt/traffic_router/conf/log4j2.xml + JAVA_HOME=/usr/lib/jvm/java-11-openjdk M2_HOME=${TC}/trafficcontrol/.m2 \ + CATALINA_BASE=/opt/traffic_router \ + TRAFFIC_MONITOR_HOSTS=trafficmonitor \ + CATALINA_OPTS=-Dlog4j.configurationFile=/opt/traffic_router/conf/log4j2.xml EXPOSE 3053:53/tcp \ - 3053:53/udp \ - 3080:80 \ - 3443:443 \ - 3333:3333 \ - 2222:3443 \ - 5005:5005 + 3053:53/udp \ + 3080:80 \ + 3443:443 \ + 3333:3333 \ + 2222:3443 \ + 5005:5005 RUN apk add --no-cache openjdk11 inotify-tools maven tomcat-native openssl && ln -s /usr/lib/jvm/java-11-openjdk/bin/jdb /bin/jdb From a5b246f88a682ecaf393e0cc0209cab5005006cf Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Mon, 11 Apr 2022 18:01:18 -0600 Subject: [PATCH 44/44] Remove unused USER and UID exports --- dev/atc.dev.sh | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/dev/atc.dev.sh b/dev/atc.dev.sh index 4c1370461c..5faf7236f6 100644 --- a/dev/atc.dev.sh +++ b/dev/atc.dev.sh @@ -178,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; -