-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c4c8dd
commit 10e4da6
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Keep cleaning up even if something fails | ||
set +e | ||
|
||
# Stop all MySQL containers. | ||
|
||
VERSIONS="3.12.14 3.13.2" | ||
|
||
for version in $MYSQL_VERSIONS; do | ||
CONTAINER_NAME="zgrab_amqp091-$version" | ||
echo "amqp091/cleanup: Stopping $CONTAINER_NAME..." | ||
docker stop $CONTAINER_NAME | ||
echo "amqp091/cleanup: ...stopped." | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash -e | ||
|
||
VERSIONS="3.12.14 3.13.2" | ||
|
||
function launch() { | ||
VERSION=$1 | ||
CONTAINER_NAME="zgrab_amqp091-$VERSION" | ||
if docker ps --filter "name=$CONTAINER_NAME" | grep -q $CONTAINER_NAME; then | ||
echo "amqp091/setup: Container $CONTAINER_NAME already running -- skipping launch..." | ||
return | ||
fi | ||
docker run -td --rm --name $CONTAINER_NAME rabbitmq:$VERSION | ||
} | ||
|
||
function waitFor() { | ||
VERSION=$1 | ||
CONTAINER_NAME=zgrab_amqp091-$VERSION | ||
echo "amqp091/setup: Waiting for $CONTAINER_NAME to become ready..." | ||
while ! (docker logs --tail all $CONTAINER_NAME | grep -q "started TCP listener on"); do | ||
echo -n "." | ||
sleep 1 | ||
done | ||
for i in $(seq 1 5); do | ||
echo -n "*" | ||
sleep 1 | ||
done | ||
echo "...ok." | ||
} | ||
|
||
echo "amqp091/setup: Launching docker containers..." | ||
for version in $VERSIONS; do | ||
launch $version | ||
done | ||
|
||
for version in $VERSIONS; do | ||
waitFor $version | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
VERSIONS="3.12.14 3.13.2" | ||
|
||
# Run the AMQP-specific integration tests: | ||
# 1. Run zgrab2 on the container | ||
# 2. Check that data.amqp091.result.server_properties.version matches $MQ_VERSION | ||
|
||
MODULE_DIR=$(dirname $0) | ||
TEST_ROOT=$MODULE_DIR/.. | ||
ZGRAB_ROOT=$MODULE_DIR/../.. | ||
ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output | ||
|
||
status=0 | ||
|
||
function doTest() { | ||
MQ_VERSION=$1 | ||
CONTAINER_NAME="zgrab_amqp091-$MQ_VERSION" | ||
OUTPUT_FILE="$ZGRAB_OUTPUT/amqp091/$MQ_VERSION.json" | ||
echo "amqp091/test: Testing MySQL Version $MQ_VERSION..." | ||
CONTAINER_NAME=$CONTAINER_NAME $ZGRAB_ROOT/docker-runner/docker-run.sh amqp091 --timeout 10s >$OUTPUT_FILE | ||
SERVER_VERSION=$(jp -u data.amqp091.result.server_properties.version <$OUTPUT_FILE) | ||
if [[ "$SERVER_VERSION" == "$MQ_VERSION."* ]]; then | ||
echo "amqp091/test: Server version matches expected version: $SERVER_VERSION == $MQ_VERSION.*" | ||
else | ||
echo "amqp091/test: Server version mismatch: Got $SERVER_VERSION, expected $MQ_VERSION.*. Full output: [[" | ||
cat $OUTPUT_FILE | ||
echo "]]" | ||
status=1 | ||
fi | ||
echo "amqp091/test: BEGIN docker+amqp091 logs from $CONTAINER_NAME [{(" | ||
docker logs --tail all $CONTAINER_NAME | ||
echo ")}] END docker+amqp091 logs from $CONTAINER_NAME" | ||
} | ||
|
||
mkdir -p $ZGRAB_OUTPUT/amqp091 | ||
|
||
for version in $VERSIONS; do | ||
doTest $version | ||
done | ||
|
||
exit $status |