-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract the test concurrency settings to scripts.gradle.kts
file
#1173
Merged
lijamie98
merged 3 commits into
stellar:develop
from
lijamie98:feature/chore-move-parallelism-to-root-project
Oct 25, 2023
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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") | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious why not include this in
scriptw.gradle.kts
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that kind of make sense too. But it is not part of
enableConcurrency
. But we may refactor in the future if we think we should extract this as well.