Skip to content

Commit

Permalink
Fixed broken & missing props in example YAML; Added new example confi…
Browse files Browse the repository at this point in the history
…g for external cluster; Added run scripts to help with getting started; Fixed object mapping for `ApproximateMonotonicClockConfiguration`; Removed hardcoded configuration for in-JVM execution;
  • Loading branch information
grighetto authored and ifesdjeen committed Dec 11, 2020
1 parent 3ca3bd0 commit 9c5eb00
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 64 deletions.
10 changes: 7 additions & 3 deletions conf/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ truncate_table: false
# to map it back to the logical timestamp of the operation that wrote this value.
clock:
approximate_monotonic:
historySize: 7300
epochPeriod: 1
epochTimeUnit: "SECONDS"
history_size: 7300
epoch_length: 1
epoch_time_unit: "SECONDS"

# Runner is a is a component that schedules operations that change the cluster (system under test)
# and model state.
Expand Down Expand Up @@ -88,3 +88,7 @@ clustering_descriptor_selector:
DELETE_COLUMN: 1
column_mask_bitsets: null
max_partition_size: 100

# Default Row Visitor
row_visitor:
default: {}
12 changes: 8 additions & 4 deletions conf/external.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ truncate_table: false
# be taken to map a real-time timestamp from the value retrieved from the database in order
# to map it back to the logical timestamp of the operation that wrote this value.
clock:
debug_approximate_monotonic:
historySize: 7300
epochPeriod: 1
epochTimeUnit: "SECONDS"
approximate_monotonic:
history_size: 7300
epoch_length: 1
epoch_time_unit: "SECONDS"

# Runner is a is a component that schedules operations that change the cluster (system under test)
# and model state.
Expand Down Expand Up @@ -89,3 +89,7 @@ clustering_descriptor_selector:
DELETE_COLUMN: 1
column_mask_bitsets: null
max_partition_size: 100

