Skip to content

Commit

Permalink
Merge pull request #2396 from openziti/test-zac-deployments
Browse files Browse the repository at this point in the history
test zac deployments
  • Loading branch information
qrkourier authored Sep 11, 2024
2 parents 738ddfb + 85aec67 commit 8d59ad0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
26 changes: 25 additions & 1 deletion dist/dist-packages/linux/linux.test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ cleanup(){
fi
)||true
done
if [[ -d "${ZITI_CONSOLE_LOCATION}" ]]
then
sudo rm -rf "${ZITI_CONSOLE_LOCATION}"
fi
echo "DEBUG: cleanup complete"
}

Expand All @@ -58,7 +62,7 @@ BASEDIR="$(cd "$(dirname "${0}")" && pwd)"
REPOROOT="$(cd "${BASEDIR}/../../.." && pwd)"
cd "${REPOROOT}"

declare -a BINS=(grep go nc nfpm)
declare -a BINS=(grep go nc nfpm curl unzip)
for BIN in "${BINS[@]}"; do
checkCommand "$BIN"
done
Expand All @@ -73,6 +77,7 @@ done
: "${ZITI_ROUTER_NAME:="linux-router1"}"
: "${ZITI_ROUTER_ADVERTISED_ADDRESS:="${ZITI_ROUTER_NAME}.127.0.0.1.sslip.io"}"
: "${ZITI_ENROLL_TOKEN:="${TMPDIR}/${ZITI_ROUTER_NAME}.jwt"}"
: "${ZITI_CONSOLE_LOCATION:="/opt/openziti/share/consoletest"}"

export \
ZITI_GO_VERSION \
Expand Down Expand Up @@ -115,6 +120,7 @@ ZITI_ENROLL_TOKEN=/tmp/${ZITI_ROUTER_NAME}.jwt \
sudo /opt/openziti/etc/controller/bootstrap.bash << CTRL
ZITI_CTRL_ADVERTISED_ADDRESS="${ZITI_CTRL_ADVERTISED_ADDRESS}"
ZITI_CTRL_ADVERTISED_PORT="${ZITI_CTRL_ADVERTISED_PORT}"
ZITI_CONSOLE_LOCATION="${ZITI_CONSOLE_LOCATION}"
ZITI_USER="admin"
ZITI_PWD="${ZITI_PWD}"
CTRL
Expand All @@ -141,6 +147,11 @@ do
done
ziti edge create edge-router "${ZITI_ROUTER_NAME}" -to "${ZITI_ENROLL_TOKEN}"

# fetch and install ziti console
sudo mkdir -p "${ZITI_CONSOLE_LOCATION}"
sudo tee "${ZITI_CONSOLE_LOCATION}/index.html" <<< "I am ZAC"
sudo chmod -R +rX "${ZITI_CONSOLE_LOCATION}"

sudo /opt/openziti/etc/router/bootstrap.bash << ROUTER
ZITI_CTRL_ADVERTISED_ADDRESS="${ZITI_CTRL_ADVERTISED_ADDRESS}"
ZITI_CTRL_ADVERTISED_PORT="${ZITI_CTRL_ADVERTISED_PORT}"
Expand Down Expand Up @@ -175,4 +186,17 @@ ZITI_CTRL_EDGE_ADVERTISED_ADDRESS=${ZITI_CTRL_ADVERTISED_ADDRESS} \
ZITI_CTRL_EDGE_ADVERTISED_PORT=${ZITI_CTRL_ADVERTISED_PORT} \
go test -v -count=1 -tags="quickstart manual" ./ziti/cmd/edge/...

ATTEMPTS=5
DELAY=3

# verify console is available
curl_cmd="curl -skSfw '%{http_code}\t%{url}\n' -o/dev/null \"https://${ZITI_CTRL_ADVERTISED_ADDRESS}:${ZITI_CTRL_ADVERTISED_PORT}/zac/\""
until ! ((ATTEMPTS)) || eval "${curl_cmd}" &> /dev/null
do
(( ATTEMPTS-- ))
echo "Waiting for zac"
sleep ${DELAY}
done
eval "${curl_cmd}"

cleanup
15 changes: 14 additions & 1 deletion dist/docker-images/compose.test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ BASEDIR="$(cd "$(dirname "${0}")" && pwd)"
REPOROOT="$(cd "${BASEDIR}/../.." && pwd)"
cd "${REPOROOT}"

declare -a BINS=(grep docker go nc)
declare -a BINS=(grep docker go nc curl)
for BIN in "${BINS[@]}"; do
checkCommand "$BIN"
done
Expand Down Expand Up @@ -128,4 +128,17 @@ ZITI_CTRL_EDGE_ADVERTISED_ADDRESS=${ZITI_CTRL_ADVERTISED_ADDRESS} \
ZITI_CTRL_EDGE_ADVERTISED_PORT=${ZITI_CTRL_ADVERTISED_PORT} \
go test -v -count=1 -tags="quickstart manual" ./ziti/cmd/edge/...

ATTEMPTS=5
DELAY=3

# verify console is available
curl_cmd="curl -skSfw '%{http_code}\t%{url}\n' -o/dev/null \"https://${ZITI_CTRL_ADVERTISED_ADDRESS}:${ZITI_CTRL_ADVERTISED_PORT}/zac/\""
until ! ((ATTEMPTS)) || eval "${curl_cmd}" &> /dev/null
do
(( ATTEMPTS-- ))
echo "Waiting for zac"
sleep ${DELAY}
done
eval "${curl_cmd}"

cleanup

0 comments on commit 8d59ad0

Please sign in to comment.