Skip to content

Commit

Permalink
Merge pull request #1066 from openziti/debug-add-identity-from-url-ce…
Browse files Browse the repository at this point in the history
…rt-key

print logs and debug facts if the test fails
  • Loading branch information
qrkourier authored Jan 7, 2025
2 parents ca54079 + 08115bd commit e83cfce
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: CI build
# callable workflows' jobs appear in the calling workflow's run, so clicking this workflow in GitHub shows no runs
name: Callable CMake Build

on:
workflow_dispatch:
Expand Down
9 changes: 8 additions & 1 deletion docker/compose.test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
services:

httpbin:
image: mccutchen/go-httpbin
expose:
Expand All @@ -9,13 +10,19 @@ services:
ziti-tun:
pull_policy: never
command: run --verbose=4 --dns-ip-range=100.95.255.128/25
environment:
- ZITI_LOG=4

ziti-host:
pull_policy: never
depends_on:
httpbin:
condition: service_started
networks:
- quickstart
command: run-host --verbose=4
# entrypoint: ["bash", "-x", "/docker-entrypoint.sh"]
environment:
- ZITI_LOG=4

quickstart:
image: ${ZITI_CLI_IMAGE:-docker.io/openziti/ziti-controller}:${ZITI_CLI_TAG:-latest}
Expand Down
61 changes: 51 additions & 10 deletions docker/docker.test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,39 @@ cleanup(){
echo "DEBUG: cleanup complete"
}

debug(){

set -o errexit
docker compose logs
docker compose exec -T quickstart bash << BASH
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace
ziti edge list edge-routers
ziti edge list terminators
ziti edge policy-advisor services httpbin-service --quiet
BASH

for SVC in ziti-{host,tun}
do
docker compose exec -T "${SVC}" bash << BASH || true
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace
ziti-edge-tunnel tunnel_status | jq
BASH
done

}

checkCommand() {
if ! command -v "$1" &>/dev/null; then
logError "this script requires command '$1'."
Expand Down Expand Up @@ -85,7 +118,7 @@ export \
ZITI_EDGE_TUNNEL_IMAGE \
ZITI_EDGE_TUNNEL_TAG \
ZITI_HOST_IMAGE \
ZITI_HOST_TAG \
ZITI_HOST_TAG

export COMPOSE_FILE="docker/compose.intercept.yml:docker/compose.host.yml:docker/compose.test.yml"

Expand Down Expand Up @@ -154,23 +187,31 @@ BASH

ZITI_ENROLL_TOKEN="$(docker compose exec quickstart cat /tmp/httpbin-host.ott.jwt)" \
docker compose up ziti-host --detach
docker compose up httpbin --detach

ZITI_ENROLL_TOKEN="$(docker compose exec quickstart cat /tmp/httpbin-client.ott.jwt)" \
docker compose up ziti-tun --detach

ATTEMPTS=5
DELAY=3
ATTEMPTS=2
DELAY=1

curl_cmd="curl --fail --max-time 1 --silent --show-error --request POST --header 'Content-Type: application/json' --data '{\"ziti\": \"works\"}' http://httpbin.ziti.internal/post"
curl_cmd="curl --fail --connect-timeout 1 --silent --show-error --request POST --header 'Content-Type: application/json' --data '{\"ziti\": \"works\"}' http://httpbin.ziti.internal/post"
until ! ((ATTEMPTS)) || eval "${curl_cmd}" &> /dev/null
do
(( ATTEMPTS-- ))
echo "Waiting for httpbin service"
: $ATTEMPTS remaining attempts - waiting for httpbin service
docker compose ps
sleep ${DELAY}
done
eval "${curl_cmd}" | jq .json

(( I_AM_ROBOT )) || read -p "Press [Enter] to continue..."

cleanup
if eval "${curl_cmd}" | jq .json
then
(( I_AM_ROBOT )) || read -rp "Press [Enter] to continue..."
cleanup
: PASSED
exit 0
else
debug
cleanup
: FAILED
exit 1
fi

0 comments on commit e83cfce

Please sign in to comment.