Skip to content

Commit

Permalink
test: configurable integration tests support (#772)
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Baliasnikov <[email protected]>
  • Loading branch information
Anton Baliasnikov authored Nov 20, 2023
1 parent 9a6e512 commit 7fd03ce
Show file tree
Hide file tree
Showing 23 changed files with 681 additions and 236 deletions.
46 changes: 8 additions & 38 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defaults:

jobs:
run-integration-tests:
name: "Run e2e tests"
name: "Run integration tests"
runs-on: ubuntu-latest
env:
REPORTS_DIR: "tests/integration-tests/target/site/serenity"
Expand Down Expand Up @@ -50,49 +50,17 @@ jobs:
legacy: true # will also install in PATH as `docker-compose`

- name: Build local version of PRISM Agent
id: build_local_prism_agent
env:
ENV_FILE: "infrastructure/local/.env"
PRISM_AGENT_PATH: "../.."
ENV_FILE: "infrastructure/local/.env"
GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
run: |
cd "${PRISM_AGENT_PATH}" || exit 129
sbt docker:publishLocal
PRISM_AGENT_VERSION=$(cut version.sbt -d '=' -f2 | tr -d '" ')
sed -i.bak "s/PRISM_AGENT_VERSION=.*/PRISM_AGENT_VERSION=${PRISM_AGENT_VERSION}/" "${ENV_FILE}" && rm -f "${ENV_FILE}.bak"
cat "${ENV_FILE}"
- name: Start Cloud Agent for issuer and verifier
env:
PORT: 8080
ADMIN_TOKEN: "admin"
DEFAULT_WALLET_ENABLED: "false"
API_KEY_AUTO_PROVISIONING: "false"
API_KEY_ENABLED: "true"
DOCKERHOST: "host.docker.internal"
uses: isbang/[email protected]
with:
compose-file: "./infrastructure/shared/docker-compose-demo.yml"
compose-flags: "--env-file ./infrastructure/local/.env -p issuer"
up-flags: "--wait"
down-flags: "--volumes"

- name: Start Cloud Agent for holder
env:
PORT: 8090
ADMIN_TOKEN: admin
DEFAULT_WALLET_ENABLED: true
DEFAULT_WALLET_WEBHOOK_URL: http://host.docker.internal:9956
DEFAULT_WALLET_AUTH_API_KEY: default
API_KEY_AUTO_PROVISIONING: false
API_KEY_ENABLED: true
DOCKERHOST: "host.docker.internal"
uses: isbang/[email protected]
with:
compose-file: "./infrastructure/shared/docker-compose-demo.yml"
compose-flags: "--env-file ./infrastructure/local/.env -p holder"
up-flags: "--wait"
down-flags: "--volumes"
echo "open_enterprise_agent_version=$(cut -d'=' -f2 version.sbt | tr -d '" ')" >> "${GITHUB_OUTPUT}"
echo "prism_node_version=$(grep PRISM_NODE_VERSION infrastructure/local/.env | cut -d'=' -f2 | tr -d ' ')" >> "${GITHUB_OUTPUT}"
- uses: actions/setup-java@v3
with:
Expand All @@ -101,6 +69,8 @@ jobs:

- name: Run integration tests
env:
PRISM_NODE_VERSION: ${{ steps.build_local_prism_agent.outputs.prism_node_version }}
OPEN_ENTERPRISE_AGENT_VERSION: ${{ steps.build_local_prism_agent.outputs.open_enterprise_agent_version }}
ATALA_GITHUB_ACTOR: ${{ secrets.ATALA_GITHUB_ACTOR }}
ATALA_GITHUB_TOKEN: ${{ secrets.ATALA_GITHUB_TOKEN }}
continue-on-error: true
Expand Down Expand Up @@ -164,6 +134,6 @@ jobs:
Failed: ${{ steps.analyze_test_results.outputs.failures }}
Errors in tests: ${{ steps.analyze_test_results.outputs.errors }}
Skipped (known bugs): ${{ steps.analyze_test_results.outputs.skipped }}
SLACK_TITLE: "Atala PRISM V2 Integration tests: ${{ steps.analyze_test_results.outputs.conclusion }}"
SLACK_TITLE: "Open Enterprise Agent Integration Tests: ${{ steps.analyze_test_results.outputs.conclusion }}"
SLACK_USERNAME: circleci
SLACK_WEBHOOK: ${{ secrets.E2E_TESTS_SLACK_WEBHOOK }}
21 changes: 0 additions & 21 deletions .github/workflows/prism-unit-tests.yml

This file was deleted.

77 changes: 0 additions & 77 deletions .github/workflows/unit-tests-common.yml

This file was deleted.

69 changes: 69 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Unit tests

# Cancel previously running workflows if new commit pushed to the branch
# this will help to push fixes earlier and stop previous workflows
concurrency:
group: ${{ github.head_ref }}${{ github.ref }}-unit-tests
cancel-in-progress: true

on:
push:
branches:
- "main"
pull_request:

jobs:
build-and-unit-tests:
name: "Build and unit tests"
runs-on: self-hosted
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
container:
image: ghcr.io/hyperledger-labs/ci-debian-jdk-22:0.1.0
volumes:
- /nix:/nix
env:
TESTCONTAINERS_RYUK_DISABLED: true
steps:
- name: Git checkout (merge)
uses: actions/checkout@v3
if: github.event_name != 'pull_request'
with:
fetch-depth: 0

- name: Git checkout (PR)
uses: actions/checkout@v3
if: github.event_name == 'pull_request'
with:
fetch-depth: 0
# see: https://frontside.com/blog/2020-05-26-github-actions-pull_request/#how-does-pull_request-affect-actionscheckout
ref: ${{ github.event.pull_request.head.sha }}

- name: Download dependencies
run: sbt +update

- name: Check formatting
run: sbt scalafmtCheckAll

- name: Run unit tests
env:
HOME: /root
run: |
sbt -v coverage test coverageAggregate
- name: Upload coverage to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: sbt coveralls

- name: Aggregate test reports
if: always()
uses: ./.github/actions/aggregate-test-reports

- name: Publish test results
if: always()
uses: EnricoMi/publish-unit-test-result-action@v2
with:
junit_files: "./target/test-reports/**/TEST-*.xml"
comment_title: "Unit Test Results"
check_name: "Unit Test Results"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<br>
<br>
<a href='https://coveralls.io/github/input-output-hk/atala-prism-building-blocks?branch=main'><img src='https://coveralls.io/repos/github/input-output-hk/atala-prism-building-blocks/badge.svg?branch=main&amp;t=91BUzX&kill_cache=1' alt='Coverage Status' /></a>
<a href="https://github.com/input-output-hk/atala-prism-building-blocks/actions/workflows/prism-unit-tests.yml"> <img src="https://github.com/input-output-hk/atala-prism-building-blocks/actions/workflows/prism-unit-tests.yml/badge.svg" alt="Unit tests" /> </a>
<a href="https://github.com/input-output-hk/atala-prism-building-blocks/actions/workflows/unit-tests.yml"> <img src="https://github.com/input-output-hk/atala-prism-building-blocks/actions/workflows/unit-tests.yml/badge.svg" alt="Unit tests" /> </a>
<a href="https://github.com/input-output-hk/atala-prism-building-blocks/actions/workflows/integration-tests.yml"> <img src="https://github.com/input-output-hk/atala-prism-building-blocks/actions/workflows/integration-tests.yml/badge.svg" alt="End-to-end tests" /> </a>
<a href="https://github.com/input-output-hk/atala-prism-building-blocks/actions/workflows/performance-tests.yml"> <img src="https://github.com/input-output-hk/atala-prism-building-blocks/actions/workflows/performance-tests.yml/badge.svg" alt="Performance tests" /> </a>
</p>
Expand Down
2 changes: 2 additions & 0 deletions tests/integration-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ dependencies {
// Hoplite for configuration
implementation("com.sksamuel.hoplite:hoplite-core:2.7.5")
implementation("com.sksamuel.hoplite:hoplite-hocon:2.7.5")
// Kotlin compose
testImplementation("org.testcontainers:testcontainers:1.19.1")
}

buildscript {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration-tests/src/test/kotlin/config/AgentConf.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.net.URL

data class AgentConf(
val url: URL,
val apikey: String?,
@ConfigAlias("webhook_url") val webhookUrl: URL?,
var apikey: String?,
@ConfigAlias("multi-tenant") val multiTenant: Boolean?,
val init: AgentInitConf?,
)
12 changes: 12 additions & 0 deletions tests/integration-tests/src/test/kotlin/config/AgentInitConf.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package config

import com.sksamuel.hoplite.ConfigAlias

data class AgentInitConf(
val version: String,
@ConfigAlias("http_port") val httpPort: Int,
@ConfigAlias("didcomm_port") val didcommPort: Int,
@ConfigAlias("secret_storage_backend") val secretStorageBackend: String,
@ConfigAlias("auth_enabled") val authEnabled: Boolean,
@ConfigAlias("keycloak_enabled") val keycloakEnabled: Boolean,
)
4 changes: 3 additions & 1 deletion tests/integration-tests/src/test/kotlin/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package config

data class Config(
val global: GlobalConf,
val admin: AgentConf,
val issuer: AgentConf,
val holder: AgentConf,
val verifier: AgentConf,
val admin: AgentConf
val agents: List<AgentInitConf>,
val services: ServicesConf
)
6 changes: 2 additions & 4 deletions tests/integration-tests/src/test/kotlin/config/GlobalConf.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package config
import com.sksamuel.hoplite.ConfigAlias

data class GlobalConf(
@ConfigAlias("auth_required") val authRequired: Boolean,
@ConfigAlias("auth_header") val authHeader: String,
@ConfigAlias("admin_auth_header") val adminAuthHeader: String,
@ConfigAlias("admin_apikey") val adminApiKey: String
@ConfigAlias("auth_header") val authHeader: String = "apikey",
@ConfigAlias("admin_auth_header") val adminAuthHeader: String = "x-admin-api-key",
)
31 changes: 31 additions & 0 deletions tests/integration-tests/src/test/kotlin/config/ServicesConf.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package config

import com.sksamuel.hoplite.ConfigAlias

data class ServicesConf(
@ConfigAlias("prism_node") val prismNode: PrismNodeConf?,
val keycloak: KeycloakConf?,
val vault: VaultConf?,
)

data class PrismNodeConf(
@ConfigAlias("http_port") val httpPort: Int,
val version: String,
)

data class KeycloakConf(
@ConfigAlias("http_port") val httpPort: Int,
val realm: String,
@ConfigAlias("client_id") val clientId: String,
@ConfigAlias("client_secret") val clientSecret: String,
val users: List<KeycloakUser>
)

data class KeycloakUser(
val username: String,
val password: String
)

data class VaultConf(
@ConfigAlias("http_port") val httpPort: Int,
)
Loading

0 comments on commit 7fd03ce

Please sign in to comment.