Skip to content

Commit

Permalink
test: enhancements + vault token test
Browse files Browse the repository at this point in the history
vault approle finish

Signed-off-by: Allain Magyar <allain.magyar@iohk.io>
  • Loading branch information
amagyar-iohk committed Mar 13, 2024
1 parent 27a157f commit 9394378
Show file tree
Hide file tree
Showing 49 changed files with 813 additions and 639 deletions.
7 changes: 7 additions & 0 deletions tests/integration-tests/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
root = true

[*.{kt,kts}]
ktlint_code_style = intellij_idea
ij_kotlin_packages_to_use_import_on_demand = **
ij_kotlin_name_count_to_use_star_import = 3
ij_kotlin_name_count_to_use_star_import_for_members = 3
20 changes: 19 additions & 1 deletion tests/integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ The following variables must be set before running the tests:
* `OPEN_ENTERPRISE_AGENT_VERSION`: version of the OEA docker image to use.

```shell
TESTS_CONFIG=/configs/basic.conf PRISM_NODE_VERSION=2.2.1 OPEN_ENTERPRISE_AGENT_VERSION=1.19.1 ./gradlew test
TESTS_CONFIG=/configs/basic.conf PRISM_NODE_VERSION=2.2.1 OPEN_ENTERPRISE_AGENT_VERSION=1.30.1 ./gradlew test
```

> Please note: there is no need to pass environment variables if you're using already running agents.
Expand All @@ -407,6 +407,24 @@ Additional `-Dcucumber.filter.tags` option can be used to specify the tags to in
TESTS_CONFIG=/configs/mt_keycloak.conf ./gradlew test -Dcucumber.filter.tags="@connection and @credentials"
```

### Gradle task

To simplify the execution, each configuration file creates a new `gradle` task. The naming rule is `test_{fileName}`.

It's possible to execute the configuration file as

```shell
PRISM_NODE_VERSION=2.2.1 OPEN_ENTERPRISE_AGENT_VERSION=1.30.1 ./gradlew test_basic
```

Also, it's possible to execute the integration tests to all configurations files. The task is named `regression`, it should take a lot of time to execute.

Note: report is not working due constrains in Serenity BDD reporting system.

```shell
PRISM_NODE_VERSION=2.2.1 OPEN_ENTERPRISE_AGENT_VERSION=1.30.1 ./gradlew regression
```

### Running scenarios in IntelliJ IDEA

To run the scenarios in IntelliJ IDEA, you need to create a new run configuration.
Expand Down
94 changes: 55 additions & 39 deletions tests/integration-tests/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
plugins {
kotlin("jvm") version "1.9.21"
idea
id("org.jetbrains.kotlin.jvm") version "1.9.0"
id("net.serenity-bdd.serenity-gradle-plugin") version "4.0.14"
id("org.jlleitschuh.gradle.ktlint") version "11.5.0"
java
id("net.serenity-bdd.serenity-gradle-plugin") version "4.0.46"
id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
}

group = "io.iohk.atala.prism"
version = "1.0-SNAPSHOT"

repositories {
mavenLocal()
mavenCentral()
maven {
url = uri("https://maven.pkg.github.com/input-output-hk/atala-automation/")
credentials {
username = System.getenv("ATALA_GITHUB_ACTOR")
password = System.getenv("ATALA_GITHUB_TOKEN")
}
}
maven {
url = uri("https://maven.pkg.github.com/hyperledger-labs/open-enterprise-agent/")
credentials {
Expand All @@ -24,45 +22,27 @@ repositories {
}

dependencies {
// Logging
implementation("org.slf4j:slf4j-log4j12:2.0.5")
// Beautify async waits
implementation("org.awaitility:awaitility-kotlin:4.2.0")
// Test engines and reports
testImplementation("junit:junit:4.13.2")
implementation("net.serenity-bdd:serenity-core:4.0.14")
implementation("net.serenity-bdd:serenity-cucumber:4.0.14")
implementation("net.serenity-bdd:serenity-screenplay-rest:4.0.14")
testImplementation("net.serenity-bdd:serenity-ensure:4.0.14")
// HTTP listener
implementation("io.ktor:ktor-server-netty:2.3.0")
implementation("io.ktor:ktor-client-apache:2.3.0")
testImplementation("io.ktor:ktor-server-netty:2.3.0")
testImplementation("io.ktor:ktor-client-apache:2.3.0")
// RestAPI client
implementation("io.iohk.atala.prism:prism-kotlin-client:1.30.0")
testImplementation("io.iohk.atala.prism:prism-kotlin-client:1.30.0")
// Test helpers library
testImplementation("io.iohk.atala:atala-automation:0.3.0")
testImplementation("io.iohk.atala:atala-automation:0.3.2")
// Hoplite for configuration
implementation("com.sksamuel.hoplite:hoplite-core:2.7.5")
implementation("com.sksamuel.hoplite:hoplite-hocon:2.7.5")
testImplementation("com.sksamuel.hoplite:hoplite-core:2.7.5")
testImplementation("com.sksamuel.hoplite:hoplite-hocon:2.7.5")
// Kotlin compose
testImplementation("org.testcontainers:testcontainers:1.19.1")
}

buildscript {
dependencies {
classpath("net.serenity-bdd:serenity-single-page-report:4.0.14")
classpath("net.serenity-bdd:serenity-json-summary-report:4.0.14")
}
}

/**
* Add HTML one-pager and JSON summary report to be produced
*/
serenity {
reports = listOf("single-page-html", "json-summary")
tasks.register<Delete>("cleanTarget") {
delete("target")
}

tasks.test {
dependsOn("cleanTarget")
testLogging.showStandardStreams = true
systemProperty("cucumber.filter.tags", System.getProperty("cucumber.filter.tags"))
}
Expand All @@ -71,6 +51,42 @@ kotlin {
jvmToolchain(19)
}

ktlint {
disabledRules.set(setOf("no-wildcard-imports"))
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
version.set("1.2.1")
}

/**
* Creates a new entry in verification group for each conf file
*/
afterEvaluate {
val folderPath = "src/test/resources/configs" // Change this to the path of your folder

val configFiles = fileTree(folderPath)
.matching { include("**/*.conf") }
.map { it.name.replace(".conf", "") }
.toList()

configFiles.forEach { fileName ->
tasks.register<Test>("test_$fileName") {
group = "verification"
testLogging.showStandardStreams = true
systemProperty("TESTS_CONFIG", "/configs/$fileName.conf")
systemProperty("PRISM_NODE_VERSION", System.getenv("PRISM_NODE_VERSION") ?: "")
systemProperty("OPEN_ENTERPRISE_AGENT_VERSION", System.getenv("OPEN_ENTERPRISE_AGENT_VERSION") ?: "")
systemProperty("cucumber.filter.tags", System.getProperty("cucumber.filter.tags"))
finalizedBy("aggregate")
}
}

/**
* Runs the integration suite for each config file present
* Restrictions: aggregation of all executions doesn't work because of serenity configuration
*/
tasks.register("regression") {
dependsOn("cleanTarget")
group = "verification"
configFiles.forEach {
dependsOn(tasks.getByName("test_$it"))
}
}
}
Binary file modified tests/integration-tests/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions tests/integration-tests/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
Loading

0 comments on commit 9394378

Please sign in to comment.