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 proper waiting logic for created strands #43726

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function executeTests() returns error? {
executionManager.addInitialParallelTest(testFunction);
}
}
map<future> futures = {};
while !executionManager.isExecutionDone() {
if executionManager.getSerialQueueLength() != 0 && executionManager.countTestInExecution() == 0 {
TestFunction testFunction = executionManager.getSerialTest();
Expand All @@ -83,9 +84,23 @@ function executeTests() returns error? {
TestFunction testFunction = executionManager.getParallelTest();
executionManager.addTestInExecution(testFunction);
DataProviderReturnType? testFunctionArgs = dataDrivenTestParams[testFunction.name];
_ = start executeTestIsolated(testFunction, testFunctionArgs);
future<()> futureEntity = start executeTestIsolated(testFunction, testFunctionArgs);
futures[testFunction.name] = futureEntity;
} else {
foreach [string, future<any|error>] futureResult in futures.entries() {
string functionName = futureResult[0];
any|error parallelResult = wait futureResult[1];
if parallelResult is error {
reportData.onFailed(name = functionName, message =
string `[parallel execution for the function ` +
string `${functionName}]${"\n"} ${getErrorMessage(parallelResult)}`, testType = GENERAL_TEST);
println(string `${"\n\t"}${functionName} has failed.${"\n"}`);
enableExit();
}
}
futures = {};
executionManager.populateExecutionQueues();
}
executionManager.populateExecutionQueues();
}
executionTime = currentTimeInMillis() - startTime;
}
Expand Down Expand Up @@ -326,7 +341,7 @@ isolated function handleTestFuncOutput(any|error output, TestFunction testFuncti
return error(getErrorMessage(output), functionName = testFunction.name);
}

