diff --git a/.github/workflows/performance-tests.yml b/.github/workflows/performance-tests.yml index 88ce05e44e..72677d3547 100644 --- a/.github/workflows/performance-tests.yml +++ b/.github/workflows/performance-tests.yml @@ -13,7 +13,9 @@ on: env: BENCHMARKING_DIR: "tests/performance-tests/atala-performance-tests-k6" - NODE_AUTH_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_ACTOR: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: run-e2e-tests: @@ -35,8 +37,8 @@ jobs: uses: docker/login-action@v2 with: registry: ghcr.io - username: ${{ secrets.ATALA_GITHUB_ACTOR }} - password: ${{ secrets.ATALA_GITHUB_TOKEN }} + username: ${{ env.GITHUB_ACTOR }} + password: ${{ env.GITHUB_TOKEN }} - uses: KengoTODA/actions-setup-docker-compose@v1 name: Install `docker-compose` @@ -46,8 +48,6 @@ jobs: - name: Build local version of PRISM Agent env: ENV_FILE: "infrastructure/local/.env" - GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }} - GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }} run: | sbt docker:publishLocal PRISM_AGENT_VERSION=$(cut version.sbt -d '=' -f2 | tr -d '" ') diff --git a/infrastructure/shared/docker-compose.yml b/infrastructure/shared/docker-compose.yml index bb44b8577a..01bcd0dd58 100644 --- a/infrastructure/shared/docker-compose.yml +++ b/infrastructure/shared/docker-compose.yml @@ -88,6 +88,7 @@ services: AGENT_DB_NAME: agent AGENT_DB_USER: postgres AGENT_DB_PASSWORD: postgres + POLLUX_STATUS_LIST_REGISTRY_PUBLIC_URL: http://${DOCKERHOST}:${PORT}/prism-agent DIDCOMM_SERVICE_URL: http://${DOCKERHOST}:${PORT}/didcomm REST_SERVICE_URL: http://${DOCKERHOST}:${PORT}/prism-agent PRISM_NODE_HOST: prism-node diff --git a/prism-agent/service/server/src/main/resources/application.conf b/prism-agent/service/server/src/main/resources/application.conf index df16405f92..1be6917b31 100644 --- a/prism-agent/service/server/src/main/resources/application.conf +++ b/prism-agent/service/server/src/main/resources/application.conf @@ -29,7 +29,8 @@ pollux { awaitConnectionThreads = ${?POLLUX_DB_AWAIT_CONNECTION_THREADS} } statusListRegistry { - publicEndpointUrl = "http://localhost:8085" + # defaults to the exposed AGENT_HTTP_PORT port + publicEndpointUrl = "http://localhost:"${agent.httpEndpoint.http.port} publicEndpointUrl = ${?POLLUX_STATUS_LIST_REGISTRY_PUBLIC_URL} } issueBgJobRecordsLimit = 25 diff --git a/tests/integration-tests/src/test/kotlin/config/services/Agent.kt b/tests/integration-tests/src/test/kotlin/config/services/Agent.kt index 1c25fb0efb..b9ac962ee1 100644 --- a/tests/integration-tests/src/test/kotlin/config/services/Agent.kt +++ b/tests/integration-tests/src/test/kotlin/config/services/Agent.kt @@ -37,6 +37,7 @@ data class Agent( "KEYCLOAK_REALM" to (keycloak?.realm ?: ""), "KEYCLOAK_CLIENT_ID" to (keycloak?.clientId ?: ""), "KEYCLOAK_CLIENT_SECRET" to (keycloak?.clientSecret ?: ""), + "POLLUX_STATUS_LIST_REGISTRY_PUBLIC_URL" to "http://host.docker.internal:$httpPort" ) // setup token authentication diff --git a/tests/integration-tests/src/test/resources/containers/agent.yml b/tests/integration-tests/src/test/resources/containers/agent.yml index 033601a9d1..75b26ea8f6 100644 --- a/tests/integration-tests/src/test/resources/containers/agent.yml +++ b/tests/integration-tests/src/test/resources/containers/agent.yml @@ -41,6 +41,7 @@ services: AGENT_HTTP_PORT: DIDCOMM_SERVICE_URL: REST_SERVICE_URL: + POLLUX_STATUS_LIST_REGISTRY_PUBLIC_URL: API_KEY_ENABLED: # Secret storage configuration SECRET_STORAGE_BACKEND: diff --git a/tests/performance-tests/atala-performance-tests-k6/.env b/tests/performance-tests/atala-performance-tests-k6/.env new file mode 100644 index 0000000000..4b8958681d --- /dev/null +++ b/tests/performance-tests/atala-performance-tests-k6/.env @@ -0,0 +1,3 @@ +PRISM_AGENT_VERSION=1.30.1-SNAPSHOT +PRISM_NODE_VERSION=2.2.1 +VAULT_DEV_ROOT_TOKEN_ID=root diff --git a/tests/performance-tests/atala-performance-tests-k6/run.sh b/tests/performance-tests/atala-performance-tests-k6/run.sh new file mode 100755 index 0000000000..03caf23bf0 --- /dev/null +++ b/tests/performance-tests/atala-performance-tests-k6/run.sh @@ -0,0 +1,176 @@ +#!/bin/bash + +set -e + +# Variables +ENV_FILE=".env" +PERF_DIR=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +AGENT_DIR="$PERF_DIR/../../.." +DOCKERFILE="$AGENT_DIR/infrastructure/shared/docker-compose.yml" +K6_URL="https://github.com/grafana/k6/releases/download/v0.45.0/k6-v0.45.0-macos-arm64.zip" +K6_ZIP_FILE="$(basename ${K6_URL})" + +# Functions +function startAgent() { + echo "Starting [$NAME] agent" + PORT="${PORT}" \ + ADMIN_TOKEN="${ADMIN_TOKEN}" \ + DEFAULT_WALLET_ENABLED="${DEFAULT_WALLET_ENABLED}" \ + DEFAULT_WALLET_AUTH_API_KEY="${DEFAULT_WALLET_AUTH_API_KEY}" \ + API_KEY_AUTO_PROVISIONING="${API_KEY_AUTO_PROVISIONING}" \ + API_KEY_ENABLED="${API_KEY_ENABLED}" \ + DOCKERHOST="${DOCKERHOST}" \ + PG_PORT="${PG_PORT}" \ + NODE_REFRESH_AND_SUBMIT_PERIOD="${NODE_REFRESH_AND_SUBMIT_PERIOD}" \ + NODE_MOVE_SCHEDULED_TO_PENDING_PERIOD="${NODE_MOVE_SCHEDULED_TO_PENDING_PERIOD}" \ + NODE_WALLET_MAX_TPS="${NODE_WALLET_MAX_TPS}" \ + docker compose -p "${NAME}" -f "${DOCKERFILE}" \ + --env-file "${ENV_FILE}" up -d --wait 2> /dev/null + echo "Agent [$NAME] healthy" +} + +function stopAgent() { + echo "Stopping [${NAME}] agent" + PORT="${PORT}" \ + DOCKERHOST="${DOCKERHOST}" \ + docker compose \ + -p "${NAME}" \ + -f "${DOCKERFILE}" \ + --env-file "${ENV_FILE}" down -v 2> /dev/null + echo "Agent [${NAME}] stopped" +} + +function createIssuer() { + local NAME="issuer" + local PORT=8080 + local ADMIN_TOKEN=admin + local DEFAULT_WALLET_ENABLED=true + local DEFAULT_WALLET_AUTH_API_KEY=default + local API_KEY_AUTO_PROVISIONING=false + local API_KEY_ENABLED=true + local DOCKERHOST="host.docker.internal" + local PG_PORT=5432 + local NODE_REFRESH_AND_SUBMIT_PERIOD="1s" + local NODE_MOVE_SCHEDULED_TO_PENDING_PERIOD="1s" + local NODE_WALLET_MAX_TPS="1000" + + startAgent +} + +function createHolder() { + local NAME="holder" + local PORT=8090 + local ADMIN_TOKEN=admin + local DEFAULT_WALLET_ENABLED=true + local DEFAULT_WALLET_AUTH_API_KEY=default + local API_KEY_AUTO_PROVISIONING=false + local API_KEY_ENABLED=true + local DOCKERHOST="host.docker.internal" + local PG_PORT=5433 + local NODE_REFRESH_AND_SUBMIT_PERIOD="1s" + local NODE_MOVE_SCHEDULED_TO_PENDING_PERIOD="1s" + local NODE_WALLET_MAX_TPS="1000" + + startAgent +} + +function createVerifier() { + local NAME="verifier" + local PORT=8100 + local ADMIN_TOKEN=admin + local DEFAULT_WALLET_ENABLED=true + local DEFAULT_WALLET_AUTH_API_KEY=default + local API_KEY_AUTO_PROVISIONING=false + local API_KEY_ENABLED=true + local DOCKERHOST="host.docker.internal" + local PG_PORT=5434 + local NODE_REFRESH_AND_SUBMIT_PERIOD="1s" + local NODE_MOVE_SCHEDULED_TO_PENDING_PERIOD="1s" + local NODE_WALLET_MAX_TPS="1000" + + startAgent +} + +function removeIssuer() { + local NAME="issuer" + local PORT=8080 + local DOCKERHOST="host.docker.internal" + + stopAgent +} + +function removeVerifier() { + local NAME="verifier" + local PORT=8100 + local DOCKERHOST="host.docker.internal" + + stopAgent +} + +function removeHolder() { + local NAME="holder" + local PORT=8090 + local DOCKERHOST="host.docker.internal" + + stopAgent +} + +# clean up on finish +function cleanup() { + echo "Removing K6 binaries" + rm k6 + rm "$K6_ZIP_FILE" + + removeIssuer & + removeVerifier & + removeHolder & + wait +} + +trap 'cleanup' EXIT + +# download and unzip k6 +echo "Downloading K6" +curl -LO -s "${K6_URL}" +unzip -j "${K6_ZIP_FILE}" > /dev/null +echo "K6 downloaded" + +## navigate to main project +cd "$AGENT_DIR" + +##sbt docker:publishLocal +PRISM_AGENT_VERSION=$(cut -d '"' -f 2 version.sbt) + +## back to performance folder +cd "$PERF_DIR" + +# set version to env file +sed -i.bak "s/PRISM_AGENT_VERSION=.*/PRISM_AGENT_VERSION=${PRISM_AGENT_VERSION}/" "${ENV_FILE}" && rm -f "${ENV_FILE}.bak" + +# create agents in parallel +createIssuer & +createHolder & +createVerifier & +wait + +# yarn install +echo "Installing dependencies" +yarn -s > /dev/null +echo "Building performance tests" +yarn webpack > /dev/null + +# start perf test +echo "Starting performance testing" + +export ISSUER_AGENT_API_KEY=default +export HOLDER_AGENT_API_KEY=default +export VERIFIER_AGENT_API_KEY=default + +./k6 run -e SCENARIO_LABEL=create-prism-did-smoke ./dist/create-prism-did-test.js +./k6 run -e SCENARIO_LABEL=credential-offer-smoke ./dist/credential-offer-test.js +./k6 run -e SCENARIO_LABEL=credential-definition-smoke ./dist/credential-definition-test.js +./k6 run -e SCENARIO_LABEL=credential-schema-smoke ./dist/credential-schema-test.js +./k6 run -e SCENARIO_LABEL=did-publishing-smoke ./dist/did-publishing-test.js +./k6 run -e SCENARIO_LABEL=connection-flow-smoke ./dist/connection-flow-test.js +./k6 run -e SCENARIO_LABEL=issuance-flow-smoke ./dist/issuance-flow-test.js +./k6 run -e SCENARIO_LABEL=present-proof-flow-smoke ./dist/present-proof-flow-test.js