Skip to content

Commit

Permalink
Add time-based execution mechanism in STF load tests
Browse files Browse the repository at this point in the history
Signed-off-by: Mesbah_Alam@ca.ibm.com <Mesbah_Alam@ca.ibm.com>
  • Loading branch information
Mesbah-Alam committed Jan 23, 2021
1 parent 7165bc1 commit 68838eb
Show file tree
Hide file tree
Showing 15 changed files with 276 additions and 305 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
import java.util.ArrayList;

import net.adoptopenjdk.loadTest.InventoryData;
import net.adoptopenjdk.stf.codeGeneration.Stage;
import net.adoptopenjdk.loadTest.TimeBasedLoadTest;
import net.adoptopenjdk.stf.environment.DirectoryRef;
import net.adoptopenjdk.stf.extensions.core.StfCoreExtension;
import net.adoptopenjdk.stf.extensions.core.StfCoreExtension.Echo;
import net.adoptopenjdk.stf.plugin.interfaces.StfPluginInterface;
import net.adoptopenjdk.stf.processes.ExpectedOutcome;
import net.adoptopenjdk.stf.processes.definitions.JavaProcessDefinition;
import net.adoptopenjdk.stf.processes.definitions.LoadTestProcessDefinition;
Expand All @@ -31,7 +30,7 @@
* This is a simple test plugin that runs a workload of tests
* from the test.classloading project.
*/
public class ClassloadingLoadTest implements StfPluginInterface {
public class ClassloadingLoadTest extends TimeBasedLoadTest {

private int testCountMultiplier = 3000;
private boolean specialTest = false;
Expand All @@ -42,12 +41,6 @@ public void help(HelpTextGenerator help) throws StfException {
+ "from the test.classloading project.");
}

public void pluginInit(StfCoreExtension stf) throws StfException {
}

public void setUp(StfCoreExtension test) throws StfException {
}

public void execute(StfCoreExtension test) throws StfException {
String jvmOptionsInUse = test.getJavaArgs(test.env().primaryJvm());

Expand Down Expand Up @@ -88,19 +81,25 @@ public void execute(StfCoreExtension test) throws StfException {
.addModules(modulesAdd)
.addPrereqJarToClasspath(JavaProcessDefinition.JarId.JUNIT)
.addPrereqJarToClasspath(JavaProcessDefinition.JarId.HAMCREST)
.addProjectToClasspath("openjdk.test.classloading")
.setAbortIfOutOfMemory(false)
.addProjectToClasspath("openjdk.test.classloading");

if (isTimeBasedLoadTest) {
loadTestInvocation = loadTestInvocation.setTimeLimit(timeLimit); // If it's a time based test, stop execution after given time duration
}

loadTestInvocation = loadTestInvocation.setAbortIfOutOfMemory(false)
.addSuite("classloading")
.setSuiteThreadCount(cpuCount - 1, 10)
.setSuiteInventory(inventoryFile)
.setSuiteNumTests(totalTests * testCountMultiplier)
.setSuiteRandomSelection();
.setSuiteInventory(inventoryFile);

if (!isTimeBasedLoadTest) {
loadTestInvocation = loadTestInvocation.setSuiteNumTests(totalTests * testCountMultiplier);
}

loadTestInvocation = loadTestInvocation.setSuiteRandomSelection();

test.doRunForegroundProcess("Run classloading tests", "CLT", Echo.ECHO_ON,
ExpectedOutcome.cleanRun().within("2h"),
ExpectedOutcome.cleanRun().within(finalTimeout),
loadTestInvocation);
}

public void tearDown(StfCoreExtension stf) throws StfException {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,21 @@

package net.adoptopenjdk.stf;

import net.adoptopenjdk.loadTest.InventoryData;
import net.adoptopenjdk.loadTest.TimeBasedLoadTest;
import net.adoptopenjdk.stf.extensions.core.StfCoreExtension;
import net.adoptopenjdk.stf.extensions.core.StfCoreExtension.Echo;
import net.adoptopenjdk.stf.plugin.interfaces.StfPluginInterface;
import net.adoptopenjdk.stf.processes.ExpectedOutcome;
import net.adoptopenjdk.stf.processes.definitions.JavaProcessDefinition;
import net.adoptopenjdk.stf.processes.definitions.LoadTestProcessDefinition;
import net.adoptopenjdk.stf.runner.modes.HelpTextGenerator;
import net.adoptopenjdk.loadTest.InventoryData;

public class ConcurrentLoadTest implements StfPluginInterface {
public class ConcurrentLoadTest extends TimeBasedLoadTest {
public void help(HelpTextGenerator help) throws StfException {
help.outputSection("ConcurrentLoadTest runs concurrency unit tests");
help.outputText("");
}

public void pluginInit(StfCoreExtension stf) throws StfException {
}

public void setUp(StfCoreExtension test) throws StfException {
}

public void execute(StfCoreExtension test) throws StfException {
String inventoryFile = "/openjdk.test.load/config/inventories/concurrent/concurrent.xml";
int totalTests = InventoryData.getNumberOfTests(test, inventoryFile);
Expand All @@ -43,20 +37,25 @@ public void execute(StfCoreExtension test) throws StfException {
LoadTestProcessDefinition loadTestInvocation = test.createLoadTestSpecification()
.addPrereqJarToClasspath(JavaProcessDefinition.JarId.JUNIT)
.addPrereqJarToClasspath(JavaProcessDefinition.JarId.HAMCREST)
.addProjectToClasspath("openjdk.test.concurrent")
.setAbortIfOutOfMemory(false)
.addProjectToClasspath("openjdk.test.concurrent");

if (isTimeBasedLoadTest) {
loadTestInvocation = loadTestInvocation.setTimeLimit(timeLimit); // If it's a time based test, stop execution after given time duration
}

loadTestInvocation = loadTestInvocation.setAbortIfOutOfMemory(false)
.addSuite("concurrent")
.setSuiteThreadCount(cpuCount - 2, 20) // Leave 1 cpu for the JIT. i for GC and set min 20
.setSuiteInventory(inventoryFile) // Point at the file which lists the tests
.setSuiteNumTests(totalTests * 20) // Run for about 2 minutes with no -X options
.setSuiteRandomSelection(); // Randomly pick the next test each time
.setSuiteInventory(inventoryFile); // Point at the file which lists the tests

if (!isTimeBasedLoadTest) {
loadTestInvocation = loadTestInvocation.setSuiteNumTests(totalTests * 20); // Run for about 2 minutes with no -X options
}

loadTestInvocation = loadTestInvocation.setSuiteRandomSelection(); // Randomly pick the next test each time

//.setSuiteNumTests(totalTests * 50) // Run for about 5 minutes
test.doRunForegroundProcess("Run concurrency unit tests", "LT", Echo.ECHO_ON,
ExpectedOutcome.cleanRun().within("1h"),
ExpectedOutcome.cleanRun().within(finalTimeout),
loadTestInvocation);
}

public void tearDown(StfCoreExtension stf) throws StfException {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
package net.adoptopenjdk.stf;

import net.adoptopenjdk.loadTest.InventoryData;
import net.adoptopenjdk.loadTest.TimeBasedLoadTest;
import net.adoptopenjdk.stf.environment.FileRef;
import net.adoptopenjdk.stf.extensions.core.StfCoreExtension;
import net.adoptopenjdk.stf.extensions.core.StfCoreExtension.Echo;
import net.adoptopenjdk.stf.plugin.interfaces.StfPluginInterface;
import net.adoptopenjdk.stf.processes.ExpectedOutcome;
import net.adoptopenjdk.stf.processes.definitions.JavaProcessDefinition;
import net.adoptopenjdk.stf.processes.definitions.LoadTestProcessDefinition;
Expand All @@ -29,7 +29,7 @@
*
* The DirectMemoryTest allocates direct memory ByteBuffers and dereferences them.
*/
public class DirectByteBufferLoadTest implements StfPluginInterface {
public class DirectByteBufferLoadTest extends TimeBasedLoadTest {
public void help(HelpTextGenerator help) throws StfException {
String testName = DirectByteBufferLoadTest.class.getSimpleName();

Expand All @@ -38,12 +38,6 @@ public void help(HelpTextGenerator help) throws StfException {
help.outputText("This test is primarily aimed at stressing the Garbage Collector.");
}

public void pluginInit(StfCoreExtension test) throws StfException {
}

public void setUp(StfCoreExtension test) throws Exception {
}

public void execute(StfCoreExtension test) throws StfException {
// The NIO workload has a dependency on filesystem.jar
FileRef filesystemJar = test.env().findTestFile("openjdk.test.nio/bin/lib/filesystem.jar");
Expand All @@ -58,19 +52,26 @@ public void execute(StfCoreExtension test) throws StfException {
.addPrereqJarToClasspath(JavaProcessDefinition.JarId.HAMCREST)
.addJarToClasspath(filesystemJar)
.addProjectToClasspath("openjdk.test.gc")
.addProjectToClasspath("openjdk.test.nio")
.addSuite("DirectByteBuffer")
.addProjectToClasspath("openjdk.test.nio");

if (isTimeBasedLoadTest) {
loadTestInvocation = loadTestInvocation.setTimeLimit(timeLimit); // If it's a time based test, stop execution after given time duration
}

loadTestInvocation = loadTestInvocation.addSuite("DirectByteBuffer")
.setSuiteThinkingTime("1ms", "1ms")// Waiting for 1ms between tests to give the system a chance to reclaim unused native memory.
.setSuiteThreadCount(cpuCount - 1, 2)
.setSuiteNumTests(numTests)
.setSuiteInventory(inventory)
.setSuiteThreadCount(cpuCount - 1, 2);

if (!isTimeBasedLoadTest) {
loadTestInvocation = loadTestInvocation.setSuiteNumTests(numTests);
}

loadTestInvocation = loadTestInvocation.setSuiteInventory(inventory)
.setSuiteRandomSelection();

test.doRunForegroundProcess("Run DirectByteBuffer load test", "DBLT", Echo.ECHO_ON,
ExpectedOutcome.cleanRun().within("5m"),
ExpectedOutcome.cleanRun().within(finalTimeout),
loadTestInvocation);
}

public void tearDown(StfCoreExtension test) throws StfException {
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,46 @@

package net.adoptopenjdk.stf;

import net.adoptopenjdk.loadTest.TimeBasedLoadTest;
import net.adoptopenjdk.stf.extensions.core.StfCoreExtension;
import net.adoptopenjdk.stf.extensions.core.StfCoreExtension.Echo;
import net.adoptopenjdk.stf.plugin.interfaces.StfPluginInterface;
import net.adoptopenjdk.stf.processes.ExpectedOutcome;
import net.adoptopenjdk.stf.processes.definitions.JavaProcessDefinition;
import net.adoptopenjdk.stf.processes.definitions.LoadTestProcessDefinition;
import net.adoptopenjdk.stf.runner.modes.HelpTextGenerator;

public class LambdaLoadTest implements StfPluginInterface {
public class LambdaLoadTest extends TimeBasedLoadTest {
public void help(HelpTextGenerator help) throws StfException {
help.outputSection("LambdaLoadTest runs unit tests for Lambda and Streams");
help.outputText("");
}

public void pluginInit(StfCoreExtension test) throws StfException {
}

public void setUp(StfCoreExtension test) throws StfException {
}

public void execute(StfCoreExtension test) throws StfException {
String inventoryFile = "/openjdk.test.load/config/inventories/lambdasAndStreams/lambda.xml";
int cpuCount = Runtime.getRuntime().availableProcessors();

LoadTestProcessDefinition loadTestInvocation = test.createLoadTestSpecification()
.addPrereqJarToClasspath(JavaProcessDefinition.JarId.JUNIT)
.addPrereqJarToClasspath(JavaProcessDefinition.JarId.HAMCREST)
.addProjectToClasspath("openjdk.test.lambdasAndStreams")
.setInactivityLimit("60m") // Since this test is run using -Xint as well, set a larger inactivity limit than default
.addProjectToClasspath("openjdk.test.lambdasAndStreams");

if (isTimeBasedLoadTest) {
loadTestInvocation = loadTestInvocation.setTimeLimit(timeLimit); // If it's a time based test, stop execution after given time duration
}

loadTestInvocation = loadTestInvocation.setInactivityLimit("60m") // Since this test is run using -Xint as well, set a larger inactivity limit than default
.addSuite("lambda") // Start args for the first suite
.setSuiteThreadCount(cpuCount - 2, 2) // Leave 1 cpu for the JIT, 1 cpu for GC and set min 2
.setSuiteInventory(inventoryFile) // Point at the file which lists the tests
.setSuiteNumTests(200) // Run this many tests
.setSuiteRandomSelection(); // Randomly pick the next test each time

.setSuiteInventory(inventoryFile); // Point at the file which lists the tests

if (!isTimeBasedLoadTest) {
loadTestInvocation = loadTestInvocation.setSuiteNumTests(200); // Run this many tests
}

loadTestInvocation = loadTestInvocation.setSuiteRandomSelection(); // Randomly pick the next test each time

test.doRunForegroundProcess("Run lambda and stream load test", "LT", Echo.ECHO_ON,
ExpectedOutcome.cleanRun().within("60m"),
ExpectedOutcome.cleanRun().within(finalTimeout),
loadTestInvocation);
}

public void tearDown(StfCoreExtension test) throws StfException {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package net.adoptopenjdk.stf;

import net.adoptopenjdk.loadTest.InventoryData;
import net.adoptopenjdk.loadTest.TimeBasedLoadTest;
import net.adoptopenjdk.stf.extensions.core.StfCoreExtension;
import net.adoptopenjdk.stf.extensions.core.StfCoreExtension.Echo;
import net.adoptopenjdk.stf.plugin.interfaces.StfPluginInterface;
import net.adoptopenjdk.stf.processes.ExpectedOutcome;
import net.adoptopenjdk.stf.processes.definitions.JavaProcessDefinition;
import net.adoptopenjdk.stf.processes.definitions.LoadTestProcessDefinition;
Expand All @@ -27,18 +27,12 @@
* This is a test plugin for Java.lang related tests, it runs a workload of
* invoke tests and project coin tests.
*/
public class LangLoadTest implements StfPluginInterface {
public class LangLoadTest extends TimeBasedLoadTest {
public void help(HelpTextGenerator help) throws StfException {
help.outputSection("LangLoadTest runs a workload of Java.lang related tests.");
help.outputText("");
}

public void pluginInit(StfCoreExtension stf) throws StfException {
}

public void setUp(StfCoreExtension test) throws StfException {
}

public void execute(StfCoreExtension test) throws StfException {
String inventoryFile = "/openjdk.test.load/config/inventories/lang/lang.xml";
int numlangTests = InventoryData.getNumberOfTests(test, inventoryFile);
Expand All @@ -47,18 +41,24 @@ public void execute(StfCoreExtension test) throws StfException {
LoadTestProcessDefinition loadTestInvocation = test.createLoadTestSpecification()
.addPrereqJarToClasspath(JavaProcessDefinition.JarId.JUNIT)
.addPrereqJarToClasspath(JavaProcessDefinition.JarId.HAMCREST)
.addProjectToClasspath("openjdk.test.lang")
.addSuite("lang")
.setSuiteThreadCount(cpuCount - 1, 2)
.setSuiteNumTests(numlangTests * 100)
.setSuiteInventory(inventoryFile)
.addProjectToClasspath("openjdk.test.lang");

if (isTimeBasedLoadTest) {
loadTestInvocation = loadTestInvocation.setTimeLimit(timeLimit); // If it's a time based test, stop execution after given time duration
}

loadTestInvocation = loadTestInvocation.addSuite("lang")
.setSuiteThreadCount(cpuCount - 1, 2);

if (!isTimeBasedLoadTest) {
loadTestInvocation = loadTestInvocation.setSuiteNumTests(numlangTests * 100);
}

loadTestInvocation = loadTestInvocation.setSuiteInventory(inventoryFile)
.setSuiteRandomSelection();

test.doRunForegroundProcess("Run lang load test", "LLT", Echo.ECHO_ON,
ExpectedOutcome.cleanRun().within("10m"),
ExpectedOutcome.cleanRun().within(finalTimeout),
loadTestInvocation);
}

public void tearDown(StfCoreExtension stf) throws StfException {
}
}
}
Loading

0 comments on commit 68838eb

Please sign in to comment.