Skip to content

Commit

Permalink
[ANCHOR-461] Extract extended tests from essential tests (#1191)
Browse files Browse the repository at this point in the history
### Description

- Renamed `integration-tests` to `essential-tests`
- Introduce `testFixtures` to improve test code share
- Extracted extended tests to `extended-tests` subproject.
  • Loading branch information
lijamie98 authored Nov 7, 2023
1 parent 98f2e3b commit 53734c1
Show file tree
Hide file tree
Showing 127 changed files with 1,110 additions and 1,046 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/sub_gradle_test_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Gradle Build. (unit tests only)
env:
run_docker: false
run: ./gradlew clean build jacocoTestReport -x integration-tests:test --no-daemon --stacktrace -x spotlessApply -x spotlessKotlinApply -x javadoc -x javadocJar -x sourcesJar
run: ./gradlew clean build jacocoTestReport -x essential-tests:test -x extended-tests:test --no-daemon --stacktrace -x spotlessApply -x spotlessKotlinApply -x javadoc -x javadocJar -x sourcesJar

- name: Run sep server, platform server, observer, and reference servers for integration tests
env:
Expand All @@ -75,6 +75,7 @@ jobs:
pwd
cp service-runner/build/libs/anchor-platform-runner-*.jar service-runner/build/libs/anchor-platform-runner.jar
java -jar service-runner/build/libs/anchor-platform-runner.jar -t &
echo "PID=$!" >> $GITHUB_ENV
- name: Wait for the sep server to start and get ready
uses: mydea/action-wait-for-api@v1
Expand All @@ -89,12 +90,22 @@ jobs:
run_docker: false
ANCHOR_DOMAIN: http://host.docker.internal:8080

run: ./gradlew integration-tests:test
run: ./gradlew essential-tests:test

- name: Run Stellar validation tool
run: |
docker run --network host -v ${GITHUB_WORKSPACE}/platform/src/test/resources://config stellar/anchor-tests:v0.6.9 --home-domain http://host.docker.internal:8080 --seps 1 6 10 12 24 31 38 --sep-config //config/stellar-anchor-tests-sep-config.json --verbose
- name: Stop docker containers
env:
TEST_PROFILE_NAME: default
run: docker-compose -f service-runner/src/main/resources/docker-compose-test.yaml down

# The following step is to be moved to another workflow.
- name: Run the extended tests
run: |
kill -9 $PID
./gradlew extended-tests:test
- name: Add coverage to PR
id: jacoco
Expand All @@ -117,7 +128,7 @@ jobs:
/home/runner/work/java-stellar-anchor-sdk/java-stellar-anchor-sdk/api-schema/build/reports/
/home/runner/work/java-stellar-anchor-sdk/java-stellar-anchor-sdk/core/build/reports/
/home/runner/work/java-stellar-anchor-sdk/java-stellar-anchor-sdk/platform/build/reports/
/home/runner/work/java-stellar-anchor-sdk/java-stellar-anchor-sdk/integration-tests/build/reports/
/home/runner/work/java-stellar-anchor-sdk/java-stellar-anchor-sdk/essential-tests/build/reports/
analyze:
name: CodeQL Analysis
Expand Down
2 changes: 1 addition & 1 deletion .run/Test - End2End Test - no fullstack.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test - End2End Test - no fullstack" type="JUnit" factoryName="JUnit">
<module name="java-stellar-anchor-sdk.integration-tests.test" />
<module name="java-stellar-anchor-sdk.essential-tests.test" />
<shortenClasspath name="ARGS_FILE" />
<extension name="coverage">
<pattern>
Expand Down
2 changes: 1 addition & 1 deletion .run/Test - End2End Test - with fullstack.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test - End2End Test - with fullstack" type="JUnit" factoryName="JUnit">
<module name="java-stellar-anchor-sdk.integration-tests.test" />
<module name="java-stellar-anchor-sdk.essential-tests.test" />
<shortenClasspath name="ARGS_FILE" />
<extension name="coverage">
<pattern>
Expand Down
2 changes: 1 addition & 1 deletion .run/Test - End2End with RPC Test - no fullstack.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test - End2End Test - no fullstack" type="JUnit" factoryName="JUnit">
<module name="java-stellar-anchor-sdk.integration-tests.test" />
<module name="java-stellar-anchor-sdk.essential-tests.test" />
<shortenClasspath name="ARGS_FILE" />
<extension name="coverage">
<pattern>
Expand Down
2 changes: 1 addition & 1 deletion .run/Test - End2End with RPC Test - with fullstack.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test - End2End Test - with fullstack" type="JUnit" factoryName="JUnit">
<module name="java-stellar-anchor-sdk.integration-tests.test" />
<module name="java-stellar-anchor-sdk.essential-tests.test" />
<shortenClasspath name="ARGS_FILE" />
<extension name="coverage">
<pattern>
Expand Down
2 changes: 1 addition & 1 deletion .run/Test - Fireblocks End2End Test - no fullstack.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test - Fireblocks End2End Test - no fullstack" type="JUnit" factoryName="JUnit">
<module name="java-stellar-anchor-sdk.integration-tests.test" />
<module name="java-stellar-anchor-sdk.essential-tests.test" />
<shortenClasspath name="ARGS_FILE" />
<extension name="coverage">
<pattern>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test - Fireblocks End2End Test - with fullstack" type="JUnit" factoryName="JUnit">
<module name="java-stellar-anchor-sdk.integration-tests.test" />
<module name="java-stellar-anchor-sdk.essential-tests.test" />
<shortenClasspath name="ARGS_FILE" />
<extension name="coverage">
<pattern>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test - Fireblocks End2End Test - no fullstack" type="JUnit" factoryName="JUnit">
<module name="java-stellar-anchor-sdk.integration-tests.test" />
<module name="java-stellar-anchor-sdk.essential-tests.test" />
<shortenClasspath name="ARGS_FILE" />
<extension name="coverage">
<pattern>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test - Fireblocks End2End Test - with fullstack" type="JUnit" factoryName="JUnit">
<module name="java-stellar-anchor-sdk.integration-tests.test" />
<module name="java-stellar-anchor-sdk.essential-tests.test" />
<shortenClasspath name="ARGS_FILE" />
<extension name="coverage">
<pattern>
Expand Down
2 changes: 1 addition & 1 deletion .run/Test - Integration Test - no fullstack.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test - Integration Test - no fullstack" type="JUnit" factoryName="JUnit">
<module name="java-stellar-anchor-sdk.integration-tests.test" />
<module name="java-stellar-anchor-sdk.essential-tests.test" />
<shortenClasspath name="ARGS_FILE" />
<extension name="coverage">
<pattern>
Expand Down
2 changes: 1 addition & 1 deletion .run/Test - Integration Test - with fullstack.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test - Integration Test - with fullstack" type="JUnit" factoryName="JUnit">
<module name="java-stellar-anchor-sdk.integration-tests.test" />
<module name="java-stellar-anchor-sdk.essential-tests.test" />
<shortenClasspath name="ARGS_FILE" />
<extension name="coverage">
<pattern>
Expand Down
2 changes: 1 addition & 1 deletion .run/Test - Kotlin Reference Server - no fullstack.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Test - Kotlin Reference Server - no fullstack" type="JUnit" factoryName="JUnit">
<module name="java-stellar-anchor-sdk.integration-tests.test" />
<module name="java-stellar-anchor-sdk.essential-tests.test" />
<shortenClasspath name="ARGS_FILE" />
<extension name="coverage">
<pattern>
Expand Down
56 changes: 0 additions & 56 deletions Makefile

This file was deleted.

22 changes: 12 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
java
`java-test-fixtures`
alias(libs.plugins.spotless)
alias(libs.plugins.kotlin.jvm) apply false
jacoco
Expand All @@ -27,6 +28,7 @@ subprojects {
apply(plugin = "java")
apply(plugin = "com.diffplug.spotless")
apply(plugin = "jacoco")
apply(plugin = "java-test-fixtures")

repositories {
mavenLocal()
Expand All @@ -45,12 +47,10 @@ subprojects {
logger.warn("!!! WARNING !!!")
logger.warn("=================")
logger.warn(
" You are running Java version:[{}]. Spotless may not work well with JDK 17.",
javaVersion
)
" You are running Java version:[{}]. Spotless may not work well with JDK 17.",
javaVersion)
logger.warn(
" In IntelliJ, go to [File -> Build -> Execution, Build, Deployment -> Gradle] and check Gradle JVM"
)
" In IntelliJ, go to [File -> Build -> Execution, Build, Deployment -> Gradle] and check Gradle JVM")
}

if (javaVersion < "11") {
Expand Down Expand Up @@ -102,6 +102,9 @@ subprojects {
testImplementation(rootProject.libs.bundles.junit)
testImplementation(rootProject.libs.jsonassert)

testFixturesImplementation(rootProject.libs.bundles.junit)
testFixturesImplementation(rootProject.libs.jsonassert)

testAnnotationProcessor(rootProject.libs.lombok)
}

Expand All @@ -124,9 +127,8 @@ subprojects {
test {
useJUnitPlatform()
systemProperty(
"junit.jupiter.testclass.order.default",
"org.junit.jupiter.api.ClassOrderer\$OrderAnnotation"
)
"junit.jupiter.testclass.order.default",
"org.junit.jupiter.api.ClassOrderer\$OrderAnnotation")

exclude("**/AnchorPlatformCustodyEnd2EndTest**")
exclude("**/AnchorPlatformCustodyApiRpcEnd2EndTest**")
Expand Down Expand Up @@ -179,8 +181,8 @@ allprojects {
tasks.jar {
manifest {
attributes(
mapOf("Implementation-Title" to project.name, "Implementation-Version" to project.version)
)
mapOf(
"Implementation-Title" to project.name, "Implementation-Version" to project.version))
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ dependencies {
implementation(libs.javax.transaction.api)

implementation(libs.commons.beanutils)
implementation(libs.commons.text)
implementation(libs.commons.io)
implementation(libs.apache.commons.lang3)
implementation(libs.log4j2.core)
Expand All @@ -45,7 +44,7 @@ dependencies {
implementation(variantOf(libs.java.stellar.sdk) { classifier("uber") })

implementation(project(":api-schema"))
implementation(project(":test-lib"))
implementation(project(":lib-util"))

testImplementation(libs.okhttp3.mockserver)
testImplementation(libs.servlet.api)
Expand Down
2 changes: 1 addition & 1 deletion docs/01 - Contributing/B - Git Guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The following artifacts are available for each workflow run:
- `/java-stellar-anchor-sdk/api-schema/build/libs`: The build artifact of the `api-schema` subproject.
- `java-stellar-anchor-sdk/core/build/reports`: The test reports of the `core` subproject.
- `java-stellar-anchor-sdk/platform/build/reports`: The test reports of the `platform` subproject.
- `java-stellar-anchor-sdk/integration-tests/build/reports`: The test reports of the `integration-tests` subproject.
- `java-stellar-anchor-sdk/essential-tests/build/reports`: The test reports of the `essential-tests` subproject.

To access the artifacts, follow these steps:
1. Go to the `Actions` tab of the repository.
Expand Down
3 changes: 2 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ contribute to this project.
- __wallet_reference_server__: Contains the wallet's reference server implementation in Kotlin.
- __service_runner__: Contains the service runner implementation that runs services, such as SEP, platform, payment
observer, and reference servers, etc. It also contains the main entry point of the Anchor Platform.
- __integration-tests__: Contains the integration tests and end-2-end tests for the Anchor Platform.
- __essential-tests__: Contains the essential integration tests and end-2-end tests for the Anchor Platform.
- __extended-tests__: Contains the extended integration tests and end-2-end tests for the Anchor Platform.

## References
[SEP-1](https://stellar.org/protocol/sep-6): Stellar Info File
Expand Down
48 changes: 48 additions & 0 deletions essential-tests/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// The alias call in plugins scope produces IntelliJ false error which is suppressed here.
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
`java-library`
`java-test-fixtures`
alias(libs.plugins.spring.boot)
alias(libs.plugins.spring.dependency.management)
alias(libs.plugins.kotlin.jvm)
}

repositories { maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } }

dependencies {
testFixturesImplementation(libs.assertj.core)
testFixturesImplementation(libs.httpclient)
testFixturesImplementation(libs.kotlin.serialization.json)

// Stellar dependencies
testFixturesImplementation(libs.stellar.wallet.sdk)
testFixturesImplementation(variantOf(libs.java.stellar.sdk) { classifier("uber") })

// Spring dependencies
testFixturesImplementation("org.springframework.boot:spring-boot-starter-data-jpa")
testFixturesImplementation("org.springframework.boot:spring-boot-starter-web")

// project dependencies
testFixturesImplementation(project(":api-schema"))
testFixturesImplementation(project(":core"))
testFixturesImplementation(project(":platform"))
testFixturesImplementation(project(":kotlin-reference-server"))
testFixturesImplementation(project(":wallet-reference-server"))
testFixturesImplementation(project(":service-runner"))
testFixturesImplementation(project(":lib-util"))
}

tasks { bootJar { enabled = false } }

// The following is to enable test concurrency
apply(from = "$rootDir/scripts.gradle.kts")
@Suppress("UNCHECKED_CAST")
val enableTestConcurrency = extra["enableTestConcurrency"] as (Test) -> Unit

tasks.test {
enableTestConcurrency(this)
exclude("**/org/stellar/anchor/platform/*Test.class")
exclude("**/org/stellar/anchor/platform/integrationtest/**")
exclude("**/org/stellar/anchor/platform/e2etest/**")
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.stellar.anchor.platform.suite
package org.stellar.anchor

import io.ktor.client.plugins.*
import io.ktor.http.*
import kotlinx.coroutines.runBlocking
import org.stellar.anchor.platform.*
import org.stellar.anchor.client.*
import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.platform.resourceAsString
import org.stellar.anchor.util.Sep1Helper.TomlContent
import org.stellar.anchor.util.Sep1Helper.parse
import org.stellar.walletsdk.ApplicationConfiguration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.platform
package org.stellar.anchor

var CLIENT_WALLET_SECRET = "SBHTWEF5U7FK53FLGDMBQYGXRUJ24VBM3M6VDXCHRIGCRG3Z64PH45LW"
var CLIENT_WALLET_ACCOUNT = "GDJLBYYKMCXNVVNABOE66NYXQGIA5AC5D223Z2KF6ZEYK4UBCA7FKLTG"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.stellar.anchor.platform.e2etest
package org.stellar.anchor.e2etest

import io.ktor.client.*
import io.ktor.client.plugins.*
Expand All @@ -11,7 +11,7 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import org.assertj.core.api.Assertions.*
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.TestInstance.*
Expand All @@ -22,6 +22,8 @@ import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.MethodSource
import org.springframework.web.util.UriComponentsBuilder
import org.stellar.anchor.AbstractIntegrationTests
import org.stellar.anchor.CLIENT_WALLET_SECRET
import org.stellar.anchor.api.callback.SendEventRequest
import org.stellar.anchor.api.callback.SendEventRequestPayload
import org.stellar.anchor.api.event.AnchorEvent
Expand All @@ -31,9 +33,7 @@ import org.stellar.anchor.api.sep.SepTransactionStatus
import org.stellar.anchor.api.sep.sep24.Sep24GetTransactionResponse
import org.stellar.anchor.auth.JwtService
import org.stellar.anchor.auth.Sep24InteractiveUrlJwt
import org.stellar.anchor.platform.CLIENT_WALLET_SECRET
import org.stellar.anchor.platform.TestConfig
import org.stellar.anchor.platform.suite.AbstractIntegrationTests
import org.stellar.anchor.util.Log.info
import org.stellar.reference.client.AnchorReferenceServerClient
import org.stellar.reference.wallet.WalletServerClient
Expand Down
Loading

0 comments on commit 53734c1

Please sign in to comment.