move integrated testing to separate module

This commit is contained in:
Jonathan Shook 2022-06-09 15:01:02 -05:00
parent fa2847a613
commit 6dd1c43db3
7 changed files with 34 additions and 471 deletions

View File

@ -43,7 +43,7 @@ public class ActivityExecutorTest {
@Test
public void testRestart() {
ActivityDef ad = ActivityDef.parseActivityDef("driver=diag;alias=test;cycles=1000;initdelay=5000;");
ActivityDef ad = ActivityDef.parseActivityDef("driver=diag;alias=test;cycles=1000;op=initdelay:initdelay=5000;");
Optional<ActivityType> activityType = new ActivityTypeLoader().load(ad);
Activity a = new DelayedInitActivity(ad);
InputDispenser idisp = new CoreInputDispenser(a);

View File

@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
// TODO: convert to Junit5 jupiter assertions
public class AsyncScriptIntegrationTests {
public class ScriptExampleTests {
public static ScenarioResult runScenario(String scriptname, String... params) {
if ((params.length % 2) != 0) {
@ -55,12 +55,12 @@ public class AsyncScriptIntegrationTests {
}
String scenarioName = "scenario " + scriptname;
System.out.println("=".repeat(29) + " Running ASYNC integration test for: " + scenarioName);
ScenariosExecutor executor = new ScenariosExecutor(AsyncScriptIntegrationTests.class.getSimpleName() + ":" + scriptname, 1);
ScenariosExecutor executor = new ScenariosExecutor(ScriptExampleTests.class.getSimpleName() + ":" + scriptname, 1);
Scenario s = new Scenario(scenarioName, Scenario.Engine.Graalvm,"stdout:300", Maturity.Any);
s.addScenarioScriptParams(paramsMap);
ClassLoader cl = AsyncScriptIntegrationTests.class.getClassLoader();
ClassLoader cl = ScriptExampleTests.class.getClassLoader();
String script;
try {
String scriptPath = "scripts/examples/" + scriptname + ".js";
@ -88,19 +88,18 @@ public class AsyncScriptIntegrationTests {
}
@Test
public void testOptimo() {
ScenarioResult scenarioResult = runScenario("optimo");
String iolog = scenarioResult.getIOLog();
System.out.println("iolog\n" + iolog);
// Pattern p = Pattern.compile(".*mean cycle rate = (\\d[.\\d]+).*", Pattern.DOTALL);
// Matcher m = p.matcher(iolog);
// assertThat(m.matches()).isTrue();
//
// String digits = m.group(1);
// assertThat(digits).isNotEmpty();
// double rate = Double.valueOf(digits);
// assertThat(rate).isCloseTo(1000, Offset.offset(100.0));
//
public void testLinkedInput() {
ScenarioResult scenarioResult = runScenario("linkedinput");
Pattern p = Pattern.compile(".*started leader.*started follower.*stopped leader.*stopped follower.*",
Pattern.DOTALL);
assertThat(p.matcher(scenarioResult.getIOLog()).matches()).isTrue();
}
@Test
public void testExceptionPropagationFromMotorThread() {
ScenarioResult scenarioResult = runScenario("activityerror");
assertThat(scenarioResult.getException()).isPresent();
assertThat(scenarioResult.getException().get().getMessage()).contains("For input string: \"unparsable\"");
}
@Test
@ -118,23 +117,6 @@ public class AsyncScriptIntegrationTests {
assertThat(rate).isCloseTo(1000, Offset.offset(100.0));
}
// The coverage of this test is also covered by the rate limiter
// specific tests
// @Test
// public void testStrideRateOnly() {
// ScenarioResult scenarioResult = runScenario("stride_rate");
// String iolog = scenarioResult.getIOLog();
// System.out.println("iolog\n" + iolog);
// Pattern p = Pattern.compile(".*stride_rate.strides.servicetime.meanRate = (\\d[.\\d]+).*", Pattern.DOTALL);
// Matcher m = p.matcher(iolog);
// assertThat(m.matches()).isTrue();
//
// String digits = m.group(1);
// assertThat(digits).isNotEmpty();
// double rate = Double.valueOf(digits);
// assertThat(rate).isCloseTo(2500, Offset.offset(500D));
// }
@Test
public void testExtensionPoint() {
ScenarioResult scenarioResult = runScenario("extensions");
@ -142,21 +124,20 @@ public class AsyncScriptIntegrationTests {
}
@Test
public void testLinkedInput() {
ScenarioResult scenarioResult = runScenario("linkedinput");
Pattern p = Pattern.compile(".*started leader.*started follower.*stopped leader.*stopped follower.*",
Pattern.DOTALL);
assertThat(p.matcher(scenarioResult.getIOLog()).matches()).isTrue();
public void testOptimo() {
ScenarioResult scenarioResult = runScenario("optimo");
String iolog = scenarioResult.getIOLog();
System.out.println("iolog\n" + iolog);
assertThat(iolog).contains("map of result was");
}
@Test
public void testExtensionCsvLogger() {
ScenarioResult scenarioResult = runScenario("extension_csvmetrics");
assertThat(scenarioResult.getIOLog()).contains("started new " +
"csvlogger: logs/csvmetricstestdir");
"csvlogger: logs/csvmetricstestdir");
}
@Test
public void testScriptParamsVariable() {
ScenarioResult scenarioResult = runScenario("params_variable", "one", "two", "three", "four");
@ -179,9 +160,9 @@ public class AsyncScriptIntegrationTests {
public void testExtensionHistoStatsLogger() throws IOException {
ScenarioResult scenarioResult = runScenario("extension_histostatslogger");
assertThat(scenarioResult.getIOLog()).contains("stdout started " +
"logging to logs/histostats.csv");
"logging to logs/histostats.csv");
List<String> strings = Files.readAllLines(Paths.get(
"logs/histostats.csv"));
"logs/histostats.csv"));
String logdata = strings.stream().collect(Collectors.joining("\n"));
assertThat(logdata).contains("min,p25,p50,p75,p90,p95,");
assertThat(logdata.split("Tag=testhistostatslogger.cycles.servicetime,").length).isGreaterThanOrEqualTo(2);
@ -254,18 +235,11 @@ public class AsyncScriptIntegrationTests {
);
}
@Test
public void testExceptionPropagationFromMotorThread() {
ScenarioResult scenarioResult = runScenario("activityerror");
assertThat(scenarioResult.getException()).isPresent();
assertThat(scenarioResult.getException().get().getMessage()).contains("For input string: \"unparsable\"");
}
@Test
public void testExceptionPropagationFromActivityInit() {
ScenarioResult scenarioResult = runScenario("activityiniterror");
assertThat(scenarioResult.getException()).isPresent();
assertThat(scenarioResult.getException().get().getMessage()).contains("For input string: \"unparsable\"");
assertThat(scenarioResult.getException().get().getMessage()).contains("Unknown config parameter 'unknown_config'");
assertThat(scenarioResult.getException()).isNotNull();
}
@ -290,15 +264,6 @@ public class AsyncScriptIntegrationTests {
// after investigating minor decreasing effect
}
// @Test
// @Disabled
// public void testCycleRateChangeOldMetrics() {
// ScenarioResult scenarioResult = runScenario("cycle_rate_change_deprecated");
// String ioLog = scenarioResult.getIOLog();
// assertThat(ioLog).contains("cycles adjusted, exiting on iteration");
// }
@Test
public void testCycleRateChangeNewMetrics() {
ScenarioResult scenarioResult = runScenario("cycle_rate_change");
@ -309,8 +274,8 @@ public class AsyncScriptIntegrationTests {
@Test
public void testExitLogic() {
ScenarioResult scenarioResult = runScenario(
"basicdiag",
"type", "diag", "cyclerate", "5", "erroroncycle", "10", "cycles", "2000"
"basicdiag",
"type", "diag", "cyclerate", "5", "erroroncycle", "10", "cycles", "2000"
);
}

View File

@ -48,7 +48,7 @@ public class ExitStatusIntegrationTests {
invoker.setLogDir("logs/test");
ProcessResult result = invoker.run("exitstatus_initexception", 15,
java, "-jar", JARNAME, "--logs-dir", "logs/test", "run",
"driver=diag", "initdelay=notanumber"
"driver=diag", "op=initdelay:initdelay=notanumber"
);
String stderr = result.getStdoutData().stream().collect(Collectors.joining("\n"));
assertThat(stderr).contains("For input string: \"notanumber\"");
@ -71,12 +71,12 @@ public class ExitStatusIntegrationTests {
// }
@Test
public void testExitStatusOnActivityAsyncStopException() {
public void testExitStatusOnActivityOpException() {
ProcessInvoker invoker = new ProcessInvoker();
invoker.setLogDir("logs/test");
ProcessResult result = invoker.run("exitstatus_asyncstoprequest", 30,
java, "-jar", JARNAME, "--logs-dir", "logs/test", "run",
"driver=diag", "async=1", "cyclerate=5", "erroroncycle=10", "cycles=2000", "-vvv"
"driver=diag", "cyclerate=5", "op=erroroncycle:erroroncycle=10", "cycles=2000", "-vvv"
);
String stdout = result.getStdoutData().stream().collect(Collectors.joining("\n"));
assertThat(stdout).contains("Diag was requested to stop on cycle 10");

View File

@ -1,309 +0,0 @@
/*
* Copyright (c) 2022 nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.nosqlbench.engine.core.script;
import io.nosqlbench.engine.core.lifecycle.ScenarioResult;
import io.nosqlbench.engine.core.lifecycle.ScenariosResults;
import io.nosqlbench.nb.annotations.Maturity;
import org.apache.commons.compress.utils.IOUtils;
import org.assertj.core.data.Offset;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
public class AsyncScriptIntegrationTests {
public static ScenarioResult runScenario(String scriptname, String... params) {
if ((params.length % 2) != 0) {
throw new RuntimeException("params must be pairwise key, value, ...");
}
Map<String, String> paramsMap = new HashMap<>();
for (int i = 0; i < params.length; i += 2) {
paramsMap.put(params[i], params[i + 1]);
}
String scenarioName = "scenario " + scriptname;
System.out.println("=".repeat(29) + " Running ASYNC integration test for: " + scenarioName);
ScenariosExecutor executor = new ScenariosExecutor(AsyncScriptIntegrationTests.class.getSimpleName() + ":" + scriptname, 1);
Scenario s = new Scenario(scenarioName, Scenario.Engine.Graalvm,"stdout:300", Maturity.Any);
s.addScenarioScriptParams(paramsMap);
ClassLoader cl = AsyncScriptIntegrationTests.class.getClassLoader();
String script;
try {
InputStream sstream = cl.getResourceAsStream("scripts/async/" + scriptname + ".js");
byte[] bytes = IOUtils.toByteArray(sstream);
script = new String(bytes, StandardCharsets.UTF_8);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
s.addScriptText(script);
// s.addScriptText("load('classpath:scripts/async/" + scriptname + ".js');");
executor.execute(s);
ScenariosResults scenariosResults = executor.awaitAllResults();
ScenarioResult scenarioResult = scenariosResults.getOne();
executor.shutdownNow();
return scenarioResult;
}
@BeforeAll
public static void logit() {
System.out.println("Running ASYNC version of Script Integration Tests.");
}
@Test
public void testOptimo() {
ScenarioResult scenarioResult = runScenario("optimo");
String iolog = scenarioResult.getIOLog();
System.out.println("iolog\n" + iolog);
// Pattern p = Pattern.compile(".*mean cycle rate = (\\d[.\\d]+).*", Pattern.DOTALL);
// Matcher m = p.matcher(iolog);
// assertThat(m.matches()).isTrue();
//
// String digits = m.group(1);
// assertThat(digits).isNotEmpty();
// double rate = Double.valueOf(digits);
// assertThat(rate).isCloseTo(1000, Offset.offset(100.0));
//
}
@Test
public void testCycleRate() {
ScenarioResult scenarioResult = runScenario("cycle_rate");
String iolog = scenarioResult.getIOLog();
System.out.println("iolog\n" + iolog);
Pattern p = Pattern.compile(".*mean cycle rate = (\\d[.\\d]+).*", Pattern.DOTALL);
Matcher m = p.matcher(iolog);
assertThat(m.matches()).isTrue();
String digits = m.group(1);
assertThat(digits).isNotEmpty();
double rate = Double.parseDouble(digits);
assertThat(rate).isCloseTo(1000, Offset.offset(100.0));
}
// The coverage of this test is also covered by the rate limiter
// specific tests
// @Test
// public void testStrideRateOnly() {
// ScenarioResult scenarioResult = runScenario("stride_rate");
// String iolog = scenarioResult.getIOLog();
// System.out.println("iolog\n" + iolog);
// Pattern p = Pattern.compile(".*stride_rate.strides.servicetime.meanRate = (\\d[.\\d]+).*", Pattern.DOTALL);
// Matcher m = p.matcher(iolog);
// assertThat(m.matches()).isTrue();
//
// String digits = m.group(1);
// assertThat(digits).isNotEmpty();
// double rate = Double.valueOf(digits);
// assertThat(rate).isCloseTo(2500, Offset.offset(500D));
// }
@Test
public void testExtensionPoint() {
ScenarioResult scenarioResult = runScenario("extensions");
assertThat(scenarioResult.getIOLog()).contains("sum is 46");
}
@Test
public void testLinkedInput() {
ScenarioResult scenarioResult = runScenario("linkedinput");
Pattern p = Pattern.compile(".*started leader.*started follower.*stopped leader.*stopped follower.*",
Pattern.DOTALL);
assertThat(p.matcher(scenarioResult.getIOLog()).matches()).isTrue();
}
@Test
public void testExtensionCsvLogger() {
ScenarioResult scenarioResult = runScenario("extension_csvmetrics");
assertThat(scenarioResult.getIOLog()).contains("started new " +
"csvlogger: logs/csvmetricstestdir");
}
@Test
public void testScriptParamsVariable() {
ScenarioResult scenarioResult = runScenario("params_variable", "one", "two", "three", "four");
assertThat(scenarioResult.getIOLog()).contains("params[\"one\"]='two'");
assertThat(scenarioResult.getIOLog()).contains("params[\"three\"]='four'");
assertThat(scenarioResult.getIOLog()).contains("overridden[\"three\"] [overridden-three-five]='five'");
assertThat(scenarioResult.getIOLog()).contains("defaulted.get[\"four\"] [defaulted-four-niner]='niner'");
}
@Test
public void testScriptParamsUndefVariableWithOverride() {
ScenarioResult scenarioResult = runScenario("undef_param", "one", "two", "three", "four");
assertThat(scenarioResult.getIOLog()).contains("before: params[\"three\"]:four");
assertThat(scenarioResult.getIOLog()).contains("before: params.three:four");
assertThat(scenarioResult.getIOLog()).contains("after: params[\"three\"]:undefined");
assertThat(scenarioResult.getIOLog()).contains("after: params.three:undefined");
}
@Test
public void testExtensionHistoStatsLogger() throws IOException {
ScenarioResult scenarioResult = runScenario("extension_histostatslogger");
assertThat(scenarioResult.getIOLog()).contains("stdout started " +
"logging to logs/histostats.csv");
List<String> strings = Files.readAllLines(Paths.get(
"logs/histostats.csv"));
String logdata = strings.stream().collect(Collectors.joining("\n"));
assertThat(logdata).contains("min,p25,p50,p75,p90,p95,");
assertThat(logdata.split("Tag=testhistostatslogger.cycles.servicetime,").length).isGreaterThanOrEqualTo(2);
}
@Test
public void testExtensionCsvOutput() throws IOException {
ScenarioResult scenarioResult = runScenario("extension_csvoutput");
List<String> strings = Files.readAllLines(Paths.get(
"logs/csvoutputtestfile.csv"));
String logdata = strings.stream().collect(Collectors.joining("\n"));
assertThat(logdata).contains("header1,header2");
assertThat(logdata).contains("value1,value2");
}
@Test
public void testExtensionHistogramLogger() throws IOException {
ScenarioResult scenarioResult = runScenario("extension_histologger");
assertThat(scenarioResult.getIOLog()).contains("stdout started logging to hdrhistodata.log");
List<String> strings = Files.readAllLines(Paths.get("hdrhistodata.log"));
String logdata = strings.stream().collect(Collectors.joining("\n"));
assertThat(logdata).contains(",HIST");
assertThat(logdata.split("Tag=testhistologger.cycles.servicetime,").length).isGreaterThanOrEqualTo(2);
}
@Test
public void testBlockingRun() {
ScenarioResult scenarioResult = runScenario("blockingrun");
int a1end = scenarioResult.getIOLog().indexOf("blockingactivity1 finished");
int a2start = scenarioResult.getIOLog().indexOf("running blockingactivity2");
assertThat(a1end).isLessThan(a2start);
}
@Test
public void testAwaitFinished() {
ScenarioResult scenarioResult = runScenario("awaitfinished");
}
@Test
public void testStartStop() {
ScenarioResult scenarioResult = runScenario("startstopdiag");
int startedAt = scenarioResult.getIOLog().indexOf("starting activity teststartstopdiag");
int stoppedAt = scenarioResult.getIOLog().indexOf("stopped activity teststartstopdiag");
assertThat(startedAt).isGreaterThan(0);
assertThat(stoppedAt).isGreaterThan(startedAt);
}
// TODO: find out why this causes a long delay after stop is called.
@Test
public void testThreadChange() {
ScenarioResult scenarioResult = runScenario("threadchange");
int changedTo1At = scenarioResult.getIOLog().indexOf("threads now 1");
int changedTo5At = scenarioResult.getIOLog().indexOf("threads now 5");
System.out.println("IOLOG:\n"+scenarioResult.getIOLog());
assertThat(changedTo1At).isGreaterThan(0);
assertThat(changedTo5At).isGreaterThan(changedTo1At);
}
@Test
public void testReadMetric() {
ScenarioResult scenarioResult = runScenario("readmetrics");
assertThat(scenarioResult.getIOLog()).contains("count: ");
}
@Test
public void testShutdownHook() {
ScenarioResult scenarioResult = runScenario("extension_shutdown_hook");
assertThat(scenarioResult.getIOLog()).doesNotContain("shutdown hook running").describedAs(
"shutdown hooks should not run in the same IO context as the main scenario"
);
}
@Test
public void testExceptionPropagationFromMotorThread() {
ScenarioResult scenarioResult = runScenario("activityerror");
assertThat(scenarioResult.getException()).isPresent();
assertThat(scenarioResult.getException().get().getMessage()).contains("For input string: \"unparsable\"");
}
@Test
public void testExceptionPropagationFromActivityInit() {
ScenarioResult scenarioResult = runScenario("activityiniterror");
assertThat(scenarioResult.getException()).isPresent();
assertThat(scenarioResult.getException().get().getMessage()).contains("For input string: \"unparsable\"");
assertThat(scenarioResult.getException()).isNotNull();
}
@Test
public void testReportedCoDelayBursty() {
ScenarioResult scenarioResult = runScenario("cocycledelay_bursty");
assertThat(scenarioResult.getIOLog()).contains("step1 metrics.waittime=");
assertThat(scenarioResult.getIOLog()).contains("step2 metrics.waittime=");
String iolog = scenarioResult.getIOLog();
System.out.println(iolog);
assertThat(iolog).contains("waittime trended back down as expected");
}
@Test
public void testReportedCoDelayStrict() {
ScenarioResult scenarioResult = runScenario("cocycledelay_strict");
assertThat(scenarioResult.getIOLog()).contains("step1 cycles.waittime=");
assertThat(scenarioResult.getIOLog()).contains("step2 cycles.waittime=");
String iolog = scenarioResult.getIOLog();
System.out.println(iolog);
// TODO: ensure that waittime is staying the same or increasing
// after investigating minor decreasing effect
}
// @Test
// @Disabled
// public void testCycleRateChangeOldMetrics() {
// ScenarioResult scenarioResult = runScenario("cycle_rate_change_deprecated");
// String ioLog = scenarioResult.getIOLog();
// assertThat(ioLog).contains("cycles adjusted, exiting on iteration");
// }
@Test
public void testCycleRateChangeNewMetrics() {
ScenarioResult scenarioResult = runScenario("cycle_rate_change");
String ioLog = scenarioResult.getIOLog();
assertThat(ioLog).contains("cycles adjusted, exiting on iteration");
}
@Test
public void testExitLogic() {
ScenarioResult scenarioResult = runScenario(
"basicdiag",
"type", "diag", "cyclerate", "5", "erroroncycle", "10", "cycles", "2000"
);
}
}

View File

@ -29,8 +29,8 @@ public class MetricsIntegrationTest {
@Test
public void testHistogramLogger() {
ActivityDef ad = ActivityDef.parseActivityDef("alias=foo;driver=diag");
Histogram testhistogram = ActivityMetrics.histogram(ad, "testhistogram");
ActivityDef ad = ActivityDef.parseActivityDef("alias=foo;driver=diag;op=noop");
Histogram testhistogram = ActivityMetrics.histogram(ad, "testhistogram", 4);
ActivityMetrics.addHistoLogger("testsession", ".*","testhisto.log","1s");
testhistogram.update(400);
testhistogram.getSnapshot();

View File

@ -24,8 +24,8 @@ public class MetricsMapperIntegrationTest {
@Test
public void testDiagMetrics() {
String diagMetrics = MetricsMapper.metricsDetail("driver=diag;alias=foo;cycles=1");
assertThat(diagMetrics).contains("metrics.foo.diagdelay.snapshot.p98ms");
String diagMetrics = MetricsMapper.metricsDetail("driver=diag;alias=foo;cycles=1;op=noop");
assertThat(diagMetrics).contains("metrics.foo.result.fiveMinuteRate");
}
}

View File

@ -1,93 +0,0 @@
/*
* Copyright (c) 2022 nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.nosqlbench.engine.core.script;
import io.nosqlbench.engine.core.lifecycle.ScenarioResult;
import io.nosqlbench.engine.core.lifecycle.ScenariosResults;
import io.nosqlbench.nb.annotations.Maturity;
import org.apache.commons.compress.utils.IOUtils;
import org.assertj.core.data.Offset;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.assertj.core.api.Assertions.assertThat;
public class ScriptIntegrationTests {
public static ScenarioResult runScenario(String scriptname, String... params) {
if ((params.length % 2) != 0) {
throw new RuntimeException("params must be pairwise key, value, ...");
}
Map<String, String> paramsMap = new HashMap<>();
for (int i = 0; i < params.length; i += 2) {
paramsMap.put(params[i], params[i + 1]);
}
String scenarioName = "scenario " + scriptname;
System.out.println("=".repeat(29) + " Running SYNC integration test for: " + scenarioName);
ScenariosExecutor e = new ScenariosExecutor(ScriptIntegrationTests.class.getSimpleName() + ":" + scriptname, 1);
Scenario s = new Scenario(scenarioName, Scenario.Engine.Graalvm,"stdout:300", Maturity.Any);
s.addScenarioScriptParams(paramsMap);
ClassLoader cl = AsyncScriptIntegrationTests.class.getClassLoader();
String script;
try {
InputStream sstream = cl.getResourceAsStream("scripts/sync/" + scriptname + ".js");
byte[] bytes = IOUtils.toByteArray(sstream);
script = new String(bytes, StandardCharsets.UTF_8);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
s.addScriptText(script);
// s.addScriptText("load('classpath:scripts/sync/" + scriptname + ".js');");
e.execute(s);
ScenariosResults scenariosResults = e.awaitAllResults();
ScenarioResult scenarioResult = scenariosResults.getOne();
return scenarioResult;
}
@BeforeAll
public static void logit() {
System.out.println("Running SYNC version of Script Integration Tests.");
}
@Test
public void testCycleRate() {
ScenarioResult scenarioResult = runScenario("sync_cycle_rate");
String iolog = scenarioResult.getIOLog();
System.out.println("iolog\n" + iolog);
Pattern p = Pattern.compile(".*mean cycle rate = (\\d[.\\d]+).*", Pattern.DOTALL);
Matcher m = p.matcher(iolog);
assertThat(m.matches()).isTrue();
String digits = m.group(1);
assertThat(digits).isNotEmpty();
double rate = Double.valueOf(digits);
assertThat(rate).isCloseTo(1000, Offset.offset(100.0));
}
}