-
Notifications
You must be signed in to change notification settings - Fork 755
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a751e26
commit f73ac1f
Showing
22 changed files
with
1,560 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
...egration-test/src/test/java/org/ballerinalang/testerina/test/TestparallelizationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...ect-based-tests/parallelisation-test/non-parallelisation-map-data-provider/Ballerina.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
org = "luheerathan" | ||
name = "test_parallelisation_test" | ||
version = "0.1.0" | ||
distribution = "2201.3.0-rc3" | ||
|
||
[build-options] | ||
observabilityIncluded = true |
55 changes: 55 additions & 0 deletions
55
...s/project-based-tests/parallelisation-test/non-parallelisation-map-data-provider/main.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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"); | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
...sts/parallelisation-test/non-parallelisation-map-data-provider/tests/data_driven_test.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} |
8 changes: 8 additions & 0 deletions
8
...t-based-tests/parallelisation-test/non-parallelisation-tuple-data-provider/Ballerina.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
org = "luheerathan" | ||
name = "test_parallelisation_test" | ||
version = "0.1.0" | ||
distribution = "2201.3.0-rc3" | ||
|
||
[build-options] | ||
observabilityIncluded = true |
Oops, something went wrong.