Skip to content

Commit

Permalink
Use node group instead of node uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
dmironov-wallarm committed Nov 11, 2024
1 parent 95f2885 commit 5aaf4e4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
ALLURE_TOKEN: ${{ steps.secrets.outputs.ALLURE_SERVER_TOKEN }}
ALLURE_ENVIRONMENT_ARCH: ${{ matrix.ARCH }}
USER_TOKEN: ${{ steps.secrets.outputs.user_token }}
WALLARM_API_TOKEN: ${{ steps.secrets.outputs.api_token }}
WALLARM_API_TOKEN: ${{ steps.secrets.outputs.user_token }}
WALLARM_API_HOST: ${{ steps.secrets.outputs.api_host }}
WALLARM_API_PRESET: ${{ steps.secrets.outputs.api_preset }}
WEBHOOK_API_KEY: ${{ steps.secrets.outputs.webhook_api_key }}
Expand Down
4 changes: 3 additions & 1 deletion test/docker-compose.single.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ services:
WALLARM_API_HOST: ${WALLARM_API_HOST}
WALLARM_API_CA_VERIFY: ${WALLARM_API_CA_VERIFY:-true}
WALLARM_API_TOKEN: ${WALLARM_API_TOKEN}
WALLARM_LABELS: ${WALLARM_LABELS:-'group=defaultDockerNode'}
NODE_GROUP_NAME: ${NODE_GROUP_NAME}
WALLARM_LABELS: "group=${NODE_GROUP_NAME}"
healthcheck:
test: bash -c '[ -f /opt/wallarm/etc/wallarm/node.yaml ]'
timeout: 5s
Expand All @@ -19,6 +20,7 @@ services:
pytest:
image: dkr.wallarm.com/tests/smoke-tests:latest
environment:
NODE_GROUP_NAME: ${NODE_GROUP_NAME}
WALLARM_API_HOST: ${WALLARM_API_HOST}
WALLARM_API_PRESET: ${WALLARM_API_PRESET:-audit}
WALLARM_API_CA_VERIFY: ${WALLARM_API_CA_VERIFY:-true}
Expand Down
5 changes: 4 additions & 1 deletion test/docker-compose.split.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ services:
WALLARM_API_HOST: ${WALLARM_API_HOST}
WALLARM_API_CA_VERIFY: ${WALLARM_API_CA_VERIFY:-true}
WALLARM_API_TOKEN: ${WALLARM_API_TOKEN}
NODE_GROUP_NAME: ${NODE_GROUP_NAME}
WALLARM_LABELS: ${WALLARM_LABELS}
POSTANALYTIC_ADDRESS: post-analytics
WALLARM_LABELS: ${WALLARM_LABELS:-'group=defaultDockerNode'}
healthcheck:
test: bash -c '[ -f /opt/wallarm/etc/wallarm/node.yaml ]'
timeout: 5s
Expand All @@ -26,6 +27,7 @@ services:
WALLARM_API_CA_VERIFY: ${WALLARM_API_CA_VERIFY:-true}
WALLARM_API_TOKEN: ${WALLARM_API_TOKEN}
POSTANALYTIC_ONLY: true
NODE_GROUP_NAME: ${NODE_GROUP_NAME}
WALLARM_LABELS: ${WALLARM_LABELS}
healthcheck:
test: bash -c '[ -f /opt/wallarm/etc/wallarm/node.yaml ]'
Expand All @@ -35,6 +37,7 @@ services:
pytest:
image: dkr.wallarm.com/tests/smoke-tests:latest
environment:
NODE_GROUP_NAME: ${NODE_GROUP_NAME}
WALLARM_API_HOST: ${WALLARM_API_HOST}
WALLARM_API_PRESET: ${WALLARM_API_PRESET:-audit}
WALLARM_API_CA_VERIFY: ${WALLARM_API_CA_VERIFY:-true}
Expand Down
17 changes: 7 additions & 10 deletions test/smoke_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function check_mandatory_vars() {
USER_TOKEN
WEBHOOK_API_KEY
WEBHOOK_UUID
NODE_GROUP_NAME
)

for var in "${mandatory[@]}"; do
Expand Down Expand Up @@ -91,16 +92,19 @@ set -a
RED='\033[0;31m'
NC='\033[0m'

export NODE_GROUP_NAME="github-docker-$(tr -dc A-Za-z0-9 </dev/urandom | head -c 12; echo)"
export WALLARM_LABELS="group=${NODE_GROUP_NAME}"

# check if all mandatory vars was defined
check_mandatory_vars

#single or split mode
NODE_MODE=$1
LOGS_DIR="${PWD}/test/logs/${NODE_MODE}"

COMPOSE_CMD="NODE_IMAGE=$IMAGE docker-compose -p $NODE_MODE -f test/docker-compose.$NODE_MODE.yaml"
COMPOSE_CMD="NODE_IMAGE=$IMAGE NODE_GROUP_NAME=$NODE_GROUP_NAME docker-compose -p $NODE_MODE -f test/docker-compose.$NODE_MODE.yaml"

echo "Staring Docker compose in ${NODE_MODE} mode ..."
echo "Staring Docker compose in ${NODE_MODE} mode using ${NODE_GROUP_NAME} group..."
eval "$COMPOSE_CMD up -d --wait --quiet-pull"

# trap for logs and exit
Expand All @@ -115,13 +119,6 @@ if [ "$ALLURE_UPLOAD_REPORT" = "true" ]; then
RUN_TESTS="pytest allurectl watch --job-uid $RAND_NUM -- pytest"
fi

echo "Retrieving Wallarm Node UUID ..."
NODE_UUID=$(eval "$COMPOSE_CMD exec node cat /opt/wallarm/etc/wallarm/node.yaml | grep uuid | awk '{print \$2}'")
if [[ -z "${NODE_UUID}" ]]; then
echo -e "${RED}Failed to retrieve Wallarm Node UUID${NC}"
exit 1
fi

PYTEST_CMD="$COMPOSE_CMD exec $GITHUB_VARS -e NODE_UUID=$NODE_UUID $RUN_TESTS -n $PYTEST_WORKERS $PYTEST_ARGS"
PYTEST_CMD="$COMPOSE_CMD exec $GITHUB_VARS $RUN_TESTS -n $PYTEST_WORKERS $PYTEST_ARGS"
echo "Running tests ..."
eval $PYTEST_CMD

0 comments on commit 5aaf4e4

Please sign in to comment.