isolated function prepareDataSet(DataProviderReturnType? testFunctionArgs, string[] keys, AnyOrError[][] values)
isolated function prepareDataSet(DataProviderReturnType? testFunctionArgs, string[] keys, AnyOrError[][] values)
returns TestType {
TestType testType = DATA_DRIVEN_MAP_OF_TUPLE;
if testFunctionArgs is map<AnyOrError[]> {
Expand Down Expand Up @@ -381,7 +396,7 @@ isolated function skipDataDrivenTest(TestFunction testFunction, string suffix, T
string[] subTests = testOptions.getFilterSubTest(functionKey);
foreach string subFilter in subTests {
string updatedSubFilter = subFilter;
if testType == DATA_DRIVEN_MAP_OF_TUPLE && subFilter.startsWith(SINGLE_QUOTE)
if testType == DATA_DRIVEN_MAP_OF_TUPLE && subFilter.startsWith(SINGLE_QUOTE)
&& subFilter.endsWith(SINGLE_QUOTE) {
updatedSubFilter = subFilter.substring(1, subFilter.length() - 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,25 +207,37 @@ isolated class ExecutionManager {
}

isolated function populateExecutionQueues() {
int i = 0;
TestCompletionStatus executionCompletionStatus = YET_TO_COMPLETE;
int testCount = 0;
lock {
int i = 0;
TestCompletionStatus executionCompletionStatus = YET_TO_COMPLETE;
while i < self.testsInExecution.length() {
testCount = self.testsInExecution.length();
}
while i < testCount {
TestFunctionMetaData? inProgressTestMetaData = ();
lock {
TestFunction testInProgress = self.testsInExecution[i];
TestFunctionMetaData? inProgressTestMetaData = self.testMetaData[testInProgress.name];
if inProgressTestMetaData == () {
continue;
}
executionCompletionStatus = inProgressTestMetaData.executionCompletionStatus;
if executionCompletionStatus == COMPLETED {
inProgressTestMetaData.dependents.reverse().forEach(
inProgressTestMetaData = self.testMetaData[testInProgress.name].cloneReadOnly();
}
if inProgressTestMetaData == () {
i += 1;
continue;
}
executionCompletionStatus = inProgressTestMetaData.executionCompletionStatus;
if executionCompletionStatus == COMPLETED {
inProgressTestMetaData.dependents.reverse().forEach(
dependent => self.checkExecutionReadiness(dependent));
lock {
_ = self.testsInExecution.remove(i);
} else if executionCompletionStatus == SUSPENDED {
testCount = self.testsInExecution.length();
}
} else if executionCompletionStatus == SUSPENDED {
lock {
_ = self.testsInExecution.remove(i);
} else {
i += 1;
testCount = self.testsInExecution.length();
}
} else {
i += 1;
}
}
}
Expand All @@ -241,9 +253,13 @@ isolated class ExecutionManager {
return;
}
testFunctionMetaData.isReadyToExecute = true;
if !testFunction.serialExecution {
}
if !testFunction.serialExecution {
lock {
self.parallelTestExecutionList.push(testFunction);
} else {
}
} else {
lock {
self.serialTestExecutionList.push(testFunction);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Running Tests with Coverage
callableName: prepareDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 105
callableName: executeDataDrivenTestSet moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 63
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 28
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ moduleName: intg_tests.dataproviders$test.0.tests.test_execute-generated_*****lineNumber: 27

Expand All @@ -51,7 +51,7 @@ Running Tests with Coverage
callableName: prepareDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 105
callableName: executeDataDrivenTestSet moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 63
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 28
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ moduleName: intg_tests.dataproviders$test.0.tests.test_execute-generated_*****lineNumber: 27

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Running Tests with Coverage
callableName: prepareDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 105
callableName: executeDataDrivenTestSet moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 63
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 28
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ moduleName: intg_tests.dataproviders$test.0.tests.test_execute-generated_*****lineNumber: 27

Expand All @@ -50,7 +50,7 @@ Running Tests with Coverage
callableName: prepareDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 105
callableName: executeDataDrivenTestSet moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 63
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 28
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ moduleName: intg_tests.dataproviders$test.0.tests.test_execute-generated_*****lineNumber: 27

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ Running Tests with Coverage
callableName: prepareDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 105
callableName: executeDataDrivenTestSet moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 63
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 28
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ moduleName: intg_tests.dataproviders$test.0.tests.test_execute-generated_*****lineNumber: 27
",functionName="testDividingValuesNegative")
callableName: handleTestFuncOutput moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 326
callableName: handleTestFuncOutput moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 341
callableName: executeTestFunction moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 130
callableName: executeDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 114
callableName: prepareDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 105
callableName: executeDataDrivenTestSet moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 63
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 28
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ moduleName: intg_tests.dataproviders$test.0.tests.test_execute-generated_*****lineNumber: 27

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Running Tests with Coverage
callableName: prepareDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 105
callableName: executeDataDrivenTestSet moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 63
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 28
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ moduleName: intg_tests.dataproviders$test.0.tests.test_execute-generated_*****lineNumber: 27

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Running Tests with Coverage
callableName: prepareDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 105
callableName: executeDataDrivenTestSet moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 63
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 28
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ moduleName: intg_tests.dataproviders$test.0.tests.test_execute-generated_*****lineNumber: 27

Expand All @@ -50,7 +50,7 @@ Running Tests with Coverage
callableName: prepareDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 105
callableName: executeDataDrivenTestSet moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 63
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 28
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ moduleName: intg_tests.dataproviders$test.0.tests.test_execute-generated_*****lineNumber: 27

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Running Tests with Coverage
callableName: prepareDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 106
callableName: executeDataDrivenTestSet moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 63
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 28
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ moduleName: intg_tests.dataproviders$test.0.tests.test_execute-generated_*****lineNumber: 27

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Running Tests with Coverage
callableName: prepareDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 102
callableName: executeDataDrivenTestSet moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 63
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 28
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ moduleName: intg_tests.dataproviders$test.0.tests.test_execute-generated_*****lineNumber: 27

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Running Tests with Coverage
callableName: prepareDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 105
callableName: executeDataDrivenTestSet moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 63
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 28
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ moduleName: intg_tests.dataproviders$test.0.tests.test_execute-generated_*****lineNumber: 27

Expand All @@ -51,7 +51,7 @@ Running Tests with Coverage
callableName: prepareDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 105
callableName: executeDataDrivenTestSet moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 63
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 28
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ moduleName: intg_tests.dataproviders$test.0.tests.test_execute-generated_*****lineNumber: 27

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Running Tests
callableName: executeFunctions moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 96
callableName: executeBeforeEachFunctions moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 52
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 23
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ fileName: failed-before-each-with-groups.bal lineNumber: 95

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Running Tests
callableName: executeFunctions moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 96
callableName: executeBeforeGroupFunctions moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 46
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 22
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ fileName: failed-before-groups-test.bal lineNumber: 110

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Running Tests
callableName: executeTestFunction moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 128
callableName: executeNonDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 74
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 30
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ fileName: groups-test.bal lineNumber: 73

Expand All @@ -44,7 +44,7 @@ Running Tests
callableName: executeTestFunction moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 128
callableName: executeNonDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 74
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 30
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ fileName: groups-test.bal lineNumber: 73

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Running Tests
callableName: executeTestFunction moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 128
callableName: executeNonDataDrivenTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 74
callableName: executeTest moduleName: ballerina.test.0 fileName: serialExecuter.bal lineNumber: 30
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 81
callableName: executeTests moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 82
callableName: startSuite moduleName: ballerina.test.0 fileName: execute.bal lineNumber: 53
callableName: __execute__ fileName: groups-test.bal lineNumber: 73

Expand Down
Loading
Loading