mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
adapt param usage to polyglot APIs
This commit is contained in:
@@ -154,18 +154,19 @@ public class AsyncScriptIntegrationTests {
|
|||||||
@Test
|
@Test
|
||||||
public void testScriptParamsVariable() {
|
public void testScriptParamsVariable() {
|
||||||
ScenarioResult scenarioResult = runScenario("params_variable", "one", "two", "three", "four");
|
ScenarioResult scenarioResult = runScenario("params_variable", "one", "two", "three", "four");
|
||||||
assertThat(scenarioResult.getIOLog()).contains("params.get(\"one\")='two'");
|
assertThat(scenarioResult.getIOLog()).contains("params[\"one\"]='two'");
|
||||||
assertThat(scenarioResult.getIOLog()).contains("params.get(\"three\")='four'");
|
assertThat(scenarioResult.getIOLog()).contains("params.[\"three\"]='four'");
|
||||||
assertThat(scenarioResult.getIOLog()).contains("params.size()=2");
|
assertThat(scenarioResult.getIOLog()).contains("overridden[\"three\"] [overridden-three-five]='five'");
|
||||||
assertThat(scenarioResult.getIOLog()).contains("params.get(\"three\") [overridden-three-five]='five'");
|
assertThat(scenarioResult.getIOLog()).contains("defaulted.get[\"four\"] [defaulted-four-niner]='niner'");
|
||||||
assertThat(scenarioResult.getIOLog()).contains("params.get(\"four\") [defaulted-four-niner]='niner'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testScriptParamsUndefVariableWithOverride() {
|
public void testScriptParamsUndefVariableWithOverride() {
|
||||||
ScenarioResult scenarioResult = runScenario("undef_param", "one", "two", "three", "four");
|
ScenarioResult scenarioResult = runScenario("undef_param", "one", "two", "three", "four");
|
||||||
assertThat(scenarioResult.getIOLog()).contains("before: params.get(\"three\"):four");
|
assertThat(scenarioResult.getIOLog()).contains("before: params[\"three\"]:four");
|
||||||
assertThat(scenarioResult.getIOLog()).contains("after: params.get(\"three\"):null");
|
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
|
@Test
|
||||||
@@ -219,6 +220,7 @@ public class AsyncScriptIntegrationTests {
|
|||||||
ScenarioResult scenarioResult = runScenario("threadchange");
|
ScenarioResult scenarioResult = runScenario("threadchange");
|
||||||
int changedTo1At = scenarioResult.getIOLog().indexOf("threads now 1");
|
int changedTo1At = scenarioResult.getIOLog().indexOf("threads now 1");
|
||||||
int changedTo5At = scenarioResult.getIOLog().indexOf("threads now 5");
|
int changedTo5At = scenarioResult.getIOLog().indexOf("threads now 5");
|
||||||
|
System.out.println("IOLOG:\n"+scenarioResult.getIOLog());
|
||||||
assertThat(changedTo1At).isGreaterThan(0);
|
assertThat(changedTo1At).isGreaterThan(0);
|
||||||
assertThat(changedTo5At).isGreaterThan(changedTo1At);
|
assertThat(changedTo5At).isGreaterThan(changedTo1At);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,31 @@
|
|||||||
print('params.get("one")=\'' + params.get("one") + "'");
|
// With the API support for Polyglot, we lost the ability to expose
|
||||||
print('params.get("three")=\'' + params.get("three") + "'");
|
// map operations (underlying Java Map API) as well as proxy methods
|
||||||
print('params.size()=' + params.size());
|
// on ECMA objects. What works now is object semantics + non-map methods.
|
||||||
|
// More testing and refinement may be needed to clarify the rules here.
|
||||||
|
|
||||||
|
// previously:
|
||||||
|
// print('params.get("one")=\'' + params.get("one") + "'"); // worked with nashorn
|
||||||
|
// print('params.get("three")=\'' + params.get("three") + "'");
|
||||||
|
// print('params.size()=' + params.size());
|
||||||
|
|
||||||
|
// Called with one=two three=four
|
||||||
|
|
||||||
|
print('params["one"]=\'' + params["one"] + "'");
|
||||||
|
print('params.["three"]=\'' + params["three"] + "'");
|
||||||
|
|
||||||
var overrides = {
|
var overrides = {
|
||||||
'three': "five"
|
'three': "five"
|
||||||
};
|
};
|
||||||
print('params.get("three") [overridden-three-five]=\'' + params.withOverrides(overrides).get("three") + "'");
|
|
||||||
|
var overridden = params.withOverrides(overrides);
|
||||||
|
|
||||||
|
print('overridden["three"] [overridden-three-five]=\'' + overridden["three"] + "'");
|
||||||
|
|
||||||
var defaults = {
|
var defaults = {
|
||||||
'four': "niner"
|
'four': "niner"
|
||||||
};
|
};
|
||||||
print('params.get("four") [defaulted-four-niner]=\'' + params.withDefaults(defaults).get("four") + "'");
|
|
||||||
|
var defaulted = params.withDefaults(defaults);
|
||||||
|
|
||||||
|
print('defaulted.get["four"] [defaulted-four-niner]=\'' + defaulted["four"] + "'");
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ scenario.start('type=diag;alias=threadchange;cycles=0..100000000;threads=1;inter
|
|||||||
activities.threadchange.threads=1;
|
activities.threadchange.threads=1;
|
||||||
print("threads now " + activities.threadchange.threads);
|
print("threads now " + activities.threadchange.threads);
|
||||||
print('waiting 500 ms');
|
print('waiting 500 ms');
|
||||||
|
scenario.waitMillis(500);
|
||||||
|
|
||||||
activities.threadchange.threads=5;
|
activities.threadchange.threads=5;
|
||||||
print("threads now " + activities.threadchange.threads);
|
print("threads now " + activities.threadchange.threads);
|
||||||
scenario.stop('threadchange');
|
scenario.stop('threadchange');
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
|
// With the API support for Polyglot, we lost the ability to expose
|
||||||
|
// map operations (underlying Java Map API) as well as proxy methods
|
||||||
|
// on ECMA objects. What works now is object semantics + non-map methods.
|
||||||
|
// More testing and refinement may be needed to clarify the rules here.
|
||||||
|
|
||||||
print("params from command line:");
|
print("params from command line:");
|
||||||
print(params);
|
print(params);
|
||||||
print('before: params.get("three"):' + params.get("three"));
|
print('before: params["three"]:' + params["three"]);
|
||||||
print('before: params.three:' + params.get("three"));
|
print('before: params.three:' + params.three);
|
||||||
|
|
||||||
var overrides = {
|
var overrides = {
|
||||||
'three': "undef",
|
'three': "undef",
|
||||||
@@ -10,7 +15,7 @@ var overrides = {
|
|||||||
print("params.three after overriding with three:UNDEF");
|
print("params.three after overriding with three:UNDEF");
|
||||||
params = params.withOverrides({'three':'UNDEF'});
|
params = params.withOverrides({'three':'UNDEF'});
|
||||||
print(params);
|
print(params);
|
||||||
print('after: params.get("three"):' + params.get("three"));
|
print('after: params["three"]:' + params["three"]);
|
||||||
print('after: params.three:' + params.get("three"));
|
print('after: params.three:' + params.three);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user