# Default Row Visitor
row_visitor:
default: {}
1 change: 1 addition & 0 deletions docker/Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ COPY ./harry-runner/target/*.jar /opt/harry/lib/
COPY ./harry-integration/target/lib/ /opt/harry/lib/
COPY ./harry-integration/target/*.jar /opt/harry/
COPY ./test/conf/logback-dtest.xml /opt/harry/test/conf/logback-dtest.xml
COPY ./conf/example.yaml /opt/harry/example.yaml
COPY ./docker/run.sh /opt/harry/

WORKDIR /opt/harry
Expand Down
3 changes: 2 additions & 1 deletion docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ while true; do
-Dorg.apache.cassandra.test.logback.configurationFile=file:///opt/harry/test/conf/logback-dtest.xml \
-cp /opt/harry/lib/*:/opt/harry/harry-integration-0.0.1-SNAPSHOT.jar \
-Dharry.root=${HARRY_DIR} \
harry.runner.HarryRunnerJvm
harry.runner.HarryRunnerJvm \
/opt/harry/example.yaml

if [ $? -ne 0 ]; then
if [ -e "failure.dump" ]; then
Expand Down
1 change: 1 addition & 0 deletions harry-core/src/harry/core/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class Configuration
.disable(YAMLGenerator.Feature.CANONICAL_OUTPUT)
.enable(YAMLGenerator.Feature.INDENT_ARRAYS));
mapper.registerSubtypes(Configuration.DebugApproximateMonotonicClockConfiguration.class);
mapper.registerSubtypes(Configuration.ApproximateMonotonicClockConfiguration.class);
mapper.registerSubtypes(Configuration.ConcurrentRunnerConfig.class);

mapper.registerSubtypes(Configuration.ExhaustiveCheckerConfig.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

public class ExternalClusterSut implements SystemUnderTest
{
public static void registerSubtype()
public static void registerSubtypes()
{
Configuration.registerSubtypes(ExternalSutConfiguration.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,16 @@
import harry.runner.HarryRunner;

import java.io.File;
import java.io.FileNotFoundException;

public class HarryRunnerExternal implements HarryRunner {

public static void main(String[] args) throws Throwable {

ExternalClusterSut.registerSubtype();

if (args.length == 0) {
throw new RuntimeException("Harry config YAML not provided.");
}

File configFile = new File(args[0]);
if (!configFile.exists()) {
throw new FileNotFoundException(configFile.getAbsolutePath());
}
if (!configFile.canRead()) {
throw new RuntimeException("Cannot read config file, check your permissions on " + configFile.getAbsolutePath());
}

Configuration config = Configuration.fromFile(configFile);
ExternalClusterSut.registerSubtypes();

HarryRunner runner = new HarryRunnerExternal();
runner.run(config.system_under_test);
File configFile = runner.loadConfig(args);

Configuration configuration = Configuration.fromFile(configFile);
runner.run(configuration);
}
}
2 changes: 1 addition & 1 deletion harry-integration/src/harry/model/sut/InJvmSut.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

public class InJvmSut implements SystemUnderTest
{
public static void init()
public static void registerSubtypes()
{
Configuration.registerSubtypes(InJvmSutConfiguration.class);
}
Expand Down
13 changes: 8 additions & 5 deletions harry-integration/src/harry/runner/HarryRunnerJvm.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package harry.runner;

import harry.core.Configuration;
import harry.model.sut.InJvmSut;

import java.io.File;

public class HarryRunnerJvm extends org.apache.cassandra.distributed.test.TestBaseImpl implements HarryRunner {

public static void main(String[] args) throws Throwable {
HarryRunnerJvm runner = new HarryRunnerJvm();
InJvmSut.registerSubtypes();

InJvmSut.InJvmSutConfiguration config = new InJvmSut.InJvmSutConfiguration(3,
10,
System.getProperty("harry.root", "/tmp/cassandra/harry/") + System.currentTimeMillis());
HarryRunnerJvm runner = new HarryRunnerJvm();
File configFile = runner.loadConfig(args);

runner.run(config);
Configuration configuration = Configuration.fromFile(configFile);
runner.run(configuration);
}


Expand Down
2 changes: 1 addition & 1 deletion harry-integration/src/harry/runner/Reproduce.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Reproduce extends TestBaseImpl

public void runWithInJvmDtest() throws Throwable
{
InJvmSut.init();
InJvmSut.registerSubtypes();

System.setProperty("cassandra.disable_tcactive_openssl", "true");
System.setProperty("relocated.shaded.io.netty.transport.noNative", "true");
Expand Down
55 changes: 25 additions & 30 deletions harry-runner/src/harry/runner/HarryRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package harry.runner;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledExecutorService;
Expand All @@ -43,7 +44,7 @@ public interface HarryRunner

Logger logger = LoggerFactory.getLogger(HarryRunner.class);

default void run(Configuration.SutConfiguration sutConfig) throws Throwable
default void run(Configuration configuration) throws Throwable
{
System.setProperty("cassandra.disable_tcactive_openssl", "true");
System.setProperty("relocated.shaded.io.netty.transport.noNative", "true");
Expand All @@ -52,35 +53,7 @@ default void run(Configuration.SutConfiguration sutConfig) throws Throwable
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
executor.setRemoveOnCancelPolicy(true);

Configuration.ConfigurationBuilder configuration = new Configuration.ConfigurationBuilder();

long seed = System.currentTimeMillis();
configuration.setSeed(seed)
.setSUT(sutConfig)
.setPartitionDescriptorSelector(new Configuration.DefaultPDSelectorConfiguration(10, 100))
.setClusteringDescriptorSelector((builder) -> {
builder.setNumberOfModificationsDistribution(new Configuration.ConstantDistributionConfig(10))
.setRowsPerModificationDistribution(new Configuration.ConstantDistributionConfig(10))
.setMaxPartitionSize(100)
.setOperationKindWeights(new Configuration.OperationKindSelectorBuilder()
.addWeight(OpSelectors.OperationKind.DELETE_ROW, 1)
.addWeight(OpSelectors.OperationKind.DELETE_COLUMN, 1)
.addWeight(OpSelectors.OperationKind.DELETE_RANGE, 1)
.addWeight(OpSelectors.OperationKind.WRITE, 97)
.build());
})
.setRowVisitor(new Configuration.DefaultRowVisitorConfiguration())
.setClock(new Configuration.ApproximateMonotonicClockConfiguration((int) TimeUnit.HOURS.toSeconds(2) + 100,
1,
TimeUnit.SECONDS))
.setRunTime(2, TimeUnit.HOURS)
.setCreateSchema(true)
.setTruncateTable(false)
.setDropSchema(false)
.setModel(ExhaustiveChecker::new)
.setRunner(new Configuration.ConcurrentRunnerConfig(1, 1, 1));

Runner runner = configuration.build().createRunner();
Runner runner = configuration.createRunner();
Run run = runner.getRun();

CompletableFuture progress = runner.initAndStartAll();
Expand Down Expand Up @@ -144,6 +117,28 @@ default void tryRun(ThrowingRunnable runnable)
}
}

/**
* Parses the command-line args and returns a File for the configuration YAML.
* @param args Command-line args.
* @return Configuration YAML file.
* @throws Exception If file is not found or cannot be read.
*/
default File loadConfig(String[] args) throws Exception {
if (args == null || args.length == 0) {
throw new Exception("Harry config YAML not provided.");
}

File configFile = new File(args[0]);
if (!configFile.exists()) {
throw new FileNotFoundException(configFile.getAbsolutePath());
}
if (!configFile.canRead()) {
throw new Exception("Cannot read config file, check your permissions on " + configFile.getAbsolutePath());
}

return configFile;
}

