Skip to content
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

Add concurrent test support #40279

Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
10fbb84
Add parallel test support
Thevakumar-Luheerathan Apr 26, 2023
7e8f394
Merge remote-tracking branch 'upstream/master' into testerina-test-pa…
Thevakumar-Luheerathan Apr 26, 2023
a751e26
Fix build failure
Thevakumar-Luheerathan Apr 26, 2023
3089586
Add tests for test parallelization
Thevakumar-Luheerathan May 11, 2023
88c0f99
Add concurrency safety validation
Thevakumar-Luheerathan May 22, 2023
ef5d4ad
Merge remote-tracking branch 'upstream/master' into testerina-test-pa…
Thevakumar-Luheerathan May 22, 2023
9ae9e79
Add isolation related tests
Thevakumar-Luheerathan May 24, 2023
7564640
Modify integration test output
Thevakumar-Luheerathan May 24, 2023
f5c59ad
Modify windows integration test outputs
Thevakumar-Luheerathan May 24, 2023
c78a5e9
Fix checkstyle failure
Thevakumar-Luheerathan May 24, 2023
2d252b6
Add comments
Thevakumar-Luheerathan Jun 2, 2023
c342bcf
Add necessary class
Thevakumar-Luheerathan Jun 5, 2023
42c91ae
Utilise the concurrent manager
Thevakumar-Luheerathan Jun 28, 2023
86b3166
Merge remote-tracking branch 'upstream/master' into testerina-test-pa…
Thevakumar-Luheerathan Jun 28, 2023
397ff57
Fix build failure
Thevakumar-Luheerathan Jun 28, 2023
e49136e
Fix hanging issue
Thevakumar-Luheerathan Jun 29, 2023
d69ef30
Fix StrandDumpTest failure
Thevakumar-Luheerathan Jul 4, 2023
c20817c
Merge remote-tracking branch 'upstream/master' into testerina-test-pa…
Thevakumar-Luheerathan Dec 11, 2023
2170c85
Add lock to exit code
Thevakumar-Luheerathan Dec 11, 2023
4b9ee0a
Modify integration test outputs
Thevakumar-Luheerathan Dec 11, 2023
e4eed51
Fix build failures
Thevakumar-Luheerathan Dec 12, 2023
ca71d05
Merge branch 'testerina-test-parallelization' of https://github.com/T…
Thevakumar-Luheerathan Dec 12, 2023
f2ae536
Restructure serial test
Thevakumar-Luheerathan Dec 14, 2023
7557e0d
Add functions to create initial test array
Thevakumar-Luheerathan Dec 14, 2023
4c29dbb
Reverse the dependents to preserve existing behaviour
Thevakumar-Luheerathan Dec 15, 2023
8be91a9
Fix build failures
Thevakumar-Luheerathan Dec 15, 2023
19ad284
Make ConcurrentExecutionManager isolated
Thevakumar-Luheerathan Jan 2, 2024
0c827c4
Create isolated functions for execution
Thevakumar-Luheerathan Jan 4, 2024
8d1c571
Merge remote-tracking branch 'origin/testerina-test-parallelization' …
Thevakumar-Luheerathan Jan 4, 2024
ae8532c
Remove async function based execution for serial execution
Thevakumar-Luheerathan Jan 5, 2024
0c7b92b
Allow readonly data provider return types only
Thevakumar-Luheerathan Jan 8, 2024
d66c5fc
Add a new test completion status
Thevakumar-Luheerathan Jan 11, 2024
c4c178f
Separate the common code from isolation and non-isolation
Thevakumar-Luheerathan Jan 11, 2024
cb5448f
Merge remote-tracking branch 'upstream/master' into testerina-test-pa…
Thevakumar-Luheerathan Jan 11, 2024
88e784e
Fix build failure
Thevakumar-Luheerathan Jan 11, 2024
988ab03
Add conditions for setup, teardown functions
Thevakumar-Luheerathan Jan 17, 2024
f8dc82d
Fix data provider related failure
Thevakumar-Luheerathan Jan 19, 2024
f18010b
Add more parallelization test cases
Thevakumar-Luheerathan Jan 19, 2024
a98a48d
Modify serial execution starter logic
Thevakumar-Luheerathan Jan 22, 2024
2857e6e
Support --parallel instead --worker
Thevakumar-Luheerathan Jan 29, 2024
bf2a24d
Address the review
Thevakumar-Luheerathan Feb 16, 2024
bdf516d
Merge remote-tracking branch 'upstream/master' into testerina-test-pa…
Thevakumar-Luheerathan Feb 19, 2024
cce17ee
Address the review
Thevakumar-Luheerathan Feb 21, 2024
baee981
Fix build failure
Thevakumar-Luheerathan Feb 22, 2024
37f2a74
Fix windows build failure
Thevakumar-Luheerathan Feb 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
public class TestArguments {

private static final int ARGUMENTS_NUMBER = 10;
private static final int ARGUMENTS_NUMBER = 11;

private final Class<?>[] argTypes;
private final Object[] argValues;
Expand All @@ -49,6 +49,7 @@ public TestArguments(String... args) {
assignValues(7, args[7]);
assignValues(8, args[8]);
assignValues(9, args[9]);
assignValues(10, args[10]);
}

public Object[] getArgValues() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ public TestCommand() {
@CommandLine.Option(names = "--debug", description = "start in remote debugging mode")
private String debugPort;

@CommandLine.Option(names = "--parallel", description = "enable parallel execution", defaultValue = "false")
Thevakumar-Luheerathan marked this conversation as resolved.
Show resolved Hide resolved
private boolean isParallelExecution;

@CommandLine.Option(names = "--list-groups", description = "list the groups available in the tests")
private boolean listGroups;

Expand Down Expand Up @@ -343,10 +346,10 @@ public void execute() {
.addTask(new CompileTask(outStream, errStream, false, isPackageModified, buildOptions.enableCache()))
// .addTask(new CopyResourcesTask(), listGroups) // merged with CreateJarTask
.addTask(new RunTestsTask(outStream, errStream, rerunTests, groupList, disableGroupList, testList,
includes, coverageFormat, moduleMap, listGroups, excludes, cliArgs),
includes, coverageFormat, moduleMap, listGroups, excludes, cliArgs, isParallelExecution),
project.buildOptions().nativeImage())
.addTask(new RunNativeImageTestTask(outStream, rerunTests, groupList, disableGroupList,
testList, includes, coverageFormat, moduleMap, listGroups),
testList, includes, coverageFormat, moduleMap, listGroups, isParallelExecution),
!project.buildOptions().nativeImage())
.addTask(new DumpBuildTimeTask(outStream), !project.buildOptions().dumpBuildTime())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import static java.util.Objects.requireNonNull;
import static org.ballerinalang.test.runtime.util.TesterinaConstants.CACHE_DIR;
import static org.ballerinalang.test.runtime.util.TesterinaConstants.CLASS_EXTENSION;
import static org.ballerinalang.test.runtime.util.TesterinaConstants.DEFAULT_TEST_WORKERS;
import static org.ballerinalang.test.runtime.util.TesterinaConstants.DOT;
import static org.ballerinalang.test.runtime.util.TesterinaConstants.DOT_REPLACER;
import static org.ballerinalang.test.runtime.util.TesterinaConstants.HYPHEN;
Expand Down Expand Up @@ -135,12 +136,13 @@ public void run() {
private boolean isRerunTestExecution;
private String singleExecTests;
private boolean listGroups;
private final boolean isParallelExecution;

TestReport testReport;

public RunNativeImageTestTask(PrintStream out, boolean rerunTests, String groupList,
String disableGroupList, String testList, String includes, String coverageFormat,
Map<String, Module> modules, boolean listGroups) {
Map<String, Module> modules, boolean listGroups, boolean isParallelExecution) {
this.out = out;
this.isRerunTestExecution = rerunTests;

Expand All @@ -154,6 +156,7 @@ public RunNativeImageTestTask(PrintStream out, boolean rerunTests, String groupL
singleExecTests = testList;
}
this.listGroups = listGroups;
this.isParallelExecution = isParallelExecution;
}


Expand Down Expand Up @@ -556,6 +559,7 @@ private int runTestSuiteWithNativeImage(Package currentPackage, Target target,
cmdArgs.add(this.singleExecTests != null ? this.singleExecTests : "");
cmdArgs.add(Boolean.toString(isRerunTestExecution));
cmdArgs.add(Boolean.toString(listGroups)); // 8
cmdArgs.add(Boolean.toString(isParallelExecution));

builder.command(cmdArgs.toArray(new String[0]));
process = builder.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public class RunTestsTask implements Task {
private boolean listGroups;
private final List<String> cliArgs;

private final boolean isParallelExecution;

TestReport testReport;
private static final Boolean isWindows = System.getProperty("os.name").toLowerCase(Locale.getDefault())
.contains("win");
Expand All @@ -122,11 +124,14 @@ public class RunTestsTask implements Task {

public RunTestsTask(PrintStream out, PrintStream err, boolean rerunTests, String groupList,
String disableGroupList, String testList, String includes, String coverageFormat,
Map<String, Module> modules, boolean listGroups, String excludes, String[] cliArgs) {
Map<String, Module> modules, boolean listGroups, String excludes, String[] cliArgs,
boolean isParallelExecution) {
this.out = out;
this.err = err;
this.isRerunTestExecution = rerunTests;
this.cliArgs = List.of(cliArgs);
this.isParallelExecution = isParallelExecution;

Thevakumar-Luheerathan marked this conversation as resolved.
Show resolved Hide resolved

if (disableGroupList != null) {
this.disableGroupList = disableGroupList;
Expand Down Expand Up @@ -349,6 +354,7 @@ private int runTestSuite(Target target, Package currentPackage, JBallerinaBacken
cmdArgs.add(this.singleExecTests != null ? this.singleExecTests : "");
cmdArgs.add(Boolean.toString(isRerunTestExecution));
cmdArgs.add(Boolean.toString(listGroups));
cmdArgs.add(Boolean.toString(isParallelExecution));
cliArgs.forEach((arg) -> {
cmdArgs.add(arg);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,18 @@ public class NativeUtils {

private static final ReflectConfigClassMethod REFLECTION_CONFIG_EXECUTE_METHOD = new ReflectConfigClassMethod(
TEST_EXEC_FUNCTION, new String[]{"io.ballerina.runtime.internal.scheduling.Strand",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString"
});
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString",
"io.ballerina.runtime.api.values.BString"
Thevakumar-Luheerathan marked this conversation as resolved.
Show resolved Hide resolved
});

//Add dynamically loading classes and methods to reflection config
public static void createReflectConfig(Path nativeConfigPath, Package currentPackage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ OPTIONS
--graalvm-build-options
Additional build options to be passed to the GraalVM native image.

--parallel
Enable parallel execution of tests.
Thevakumar-Luheerathan marked this conversation as resolved.
Show resolved Hide resolved

Thevakumar-Luheerathan marked this conversation as resolved.
Show resolved Hide resolved

ARGUMENTS
(-Ckey=value)...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,24 @@ dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.runtime"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "test"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.error"}
{org = "ballerina", name = "lang.error"},
{org = "ballerina", name = "lang.runtime"}
]
modules = [
{org = "ballerina", packageName = "test", moduleName = "test"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ public class TestFunctionVisitor extends NodeVisitor {

static final List<String> TEST_STATIC_ANNOTATION_NAMES = List.of(
"Config", "BeforeSuite", "AfterSuite", "BeforeGroups", "AfterGroups", "BeforeEach", "AfterEach");
static final String CONFIG_ANNOTATION = "Config";
private static final String TEST_DYNAMIC_ANNOTATION_NAME = "Factory";
private static final String TEST_MODULE_NAME = "test";

private final List<FunctionDefinitionNode> testStaticFunctions;
private final List<FunctionDefinitionNode> testSetUpTearDownFunctions;
private final List<FunctionDefinitionNode> testDynamicFunctions;
private final List<FunctionDefinitionNode> testFunctions;

public TestFunctionVisitor() {
this.testStaticFunctions = new ArrayList<>();
this.testSetUpTearDownFunctions = new ArrayList<>();
this.testDynamicFunctions = new ArrayList<>();
this.testFunctions = new ArrayList<>();
}

@Override
Expand All @@ -73,7 +76,11 @@ public void visit(FunctionDefinitionNode functionDefinitionNode) {
String identifier = qualifiedNameReferenceNode.identifier().text();
if (TEST_MODULE_NAME.equals(modulePrefix)) {
if (TEST_STATIC_ANNOTATION_NAMES.contains(identifier)) {
testStaticFunctions.add(functionDefinitionNode);
if (CONFIG_ANNOTATION.equals(identifier)) {
testFunctions.add(functionDefinitionNode);
} else {
testSetUpTearDownFunctions.add(functionDefinitionNode);
}
} else if (TEST_DYNAMIC_ANNOTATION_NAME.equals(identifier)) {
testDynamicFunctions.add(functionDefinitionNode);
}
Expand All @@ -83,7 +90,9 @@ public void visit(FunctionDefinitionNode functionDefinitionNode) {
}

public List<FunctionDefinitionNode> getTestStaticFunctions() {
return this.testStaticFunctions;
List<FunctionDefinitionNode> testStaticFunctions = new ArrayList<>(testSetUpTearDownFunctions);
testStaticFunctions.addAll(testFunctions);
return testStaticFunctions;
}

public List<FunctionDefinitionNode> getTestDynamicFunctions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class TesterinaCompilerPluginConstants {
public static final String TESTS_PARAMETER = "tests";
public static final String RERUN_FAILED_PARAMETER = "rerunFailed";
public static final String LIST_GROUPS_PARAMETER = "listGroups";
public static final String PARALLEL_TEST_JOB_COUNT_PARAMETER = "testWorkers";

private TesterinaCompilerPluginConstants() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public static void addSetTestOptionsCall(List<StatementNode> statements) {
getPositionalArg(TesterinaCompilerPluginConstants.DISABLE_GROUPS_PARAMETER),
getPositionalArg(TesterinaCompilerPluginConstants.TESTS_PARAMETER),
getPositionalArg(TesterinaCompilerPluginConstants.RERUN_FAILED_PARAMETER),
getPositionalArg(TesterinaCompilerPluginConstants.LIST_GROUPS_PARAMETER)))));
getPositionalArg(TesterinaCompilerPluginConstants.LIST_GROUPS_PARAMETER),
getPositionalArg(TesterinaCompilerPluginConstants.PARALLEL_TEST_JOB_COUNT_PARAMETER)))));
}

public static void addStartSuiteCall(List<StatementNode> statements) {
Expand Down Expand Up @@ -284,7 +285,9 @@ public static FunctionSignatureNode getFunctionSignature() {
NodeFactory.createToken(SyntaxKind.COMMA_TOKEN),
getStringParameter(TesterinaCompilerPluginConstants.RERUN_FAILED_PARAMETER),
NodeFactory.createToken(SyntaxKind.COMMA_TOKEN),
getStringParameter(TesterinaCompilerPluginConstants.LIST_GROUPS_PARAMETER)),
getStringParameter(TesterinaCompilerPluginConstants.LIST_GROUPS_PARAMETER),
NodeFactory.createToken(SyntaxKind.COMMA_TOKEN),
getStringParameter(TesterinaCompilerPluginConstants.PARALLEL_TEST_JOB_COUNT_PARAMETER)),
NodeFactory.createToken(SyntaxKind.CLOSE_PAREN_TOKEN), returnTypeDescriptorNode);
}

Expand Down
Loading
Loading