Skip to content

Commit

Permalink
reset sharding-e2e-test.sh changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fghanmi committed Jul 23, 2024
1 parent adefa6b commit 9117ec8
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions tests/sharding-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,20 @@ set -ex
# Things to install first:
# - jq, createtree

docker_compose="docker compose"
if ! ${docker_compose} version >/dev/null 2>&1; then
docker_compose="docker-compose"
fi

# Spin up services as usual

echo "Installing createtree..."
go install github.com/google/trillian/cmd/createtree@latest

echo "starting services"
${docker_compose} up -d --build
docker-compose up -d
rm ~/.rekor/state.json || true

echo "building CLI"
echo "building CLI and server"
go build -o rekor-cli ./cmd/rekor-cli
REKOR_CLI=$(pwd)/rekor-cli
go build -o rekor-server ./cmd/rekor-server


function check_log_index () {
logIndex=$1
Expand Down Expand Up @@ -67,7 +64,7 @@ function waitForRekorServer () {
count=0

echo -n "waiting up to 60 sec for system to start"
until [ $(${docker_compose} ps | grep -c "(healthy)") == 3 ];
until [ $(docker-compose ps | grep -c "(healthy)") == 3 ];
do
if [ $count -eq 6 ]; then
echo "! timeout reached"
Expand All @@ -87,17 +84,17 @@ function waitForRekorServer () {
function collectLogsOnFailure () {
if [[ "$1" -ne "0" ]]; then
echo "failure detected, collecting docker-compose logs"
${docker_compose} logs --no-color > /tmp/docker-compose.log
docker-compose logs --no-color > /tmp/docker-compose.log
exit $1
elif ${docker_compose} logs --no-color | grep -q "panic: runtime error:" ; then
elif docker-compose logs --no-color | grep -q "panic: runtime error:" ; then
# if we're here, we found a panic
echo "failing due to panics detected in logs"
${docker_compose} logs --no-color > /tmp/docker-compose.log
docker-compose logs --no-color > /tmp/docker-compose.log
exit 1
fi
exit 0
}
trap "collectLogsOnFailure \$?" EXIT
trap "collectLogsOnFailure $?" EXIT

echo "Waiting for rekor server to come up..."
waitForRekorServer
Expand Down Expand Up @@ -192,7 +189,7 @@ EOF

# Spin up the new Rekor

${docker_compose} -f $COMPOSE_FILE up -d
docker-compose -f $COMPOSE_FILE up -d
waitForRekorServer
$REKOR_CLI loginfo --rekor_server http://localhost:3000

Expand Down Expand Up @@ -268,13 +265,13 @@ NUM_ELEMENTS=$(curl -f -H "Content-Type: application/json" --data '{"logIndexes"
stringsMatch $NUM_ELEMENTS "2"

# Make sure we get the expected LogIndex in the response when calling /retrieve endpoint
RETRIEVE_LOGINDEX1=$(curl -f http://localhost:3000/api/v1/log/entries/retrieve -H "Content-Type: application/json" -H "Accept: application/json" -d "{ \"logIndexes\": [1]}" | jq '.[0]' | jq -r "with_entries(select(.key|test(\"^"$ENTRY_ID_1"$\"))) | .[].logIndex")
RETRIEVE_LOGINDEX1=$(curl -f http://localhost:3000/api/v1/log/entries/retrieve -H "Content-Type: application/json" -H "Accept: application/json" -d "{ \"logIndexes\": [1]}" | jq '.[0]' | jq -r .$UUID1.logIndex)
stringsMatch $RETRIEVE_LOGINDEX1 "1"

# Make sure that verification succeeds via UUID
echo
echo "Testing rekor-cli verification via UUID..."
$REKOR_CLI verify --uuid $ENTRY_ID_1 --rekor_server http://localhost:3000
$REKOR_CLI verify --uuid $UUID1 --rekor_server http://localhost:3000

# Make sure that verification succeeds via Entry ID (Tree ID in hex + UUID)
echo
Expand Down

0 comments on commit 9117ec8

Please sign in to comment.