direct implementation of run, start, wait, await, example, forceStop

This commit is contained in:
Jonathan Shook
2023-12-18 22:54:05 -06:00
parent 7f082a2767
commit 0a4b105c3e
19 changed files with 530 additions and 65 deletions

View File

@@ -105,6 +105,7 @@ public class NBCLIScenarioPreprocessorTest {
List<Cmd> cmds = opts.getCommands();
assertThat(cmds.size()).isEqualTo(1);
assertThat(cmds.get(0).getArgMap()).isEqualTo(Map.of(
"_impl","run",
"alias", "with_template",
"container", "template_test",
"cycles", "20",
@@ -122,6 +123,7 @@ public class NBCLIScenarioPreprocessorTest {
List<Cmd> cmds = opts.getCommands();
assertThat(cmds.size()).isEqualTo(1);
assertThat(cmds.get(0).getArgMap()).isEqualTo(Map.of(
"_impl", "run",
"alias", "schema",
"container", "schema_only",
"cycles-test", "20",
@@ -176,6 +178,7 @@ public class NBCLIScenarioPreprocessorTest {
List<Cmd> cmds = opts.getCommands();
assertThat(cmds.size()).isEqualTo(1);
assertThat(cmds.get(0).getArgMap()).isEqualTo(Map.of(
"_impl","run",
"alias", "schema",
"container", "schema_only",
"cycles-test", "20",

View File

@@ -137,23 +137,23 @@ public class TestNBCLIOptions {
.isThrownBy(() -> new NBCLIOptions(new String[]{"script"}));
}
@Test
public void shouldRecognizeStartActivityCmd() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "start", "driver=woot" });
List<Cmd> cmds = opts.getCommands();
assertThat(cmds).hasSize(1);
assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.start);
}
@Test
public void shouldRecognizeRunActivityCmd() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "run", "driver=runwoot" });
List<Cmd> cmds = opts.getCommands();
assertThat(cmds).hasSize(1);
assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.run);
}
// @Test
// public void shouldRecognizeStartActivityCmd() {
// NBCLIOptions opts = new NBCLIOptions(new String[]{ "start", "driver=woot" });
// List<Cmd> cmds = opts.getCommands();
// assertThat(cmds).hasSize(1);
// assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.start);
//
// }
//
// @Test
// public void shouldRecognizeRunActivityCmd() {
// NBCLIOptions opts = new NBCLIOptions(new String[]{ "run", "driver=runwoot" });
// List<Cmd> cmds = opts.getCommands();
// assertThat(cmds).hasSize(1);
// assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.run);
//
// }
// @Test
// public void shouldRecognizeStopActivityCmd() {
@@ -172,14 +172,14 @@ public class TestNBCLIOptions {
.isThrownBy(() -> new NBCLIOptions(new String[]{ "stop", "woah=woah" }));
}
@Test
public void shouldRecognizeAwaitActivityCmd() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "await", "activity=awaitme" });
List<Cmd> cmds = opts.getCommands();
assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.await);
assertThat(cmds.get(0).getArgValue("activity")).isEqualTo("awaitme");
}
// @Test
// public void shouldRecognizeAwaitActivityCmd() {
// NBCLIOptions opts = new NBCLIOptions(new String[]{ "await", "activity=awaitme" });
// List<Cmd> cmds = opts.getCommands();
// assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.await);
// assertThat(cmds.get(0).getArgValue("activity")).isEqualTo("awaitme");
//
// }
@Disabled("semantic parsing is reserved until later after generalizing syntax")
@Test
@@ -188,14 +188,14 @@ public class TestNBCLIOptions {
.isThrownBy(() -> new NBCLIOptions(new String[]{ "await", "awaitme=notvalid" }));
}
@Test
public void shouldRecognizewaitMillisCmd() {
NBCLIOptions opts = new NBCLIOptions(new String[]{ "waitmillis", "ms=23234" });
List<Cmd> cmds = opts.getCommands();
assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.waitMillis);
assertThat(cmds.get(0).getArgValue("ms")).isEqualTo("23234");
}
// @Test
// public void shouldRecognizewaitMillisCmd() {
// NBCLIOptions opts = new NBCLIOptions(new String[]{ "waitmillis", "ms=23234" });
// List<Cmd> cmds = opts.getCommands();
// assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.waitMillis);
// assertThat(cmds.get(0).getArgValue("ms")).isEqualTo("23234");
//
// }
@Test
public void listWorkloads() {

View File

@@ -74,12 +74,7 @@ public class BasicScriptBuffer implements ScriptBuffer {
}
break;
case java:
case start: // start activity
case run: // run activity
case await: // await activity
// case stop: // stop activity
case forceStop: // force stopping activity
case waitMillis:
sb.append("controller.").append(cmd.asScriptText()).append("\n");
//// // Sanity check that this can parse before using it

View File

@@ -23,14 +23,14 @@ package io.nosqlbench.engine.cmdstream;
* or an error is thrown.
*/
public enum CmdType {
run(),
start(),
// run(),
// start(),
// stop(CmdParam.of("activity")),
forceStop(CmdParam.of("activity")),
// forceStop(CmdParam.of("activity")),
script(CmdParam.of("path", s -> s)),
java(CmdParam.of("class", s -> s)),
await(CmdParam.of("activity")),
waitMillis(CmdParam.of("ms", Long::parseLong)),
// await(CmdParam.of("activity")),
// waitMillis(CmdParam.of("ms", Long::parseLong)),
fragment(CmdParam.ofFreeform("fragment")),
container(CmdParam.of("name")),
indirect(CmdParam.of("indirect"));

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2023 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.lifecycle.commands;
import io.nosqlbench.engine.core.lifecycle.scenario.container.ContainerActivitiesController;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBBufferedContainer;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBBaseCommand;
import io.nosqlbench.nb.annotations.Service;
import io.nosqlbench.nb.api.engine.util.Unit;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.concurrent.locks.LockSupport;
@Service(value = NBBaseCommand.class, selector = "await")
public class CMD_await extends NBBaseCommand {
public final static Logger logger = LogManager.getLogger("await");
public CMD_await(NBBufferedContainer parentComponent, String stepName, String targetScenario) {
super(parentComponent, stepName, targetScenario);
}
@Override
public Object invoke(NBCommandParams params, PrintWriter stdout, PrintWriter stderr, Reader stdin, ContainerActivitiesController controller) {
controller.await(params);
return null;
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2023 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.lifecycle.commands;
import io.nosqlbench.engine.api.activityapi.core.Activity;
import io.nosqlbench.engine.core.lifecycle.scenario.container.ContainerActivitiesController;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBBufferedContainer;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBBaseCommand;
import io.nosqlbench.nb.annotations.Service;
import io.nosqlbench.nb.api.errors.BasicError;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.Optional;
@Service(value = NBBaseCommand.class,selector = "example")
public class CMD_example extends NBBaseCommand {
public final static Logger logger = LogManager.getLogger("example");
public CMD_example(NBBufferedContainer parentComponent, String stepName, String targetScenario) {
super(parentComponent, stepName, targetScenario);
}
@Override
public Object invoke(NBCommandParams params, PrintWriter stdout, PrintWriter stderr, Reader stdin, ContainerActivitiesController controller) {
return null;
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2023 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.lifecycle.commands;
import io.nosqlbench.engine.api.activityapi.core.Activity;
import io.nosqlbench.engine.core.lifecycle.scenario.container.ContainerActivitiesController;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBBufferedContainer;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBBaseCommand;
import io.nosqlbench.nb.annotations.Service;
import io.nosqlbench.nb.api.errors.BasicError;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.Optional;
@Service(value = NBBaseCommand.class,selector = "force_stop")
public class CMD_forceStop extends NBBaseCommand {
public final static Logger logger = LogManager.getLogger("force_stop");
public CMD_forceStop(NBBufferedContainer parentComponent, String stepName, String targetScenario) {
super(parentComponent, stepName, targetScenario);
}
@Override
public Object invoke(NBCommandParams params, PrintWriter stdout, PrintWriter stderr, Reader stdin, ContainerActivitiesController controller) {
controller.forceStop(params);
return null;
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 2023 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.lifecycle.commands;
import io.nosqlbench.engine.core.lifecycle.scenario.container.ContainerActivitiesController;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBBufferedContainer;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBBaseCommand;
import io.nosqlbench.nb.annotations.Service;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.PrintWriter;
import java.io.Reader;
@Service(value = NBBaseCommand.class, selector = "run")
public class CMD_run extends NBBaseCommand {
public final static Logger logger = LogManager.getLogger("run");
public CMD_run(NBBufferedContainer parentComponent, String stepName, String targetScenario) {
super(parentComponent, stepName, targetScenario);
}
@Override
public Object invoke(NBCommandParams params, PrintWriter stdout, PrintWriter stderr, Reader stdin, ContainerActivitiesController controller) {
controller.run(params);
return null;
}
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2023 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.lifecycle.commands;
import io.nosqlbench.engine.api.activityapi.core.Activity;
import io.nosqlbench.engine.core.lifecycle.scenario.container.ContainerActivitiesController;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBBufferedContainer;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBBaseCommand;
import io.nosqlbench.nb.annotations.Service;
import io.nosqlbench.nb.api.errors.BasicError;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.Optional;
@Service(value = NBBaseCommand.class,selector = "start")
public class CMD_start extends NBBaseCommand {
public final static Logger logger = LogManager.getLogger("start");
public CMD_start(NBBufferedContainer parentComponent, String stepName, String targetScenario) {
super(parentComponent, stepName, targetScenario);
}
@Override
public Object invoke(NBCommandParams params, PrintWriter stdout, PrintWriter stderr, Reader stdin, ContainerActivitiesController controller) {
return controller.start(params);
}
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright (c) 2023 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.lifecycle.commands;
import com.amazonaws.services.s3.model.transform.Unmarshallers;
import io.nosqlbench.engine.core.lifecycle.scenario.container.ContainerActivitiesController;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBBufferedContainer;
import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBBaseCommand;
import io.nosqlbench.nb.annotations.Service;
import io.nosqlbench.nb.api.engine.util.Unit;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.Optional;
import java.util.concurrent.locks.LockSupport;
import java.util.stream.LongStream;
@Service(value = NBBaseCommand.class, selector = "example")
public class CMD_wait extends NBBaseCommand {
public final static Logger logger = LogManager.getLogger("example");
public CMD_wait(NBBufferedContainer parentComponent, String stepName, String targetScenario) {
super(parentComponent, stepName, targetScenario);
}
@Override
public Object invoke(NBCommandParams params, PrintWriter stdout, PrintWriter stderr, Reader stdin, ContainerActivitiesController controller) {
long ns = 0L;
ns += params.maybeGet("ms")
.or(() -> params.maybeGet("millis"))
.map(Long::parseLong)
.map(l -> l * 1_000_000L)
.orElse(0L);
ns += params.maybeGet("us")
.or(() -> params.maybeGet("micros"))
.map(Long::parseLong)
.map(l -> l * 1_000L)
.orElse(0L);
ns += params.maybeGet("ns")
.or(() -> params.maybeGet("nanos"))
.map(Long::parseLong)
.orElse(0L);
ns += params.maybeGet("unit")
.flatMap(Unit::nanosecondsFor)
.orElse(0L);
LockSupport.parkNanos(ns);
return ns;
}
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2023 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.lifecycle.commands;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBCommandInfo;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBInvokableCommand;
import io.nosqlbench.nb.annotations.Service;
@Service(value = NBCommandInfo.class,selector = "await")
public class INFO_await extends NBCommandInfo {
@Override
public Class<? extends NBInvokableCommand> getType() {
return CMD_await.class;
}
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2023 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.lifecycle.commands;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBCommandInfo;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBInvokableCommand;
import io.nosqlbench.nb.annotations.Service;
@Service(value = NBCommandInfo.class,selector = "start")
public class INFO_example extends NBCommandInfo {
@Override
public Class<? extends NBInvokableCommand> getType() {
return CMD_example.class;
}
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2023 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.lifecycle.commands;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBCommandInfo;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBInvokableCommand;
import io.nosqlbench.nb.annotations.Service;
@Service(value = NBCommandInfo.class,selector = "force_stop")
public class INFO_forceStop extends NBCommandInfo {
@Override
public Class<? extends NBInvokableCommand> getType() {
return CMD_forceStop.class;
}
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2023 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.lifecycle.commands;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBCommandInfo;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBInvokableCommand;
import io.nosqlbench.nb.annotations.Service;
@Service(value = NBCommandInfo.class,selector = "run")
public class INFO_run extends NBCommandInfo {
@Override
public Class<? extends NBInvokableCommand> getType() {
return CMD_run.class;
}
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2023 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.lifecycle.commands;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBCommandInfo;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBInvokableCommand;
import io.nosqlbench.nb.annotations.Service;
@Service(value = NBCommandInfo.class,selector = "start")
public class INFO_start extends NBCommandInfo {
@Override
public Class<? extends NBInvokableCommand> getType() {
return CMD_start.class;
}
}

View File

@@ -0,0 +1,29 @@
/*
* Copyright (c) 2023 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.lifecycle.commands;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBCommandInfo;
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBInvokableCommand;
import io.nosqlbench.nb.annotations.Service;
@Service(value = NBCommandInfo.class,selector = "wait")
public class INFO_wait extends NBCommandInfo {
@Override
public Class<? extends NBInvokableCommand> getType() {
return CMD_wait.class;
}
}

View File

@@ -27,7 +27,7 @@ public class NBScriptCommandResolver implements NBInvokableResolver {
@Override
public NBInvokableCommand resolve(Cmd cmd, NBBufferedContainer parent, String phaseName) {
return switch (cmd.getCmdType()) {
case run, await, forceStop, start, waitMillis, fragment, script->
case fragment, script->
new NBScriptedCommand(parent, phaseName, cmd.getTargetContext()).add(cmd);
// case fragment ->
// new NBScriptedCommand(parent, phaseName, cmd.getTargetContext()).addScriptText(cmd.getArgValue("fragment"));

View File

@@ -19,6 +19,7 @@ package io.nosqlbench.engine.core.lifecycle.session;
import io.nosqlbench.engine.cmdstream.Cmd;
import io.nosqlbench.engine.cmdstream.CmdType;
import io.nosqlbench.nb.api.errors.BasicError;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.util.LinkedList;
@@ -34,36 +35,37 @@ class CmdParserTest {
public void testSingleCommand() {
List<Cmd> cmds = CmdParser.parse("testcmd42");
assertThat(cmds).hasSize(1);
assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.indirect);
assertThat(cmds.get(0).getArgValue("_impl")).isEqualTo("testcmd42");
assertThat(cmds.getFirst().getCmdType()).isEqualTo(CmdType.indirect);
assertThat(cmds.getFirst().getArgValue("_impl")).isEqualTo("testcmd42");
}
@Test
public void testSingleCommandWithArgs() {
List<Cmd> cmds = CmdParser.parse("testcmd43 param1=value1");
assertThat(cmds).hasSize(1);
assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.indirect);
assertThat(cmds.get(0).getArgValue("_impl")).isEqualTo("testcmd43");
assertThat(cmds.get(0).getArgValue("param1")).isEqualTo("value1");
assertThat(cmds.getFirst().getCmdType()).isEqualTo(CmdType.indirect);
assertThat(cmds.getFirst().getArgValue("_impl")).isEqualTo("testcmd43");
assertThat(cmds.getFirst().getArgValue("param1")).isEqualTo("value1");
}
@Test
public void testSingleDquotedArg() {
List<Cmd> cmds = CmdParser.parse("testcmd44 param1=\"value1\"");
assertThat(cmds).hasSize(1);
assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.indirect);
assertThat(cmds.get(0).getArgValue("_impl")).isEqualTo("testcmd44");
assertThat(cmds.get(0).getArgValue("param1")).isEqualTo("value1");
assertThat(cmds.getFirst().getCmdType()).isEqualTo(CmdType.indirect);
assertThat(cmds.getFirst().getArgValue("_impl")).isEqualTo("testcmd44");
assertThat(cmds.getFirst().getArgValue("param1")).isEqualTo("value1");
}
@Disabled
@Test
public void testSpecialSymbolValue() {
List<Cmd> cmds = CmdParser.parse("start param1="+ CmdParser.SYMBOLS+ " param2='"+ CmdParser.SYMBOLS+ "' param3=\""+ CmdParser.SYMBOLS+ "\"");
assertThat(cmds).hasSize(1);
assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.start);
assertThat(cmds.get(0).getArgValue("param1")).isEqualTo(CmdParser.SYMBOLS);
assertThat(cmds.get(0).getArgValue("param2")).isEqualTo(CmdParser.SYMBOLS);
assertThat(cmds.get(0).getArgValue("param3")).isEqualTo(CmdParser.SYMBOLS);
// assertThat(cmds.getFirst().getCmdType()).isEqualTo(CmdType.start);
assertThat(cmds.getFirst().getArgValue("param1")).isEqualTo(CmdParser.SYMBOLS);
assertThat(cmds.getFirst().getArgValue("param2")).isEqualTo(CmdParser.SYMBOLS);
assertThat(cmds.getFirst().getArgValue("param3")).isEqualTo(CmdParser.SYMBOLS);
}
@Test
@@ -76,23 +78,24 @@ class CmdParserTest {
"an error should be thrown if a named parameter is specified without a prior command.");
}
@Disabled
@Test
public void testThatSymbolsAreQuotedInStringForm() {
List<Cmd> cmds = CmdParser.parse("start param1=value1 param2='~should be quoted'");
assertThat(cmds.size()).isEqualTo(1);
assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.start);
assertThat(cmds.get(0).getArgValue("param1")).isEqualTo("value1");
assertThat(cmds.get(0).getArgValue("param2")).isEqualTo("~should be quoted");
assertThat(cmds.get(0).toString()).isEqualTo("start param1=value1 param2='~should be quoted'");
// assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.start);
assertThat(cmds.getFirst().getArgValue("param1")).isEqualTo("value1");
assertThat(cmds.getFirst().getArgValue("param2")).isEqualTo("~should be quoted");
assertThat(cmds.getFirst().toString()).isEqualTo("start param1=value1 param2='~should be quoted'");
}
@Test
public void testBasicArgvParser() {
LinkedList<Cmd> cmds = CmdParser.parseArgvCommands(new LinkedList<>(List.of("_cmd4", "param1=value1")));
assertThat(cmds.size()).isEqualTo(1);
assertThat(cmds.get(0).getCmdType()).isEqualTo(CmdType.indirect);
assertThat(cmds.get(0).getArgValue("_impl")).isEqualTo("_cmd4");
assertThat(cmds.get(0).getArgValue("param1")).isEqualTo("value1");
assertThat(cmds.getFirst().getCmdType()).isEqualTo(CmdType.indirect);
assertThat(cmds.getFirst().getArgValue("_impl")).isEqualTo("_cmd4");
assertThat(cmds.getFirst().getArgValue("param1")).isEqualTo("value1");
}
}

View File

@@ -361,12 +361,12 @@
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>23.1.1</version>
<version>23.0.1</version>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
<version>23.0.2</version>
<version>23.0.1</version>
<scope>runtime</scope>
</dependency>
<dependency>