-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract the test concurrency settings to
scripts.gradle.kts
file (#…
…1173) ### Description Extract the test concurrency settings to `scripts.gradle.kts` file
- Loading branch information
Showing
7 changed files
with
49 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package org.stellar.anchor.platform.test | ||
|
||
import java.lang.Thread.sleep | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.assertThrows | ||
import org.stellar.anchor.api.exception.SepNotFoundException | ||
|
@@ -64,14 +63,11 @@ class Sep12Tests(config: TestConfig, toml: Sep1Helper.TomlContent, jwt: String) | |
var pr = sep12Client.putCustomer(customer) | ||
printResponse(pr) | ||
|
||
sleep(1000) | ||
|
||
// make sure the customer was uploaded correctly. | ||
printRequest("Calling GET /customer", customer) | ||
var gr = sep12Client.getCustomer(pr!!.id) | ||
printResponse(gr) | ||
|
||
assertEquals(Sep12Status.NEEDS_INFO, gr?.status) | ||
assertEquals(pr.id, gr?.id) | ||
|
||
customer.emailAddress = "[email protected]" | ||
|
@@ -102,6 +98,7 @@ class Sep12Tests(config: TestConfig, toml: Sep1Helper.TomlContent, jwt: String) | |
assertEquals("customer for 'id' '$id' not found", ex.message) | ||
println(ex) | ||
} | ||
|
||
fun testAll() { | ||
println("Performing Sep12 tests...") | ||
`test put, get customers`() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
extra["enableTestConcurrency"] = | ||
fun(test: Test) { | ||
test.systemProperty("junit.jupiter.execution.parallel.enabled", true) | ||
// Use PER_METHOD test instance life cycle. This avoids the race condition when tests are run in | ||
// parallel mode and | ||
// if the test class has a non-static fields. The non-static fields are shared across all test | ||
// methods. If the life cycle is not PER_METHOD, the test methods may overwrite the fields and | ||
// cause test failures. | ||
// | ||
// However, the life cycle can still be over-written by @TestInstance(Lifecycle) annotation. | ||
// See https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution | ||
test.systemProperty("junit.jupiter.testinstance.lifecycle.default", "per_method") | ||
// Allocate thread count based on available processors | ||
test.systemProperty("junit.jupiter.execution.parallel.config.strategy", "dynamic") | ||
// Set default parallel mode to same thread. All tests within a class are run in sequence. | ||
test.systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") | ||
// Set default parallel mode for classes to concurrent. All test classes are run in parallel. | ||
test.systemProperty("junit.jupiter.execution.parallel.mode.classes.default", "concurrent") | ||
|
||
test.maxParallelForks = | ||
(Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1).also { | ||
println("$test setting maxParallelForks to $it") | ||
} | ||
} |