Skip to content

Commit

Permalink
Replace docker-compose with plugin if available (#2153)
Browse files Browse the repository at this point in the history
Fixes CI error "ERROR: for rekor_rekor-server_1  'ContainerConfig'".

Signed-off-by: Colleen Murphy <[email protected]>
  • Loading branch information
cmurphy authored Jun 19, 2024
1 parent 332c7ca commit abcdf4b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
35 changes: 20 additions & 15 deletions tests/issue-872-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@
set -e
testdir=$(dirname "$0")

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

echo "* starting services"
docker-compose up -d
${docker_compose} up -d

echo "* building CLI"
go build -o rekor-cli ./cmd/rekor-cli
Expand Down Expand Up @@ -50,7 +55,7 @@ trap "rm -rf $REKORTMPDIR" EXIT
waitForRekorServer

echo "* stopping rekor to test issue #872"
docker-compose stop rekor-server
${docker_compose} stop rekor-server

docker volume rm -f issue872_attestations || true
ATT_VOLUME=$(docker volume create --name issue872_attestations)
Expand Down Expand Up @@ -90,7 +95,7 @@ volumes:
EOF

echo "* starting rekor v0.6.0 to test issue #872"
docker-compose -f $V060_COMPOSE_FILE --project-directory=$PWD up -d rekor-server-issue-872-v060
${docker_compose} -f $V060_COMPOSE_FILE --project-directory=$PWD up -d rekor-server-issue-872-v060
sleep 5

# this rekor-cli image is based on v0.6.0 and has the fix for issue #800
Expand All @@ -104,8 +109,8 @@ V060_UPLOAD_OUTPUT=$REKORTMPDIR/issue-872-upload-output
echo "* inserting intoto entry into Rekor v0.6.0"
if ! $ISSUE800_CLI upload --type intoto --artifact tests/intoto_dsse.json --public-key tests/intoto_dsse.pem --format=json --rekor_server=http://localhost:3000 > $V060_UPLOAD_OUTPUT; then
echo "* failed to insert intoto entry to test issue #872, exiting"
docker-compose logs --no-color > /tmp/docker-compose.log
docker-compose -f $V060_COMPOSE_FILE --project-directory=$PWD logs rekor-server-issue-872-v060 > /tmp/post-insert-docker-compose.log
${docker_compose} logs --no-color > /tmp/docker-compose.log
${docker_compose} -f $V060_COMPOSE_FILE --project-directory=$PWD logs rekor-server-issue-872-v060 > /tmp/post-insert-docker-compose.log
exit 1
fi

Expand All @@ -114,8 +119,8 @@ V060_GET_OUTPUT=$REKORTMPDIR/issue-872-get-output
echo "* read back entry from Rekor v0.6.0"
if ! $ISSUE800_CLI get --log-index=$ISSUE872_UPLOAD_INDEX --format=json --rekor_server=http://localhost:3000 > $V060_GET_OUTPUT; then
echo "* failed to retrieve entry from rekor v0.6.0 to test issue #872, exiting"
docker-compose logs --no-color > /tmp/docker-compose.log
docker-compose -f $V060_COMPOSE_FILE --project-directory=$PWD logs rekor-server-issue-872-v060 > /tmp/post-insert-docker-compose.log
${docker_compose} logs --no-color > /tmp/docker-compose.log
${docker_compose} -f $V060_COMPOSE_FILE --project-directory=$PWD logs rekor-server-issue-872-v060 > /tmp/post-insert-docker-compose.log
exit 1
fi

Expand All @@ -124,16 +129,16 @@ V060_ATT_LENGTH=$(jq -r '.Attestation | length' $V060_GET_OUTPUT)
if [ $V060_ATT_LENGTH -eq 0 ]; then
echo "* failed to read back attestation while testing issue #872 against rekor v0.6.0, exiting"
cat $V060_GET_OUTPUT
docker-compose logs --no-color > /tmp/docker-compose.log
docker-compose -f $V060_COMPOSE_FILE --project-directory=$PWD logs rekor-server-issue-872-v060 > /tmp/post-insert-docker-compose.log
${docker_compose} logs --no-color > /tmp/docker-compose.log
${docker_compose} -f $V060_COMPOSE_FILE --project-directory=$PWD logs rekor-server-issue-872-v060 > /tmp/post-insert-docker-compose.log
exit 1
fi

echo "* grabbing TreeID to use when starting older version"
REKOR_TRILLIAN_LOG_SERVER_TLOG_ID=$($ISSUE800_CLI loginfo --rekor_server=http://localhost:3000 --format=json | jq -r .TreeID)
echo "* stopping rekor v0.6.0 to test issue #872"
docker-compose -f $V060_COMPOSE_FILE --project-directory=$PWD logs rekor-server-issue-872-v060 > /tmp/post-insert-docker-compose.log
docker-compose -f $V060_COMPOSE_FILE --project-directory=$PWD stop rekor-server-issue-872-v060
${docker_compose} -f $V060_COMPOSE_FILE --project-directory=$PWD logs rekor-server-issue-872-v060 > /tmp/post-insert-docker-compose.log
${docker_compose} -f $V060_COMPOSE_FILE --project-directory=$PWD stop rekor-server-issue-872-v060

COMPOSE_FILE=$REKORTMPDIR/docker-compose-issue872.yaml
cat << EOF > $COMPOSE_FILE
Expand Down Expand Up @@ -177,14 +182,14 @@ EOF

docker network prune -f
echo "* starting rekor under test to ensure attestation inserted in old version is successfully returned"
docker-compose -f $COMPOSE_FILE --project-directory=$PWD up -d
${docker_compose} -f $COMPOSE_FILE --project-directory=$PWD up -d
waitForRekorServer

ISSUE872_GET_ENTRY=$REKORTMPDIR/issue-872-get-entry
echo "* fetching previous entry made under v0.6.0"
if ! $REKOR_CLI get --log-index=$ISSUE872_UPLOAD_INDEX --rekor_server=http://localhost:3000 --format=json > $ISSUE872_GET_ENTRY; then
echo "* failed to read back intoto entry while testing issue #872, exiting"
docker-compose logs --no-color > /tmp/docker-compose.log
${docker_compose} logs --no-color > /tmp/docker-compose.log
exit 1
fi

Expand All @@ -194,8 +199,8 @@ ATT_LENGTH=$(jq -r '.Attestation | length' $ISSUE872_GET_ENTRY)
if [ $ATT_LENGTH -eq 0 ]; then
echo "* failed to read back attestation while testing issue #872, exiting"
cat $ISSUE872_GET_ENTRY
docker-compose logs --no-color > /tmp/docker-compose.log
${docker_compose} logs --no-color > /tmp/docker-compose.log
exit 1
else
echo "* tests succeeded!"
fi
fi
23 changes: 14 additions & 9 deletions tests/rekor-harness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ set -e

TREE_ID=""

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

function start_server () {
server_version=$1
current_branch=$(git rev-parse --abbrev-ref HEAD)
git checkout $server_version
if [ $(docker-compose ps | grep -c "(healthy)") == 0 ]; then
if [ $(${docker_compose} ps | grep -c "(healthy)") == 0 ]; then
echo "starting services with version $server_version"
docker-compose up -d --build
${docker_compose} up -d --build
sleep 30
make rekor-cli
export TREE_ID=$(./rekor-cli loginfo --format json --rekor_server http://localhost:3000 --store_tree_state=false | jq -r .TreeID)
Expand All @@ -36,17 +41,17 @@ function start_server () {
replace="\"--trillian_log_server.tlog_id=$TREE_ID\","
sed -i "s/$search/$replace/" docker-compose.yml

docker-compose up -d --build rekor-server
${docker_compose} up -d --build rekor-server
fi

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"
cat docker-compose.yml
docker-compose logs --no-color > /tmp/docker-compose.log
${docker_compose} logs --no-color > /tmp/docker-compose.log
exit 1
else
echo -n "."
Expand Down Expand Up @@ -76,13 +81,13 @@ function run_tests () {

go clean -testcache
if ! REKORTMPDIR=$REKORTMPDIR SERVER_VERSION=$1 CLI_VERSION=$2 go test -run TestHarness -v -tags=e2e ./tests/ ; then
docker-compose logs --no-color > /tmp/docker-compose.log
${docker_compose} logs --no-color > /tmp/docker-compose.log
exit 1
fi
if docker-compose logs --no-color | grep -q "panic: runtime error:" ; then
if ${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
}
Expand All @@ -102,7 +107,7 @@ VERSIONS="$VERSIONS $HEAD"
echo $VERSIONS

export REKOR_HARNESS_TMPDIR="$(mktemp -d -t rekor_test_harness.XXXXXX)"
docker-compose down
${docker_compose} down

for server_version in $VERSIONS
do
Expand Down

0 comments on commit abcdf4b

Please sign in to comment.