From f73ac1f5e68631782833042e82178101709a2a5f Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Wed, 3 May 2023 17:41:20 +0530 Subject: [PATCH] Add tests for test parallelization --- .../src/main/ballerina/execute.bal | 52 ++- .../test/TestparallelizationTest.java | 156 +++++++ .../testerina/test/utils/CommonUtils.java | 4 + .../Ballerina.toml | 8 + .../main.bal | 55 +++ .../tests/data_driven_test.bal | 60 +++ .../Ballerina.toml | 8 + .../main.bal | 55 +++ .../tests/data_driven_test.bal | 51 +++ .../Ballerina.toml | 8 + .../main.bal | 55 +++ .../tests/data_driven_test.bal | 59 +++ .../Ballerina.toml | 8 + .../parallelisation-parallelizable/main.bal | 55 +++ .../tests/normalTest.bal | 383 ++++++++++++++++++ .../Ballerina.toml | 7 + .../parallelisation-simple-test/main.bal | 55 +++ .../tests/normalTest.bal | 383 ++++++++++++++++++ .../Ballerina.toml | 8 + .../main.bal | 55 +++ .../tests/data_driven_test.bal | 51 +++ .../src/test/resources/testng.xml | 1 + 22 files changed, 1560 insertions(+), 17 deletions(-) create mode 100644 tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/TestparallelizationTest.java create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-map-data-provider/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-map-data-provider/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-map-data-provider/tests/data_driven_test.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-tuple-data-provider/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-tuple-data-provider/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-tuple-data-provider/tests/data_driven_test.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-map-data-provider/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-map-data-provider/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-map-data-provider/tests/data_driven_test.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-parallelizable/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-parallelizable/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-parallelizable/tests/normalTest.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-simple-test/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-simple-test/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-simple-test/tests/normalTest.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-tuple-data-provider/Ballerina.toml create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-tuple-data-provider/main.bal create mode 100644 tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-tuple-data-provider/tests/data_driven_test.bal diff --git a/misc/testerina/modules/testerina-core/src/main/ballerina/execute.bal b/misc/testerina/modules/testerina-core/src/main/ballerina/execute.bal index 504046a8a9bc..d4434d955bb3 100644 --- a/misc/testerina/modules/testerina-core/src/main/ballerina/execute.bal +++ b/misc/testerina/modules/testerina-core/src/main/ballerina/execute.bal @@ -78,42 +78,60 @@ function executeTests() returns error? { } + int paralalTestExecutionListLength = parallelTestExecutionList.length(); + int serialTestExecutionListLength = serialTestExecutionList.length(); + while true { - if (parallelTestExecutionList.length() == 0 && getAvailableWorkerCount() == testWorkers - && serialTestExecutionList.length() == 0) { + + TestFunction? testFunction = (); + lock { + paralalTestExecutionListLength = parallelTestExecutionList.length(); + serialTestExecutionListLength = serialTestExecutionList.length(); + } + + if (paralalTestExecutionListLength == 0 && getAvailableWorkerCount() == testWorkers + && serialTestExecutionListLength == 0) { break; } if (getAvailableWorkerCount() != 0) { - if parallelTestExecutionList.length() == 0 && serialTestExecutionList.length() == 0 { + if paralalTestExecutionListLength == 0 && serialTestExecutionListLength == 0 { runtime:sleep(0.0001); continue; } - if (serialTestExecutionList.length() != 0 && getAvailableWorkerCount() == testWorkers) { + if (serialTestExecutionListLength != 0 && getAvailableWorkerCount() == testWorkers) { + lock { + testFunction = serialTestExecutionList.remove(0); + } - TestFunction testFunction = serialTestExecutionList.remove(0); - allocateWorker(); - future serialWaiter = start executeTest(testFunction); - any _ = check wait serialWaiter; + if testFunction is TestFunction { + allocateWorker(); + future serialWaiter = start executeTest(testFunction); + any _ = check wait serialWaiter; + } - } else if parallelTestExecutionList.length() != 0 && serialTestExecutionList.length() == 0 { - TestFunction testFunction = parallelTestExecutionList.remove(0); - allocateWorker(); - future<(error?)> parallelWaiter = start executeTest(testFunction); - runtime:sleep(0.0001); - if isDataDrivenTest(testFunction) { - any _ = check wait parallelWaiter; + } else if paralalTestExecutionListLength != 0 && serialTestExecutionListLength == 0 { + lock { + testFunction = parallelTestExecutionList.remove(0); + } + if testFunction is TestFunction { + allocateWorker(); + future<(error?)> parallelWaiter = start executeTest(testFunction); + if isDataDrivenTest(testFunction) { + any _ = check wait parallelWaiter; + } } } } else { runtime:sleep(0.0001); } + runtime:sleep(0.0001); } - // println("Test execution time :" + (currentTimeInMillis() - startTime).toString() + "ms"); + println("\n\t\tTest execution time :" + (currentTimeInMillis() - startTime).toString() + "ms\n"); } function executeTest(TestFunction testFunction) returns error? { @@ -161,7 +179,6 @@ function executeTest(TestFunction testFunction) returns error? { } testFunction.dependents.forEach(dependent => checkExecutionReadiness(dependent)); releaseWorker(); - // isSerialTestExecution = !isSerialTestExecution && !testFunction.parallelizable; } function checkExecutionReadiness(TestFunction testFunction) { @@ -227,6 +244,7 @@ function executeDataDrivenTestSet(TestFunction testFunction) returns error? { runtime:sleep(0.0001); continue; } + runtime:sleep(0.0001); } allocateWorker(); } diff --git a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/TestparallelizationTest.java b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/TestparallelizationTest.java new file mode 100644 index 000000000000..6f69ed8c48ee --- /dev/null +++ b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/TestparallelizationTest.java @@ -0,0 +1,156 @@ +package org.ballerinalang.testerina.test; + +import org.ballerinalang.test.context.BMainInstance; +import org.ballerinalang.test.context.BallerinaTestException; +import org.ballerinalang.testerina.test.utils.AssertionUtils; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.util.HashMap; + +import static org.ballerinalang.testerina.test.utils.CommonUtils.replaceExecutionTime; + +public class TestparallelizationTest extends BaseTestCase { + + private BMainInstance balClient; + private String projectPath; + + @BeforeClass + public void setup() throws BallerinaTestException { + balClient = new BMainInstance(balServer); + projectPath = projectBasedTestsPath.resolve("parallelisation-test").toString(); + } + + @Test + public void testParallelization() throws BallerinaTestException, IOException { + String[] args = mergeCoverageArgs(new String[]{"--workers=30", "parallelisation-simple-test"}); + String output = balClient.runMainAndReadStdOut("test", args, + new HashMap<>(), projectPath, false); + Float executionTimeW30 = getTimeForTestExecution(output); + output = replaceExecutionTime(output); +// AssertionUtils.assertOutput("TestparallelizationTest-testParallelization_w1.txt", output); + + + args = mergeCoverageArgs(new String[]{"--workers=1", "parallelisation-simple-test", }); + output = balClient.runMainAndReadStdOut("test", args, + new HashMap<>(), projectPath, false); + Float executionTimeW1 = getTimeForTestExecution(output); + output = replaceExecutionTime(output); +// AssertionUtils.assertOutput("TestparallelizationTest-testParallelization_w30.txt", output); + + Assert.assertTrue(executionTimeW1 / 3 > executionTimeW30); + + } + + @Test + public void testNonParallelizable() throws BallerinaTestException, IOException { + String[] args = mergeCoverageArgs(new String[]{"--workers=30", "parallelisation-parallelizable"}); + String output = balClient.runMainAndReadStdOut("test", args, + new HashMap<>(), projectPath, false); + Float executionTimeW30 = getTimeForTestExecution(output); + output = replaceExecutionTime(output); +// AssertionUtils.assertOutput("TestparallelizationTest-testNonParallelizable_w1.txt", output); + + + args = mergeCoverageArgs(new String[]{"--workers=1", "parallelisation-parallelizable", }); + output = balClient.runMainAndReadStdOut("test", args, + new HashMap<>(), projectPath, false); + Float executionTimeW1 = getTimeForTestExecution(output); + output = replaceExecutionTime(output); +// AssertionUtils.assertOutput("TestparallelizationTest-testNonParallelizable_w30.txt", output); + + Assert.assertTrue(executionTimeW1 - executionTimeW30 < 1000); + } + + + @Test + public void testParalallelizableTupleDataProvider() throws BallerinaTestException, IOException { + String[] args = mergeCoverageArgs(new String[]{"--workers=30", "parallelisation-tuple-data-provider"}); + String output = balClient.runMainAndReadStdOut("test", args, + new HashMap<>(), projectPath, false); + Float executionTimeW30 = getTimeForTestExecution(output); + output = replaceExecutionTime(output); +// AssertionUtils.assertOutput("TestparallelizationTest-testParalallelizableTupleDataProvider_w1.txt", output); + + + args = mergeCoverageArgs(new String[]{"--workers=1", "parallelisation-tuple-data-provider", }); + output = balClient.runMainAndReadStdOut("test", args, + new HashMap<>(), projectPath, false); + Float executionTimeW1 = getTimeForTestExecution(output); + output = replaceExecutionTime(output); +// AssertionUtils.assertOutput("TestparallelizationTest-testParalallelizableTupleDataProvider_w30.txt", output); + + Assert.assertTrue(executionTimeW1 / 3 > executionTimeW30); + } + + @Test + public void testParalallelizableMapDataProvider() throws BallerinaTestException, IOException { + String[] args = mergeCoverageArgs(new String[]{"--workers=30", "parallelisation-map-data-provider"}); + String output = balClient.runMainAndReadStdOut("test", args, + new HashMap<>(), projectPath, false); + Float executionTimeW30 = getTimeForTestExecution(output); + output = replaceExecutionTime(output); +// AssertionUtils.assertOutput("TestparallelizationTest-testParalallelizableMapDataProvider_w1.txt", output); + + + args = mergeCoverageArgs(new String[]{"--workers=1", "parallelisation-map-data-provider", }); + output = balClient.runMainAndReadStdOut("test", args, + new HashMap<>(), projectPath, false); + Float executionTimeW1 = getTimeForTestExecution(output); + output = replaceExecutionTime(output); +// AssertionUtils.assertOutput("TestparallelizationTest-testParalallelizableMapDataProvider_w30.txt", output); + + Assert.assertTrue(executionTimeW1 / 3 > executionTimeW30); + } + + @Test + public void testNonParalallelizableTupleDataProvider() throws BallerinaTestException, IOException { + String[] args = mergeCoverageArgs(new String[]{"--workers=30", "non-parallelisation-tuple-data-provider"}); + String output = balClient.runMainAndReadStdOut("test", args, + new HashMap<>(), projectPath, false); + Float executionTimeW30 = getTimeForTestExecution(output); + output = replaceExecutionTime(output); +// AssertionUtils.assertOutput("TestparallelizationTest-testNonParalallelizableTupleDataProvider_w1.txt", +// output); + + + args = mergeCoverageArgs(new String[]{"--workers=1", "non-parallelisation-tuple-data-provider", }); + output = balClient.runMainAndReadStdOut("test", args, + new HashMap<>(), projectPath, false); + Float executionTimeW1 = getTimeForTestExecution(output); + output = replaceExecutionTime(output); +// AssertionUtils.assertOutput("TestparallelizationTest-testNonParalallelizableTupleDataProvider_w30.txt", +// output); + + Assert.assertTrue(executionTimeW1 - executionTimeW30 < 1000); + } + + @Test + public void testNonParalallelizableMapDataProvider() throws BallerinaTestException, IOException { + String[] args = mergeCoverageArgs(new String[]{"--workers=30", "non-parallelisation-map-data-provider"}); + String output = balClient.runMainAndReadStdOut("test", args, + new HashMap<>(), projectPath, false); + Float executionTimeW30 = getTimeForTestExecution(output); + output = replaceExecutionTime(output); +// AssertionUtils.assertOutput("TestparallelizationTest-testNonParalallelizableMapDataProvider_w1.txt", output); + + + args = mergeCoverageArgs(new String[]{"--workers=1", "parallelisation-map-data-provider", }); + output = balClient.runMainAndReadStdOut("test", args, + new HashMap<>(), projectPath, false); + Float executionTimeW1 = getTimeForTestExecution(output); + output = replaceExecutionTime(output); +// AssertionUtils.assertOutput("TestparallelizationTest-testNonParalallelizableMapDataProvider_w30.txt", output); + + Assert.assertTrue(executionTimeW1 - executionTimeW30 < 1000); + } + + private float getTimeForTestExecution(String output) { + int firstPos = output.indexOf("Test execution time :") + ("Test execution time :").length(); + int lastPos = output.indexOf("ms"); + String executionTime = output.substring(firstPos, lastPos); + return Float.parseFloat(executionTime); + } +} diff --git a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/utils/CommonUtils.java b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/utils/CommonUtils.java index d2a921f468d4..3ec2b442c7f3 100644 --- a/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/utils/CommonUtils.java +++ b/tests/testerina-integration-test/src/test/java/org/ballerinalang/testerina/test/utils/CommonUtils.java @@ -28,6 +28,10 @@ public class CommonUtils { private CommonUtils() { } + public static String replaceExecutionTime(String content) { + return replaceVaryingString("Test execution time :", "ms", content); + } + public static String replaceVaryingString(String firstString, String endString, String content) { String modifiedContent = content; int firstPos = modifiedContent.indexOf(firstString); diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-map-data-provider/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-map-data-provider/Ballerina.toml new file mode 100644 index 000000000000..a0611873503a --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-map-data-provider/Ballerina.toml @@ -0,0 +1,8 @@ +[package] +org = "luheerathan" +name = "test_parallelisation_test" +version = "0.1.0" +distribution = "2201.3.0-rc3" + +[build-options] +observabilityIncluded = true diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-map-data-provider/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-map-data-provider/main.bal new file mode 100644 index 000000000000..a37ada63a432 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-map-data-provider/main.bal @@ -0,0 +1,55 @@ +import ballerina/io; +import ballerina/lang.runtime; +import ballerina/time; + +int employedCount = 20000; +int[] quantities_ = [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + + 23, + 24 +]; + +public function main() { + decimal now = time:monotonicNow(); + int count = 10; + + while true { + if count > 0 { + future<()> f = start get_average(); + count -= 1; + } + // int avg = get_average(); + // io:println("Average: ", avg); + + } + +} + +function get_average() { + runtime:sleep(10); + io:println("Helllwo"); + +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-map-data-provider/tests/data_driven_test.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-map-data-provider/tests/data_driven_test.bal new file mode 100644 index 000000000000..6e72c437a4de --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-map-data-provider/tests/data_driven_test.bal @@ -0,0 +1,60 @@ + +import ballerina/lang.runtime; +import ballerina/test; + +@test:Config { + dataProvider: mapDataProvider, + parallelizable: false +} +function mapDataProviderTest(int value1, int value2, string fruit) returns error? { + test:assertEquals(value1, value2, msg = "The provided values are not equal"); + runtime:sleep(0.5); + test:assertEquals(fruit.length(), 6); +} + +function mapDataProvider() returns map<[int, int, string]>|error { + map<[int, int, string]> dataSet = { + "banana": [10, 10, "banana"], + "cherry": [5, 5, "cherry"], + "apple": [5, 5, "apple"], + "orange": [5, 5, "orange"], + "carrot": [5, 5, "carrot"], + "lemon": [5, 5, "lemon"], + "tomatto": [5, 5, "tomatto"], + "papaya": [5, 5, "papaya"], + "grapes": [5, 5, "grapes"], + "mango": [5, 5, "mango"], + "pineapple": [5, 5, "pineapple"], + "watermelon": [5, 5, "watermelon"], + "strawberry": [5, 5, "strawberry"], + "melon": [5, 5, "melon"], + "guava": [5, 5, "guava"], + "pomegranate": [5, 5, "pomegranate"], + "jackfruit": [5, 5, "jackfruit"], + "coconut": [5, 5, "coconut"], + "peach": [5, 5, "peach"], + "pear": [5, 5, "pear"], + "plum": [5, 5, "plum"], + "blueberry": [5, 5, "blueberry"], + "raspberry": [5, 5, "raspberry"], + "kiwi": [5, 5, "kiwi"], + "avocado": [5, 5, "avocado"], + "cucumber": [5, 5, "cucumber"], + "pepper": [5, 5, "pepper"], + "onion": [5, 5, "onion"], + "potato": [5, 5, "potato"], + "tomato": [5, 5, "tomato"], + "garlic": [5, 5, "garlic"], + "ginger": [5, 5, "ginger"], + "spinach": [5, 5, "spinach"], + "broccoli": [5, 5, "broccoli"], + "cauliflower": [5, 5, "cauliflower"], + "cabbage": [5, 5, "cabbage"], + "beetroot": [5, 5, "beetroot"], + "celery": [5, 5, "celery"], + "corn": [5, 5, "corn"], + "mushroom": [5, 5, "mushroom"] + + }; + return dataSet; +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-tuple-data-provider/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-tuple-data-provider/Ballerina.toml new file mode 100644 index 000000000000..a0611873503a --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-tuple-data-provider/Ballerina.toml @@ -0,0 +1,8 @@ +[package] +org = "luheerathan" +name = "test_parallelisation_test" +version = "0.1.0" +distribution = "2201.3.0-rc3" + +[build-options] +observabilityIncluded = true diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-tuple-data-provider/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-tuple-data-provider/main.bal new file mode 100644 index 000000000000..a37ada63a432 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-tuple-data-provider/main.bal @@ -0,0 +1,55 @@ +import ballerina/io; +import ballerina/lang.runtime; +import ballerina/time; + +int employedCount = 20000; +int[] quantities_ = [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + + 23, + 24 +]; + +public function main() { + decimal now = time:monotonicNow(); + int count = 10; + + while true { + if count > 0 { + future<()> f = start get_average(); + count -= 1; + } + // int avg = get_average(); + // io:println("Average: ", avg); + + } + +} + +function get_average() { + runtime:sleep(10); + io:println("Helllwo"); + +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-tuple-data-provider/tests/data_driven_test.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-tuple-data-provider/tests/data_driven_test.bal new file mode 100644 index 000000000000..24f48cf0f53e --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/non-parallelisation-tuple-data-provider/tests/data_driven_test.bal @@ -0,0 +1,51 @@ +import ballerina/lang.runtime; +import ballerina/test; + +@test:Config { + dataProvider: stringDataProvider, + parallelizable: false +} +function testAddingValues0(string fValue, string sValue, string result) returns error? { + int value1 = check 'int:fromString(fValue); + int value2 = check 'int:fromString(sValue); + int result1 = check 'int:fromString(result); + runtime:sleep(1); + test:assertEquals(value1 + value2, result1, msg = "Incorrect Sum"); +} + +function stringDataProvider() returns (string[][]) { + return [ + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"], + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"], + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"], + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"] + , + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"], + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"], + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"] + , + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"], + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"], + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"] + ]; +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-map-data-provider/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-map-data-provider/Ballerina.toml new file mode 100644 index 000000000000..a0611873503a --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-map-data-provider/Ballerina.toml @@ -0,0 +1,8 @@ +[package] +org = "luheerathan" +name = "test_parallelisation_test" +version = "0.1.0" +distribution = "2201.3.0-rc3" + +[build-options] +observabilityIncluded = true diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-map-data-provider/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-map-data-provider/main.bal new file mode 100644 index 000000000000..a37ada63a432 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-map-data-provider/main.bal @@ -0,0 +1,55 @@ +import ballerina/io; +import ballerina/lang.runtime; +import ballerina/time; + +int employedCount = 20000; +int[] quantities_ = [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + + 23, + 24 +]; + +public function main() { + decimal now = time:monotonicNow(); + int count = 10; + + while true { + if count > 0 { + future<()> f = start get_average(); + count -= 1; + } + // int avg = get_average(); + // io:println("Average: ", avg); + + } + +} + +function get_average() { + runtime:sleep(10); + io:println("Helllwo"); + +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-map-data-provider/tests/data_driven_test.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-map-data-provider/tests/data_driven_test.bal new file mode 100644 index 000000000000..4edbaafb8182 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-map-data-provider/tests/data_driven_test.bal @@ -0,0 +1,59 @@ + +import ballerina/lang.runtime; +import ballerina/test; + +@test:Config { + dataProvider: mapDataProvider +} +function mapDataProviderTest(int value1, int value2, string fruit) returns error? { + test:assertEquals(value1, value2, msg = "The provided values are not equal"); + runtime:sleep(0.5); + test:assertEquals(fruit.length(), 6); +} + +function mapDataProvider() returns map<[int, int, string]>|error { + map<[int, int, string]> dataSet = { + "banana": [10, 10, "banana"], + "cherry": [5, 5, "cherry"], + "apple": [5, 5, "apple"], + "orange": [5, 5, "orange"], + "carrot": [5, 5, "carrot"], + "lemon": [5, 5, "lemon"], + "tomatto": [5, 5, "tomatto"], + "papaya": [5, 5, "papaya"], + "grapes": [5, 5, "grapes"], + "mango": [5, 5, "mango"], + "pineapple": [5, 5, "pineapple"], + "watermelon": [5, 5, "watermelon"], + "strawberry": [5, 5, "strawberry"], + "melon": [5, 5, "melon"], + "guava": [5, 5, "guava"], + "pomegranate": [5, 5, "pomegranate"], + "jackfruit": [5, 5, "jackfruit"], + "coconut": [5, 5, "coconut"], + "peach": [5, 5, "peach"], + "pear": [5, 5, "pear"], + "plum": [5, 5, "plum"], + "blueberry": [5, 5, "blueberry"], + "raspberry": [5, 5, "raspberry"], + "kiwi": [5, 5, "kiwi"], + "avocado": [5, 5, "avocado"], + "cucumber": [5, 5, "cucumber"], + "pepper": [5, 5, "pepper"], + "onion": [5, 5, "onion"], + "potato": [5, 5, "potato"], + "tomato": [5, 5, "tomato"], + "garlic": [5, 5, "garlic"], + "ginger": [5, 5, "ginger"], + "spinach": [5, 5, "spinach"], + "broccoli": [5, 5, "broccoli"], + "cauliflower": [5, 5, "cauliflower"], + "cabbage": [5, 5, "cabbage"], + "beetroot": [5, 5, "beetroot"], + "celery": [5, 5, "celery"], + "corn": [5, 5, "corn"], + "mushroom": [5, 5, "mushroom"] + + }; + return dataSet; +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-parallelizable/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-parallelizable/Ballerina.toml new file mode 100644 index 000000000000..a0611873503a --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-parallelizable/Ballerina.toml @@ -0,0 +1,8 @@ +[package] +org = "luheerathan" +name = "test_parallelisation_test" +version = "0.1.0" +distribution = "2201.3.0-rc3" + +[build-options] +observabilityIncluded = true diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-parallelizable/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-parallelizable/main.bal new file mode 100644 index 000000000000..a37ada63a432 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-parallelizable/main.bal @@ -0,0 +1,55 @@ +import ballerina/io; +import ballerina/lang.runtime; +import ballerina/time; + +int employedCount = 20000; +int[] quantities_ = [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + + 23, + 24 +]; + +public function main() { + decimal now = time:monotonicNow(); + int count = 10; + + while true { + if count > 0 { + future<()> f = start get_average(); + count -= 1; + } + // int avg = get_average(); + // io:println("Average: ", avg); + + } + +} + +function get_average() { + runtime:sleep(10); + io:println("Helllwo"); + +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-parallelizable/tests/normalTest.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-parallelizable/tests/normalTest.bal new file mode 100644 index 000000000000..4763450f2cd9 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-parallelizable/tests/normalTest.bal @@ -0,0 +1,383 @@ + +import ballerina/test; +import ballerina/lang.runtime; + +@test:BeforeSuite +function beforeSuiteFunc() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false} +function testFunction() { + test:assertTrue(true, msg = "Failed!"); +} + +@test:Config {parallelizable: false} +function testAssertEquals1() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1]} +function testAssertEquals2() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2]} +function testAssertEquals3() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2]} +function testAssertEquals4() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals4]} +function testAssertEquals5() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals4, testAssertEquals5]} +function testAssertEquals6() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false} +function testAssertEquals7() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals6]} +function testAssertEquals8() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals4, testAssertEquals8]} +function testAssertEquals9() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals8, testAssertEquals7, testAssertEquals11]} +function testAssertEquals10() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false} +function testAssertEquals11() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals7]} +function testAssertEquals12() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals6]} +function testAssertEquals13() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false} +function testAssertEquals14() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false} +function testAssertEquals15() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals13]} +function testAssertEquals16() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false} +function testAssertEquals17() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals17]} +function testAssertEquals18() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals16]} +function testAssertEquals19() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals16]} +function testAssertEquals20() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals14]} +function testAssertEquals21() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals14, testAssertEquals15]} +function testAssertEquals22() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals15, testAssertEquals21]} +function testAssertEquals23() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals19, testAssertEquals20]} +function testAssertEquals24() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals20, testAssertEquals24, testAssertEquals12, testAssertEquals11]} +function testAssertEquals25() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals25, testAssertEquals24]} +function testAssertEquals26() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals24, testAssertEquals26]} +function testAssertEquals27() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false} +function testAssertEquals28() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals28]} +function testAssertEquals29() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals28]} +function testAssertEquals30() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals28]} +function testAssertEquals31() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals28]} +function testAssertEquals32() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals28]} +function testAssertEquals33() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals34() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals35() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals36() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals37() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals38() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals39() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals40() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals41() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals42() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals43() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals44() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals45() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals46() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals47() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals48() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals49() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals50() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals51() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals52() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals53() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals54() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals55() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals56() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals57() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals58() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals59() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false, dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals60() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +// After Suite Function + +@test:AfterSuite +function afterSuiteFunc() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-simple-test/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-simple-test/Ballerina.toml new file mode 100644 index 000000000000..10927eae3866 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-simple-test/Ballerina.toml @@ -0,0 +1,7 @@ +[package] +org = "luheerathan" +name = "test_parallelisation_test" + + +[build-options] +observabilityIncluded = true diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-simple-test/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-simple-test/main.bal new file mode 100644 index 000000000000..a37ada63a432 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-simple-test/main.bal @@ -0,0 +1,55 @@ +import ballerina/io; +import ballerina/lang.runtime; +import ballerina/time; + +int employedCount = 20000; +int[] quantities_ = [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + + 23, + 24 +]; + +public function main() { + decimal now = time:monotonicNow(); + int count = 10; + + while true { + if count > 0 { + future<()> f = start get_average(); + count -= 1; + } + // int avg = get_average(); + // io:println("Average: ", avg); + + } + +} + +function get_average() { + runtime:sleep(10); + io:println("Helllwo"); + +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-simple-test/tests/normalTest.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-simple-test/tests/normalTest.bal new file mode 100644 index 000000000000..4e440ae4e673 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-simple-test/tests/normalTest.bal @@ -0,0 +1,383 @@ + +import ballerina/test; +import ballerina/lang.runtime; + +@test:BeforeSuite +function beforeSuiteFunc() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {} +function testFunction() { + test:assertTrue(true, msg = "Failed!"); +} + +@test:Config {} +function testAssertEquals1() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1]} +function testAssertEquals2() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2]} +function testAssertEquals3() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2]} +function testAssertEquals4() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals4]} +function testAssertEquals5() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals4, testAssertEquals5], parallelizable: false} +function testAssertEquals6() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {} +function testAssertEquals7() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals6]} +function testAssertEquals8() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals4, testAssertEquals8]} +function testAssertEquals9() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals8, testAssertEquals7, testAssertEquals11]} +function testAssertEquals10() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false} +function testAssertEquals11() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals7]} +function testAssertEquals12() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals6]} +function testAssertEquals13() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false} +function testAssertEquals14() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {} +function testAssertEquals15() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals13]} +function testAssertEquals16() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {} +function testAssertEquals17() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals17]} +function testAssertEquals18() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals16]} +function testAssertEquals19() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals16]} +function testAssertEquals20() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals14]} +function testAssertEquals21() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals14, testAssertEquals15]} +function testAssertEquals22() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals15, testAssertEquals21]} +function testAssertEquals23() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals19, testAssertEquals20], parallelizable: false} +function testAssertEquals24() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals20, testAssertEquals24, testAssertEquals12, testAssertEquals11]} +function testAssertEquals25() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals25, testAssertEquals24]} +function testAssertEquals26() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals24, testAssertEquals26]} +function testAssertEquals27() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {parallelizable: false} +function testAssertEquals28() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals28]} +function testAssertEquals29() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals28]} +function testAssertEquals30() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals28]} +function testAssertEquals31() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals28]} +function testAssertEquals32() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals28]} +function testAssertEquals33() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals34() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals35() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals36() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals37() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals38() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals39() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals40() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals41() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals42() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals43() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals44() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals45() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals46() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals47() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals48() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals49() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals50() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals51() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals52() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals53() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals54() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals55() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals56() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals57() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals58() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals59() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +@test:Config {dependsOn: [testAssertEquals1, testAssertEquals2, testAssertEquals4, testAssertEquals5, testAssertEquals6, testAssertEquals7, testAssertEquals8, testAssertEquals9, testAssertEquals10, testFunction]} +function testAssertEquals60() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + +// After Suite Function + +@test:AfterSuite +function afterSuiteFunc() { + runtime:sleep(0.5); + test:assertEquals(100, 100); +} + diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-tuple-data-provider/Ballerina.toml b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-tuple-data-provider/Ballerina.toml new file mode 100644 index 000000000000..a0611873503a --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-tuple-data-provider/Ballerina.toml @@ -0,0 +1,8 @@ +[package] +org = "luheerathan" +name = "test_parallelisation_test" +version = "0.1.0" +distribution = "2201.3.0-rc3" + +[build-options] +observabilityIncluded = true diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-tuple-data-provider/main.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-tuple-data-provider/main.bal new file mode 100644 index 000000000000..a37ada63a432 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-tuple-data-provider/main.bal @@ -0,0 +1,55 @@ +import ballerina/io; +import ballerina/lang.runtime; +import ballerina/time; + +int employedCount = 20000; +int[] quantities_ = [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + + 23, + 24 +]; + +public function main() { + decimal now = time:monotonicNow(); + int count = 10; + + while true { + if count > 0 { + future<()> f = start get_average(); + count -= 1; + } + // int avg = get_average(); + // io:println("Average: ", avg); + + } + +} + +function get_average() { + runtime:sleep(10); + io:println("Helllwo"); + +} diff --git a/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-tuple-data-provider/tests/data_driven_test.bal b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-tuple-data-provider/tests/data_driven_test.bal new file mode 100644 index 000000000000..ac145f2c4e51 --- /dev/null +++ b/tests/testerina-integration-test/src/test/resources/project-based-tests/parallelisation-test/parallelisation-tuple-data-provider/tests/data_driven_test.bal @@ -0,0 +1,51 @@ +import ballerina/lang.runtime; +import ballerina/test; + +@test:Config { + dataProvider: stringDataProvider, + parallelizable: true +} +function testAddingValues0(string fValue, string sValue, string result) returns error? { + int value1 = check 'int:fromString(fValue); + int value2 = check 'int:fromString(sValue); + int result1 = check 'int:fromString(result); + runtime:sleep(1); + test:assertEquals(value1 + value2, result1, msg = "Incorrect Sum"); +} + +function stringDataProvider() returns (string[][]) { + return [ + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"], + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"], + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"], + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"] + , + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"], + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"], + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"] + , + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"], + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"], + ["1", "2", "3"], + ["10", "20", "30"], + ["5", "6", "11"] + ]; +} diff --git a/tests/testerina-integration-test/src/test/resources/testng.xml b/tests/testerina-integration-test/src/test/resources/testng.xml index c827e46ae5b1..81b6bc32d891 100644 --- a/tests/testerina-integration-test/src/test/resources/testng.xml +++ b/tests/testerina-integration-test/src/test/resources/testng.xml @@ -54,6 +54,7 @@ under the License. +