Merge branch 'main' of github.com:nosqlbench/nosqlbench

This commit is contained in:
Jonathan Shook
2023-02-06 15:26:39 -06:00
6 changed files with 70 additions and 74 deletions

View File

@@ -53,7 +53,7 @@ public class RunStateImage {
return true;
}
public boolean isNonOther(RunState... runStates) {
public boolean isNoneOther(RunState... runStates) {
int[] scan = Arrays.copyOf(counts, counts.length);
for (RunState runState : runStates) {
scan[runState.ordinal()]=0;

View File

@@ -33,7 +33,7 @@ public class RunStateImageTest {
assertThat(image.is(RunState.Starting)).isTrue();
assertThat(image.isTimeout()).isFalse();
assertThat(image.is(RunState.Errored)).isFalse();
assertThat(image.isNonOther(RunState.Starting, RunState.Running)).isTrue();
assertThat(image.isNoneOther(RunState.Starting, RunState.Running)).isTrue();
RunState maxState = image.getMaxState();
assertThat(maxState).isEqualTo(RunState.values()[RunState.Running.ordinal()]);
RunState minState = image.getMinState();

View File

@@ -280,7 +280,7 @@ public class ActivityExecutor implements ActivityController, ParameterMap.Listen
}
}
private void alignMotorStateToIntendedActivityState() {
private synchronized void alignMotorStateToIntendedActivityState() {
RunState intended = activity.getRunState();
logger.trace(() -> "ADJUSTING to INTENDED " + intended);
switch (intended) {

View File

@@ -45,44 +45,48 @@ import static org.assertj.core.api.Assertions.fail;
class ActivityExecutorTest {
private static final Logger logger = LogManager.getLogger(ActivityExecutorTest.class);
@Test
synchronized void testRestart() {
ActivityDef activityDef = ActivityDef.parseActivityDef("driver=diag;alias=test;cycles=1000;op=initdelay:initdelay=5000;");
new ActivityTypeLoader().load(activityDef);
final Activity activity = new DelayedInitActivity(activityDef);
InputDispenser inputDispenser = new CoreInputDispenser(activity);
ActionDispenser adisp = new CoreActionDispenser(activity);
OutputDispenser tdisp = CoreServices.getOutputDispenser(activity).orElse(null);
final MotorDispenser<?> mdisp = new CoreMotorDispenser(activity, inputDispenser, adisp, tdisp);
activity.setActionDispenserDelegate(adisp);
activity.setOutputDispenserDelegate(tdisp);
activity.setInputDispenserDelegate(inputDispenser);
activity.setMotorDispenserDelegate(mdisp);
final ExecutorService executor = Executors.newCachedThreadPool();
ActivityExecutor activityExecutor = new ActivityExecutor(activity, "test-restart");
final Future<ExecutionResult> future = executor.submit(activityExecutor);
try {
activityDef.setThreads(1);
activityExecutor.startActivity();
activityExecutor.stopActivity();
activityExecutor.startActivity();
activityExecutor.stopActivity();
future.get();
} catch (Exception e) {
throw new RuntimeException(e);
}
executor.shutdown();
assertThat(inputDispenser.getInput(10).getInputSegment(3)).isNotNull();
}
// TODO: Design review of this mechanism
// @Test
// synchronized void testRestart() {
// ActivityDef activityDef = ActivityDef.parseActivityDef("driver=diag;alias=test-restart;cycles=1000;cyclerate=10;op=initdelay:initdelay=5000;");
// new ActivityTypeLoader().load(activityDef);
//
// final Activity activity = new DelayedInitActivity(activityDef);
// InputDispenser inputDispenser = new CoreInputDispenser(activity);
// ActionDispenser adisp = new CoreActionDispenser(activity);
// OutputDispenser tdisp = CoreServices.getOutputDispenser(activity).orElse(null);
//
// final MotorDispenser<?> mdisp = new CoreMotorDispenser(activity, inputDispenser, adisp, tdisp);
// activity.setActionDispenserDelegate(adisp);
// activity.setOutputDispenserDelegate(tdisp);
// activity.setInputDispenserDelegate(inputDispenser);
// activity.setMotorDispenserDelegate(mdisp);
//
// final ExecutorService executor = Executors.newCachedThreadPool();
// ActivityExecutor activityExecutor = new ActivityExecutor(activity, "test-restart");
// final Future<ExecutionResult> future = executor.submit(activityExecutor);
// try {
// activityDef.setThreads(1);
// activityExecutor.startActivity();
// Thread.sleep(100L);
// activityExecutor.stopActivity();
// Thread.sleep(100L);
// activityExecutor.startActivity();
// Thread.sleep(100L);
// activityExecutor.stopActivity();
// future.get();
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// executor.shutdown();
// assertThat(inputDispenser.getInput(10).getInputSegment(3)).isNotNull();
//
// }
@Test
synchronized void testDelayedStartSanity() {
final ActivityDef activityDef = ActivityDef.parseActivityDef("driver=diag;alias=test;cycles=1000;initdelay=2000;");
final ActivityDef activityDef = ActivityDef.parseActivityDef("driver=diag;alias=test-delayed-start;cycles=1000;initdelay=2000;");
new ActivityTypeLoader().load(activityDef);
final Activity activity = new DelayedInitActivity(activityDef);
@@ -118,7 +122,7 @@ class ActivityExecutorTest {
@Test
synchronized void testNewActivityExecutor() {
ActivityDef activityDef = ActivityDef.parseActivityDef("driver=diag;alias=test;cycles=1000;initdelay=5000;");
ActivityDef activityDef = ActivityDef.parseActivityDef("driver=diag;alias=test-dynamic-params;cycles=1000;initdelay=5000;");
new ActivityTypeLoader().load(activityDef);
getActivityMotorFactory(motorActionDelay(999), new AtomicInput(activityDef));

View File

@@ -1,36 +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.experimental;
import org.junit.jupiter.api.Test;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class CompletableTests {
@Test
public void testCompletionStages() {
CompletableFuture<Object> f = new CompletableFuture<>();
ExecutorService executorService = Executors.newCachedThreadPool();
CompletableFuture<Object> objectCompletableFuture = f.completeAsync(() -> "foo", executorService);
boolean bar = objectCompletableFuture.complete("bar");
}
}

28
scripts/.delete-tags Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
printf "WARNING:\n"
printf " This will remove any tags which were known to be stale as of 5.17.0\n"
printf " Only these will be kept:\n"
printf " - 5.*\n"
printf " - nb-5.*\n"
printf " - nosqlbench-5.*\n"
printf " - nosqlbench-4.17.20+\n"
printf " - nosqlbench-4.15.100+\n"
printf " FURTHER: This removes all your local tags first and then synchronizes\n"
printf " from origin. If you have any special tags only on local, it will remove them.\n"
printf " If you do NOT want to do this, hit control-c now!\n"
read response
#delete all the remote tags with the pattern your looking for ...
git tag \
| grep -v '5\.' \
| grep -v 'nosqlbench-5\.' \
| grep -v 'nb-5\.' \
| grep -v 'nosqlbench-4\.17\.[23][0-9]' \
| grep -v 'nosqlbench-4\.15\.10[0-9]' \
| xargs -n 1 -I% git push origin :refs/tags/%
# delete all your local tags
git tag | xargs -I% git tag -d %
# fetch the remote tags which still remain
git fetch