/**
* If you want to see how Harry detects problems!
*/
Expand Down
3 changes: 3 additions & 0 deletions run-external.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

java -Dlogback.configurationFile=test/conf/logback-dtest.xml -jar harry-integration-external/target/harry-integration-external-0.0.1-SNAPSHOT.jar conf/external.yaml
49 changes: 49 additions & 0 deletions run-jvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh

java -ea \
-Xms4g \
-Xmx4g \
-XX:MaxRAM=4g \
-XX:MaxMetaspaceSize=384M \
-XX:MetaspaceSize=128M \
-XX:SoftRefLRUPolicyMSPerMB=0 \
-XX:MaxDirectMemorySize=2g \
-Dcassandra.memtable_row_overhead_computation_step=100 \
-Djdk.attach.allowAttachSelf=true \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:-UseBiasedLocking \
-XX:+UseTLAB \
-XX:+ResizeTLAB \
-XX:+UseNUMA \
-XX:+PerfDisableSharedMem \
-XX:+UseConcMarkSweepGC \
-XX:+CMSParallelRemarkEnabled \
-XX:SurvivorRatio=8 \
-XX:MaxTenuringThreshold=1 \
-XX:CMSInitiatingOccupancyFraction=75 \
-XX:+UseCMSInitiatingOccupancyOnly \
-XX:CMSWaitDuration=10000 \
-XX:+CMSParallelInitialMarkEnabled \
-XX:+CMSEdenChunksRecordAlways \
-XX:+CMSClassUnloadingEnabled \
-XX:+UseCondCardMark \
-XX:OnOutOfMemoryError=kill \
--add-exports java.base/jdk.internal.misc=ALL-UNNAMED \
--add-exports java.base/jdk.internal.ref=ALL-UNNAMED \
--add-exports java.base/sun.nio.ch=ALL-UNNAMED \
--add-exports java.management.rmi/com.sun.jmx.remote.internal.rmi=ALL-UNNAMED \
--add-exports java.rmi/sun.rmi.registry=ALL-UNNAMED \
--add-exports java.rmi/sun.rmi.server=ALL-UNNAMED \
--add-exports java.sql/java.sql=ALL-UNNAMED \
--add-opens java.base/java.lang.module=ALL-UNNAMED \
--add-opens java.base/jdk.internal.loader=ALL-UNNAMED \
--add-opens java.base/jdk.internal.ref=ALL-UNNAMED \
--add-opens java.base/jdk.internal.reflect=ALL-UNNAMED \
--add-opens java.base/jdk.internal.math=ALL-UNNAMED \
--add-opens java.base/jdk.internal.module=ALL-UNNAMED \
--add-opens java.base/jdk.internal.util.jar=ALL-UNNAMED \
--add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED \
-Dorg.apache.cassandra.test.logback.configurationFile=file://test/conf/logback-dtest.xml \
-cp harry-integration/target/harry-integration-0.0.1-SNAPSHOT.jar:$(find harry-integration/target/dependency/*.jar | tr -s '\n' ':'). \
harry.runner.HarryRunnerJvm \
conf/example.yaml

0 comments on commit 9c5eb00

Please sign in to comment.