You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "ifesdjeen (via GitHub)" <gi...@apache.org> on 2023/11/29 17:05:49 UTC
[PR] History Builder API 2.0 [cassandra-harry]
ifesdjeen opened a new pull request, #24:
URL: https://github.com/apache/cassandra-harry/pull/24
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417677629
##########
harry-core/src/harry/ddl/ColumnSpec.java:
##########
@@ -186,6 +186,19 @@ public String nameForParser()
{
return cqlName;
}
+
+ public boolean equals(Object o)
Review Comment:
nit: `@Override` on this and `hashCode()`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1415165458
##########
harry-core/src/harry/generators/EntropySource.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 harry.generators;
+
+import harry.core.VisibleForTesting;
+
+/**
+ * Random generator interface that offers:
+ * * Settable seed
+ * * Ability to generate multiple "next" random seeds
+ * * Ability to generate multiple "dependent" seeds, from which we can retrace the base seed with subtraction
+ */
+public interface EntropySource
+{
+ long next();
+ void seed(long seed);
Review Comment:
yeah, you can re-seed any time, at least as of now...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417890937
##########
harry-core/src/harry/reconciler/Reconciler.java:
##########
@@ -87,31 +87,36 @@ class Processor extends VisitExecutor
{
// Whether a partition deletion was encountered on this LTS.
private boolean hadPartitionDeletion = false;
+ private boolean hadTrackingRowWrite = false;
private final List<Ranges.Range> rangeDeletes = new ArrayList<>();
- private final List<ReplayingVisitor.Operation> writes = new ArrayList<>();
- private final List<ReplayingVisitor.Operation> columnDeletes = new ArrayList<>();
+ private final List<Operation> writes = new ArrayList<>();
+ private final List<Operation> columnDeletes = new ArrayList<>();
@Override
- protected void operation(long lts, long pd, long cd, long opId, OpSelectors.OperationKind opType)
+ protected void operation(Operation operation)
{
if (hadPartitionDeletion)
return;
- switch (opType)
+ long lts = operation.lts();
+ assert pdSelector.pd(operation.lts(), schema) == operation.pd();
+
+ if (operation.opKind() != OpSelectors.OperationKind.DELETE_PARTITION)
+ partitionState.visitedLts.add(operation.lts());
Review Comment:
extracted into a method and documented:
```
/**
* All operations apart from partiton delition, including partition hist are visible since if there is a
* partition liveness marker, partition's static column is going to survive. We use this method to match
* computed LTS with tracked ones.
*/
public boolean hasVisibleVisit()
{
return this != OpSelectors.OperationKind.DELETE_PARTITION;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417668621
##########
harry-core/src/harry/data/ResultSetRow.java:
##########
@@ -55,12 +78,26 @@ public ResultSetRow clone()
Arrays.copyOf(vds, vds.length), Arrays.copyOf(lts, lts.length));
}
+ public boolean equals(Object o)
Review Comment:
nit: `@Override` ?
I don't know if you'll need a `hashCode()` here or ever have this in a collection, but I'm compelled by habit to mention it :p
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417670953
##########
harry-core/src/harry/data/ResultSetRow.java:
##########
@@ -32,20 +35,40 @@ public class ResultSetRow
public final long[] sds;
public final long[] slts;
+ public final List<Long> visited_lts;
+
+ private ResultSetRow(long pd,
+ long cd,
+ long[] sds,
+ long[] slts,
+ long[] vds,
+ long[] lts)
+ {
+ this(pd, cd, sds, slts, vds, lts, Collections.emptyList());
+ }
public ResultSetRow(long pd,
long cd,
long[] sds,
long[] slts,
long[] vds,
- long[] lts)
+ long[] lts,
+ List<Long> visited_lts)
{
+ assert slts.length == sds.length;
+ assert lts.length == vds.length;
this.pd = pd;
this.cd = cd;
this.vds = vds;
this.lts = lts;
this.sds = sds;
this.slts = slts;
+ this.visited_lts = visited_lts;
+ }
+
+ public boolean hasStaticColumns()
+ {
+ return slts.length > 0;
}
public ResultSetRow clone()
Review Comment:
nit: `@Override`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1416299320
##########
harry-core/src/harry/runner/LockingDataTracker.java:
##########
@@ -65,7 +65,7 @@ public void beginModification(long lts)
{
Review Comment:
yes, final not static! 👍
##########
harry-core/src/harry/runner/LockingDataTracker.java:
##########
@@ -65,7 +65,7 @@ public void beginModification(long lts)
{
Review Comment:
yes, final not static! 👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1418876582
##########
harry-integration/test/harry/dsl/HistoryBuilderIntegrationTest.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 harry.dsl;
+
+import java.util.Random;
+import java.util.function.LongSupplier;
+import java.util.function.Supplier;
+
+import org.junit.Test;
+
+import harry.checker.ModelChecker;
+import harry.core.Configuration;
+import harry.core.Run;
+import harry.ddl.SchemaGenerators;
+import harry.ddl.SchemaSpec;
+import harry.generators.JdkRandomEntropySource;
+import harry.model.Model;
+import harry.model.ModelTestBase;
+import harry.model.QuiescentChecker;
+import harry.operations.Query;
+import harry.reconciler.Reconciler;
+import harry.visitors.ReplayingVisitor;
+
+public class HistoryBuilderIntegrationTest extends ModelTestBase
+{
+ private final long seed = 1L;
+ private final int STEPS_PER_ITERATION = 1_000;
+ private final int MAX_PARTITIONS = 100;
+
+ protected Configuration.ModelConfiguration modelConfiguration()
+ {
+ return new Configuration.QuiescentCheckerConfig();
+ }
+
+ public Configuration.ConfigurationBuilder configuration(long seed, SchemaSpec schema)
+ {
+ return super.configuration(seed, schema)
+ .setPartitionDescriptorSelector(new Configuration.DefaultPDSelectorConfiguration(2, 2))
+ .setClusteringDescriptorSelector((builder) -> builder.setOperationsPerLtsDistribution(new Configuration.ConstantDistributionConfig(100_000)));
+ }
+
+ @Test
+ public void simpleDSLTest() throws Throwable
+ {
+ Supplier<SchemaSpec> supplier = SchemaGenerators.progression(SchemaGenerators.DEFAULT_SWITCH_AFTER);
+ for (int i = 0; i < SchemaGenerators.DEFAULT_RUNS; i++)
+ {
+ SchemaSpec schema = supplier.get();
+ Configuration config = configuration(i, schema).build();
+
+ Run run = config.createRun();
+ beforeEach();
+ run.sut.schemaChange(schema.compile().cql());
+
+ ModelChecker<SingleOperationBuilder> modelChecker = new ModelChecker<>();
+ JdkRandomEntropySource entropySource = new JdkRandomEntropySource(new Random(seed));
+
+ LongSupplier[] valueGenerators = new LongSupplier[run.schemaSpec.regularColumns.size()];
+ for (int j = 0; j < valueGenerators.length; j++)
+ {
+ valueGenerators[j] = new ValueDescriptorIndexGenerator(run.schemaSpec.regularColumns.get(j),
+ run.rng)
+ .toSupplier(entropySource.derive(), 20, 0.2f);
+ }
+
+ int maxPartitionSize = 100;
+ modelChecker.init(new HistoryBuilder(seed, maxPartitionSize, 10, schema))
+ .step((history) -> {
+ return history.insert();
+ })
+ .step((history) -> {
+ return history.insert(entropySource.nextInt(maxPartitionSize));
+ })
+ .step((history) -> {
+ int row = entropySource.nextInt(maxPartitionSize);
+ long[] vds = new long[valueGenerators.length];
+ for (int j = 0; j < valueGenerators.length; j++)
+ vds[j] = valueGenerators[j].getAsLong();
+
+ return history.insert(row, vds);
+ })
+ .step((history) -> {
+ return history.deleteRow();
+ })
+ .step((history) -> {
+ return history.deleteRow(entropySource.nextInt(maxPartitionSize));
+ })
+ .step(SingleOperationBuilder::deletePartition)
+ .step(SingleOperationBuilder::deleteColumns)
+ .step(SingleOperationBuilder::deleteRowSlice)
+ .step((history) -> {
+ return history.deleteRowRange();
+ })
+ .step((history) -> {
+ return history.deleteRowRange(entropySource.nextInt(maxPartitionSize),
+ entropySource.nextInt(maxPartitionSize),
+ entropySource.nextBoolean(),
+ entropySource.nextBoolean());
+ })
+ .step((history) -> history instanceof HistoryBuilder,
+ (history) -> ((HistoryBuilder) history).beginBatch())
+ .step((history) -> (history instanceof BatchVisitBuilder) && ((BatchVisitBuilder) history).size() > 1,
+ (history) -> ((BatchVisitBuilder) history).endBatch())
+ .exitCondition((history) -> {
+ if (!(history instanceof HistoryBuilder))
+ return false;
+
+ HistoryBuilder historyBuilder = (HistoryBuilder) history;
+ ReplayingVisitor visitor = historyBuilder.visitor(run.tracker, run.sut);
+ visitor.replayAll();
+
+ if (historyBuilder.presetSelector.pds().size() < MAX_PARTITIONS)
+ return false;
+
+ Model model = historyBuilder.checker(run.tracker, sut);
+
+ for (Long pd : historyBuilder.presetSelector.pds())
+ model.validate(Query.selectPartition(run.schemaSpec, pd,false));
+
+ return true;
+ })
+ .run(STEPS_PER_ITERATION, seed);
Review Comment:
Right, we create a model checker that triggers series of random steps, then replays them against the SUT, and validates visited partitions.
> Then when we check the exit condition, we actually replay the operations to the SUT from the beginning up to the last visited LTS and validate the model.
So there are two different history builders: one replaying (with auto-replay on) and one that simply creates series of events, in case you would like to preturb / execute them in some sophisticated way. There was no specific way for us to collect and then replay things, but I have first created a regular history builder, and then replaying one, built on top of the first one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1418879101
##########
harry-integration/test/harry/model/HistoryBuilderTest.java:
##########
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 harry.model;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import harry.core.Configuration;
-import harry.core.Run;
-import harry.ddl.SchemaSpec;
-import harry.dsl.HistoryBuilder;
-import harry.util.TestRunner;
-import harry.visitors.ReplayingVisitor;
-import harry.visitors.VisitExecutor;
-
-public class HistoryBuilderTest
Review Comment:
Oh weird, not sure why it has not gotten removed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417751800
##########
harry-core/src/harry/reconciler/PartitionState.java:
##########
@@ -113,18 +126,18 @@ public boolean isEmpty()
return rows.isEmpty();
}
- private Reconciler.RowState updateRowState(Reconciler.RowState currentState, List<ColumnSpec<?>> columns, long cd, long[] vds, long lts, boolean writePrimaryKeyLiveness)
+ private Reconciler.RowState updateRowState(Reconciler.RowState currentState, List<ColumnSpec<?>> columns, long cd, long[] sds, long lts, boolean writePrimaryKeyLiveness)
Review Comment:
Stumbling over naming here a bit. We have `sds`, and methods calling this w/ the argument `staticVds` or `vds`. `updateRowState()` isn't always called w/ static values (or value descriptors) right? (Aside: Would `vds` for normal column values and `svds` make sense for static values?)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1416298828
##########
harry-core/src/harry/dsl/HistoryBuilder.java:
##########
@@ -19,598 +19,511 @@
package harry.dsl;
import java.util.*;
-import java.util.function.Consumer;
import java.util.function.LongSupplier;
-import harry.core.Run;
+import harry.core.Configuration;
+import harry.core.MetricReporter;
+import harry.ddl.SchemaSpec;
+import harry.generators.EntropySource;
+import harry.generators.JdkRandomEntropySource;
+import harry.model.Model;
import harry.model.OpSelectors;
+import harry.model.QuiescentChecker;
+import harry.model.clock.ApproximateMonotonicClock;
+import harry.model.sut.SystemUnderTest;
+import harry.operations.Query;
+import harry.reconciler.Reconciler;
+import harry.runner.DataTracker;
import harry.visitors.MutatingRowVisitor;
import harry.visitors.MutatingVisitor;
import harry.visitors.ReplayingVisitor;
import harry.visitors.VisitExecutor;
-import static harry.model.OpSelectors.DefaultPdSelector.PARTITION_DESCRIPTOR_STREAM_ID;
+// TODO: we can implement a pluggable time source via a custom clock, too; the only limitation is that order
+// of timestamps has to be consistent with LTS order
// TODO: we could use some sort of compact data structure or file format for navigable operation history
-public class HistoryBuilder implements Iterable<ReplayingVisitor.Visit>
+// this can have a _huge_ advantage of being able to produce arbitrary patterns, since you can specify history
+// either in a _very_ random way, or in a _very_ predictable way, but still leave a footprint extremely small,
+// since if you do not specify the details, we just produce fully random operations.
+
+/**
+ * History builder is a component for a simple yet flexible generation of arbitrary data.
+ *
+ *
Review Comment:
Added quite a bit of doc now
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417907279
##########
harry-core/src/harry/generators/RandomGenerator.java:
##########
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 harry.generators;
-
-import harry.core.VisibleForTesting;
-
-/**
- * Random generator interface that offers:
- * * Settable seed
- * * Ability to generate multiple "next" random seeds
- * * Ability to generate multiple "dependent" seeds, from which we can retrace the base seed with subtraction
- */
-public interface RandomGenerator
Review Comment:
nit: meant to remove the file as well?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1416267095
##########
harry-integration/test/harry/model/HistoryBuilderIntegrationTest.java:
##########
@@ -1,192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 harry.model;
-
-import java.util.HashSet;
-import java.util.Random;
-import java.util.Set;
-import java.util.function.Supplier;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import harry.core.Configuration;
-import harry.core.Run;
-import harry.ddl.SchemaGenerators;
-import harry.ddl.SchemaSpec;
-import harry.dsl.HistoryBuilder;
-import harry.operations.CompiledStatement;
-import harry.operations.Query;
-import harry.operations.QueryGenerator;
-import harry.reconciler.Reconciler;
-import harry.util.TestRunner;
-import harry.visitors.MutatingVisitor;
-import harry.visitors.MutatingRowVisitor;
-import harry.visitors.ReplayingVisitor;
-
-public class HistoryBuilderIntegrationTest extends ModelTestBase
Review Comment:
Yes, this is for the old, bad history builder!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1418054105
##########
harry-core/src/harry/checker/ModelChecker.java:
##########
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 harry.checker;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.function.Consumer;
+
+import harry.generators.EntropySource;
+import harry.generators.JdkRandomEntropySource;
+
+public class ModelChecker<STATE>
+{
+ private final List<StepExecutor<STATE>> steps;
+ private final List<Precondition<STATE>> invariants;
+ private Precondition<STATE> exitCondition;
+ private Consumer<STATE> beforeAll;
+ private Consumer<STATE> afterAll;
+ private STATE init;
+
+ public ModelChecker()
+ {
+ steps = new ArrayList<>();
+ invariants = new ArrayList<>();
+ }
+
+ public void run() throws Throwable
+ {
+ run(Integer.MAX_VALUE, System.currentTimeMillis());
+ }
+
+ public void run(int maxSteps, long seed) throws Throwable
+ {
+ assert init != null : "Initial condition is not specified";
+
+ Ref<STATE> state = new Ref<>(init);
+ EntropySource entropySource = new JdkRandomEntropySource(new Random(seed));
+ if (beforeAll != null)
+ beforeAll.accept(state.get());
+
+ for (int i = 0; i < maxSteps; i++)
+ {
+ if (exitCondition != null && exitCondition.test(state.get()))
+ return;
+
+ // TODO: add randomisation / probability for triggering a specific step
+ steps.get(entropySource.nextInt(steps.size())).execute(state, entropySource.derive());
+ for (Precondition<STATE> invariant : invariants)
+ invariant.test(state.get());
+ }
+
+ if (afterAll != null)
+ afterAll.accept(state.get());
+ }
+ public ModelChecker<STATE> init(STATE state)
+ {
+ this.init = state;
+ return this;
+ }
+
+ public ModelChecker<STATE> beforeAll(Consumer<STATE> precondition)
+ {
+ this.beforeAll = precondition;
+ return this;
+ }
+
+ public ModelChecker<STATE> afterAll(Consumer<STATE> postcondition)
+ {
+ this.afterAll = postcondition;
+ return this;
+ }
+
+ public ModelChecker<STATE> exitCondition(Precondition<STATE> precondition)
+ {
+ this.exitCondition = precondition;
+ return this;
+ }
+
+ public ModelChecker<STATE> step(Precondition<STATE> precondition, Step<STATE> step)
+ {
+ steps.add((ref, entropySource) -> {
+ ref.map(state -> {
+ if (!precondition.test(state))
+ return state;
+
+ return step.next(state, entropySource);
+ });
+ });
+
+ return this;
+ }
+
+ public ModelChecker<STATE> invariant(Precondition<STATE> invariant)
+ {
+ invariants.add(invariant);
+ return this;
+ }
+
+ public ModelChecker<STATE> step(Step<STATE> step)
+ {
+ return step(Precondition.alwaysTrue(), step);
+ }
+
+ public ModelChecker<STATE> step(StatePrecondition<STATE> precondition, ThrowingFunction<STATE, STATE> step)
+ {
+ steps.add((ref, entropySource) -> {
+ ref.map(state -> {
+ if (!precondition.test(state))
+ return state;
+
+ return step.apply(state);
+ });
+ });
+
+ return this;
+ }
+
+ public ModelChecker<STATE> step(ThrowingConsumer<STATE> step)
+ {
+ return step((t, entropySource) -> {
+ step.consume(t);
+ return t;
+ });
+ }
+ public ModelChecker<STATE> step(ThrowingFunction<STATE, STATE> step)
+ {
+ return step((t, entropySource) -> {
+ return step.apply(t);
+ });
+ }
+
+ static interface StepExecutor<STATE>
+ {
+ void execute(Ref<STATE> state, EntropySource entropySource) throws Throwable;
+ }
+
+ public static interface StatePrecondition<STATE>
+ {
+ boolean test(STATE state) throws Throwable;
+ }
+
+ public static interface Precondition<STATE>
+ {
+ boolean test(STATE state) throws Throwable;
+
+ public static <STATE> Precondition<STATE> alwaysTrue()
+ {
+ return (a) -> true;
+ }
+ }
+
+ public static interface Step<STATE>
Review Comment:
nit: None of the interfaces need the `static` keyword
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417987633
##########
harry-integration/test/harry/model/HistoryBuilderTest.java:
##########
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 harry.model;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import harry.core.Configuration;
-import harry.core.Run;
-import harry.ddl.SchemaSpec;
-import harry.dsl.HistoryBuilder;
-import harry.util.TestRunner;
-import harry.visitors.ReplayingVisitor;
-import harry.visitors.VisitExecutor;
-
-public class HistoryBuilderTest
Review Comment:
nit: Remove file as well?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417911392
##########
harry-core/src/harry/generators/PcgRSUFast.java:
##########
@@ -56,12 +57,54 @@ public void seek(long step)
advance(step - this.step);
}
+ public EntropySource derive()
+ {
+ return new PcgRSUFast(PCGFastPure.nextState(state, stream), stream);
+ }
+
+ @Override
public long next()
{
nextStep();
return PCGFastPure.shuffle(state);
}
+ public long nextAt(long step)
+ {
+ seek(step);
+ return next();
+ }
+
+ public int nextInt()
+ {
+ return RngUtils.asInt(next());
+ }
+
+ public int nextInt(int max)
+ {
+ return RngUtils.asInt(next(), max);
+ }
+
+ public int nextInt(int min, int max)
+ {
+ return RngUtils.asInt(next(), min, max);
+ }
+
+ public long nextLong(long min, long max)
+ {
+ return RngUtils.trim(next(), min, max);
+ }
+
+ public float nextFloat()
+ {
+ return RngUtils.asFloat(next());
+ }
+
+ public boolean nextBoolean()
+ {
+ return RngUtils.asBoolean(next());
+ }
Review Comment:
nit: All these `nextX()` methods and `derive()` could use an `@Override`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417669538
##########
harry-core/src/harry/data/ResultSetRow.java:
##########
@@ -32,20 +35,40 @@ public class ResultSetRow
public final long[] sds;
public final long[] slts;
+ public final List<Long> visited_lts;
+
+ private ResultSetRow(long pd,
+ long cd,
+ long[] sds,
+ long[] slts,
+ long[] vds,
+ long[] lts)
+ {
+ this(pd, cd, sds, slts, vds, lts, Collections.emptyList());
+ }
public ResultSetRow(long pd,
long cd,
long[] sds,
long[] slts,
long[] vds,
- long[] lts)
+ long[] lts,
+ List<Long> visited_lts)
{
+ assert slts.length == sds.length;
+ assert lts.length == vds.length;
Review Comment:
nit: Brief message be helpful for when these trigger?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1418882457
##########
harry-core/src/harry/model/OpSelectors.java:
##########
@@ -78,6 +78,7 @@ default long prev(long r)
* 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.
*/
+ // TOD: rename to just "Clock", it is not monotonic anymore
Review Comment:
May as well do it now! Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417671370
##########
harry-core/src/harry/data/ResultSetRow.java:
##########
@@ -55,12 +78,26 @@ public ResultSetRow clone()
Arrays.copyOf(vds, vds.length), Arrays.copyOf(lts, lts.length));
Review Comment:
Does `visited_lts` need to be part of the clone?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417923213
##########
harry-core/src/harry/model/sut/DoubleWritingSut.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 harry.model.sut;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.regex.Pattern;
+
+public class DoubleWritingSut implements SystemUnderTest
+{
+ private final SystemUnderTest primary;
+ private final SystemUnderTest secondary;
+
+ public DoubleWritingSut(SystemUnderTest primary,
+ SystemUnderTest secondary)
+ {
+ this.primary = primary;
+ this.secondary = secondary;
+ }
+ public boolean isShutdown()
+ {
+ return primary.isShutdown();
+ }
+
+ public void shutdown()
+ {
+ primary.shutdown();
+ }
+
+ private static final Pattern pattern = Pattern.compile("select", Pattern.CASE_INSENSITIVE);
Review Comment:
nit: Should we use `^select` just out of paranoia? (I guess you can also just guarantee there won't be random column names like `fooSelect` :D
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1416160254
##########
harry-integration/test/harry/model/HistoryBuilderIntegrationTest.java:
##########
@@ -1,192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 harry.model;
-
-import java.util.HashSet;
-import java.util.Random;
-import java.util.Set;
-import java.util.function.Supplier;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import harry.core.Configuration;
-import harry.core.Run;
-import harry.ddl.SchemaGenerators;
-import harry.ddl.SchemaSpec;
-import harry.dsl.HistoryBuilder;
-import harry.operations.CompiledStatement;
-import harry.operations.Query;
-import harry.operations.QueryGenerator;
-import harry.reconciler.Reconciler;
-import harry.util.TestRunner;
-import harry.visitors.MutatingVisitor;
-import harry.visitors.MutatingRowVisitor;
-import harry.visitors.ReplayingVisitor;
-
-public class HistoryBuilderIntegrationTest extends ModelTestBase
Review Comment:
nit: Did we mean to delete this file?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417705068
##########
harry-core/src/harry/visitors/MutatingVisitor.java:
##########
@@ -66,17 +67,52 @@ public MutatingVisitor(Run run,
super(run, visitExecutor);
}
+ public static class LtsTrackingVisitExecutor extends MutatingVisitExecutor
+ {
+ public LtsTrackingVisitExecutor(OpSelectors.DescriptorSelector descriptorSelector, DataTracker tracker, SystemUnderTest sut, SchemaSpec schema, OperationExecutor rowVisitor, SystemUnderTest.ConsistencyLevel consistencyLevel)
+ {
+ super(descriptorSelector, tracker, sut, schema, rowVisitor, consistencyLevel);
+ }
+
+ @Override
+ public void afterLts(long lts, long pd)
+ {
+ if (hadVisibleVisit)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("UPDATE ").append(schema.keyspace).append(".").append(schema.table)
+ .append(" SET visited_lts = visited_lts + [").append(lts).append("] ")
Review Comment:
So we're guaranteed the schema has `visited_lts` here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417760301
##########
harry-core/src/harry/reconciler/Reconciler.java:
##########
@@ -189,26 +199,27 @@ protected void afterLts(long lts, long pd)
}
partitionState.write(cd,
- descriptorSelector.vds(pd, cd, lts, opId, op.opType, schema),
+ writeOp.vds(),
lts,
- op.opType == OpSelectors.OperationKind.INSERT || op.opType == OpSelectors.OperationKind.INSERT_WITH_STATICS);
+ op.opKind() == OpSelectors.OperationKind.INSERT || op.opKind() == OpSelectors.OperationKind.INSERT_WITH_STATICS);
Review Comment:
nit: Might work to rename this `opKind()` -> `kind()`, so it reads `op.kind()`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1418072590
##########
harry-integration/test/harry/dsl/HistoryBuilderIntegrationTest.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 harry.dsl;
+
+import java.util.Random;
+import java.util.function.LongSupplier;
+import java.util.function.Supplier;
+
+import org.junit.Test;
+
+import harry.checker.ModelChecker;
+import harry.core.Configuration;
+import harry.core.Run;
+import harry.ddl.SchemaGenerators;
+import harry.ddl.SchemaSpec;
+import harry.generators.JdkRandomEntropySource;
+import harry.model.Model;
+import harry.model.ModelTestBase;
+import harry.model.QuiescentChecker;
+import harry.operations.Query;
+import harry.reconciler.Reconciler;
+import harry.visitors.ReplayingVisitor;
+
+public class HistoryBuilderIntegrationTest extends ModelTestBase
+{
+ private final long seed = 1L;
+ private final int STEPS_PER_ITERATION = 1_000;
+ private final int MAX_PARTITIONS = 100;
+
+ protected Configuration.ModelConfiguration modelConfiguration()
+ {
+ return new Configuration.QuiescentCheckerConfig();
+ }
+
+ public Configuration.ConfigurationBuilder configuration(long seed, SchemaSpec schema)
+ {
+ return super.configuration(seed, schema)
+ .setPartitionDescriptorSelector(new Configuration.DefaultPDSelectorConfiguration(2, 2))
+ .setClusteringDescriptorSelector((builder) -> builder.setOperationsPerLtsDistribution(new Configuration.ConstantDistributionConfig(100_000)));
+ }
+
+ @Test
+ public void simpleDSLTest() throws Throwable
+ {
+ Supplier<SchemaSpec> supplier = SchemaGenerators.progression(SchemaGenerators.DEFAULT_SWITCH_AFTER);
+ for (int i = 0; i < SchemaGenerators.DEFAULT_RUNS; i++)
+ {
+ SchemaSpec schema = supplier.get();
+ Configuration config = configuration(i, schema).build();
+
+ Run run = config.createRun();
+ beforeEach();
+ run.sut.schemaChange(schema.compile().cql());
+
+ ModelChecker<SingleOperationBuilder> modelChecker = new ModelChecker<>();
+ JdkRandomEntropySource entropySource = new JdkRandomEntropySource(new Random(seed));
+
+ LongSupplier[] valueGenerators = new LongSupplier[run.schemaSpec.regularColumns.size()];
+ for (int j = 0; j < valueGenerators.length; j++)
+ {
+ valueGenerators[j] = new ValueDescriptorIndexGenerator(run.schemaSpec.regularColumns.get(j),
+ run.rng)
+ .toSupplier(entropySource.derive(), 20, 0.2f);
+ }
+
+ int maxPartitionSize = 100;
+ modelChecker.init(new HistoryBuilder(seed, maxPartitionSize, 10, schema))
+ .step((history) -> {
+ return history.insert();
+ })
+ .step((history) -> {
+ return history.insert(entropySource.nextInt(maxPartitionSize));
+ })
+ .step((history) -> {
+ int row = entropySource.nextInt(maxPartitionSize);
+ long[] vds = new long[valueGenerators.length];
+ for (int j = 0; j < valueGenerators.length; j++)
+ vds[j] = valueGenerators[j].getAsLong();
+
+ return history.insert(row, vds);
+ })
+ .step((history) -> {
+ return history.deleteRow();
+ })
+ .step((history) -> {
+ return history.deleteRow(entropySource.nextInt(maxPartitionSize));
+ })
+ .step(SingleOperationBuilder::deletePartition)
+ .step(SingleOperationBuilder::deleteColumns)
+ .step(SingleOperationBuilder::deleteRowSlice)
+ .step((history) -> {
+ return history.deleteRowRange();
+ })
+ .step((history) -> {
+ return history.deleteRowRange(entropySource.nextInt(maxPartitionSize),
+ entropySource.nextInt(maxPartitionSize),
+ entropySource.nextBoolean(),
+ entropySource.nextBoolean());
+ })
+ .step((history) -> history instanceof HistoryBuilder,
+ (history) -> ((HistoryBuilder) history).beginBatch())
+ .step((history) -> (history instanceof BatchVisitBuilder) && ((BatchVisitBuilder) history).size() > 1,
+ (history) -> ((BatchVisitBuilder) history).endBatch())
+ .exitCondition((history) -> {
+ if (!(history instanceof HistoryBuilder))
+ return false;
+
+ HistoryBuilder historyBuilder = (HistoryBuilder) history;
+ ReplayingVisitor visitor = historyBuilder.visitor(run.tracker, run.sut);
+ visitor.replayAll();
+
+ if (historyBuilder.presetSelector.pds().size() < MAX_PARTITIONS)
+ return false;
+
+ Model model = historyBuilder.checker(run.tracker, sut);
+
+ for (Long pd : historyBuilder.presetSelector.pds())
+ model.validate(Query.selectPartition(run.schemaSpec, pd,false));
+
+ return true;
+ })
+ .run(STEPS_PER_ITERATION, seed);
Review Comment:
So I'll summarize what I think is going on here, and then my review should be complete...
We create a `ModelChecker` with single-operation steps to...
1.) Record a series of operations against the model using a `HistoryBuilder` as the state container.
2.) Replay them all against the SUT.
3.) Validate all the partitions we visited.
There are some details I'm not clear on, though. It looks like `ModelChecker#run()` executes individual steps, and each step execution adds data to the `HistoryBuilder` log. Then when we check the exit condition, we actually replay the operations to the SUT from the beginning up to the last visited LTS and validate the model.
Am I one the right track?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417941232
##########
harry-core/src/harry/model/OpSelectors.java:
##########
@@ -78,6 +78,7 @@ default long prev(long r)
* 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.
*/
+ // TOD: rename to just "Clock", it is not monotonic anymore
Review Comment:
nit: Something we want to do here or in another patch?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417874347
##########
harry-core/src/harry/visitors/MutatingVisitor.java:
##########
@@ -66,17 +67,52 @@ public MutatingVisitor(Run run,
super(run, visitExecutor);
}
+ public static class LtsTrackingVisitExecutor extends MutatingVisitExecutor
+ {
+ public LtsTrackingVisitExecutor(OpSelectors.DescriptorSelector descriptorSelector, DataTracker tracker, SystemUnderTest sut, SchemaSpec schema, OperationExecutor rowVisitor, SystemUnderTest.ConsistencyLevel consistencyLevel)
+ {
+ super(descriptorSelector, tracker, sut, schema, rowVisitor, consistencyLevel);
+ }
+
+ @Override
+ public void afterLts(long lts, long pd)
+ {
+ if (hadVisibleVisit)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("UPDATE ").append(schema.keyspace).append(".").append(schema.table)
+ .append(" SET visited_lts = visited_lts + [").append(lts).append("] ")
Review Comment:
added assert in constructor.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1418887046
##########
harry-core/src/harry/generators/RandomGenerator.java:
##########
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 harry.generators;
-
-import harry.core.VisibleForTesting;
-
-/**
- * Random generator interface that offers:
- * * Settable seed
- * * Ability to generate multiple "next" random seeds
- * * Ability to generate multiple "dependent" seeds, from which we can retrace the base seed with subtraction
- */
-public interface RandomGenerator
Review Comment:
ok i know the reason: `patch -p1` does not remove files! Fixed now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417754733
##########
harry-core/src/harry/reconciler/Reconciler.java:
##########
@@ -87,31 +87,36 @@ class Processor extends VisitExecutor
{
// Whether a partition deletion was encountered on this LTS.
private boolean hadPartitionDeletion = false;
+ private boolean hadTrackingRowWrite = false;
private final List<Ranges.Range> rangeDeletes = new ArrayList<>();
- private final List<ReplayingVisitor.Operation> writes = new ArrayList<>();
- private final List<ReplayingVisitor.Operation> columnDeletes = new ArrayList<>();
+ private final List<Operation> writes = new ArrayList<>();
+ private final List<Operation> columnDeletes = new ArrayList<>();
@Override
- protected void operation(long lts, long pd, long cd, long opId, OpSelectors.OperationKind opType)
+ protected void operation(Operation operation)
{
if (hadPartitionDeletion)
return;
- switch (opType)
+ long lts = operation.lts();
+ assert pdSelector.pd(operation.lts(), schema) == operation.pd();
Review Comment:
nit: Quick message for the assert indicating what went wrong?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417972496
##########
harry-core/src/harry/visitors/VisitExecutor.java:
##########
@@ -19,14 +19,105 @@
package harry.visitors;
import harry.model.OpSelectors;
+import harry.operations.Query;
+import harry.util.BitSet;
public abstract class VisitExecutor
{
protected abstract void beforeLts(long lts, long pd);
protected abstract void afterLts(long lts, long pd);
- protected abstract void operation(long lts, long pd, long cd, long opId, OpSelectors.OperationKind kind);
+ protected abstract void operation(Operation operation);
public abstract void shutdown() throws InterruptedException;
+
+ public interface WriteOp extends Operation
+ {
+ long pd();
Review Comment:
nit: Already inherits `pd()` from `Operation`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "aratno (via GitHub)" <gi...@apache.org>.
aratno commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1415891075
##########
harry-core/src/harry/generators/EntropySource.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 harry.generators;
+
+import harry.core.VisibleForTesting;
+
+/**
+ * Random generator interface that offers:
+ * * Settable seed
+ * * Ability to generate multiple "next" random seeds
+ * * Ability to generate multiple "dependent" seeds, from which we can retrace the base seed with subtraction
+ */
+public interface EntropySource
+{
+ long next();
+ void seed(long seed);
Review Comment:
In what situations would it make sense to re-seed? Seems like this could lead to runs that can't reproduce (unless we record every seed + when it was applied).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1416263099
##########
harry-core/src/harry/dsl/HistoryBuilder.java:
##########
@@ -19,598 +19,511 @@
package harry.dsl;
import java.util.*;
-import java.util.function.Consumer;
import java.util.function.LongSupplier;
-import harry.core.Run;
+import harry.core.Configuration;
+import harry.core.MetricReporter;
+import harry.ddl.SchemaSpec;
+import harry.generators.EntropySource;
+import harry.generators.JdkRandomEntropySource;
+import harry.model.Model;
import harry.model.OpSelectors;
+import harry.model.QuiescentChecker;
+import harry.model.clock.ApproximateMonotonicClock;
+import harry.model.sut.SystemUnderTest;
+import harry.operations.Query;
+import harry.reconciler.Reconciler;
+import harry.runner.DataTracker;
import harry.visitors.MutatingRowVisitor;
import harry.visitors.MutatingVisitor;
import harry.visitors.ReplayingVisitor;
import harry.visitors.VisitExecutor;
-import static harry.model.OpSelectors.DefaultPdSelector.PARTITION_DESCRIPTOR_STREAM_ID;
+// TODO: we can implement a pluggable time source via a custom clock, too; the only limitation is that order
+// of timestamps has to be consistent with LTS order
Review Comment:
Yes, sure. The idea here is that you can come with your own timestamps, not have Harry generate them. Maybe for some weird edge condition testing or something.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1416260953
##########
harry-core/src/harry/visitors/MutatingVisitor.java:
##########
@@ -116,21 +163,23 @@ public void afterLts(long lts, long pd)
statements.clear();
bindings.clear();
- executeWithRetries(lts, pd, new CompiledStatement(query, bindingsArray));
+ CompiledStatement compiledStatement = new CompiledStatement(query, bindingsArray);
+ executeWithRetries(lts, pd, compiledStatement);
tracker.endModification(lts);
+ hadVisibleVisit = false;
}
@Override
- public void operation(long lts, long pd, long cd, long opId, OpSelectors.OperationKind opType)
+ public void operation(Operation operation)
{
- CompiledStatement statement = operationInternal(lts, pd, cd, opId, opType);
- statements.add(statement.cql());
- Collections.addAll(bindings, statement.bindings());
+ hadVisibleVisit = operation.opKind() != OpSelectors.OperationKind.DELETE_PARTITION;
Review Comment:
They are visible since if there is a partition liveness marker, partition's static column is going to survive. Adding a comment!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "aratno (via GitHub)" <gi...@apache.org>.
aratno commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1414751715
##########
harry-core/src/harry/generators/EntropySource.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 harry.generators;
+
+import harry.core.VisibleForTesting;
+
+/**
+ * Random generator interface that offers:
+ * * Settable seed
+ * * Ability to generate multiple "next" random seeds
+ * * Ability to generate multiple "dependent" seeds, from which we can retrace the base seed with subtraction
+ */
+public interface EntropySource
+{
+ long next();
+ void seed(long seed);
Review Comment:
Is re-seeding supported after `next` is called?
##########
harry-core/src/harry/model/sut/DoubleWritingSut.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 harry.model.sut;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.regex.Pattern;
+
+public class DoubleWritingSut implements SystemUnderTest
+{
+ private final SystemUnderTest primary;
+ private final SystemUnderTest secondary;
+
+ public DoubleWritingSut(SystemUnderTest primary,
+ SystemUnderTest secondary)
+ {
+ this.primary = primary;
+ this.secondary = secondary;
+ }
+ public boolean isShutdown()
+ {
+ return primary.isShutdown();
+ }
+
+ public void shutdown()
+ {
+ primary.shutdown();
+ }
+
+ private static final Pattern pattern = Pattern.compile("select", Pattern.CASE_INSENSITIVE);
+
+ public Object[][] execute(String statement, ConsistencyLevel cl, Object... bindings)
+ {
+ if (pattern.matcher(statement).find())
+ return primary.execute(statement, cl, bindings);
+
+ secondary.execute(statement, cl, bindings);
+ return primary.execute(statement, cl, bindings);
+ }
+
+ public CompletableFuture<Object[][]> executeAsync(String statement, ConsistencyLevel cl, Object... bindings)
+ {
+ return null;
Review Comment:
Would prefer an UnsupportedOperationException here
##########
harry-core/src/harry/model/SelectHelper.java:
##########
@@ -271,6 +275,18 @@ public static ResultSetRow resultSetToRow(SchemaSpec schema, OpSelectors.Monoton
System.arraycopy(result, partitionKey.length + clusteringKey.length, staticColumns, 0, staticColumns.length);
System.arraycopy(result, partitionKey.length + clusteringKey.length + staticColumns.length, regularColumns, 0, regularColumns.length);
+
+ List<Long> visited_lts_list;
+ if (schema.trackLts)
+ {
+ visited_lts_list = (List<Long>) result[result.length - 1];
+ visited_lts_list.sort(Long::compare);
Review Comment:
Don't we want these in the original order returned by the query?
##########
harry-core/src/harry/visitors/MutatingVisitor.java:
##########
@@ -116,21 +163,23 @@ public void afterLts(long lts, long pd)
statements.clear();
bindings.clear();
- executeWithRetries(lts, pd, new CompiledStatement(query, bindingsArray));
+ CompiledStatement compiledStatement = new CompiledStatement(query, bindingsArray);
+ executeWithRetries(lts, pd, compiledStatement);
tracker.endModification(lts);
+ hadVisibleVisit = false;
}
@Override
- public void operation(long lts, long pd, long cd, long opId, OpSelectors.OperationKind opType)
+ public void operation(Operation operation)
{
- CompiledStatement statement = operationInternal(lts, pd, cd, opId, opType);
- statements.add(statement.cql());
- Collections.addAll(bindings, statement.bindings());
+ hadVisibleVisit = operation.opKind() != OpSelectors.OperationKind.DELETE_PARTITION;
Review Comment:
Aren't delete range / slice also not visible?
##########
harry-core/src/harry/generators/EntropySource.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 harry.generators;
+
+import harry.core.VisibleForTesting;
+
+/**
+ * Random generator interface that offers:
+ * * Settable seed
+ * * Ability to generate multiple "next" random seeds
+ * * Ability to generate multiple "dependent" seeds, from which we can retrace the base seed with subtraction
+ */
+public interface EntropySource
+{
+ long next();
+ void seed(long seed);
+
+ // We derive from entropy source here to avoid letting the step change state for other states
+ // For example, if you start drawing more entropy bits from one of the steps, but won't change
+ // other steps, their states won't change either.
Review Comment:
I like this description + API, makes the PCG "parallel streams" concept easier to understand for people that are less familiar
##########
harry-core/src/harry/dsl/HistoryBuilder.java:
##########
@@ -19,598 +19,511 @@
package harry.dsl;
import java.util.*;
-import java.util.function.Consumer;
import java.util.function.LongSupplier;
-import harry.core.Run;
+import harry.core.Configuration;
+import harry.core.MetricReporter;
+import harry.ddl.SchemaSpec;
+import harry.generators.EntropySource;
+import harry.generators.JdkRandomEntropySource;
+import harry.model.Model;
import harry.model.OpSelectors;
+import harry.model.QuiescentChecker;
+import harry.model.clock.ApproximateMonotonicClock;
+import harry.model.sut.SystemUnderTest;
+import harry.operations.Query;
+import harry.reconciler.Reconciler;
+import harry.runner.DataTracker;
import harry.visitors.MutatingRowVisitor;
import harry.visitors.MutatingVisitor;
import harry.visitors.ReplayingVisitor;
import harry.visitors.VisitExecutor;
-import static harry.model.OpSelectors.DefaultPdSelector.PARTITION_DESCRIPTOR_STREAM_ID;
+// TODO: we can implement a pluggable time source via a custom clock, too; the only limitation is that order
+// of timestamps has to be consistent with LTS order
Review Comment:
Don't all Harry clocks have this requirement? OffsetClock and ApproximateMonotonicClock both provide monotonicity of RTS given monotonic LTSs.
##########
harry-core/src/harry/dsl/HistoryBuilder.java:
##########
@@ -19,598 +19,511 @@
package harry.dsl;
import java.util.*;
-import java.util.function.Consumer;
import java.util.function.LongSupplier;
-import harry.core.Run;
+import harry.core.Configuration;
+import harry.core.MetricReporter;
+import harry.ddl.SchemaSpec;
+import harry.generators.EntropySource;
+import harry.generators.JdkRandomEntropySource;
+import harry.model.Model;
import harry.model.OpSelectors;
+import harry.model.QuiescentChecker;
+import harry.model.clock.ApproximateMonotonicClock;
+import harry.model.sut.SystemUnderTest;
+import harry.operations.Query;
+import harry.reconciler.Reconciler;
+import harry.runner.DataTracker;
import harry.visitors.MutatingRowVisitor;
import harry.visitors.MutatingVisitor;
import harry.visitors.ReplayingVisitor;
import harry.visitors.VisitExecutor;
-import static harry.model.OpSelectors.DefaultPdSelector.PARTITION_DESCRIPTOR_STREAM_ID;
+// TODO: we can implement a pluggable time source via a custom clock, too; the only limitation is that order
+// of timestamps has to be consistent with LTS order
// TODO: we could use some sort of compact data structure or file format for navigable operation history
-public class HistoryBuilder implements Iterable<ReplayingVisitor.Visit>
+// this can have a _huge_ advantage of being able to produce arbitrary patterns, since you can specify history
+// either in a _very_ random way, or in a _very_ predictable way, but still leave a footprint extremely small,
+// since if you do not specify the details, we just produce fully random operations.
+
+/**
+ * History builder is a component for a simple yet flexible generation of arbitrary data.
+ *
+ *
Review Comment:
It seems like this is intended to be a common entrypoint for people to create new Harry tests. Those people are likely to look at this file first. Can you expand on this doc?
##########
harry-core/src/harry/visitors/GeneratingVisitor.java:
##########
@@ -50,10 +55,178 @@ private void generate(long lts, long pd)
int opsPerLts = descriptorSelector.operationsPerLts(lts);
for (long opId = 0; opId < opsPerLts; opId++)
{
- long cd = descriptorSelector.cd(pd, lts, opId, schema);
- OpSelectors.OperationKind opType = descriptorSelector.operationType(pd, lts, opId);
- operation(lts, pd, cd, opId, opType);
+ OpSelectors.OperationKind opKind = descriptorSelector.operationType(pd, lts, opId);
+ BaseOperation operation;
+ switch (opKind)
+ {
+ case INSERT:
+ case UPDATE:
+ operation = writeOp(lts, pd, opId, opKind);
+ break;
+ case INSERT_WITH_STATICS:
+ case UPDATE_WITH_STATICS:
+ operation = writeRegularAndStatic(lts, pd, opId, opKind);
+ break;
+ case DELETE_ROW:
+ {
+ long cd = descriptorSelector.cd(pd, lts, opId, schema);
+ operation = new GeneratedDeleteRowOp(lts, pd, cd, opId, opKind);
+ break;
+ }
+ case DELETE_COLUMN:
+ case DELETE_COLUMN_WITH_STATICS:
+ {
+ long cd = descriptorSelector.cd(pd, lts, opId, schema);
+ BitSet columns = descriptorSelector.columnMask(pd, lts, opId, opKind);
+ operation = new GeneratedDeleteColumnsOp(lts, pd, cd, opId, opKind, columns);
+ break;
+ }
+ case DELETE_PARTITION:
+ case DELETE_RANGE:
+ case DELETE_SLICE:
+ operation = new GeneratedDeleteOp(lts, pd, opId, opKind, rangeSelector);
+ break;
+ default:
+ throw new IllegalStateException("All cases are covered but not " + opKind);
+ }
+ operation(operation);
}
afterLts(lts, pd);
}
+
+ public BaseOperation writeOp(long lts, long pd, long opId, OpSelectors.OperationKind kind)
+ {
+ long cd = descriptorSelector.cd(pd, lts, opId, schema);
+
+ return new GeneratedWriteOp(lts, pd, cd, opId, kind)
+ {
+ @Override
+ public long[] vds()
+ {
+ return descriptorSelector.vds(pd, cd(), lts, opId, opKind(), schema);
+ }
+ };
+ }
+
+ public BaseOperation writeRegularAndStatic(long lts, long pd, long opId, OpSelectors.OperationKind kind)
+ {
+ long cd = descriptorSelector.cd(pd, lts, opId, schema);
+
+ return new GeneratedWriteWithStaticOp(lts, pd, cd, opId, kind)
+ {
+ public long[] sds()
+ {
+ return descriptorSelector.sds(pd, cd(), lts, opId, opKind(), schema);
+ }
+
+ @Override
+ public long[] vds()
+ {
+ return descriptorSelector.vds(pd, cd(), lts, opId, opKind(), schema);
+ }
+ };
+ }
+
+ public abstract static class GeneratedWriteOp extends BaseOperation implements ReplayingVisitor.WriteOp
+ {
+ protected final long cd;
+ public GeneratedWriteOp(long lts, long pd, long cd, long opId, OpSelectors.OperationKind opKind)
+ {
+ super(lts, pd, opId, opKind);
+ this.cd = cd;
+ }
+
+ @Override
+ public long cd()
+ {
+ return cd;
+ }
+ }
+
+ public abstract static class GeneratedWriteWithStaticOp extends GeneratedWriteOp implements ReplayingVisitor.WriteStaticOp
+ {
+ public GeneratedWriteWithStaticOp(long lts, long pd, long cd, long opId, OpSelectors.OperationKind opKind)
+ {
+ super(lts, pd, cd, opId, opKind);
+ }
+ }
+
+ public static class GeneratedDeleteRowOp extends BaseOperation implements ReplayingVisitor.DeleteRowOp
+ {
+ private final long cd;
+ public GeneratedDeleteRowOp(long lts, long pd, long cd, long opId, OpSelectors.OperationKind opKind)
+ {
+ super(lts, pd, opId, opKind);
+ this.cd = cd;
+ }
+
+ @Override
+ public long cd()
+ {
+ return cd;
+ }
+ }
+
+ public static class GeneratedDeleteOp extends BaseOperation implements ReplayingVisitor.DeleteOp
+ {
+ private final Query relations;
+
+ public GeneratedDeleteOp(long lts, long pd, long opId, OpSelectors.OperationKind opKind, QueryGenerator queryGenerator)
+ {
+ this(lts, pd, opId, opKind, queryGenerator.inflate( lts, opId, queryKind(opKind)));
+ }
+
+ public GeneratedDeleteOp(long lts, long pd, long opId, OpSelectors.OperationKind opKind, Query relations)
+ {
+ super(lts, pd, opId, opKind);
+ this.relations = relations;
+ }
+
+ @Override
+ public Query relations()
+ {
+ return relations;
+ }
+
+ protected static Query.QueryKind queryKind(OpSelectors.OperationKind opKind)
+ {
+ switch (opKind)
+ {
+ case DELETE_PARTITION:
+ return Query.QueryKind.SINGLE_PARTITION;
+ case DELETE_ROW:
+ return Query.QueryKind.SINGLE_CLUSTERING;
+ case DELETE_RANGE:
+ return Query.QueryKind.CLUSTERING_RANGE;
+ case DELETE_SLICE:
+ return Query.QueryKind.CLUSTERING_SLICE;
+ default:
+ throw new IllegalStateException(String.format("Can not transform %s into delete", opKind));
+ }
+ }
+ }
+
+ public static class GeneratedDeleteColumnsOp extends BaseOperation implements ReplayingVisitor.DeleteColumnsOp
+ {
+ private final long cd;
+ private final BitSet columnMask;
+
+ public GeneratedDeleteColumnsOp(long lts, long pd, long cd, long opId, OpSelectors.OperationKind opKind, BitSet columnMask)
+ {
+ super(lts, pd, opId, opKind);
+ this.cd = cd;
+ this.columnMask = columnMask;
+ }
+
+ public long cd()
+ {
+ return cd;
+ }
+
+ @Override
+ public harry.util.BitSet columns()
Review Comment:
Unnecessary qualified class name
##########
harry-core/src/harry/visitors/MutatingRowVisitor.java:
##########
@@ -26,108 +26,90 @@
import harry.operations.CompiledStatement;
import harry.operations.DeleteHelper;
import harry.operations.WriteHelper;
-import harry.operations.Query;
-import harry.operations.QueryGenerator;
import harry.util.BitSet;
public class MutatingRowVisitor implements OperationExecutor
{
protected final SchemaSpec schema;
protected final OpSelectors.MonotonicClock clock;
- protected final OpSelectors.DescriptorSelector descriptorSelector;
- protected final QueryGenerator rangeSelector;
protected final MetricReporter metricReporter;
public MutatingRowVisitor(Run run)
{
this(run.schemaSpec,
run.clock,
- run.descriptorSelector,
- run.rangeSelector,
run.metricReporter);
}
@VisibleForTesting
public MutatingRowVisitor(SchemaSpec schema,
OpSelectors.MonotonicClock clock,
- OpSelectors.DescriptorSelector descriptorSelector,
- QueryGenerator rangeSelector,
MetricReporter metricReporter)
{
this.metricReporter = metricReporter;
this.schema = schema;
this.clock = clock;
- this.descriptorSelector = descriptorSelector;
- this.rangeSelector = rangeSelector;
}
- public CompiledStatement insert(long lts, long pd, long cd, long opId)
+ public CompiledStatement insert(VisitExecutor.WriteOp op)
Review Comment:
A very welcome improvement!
##########
harry-core/src/harry/model/sut/DoubleWritingSut.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 harry.model.sut;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.regex.Pattern;
+
+public class DoubleWritingSut implements SystemUnderTest
+{
+ private final SystemUnderTest primary;
+ private final SystemUnderTest secondary;
+
+ public DoubleWritingSut(SystemUnderTest primary,
+ SystemUnderTest secondary)
+ {
+ this.primary = primary;
+ this.secondary = secondary;
+ }
+ public boolean isShutdown()
+ {
+ return primary.isShutdown();
+ }
+
+ public void shutdown()
+ {
+ primary.shutdown();
+ }
+
+ private static final Pattern pattern = Pattern.compile("select", Pattern.CASE_INSENSITIVE);
+
+ public Object[][] execute(String statement, ConsistencyLevel cl, Object... bindings)
+ {
+ if (pattern.matcher(statement).find())
+ return primary.execute(statement, cl, bindings);
Review Comment:
Eventually could see an `Operation<SUT>` API in the future, to make this easier to express
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1415169188
##########
harry-core/src/harry/model/SelectHelper.java:
##########
@@ -271,6 +275,18 @@ public static ResultSetRow resultSetToRow(SchemaSpec schema, OpSelectors.Monoton
System.arraycopy(result, partitionKey.length + clusteringKey.length, staticColumns, 0, staticColumns.length);
System.arraycopy(result, partitionKey.length + clusteringKey.length + staticColumns.length, regularColumns, 0, regularColumns.length);
+
+ List<Long> visited_lts_list;
+ if (schema.trackLts)
+ {
+ visited_lts_list = (List<Long>) result[result.length - 1];
+ visited_lts_list.sort(Long::compare);
Review Comment:
Good point. But since we _mostly_ use these to compare with actually visited LTS (which are in monotonically increasing order), we are sorting them here. I could not find a use-case for knowing the order things were inserted in. Maybe we can have a more sophisticated checker that can check query bounds / visibility or something.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1416187401
##########
harry-core/src/harry/runner/LockingDataTracker.java:
##########
@@ -65,7 +65,7 @@ public void beginModification(long lts)
{
Review Comment:
Unrelated to the patch I guess, but should `readingFrom` and `writingTo` be final above?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417755669
##########
harry-core/src/harry/reconciler/Reconciler.java:
##########
@@ -87,31 +87,36 @@ class Processor extends VisitExecutor
{
// Whether a partition deletion was encountered on this LTS.
private boolean hadPartitionDeletion = false;
+ private boolean hadTrackingRowWrite = false;
private final List<Ranges.Range> rangeDeletes = new ArrayList<>();
- private final List<ReplayingVisitor.Operation> writes = new ArrayList<>();
- private final List<ReplayingVisitor.Operation> columnDeletes = new ArrayList<>();
+ private final List<Operation> writes = new ArrayList<>();
+ private final List<Operation> columnDeletes = new ArrayList<>();
@Override
- protected void operation(long lts, long pd, long cd, long opId, OpSelectors.OperationKind opType)
+ protected void operation(Operation operation)
{
if (hadPartitionDeletion)
return;
- switch (opType)
+ long lts = operation.lts();
+ assert pdSelector.pd(operation.lts(), schema) == operation.pd();
+
+ if (operation.opKind() != OpSelectors.OperationKind.DELETE_PARTITION)
+ partitionState.visitedLts.add(operation.lts());
Review Comment:
Deleting the whole partition doesn't count as a visit?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417872899
##########
harry-core/src/harry/data/ResultSetRow.java:
##########
@@ -55,12 +78,26 @@ public ResultSetRow clone()
Arrays.copyOf(vds, vds.length), Arrays.copyOf(lts, lts.length));
}
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ResultSetRow that = (ResultSetRow) o;
+ return pd == that.pd &&
+ cd == that.cd &&
+ Arrays.equals(vds, that.vds) &&
+ Arrays.equals(lts, that.lts) &&
+ Arrays.equals(sds, that.sds) &&
+ Arrays.equals(slts, that.slts) &&
+ Objects.equals(visited_lts, that.visited_lts);
+ }
+
public String toString()
Review Comment:
yeah, here i would probably leave it out since we display it separately
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417893324
##########
harry-core/src/harry/reconciler/Reconciler.java:
##########
@@ -189,26 +199,27 @@ protected void afterLts(long lts, long pd)
}
partitionState.write(cd,
- descriptorSelector.vds(pd, cd, lts, opId, op.opType, schema),
+ writeOp.vds(),
lts,
- op.opType == OpSelectors.OperationKind.INSERT || op.opType == OpSelectors.OperationKind.INSERT_WITH_STATICS);
+ op.opKind() == OpSelectors.OperationKind.INSERT || op.opKind() == OpSelectors.OperationKind.INSERT_WITH_STATICS);
Review Comment:
renamed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417879232
##########
harry-core/src/harry/reconciler/PartitionState.java:
##########
@@ -113,18 +126,18 @@ public boolean isEmpty()
return rows.isEmpty();
}
- private Reconciler.RowState updateRowState(Reconciler.RowState currentState, List<ColumnSpec<?>> columns, long cd, long[] vds, long lts, boolean writePrimaryKeyLiveness)
+ private Reconciler.RowState updateRowState(Reconciler.RowState currentState, List<ColumnSpec<?>> columns, long cd, long[] sds, long lts, boolean writePrimaryKeyLiveness)
Review Comment:
Renamed `staticVds` to `sds`, and renamed `sds` here to just `vds` (i.e. value descriptors).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417673577
##########
harry-core/src/harry/data/ResultSetRow.java:
##########
@@ -55,12 +78,26 @@ public ResultSetRow clone()
Arrays.copyOf(vds, vds.length), Arrays.copyOf(lts, lts.length));
}
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ResultSetRow that = (ResultSetRow) o;
+ return pd == that.pd &&
+ cd == that.cd &&
+ Arrays.equals(vds, that.vds) &&
+ Arrays.equals(lts, that.lts) &&
+ Arrays.equals(sds, that.sds) &&
+ Arrays.equals(slts, that.slts) &&
+ Objects.equals(visited_lts, that.visited_lts);
+ }
+
public String toString()
Review Comment:
nit: Does `visited_lts` need to be part of the `toString()`, or is it something that might grow to be potentially huge and not visually friendly? :D
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417760301
##########
harry-core/src/harry/reconciler/Reconciler.java:
##########
@@ -189,26 +199,27 @@ protected void afterLts(long lts, long pd)
}
partitionState.write(cd,
- descriptorSelector.vds(pd, cd, lts, opId, op.opType, schema),
+ writeOp.vds(),
lts,
- op.opType == OpSelectors.OperationKind.INSERT || op.opType == OpSelectors.OperationKind.INSERT_WITH_STATICS);
+ op.opKind() == OpSelectors.OperationKind.INSERT || op.opKind() == OpSelectors.OperationKind.INSERT_WITH_STATICS);
Review Comment:
nit: Might work to just name this `opKind()` -> `kind()`, so it reads `op.kind()`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1415166608
##########
harry-core/src/harry/model/sut/DoubleWritingSut.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 harry.model.sut;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.regex.Pattern;
+
+public class DoubleWritingSut implements SystemUnderTest
+{
+ private final SystemUnderTest primary;
+ private final SystemUnderTest secondary;
+
+ public DoubleWritingSut(SystemUnderTest primary,
+ SystemUnderTest secondary)
+ {
+ this.primary = primary;
+ this.secondary = secondary;
+ }
+ public boolean isShutdown()
+ {
+ return primary.isShutdown();
+ }
+
+ public void shutdown()
+ {
+ primary.shutdown();
+ }
+
+ private static final Pattern pattern = Pattern.compile("select", Pattern.CASE_INSENSITIVE);
+
+ public Object[][] execute(String statement, ConsistencyLevel cl, Object... bindings)
+ {
+ if (pattern.matcher(statement).find())
+ return primary.execute(statement, cl, bindings);
Review Comment:
great idea! if you like, you can open a jira and we hopefully will get to it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417872474
##########
harry-core/src/harry/data/ResultSetRow.java:
##########
@@ -55,12 +78,26 @@ public ResultSetRow clone()
Arrays.copyOf(vds, vds.length), Arrays.copyOf(lts, lts.length));
Review Comment:
yes! thank you for spotting!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417955693
##########
harry-integration/test/harry/dsl/HistoryBuilderIntegrationTest.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 harry.dsl;
+
+import java.util.Random;
+import java.util.function.LongSupplier;
+import java.util.function.Supplier;
+
+import org.junit.Test;
+
+import harry.checker.ModelChecker;
+import harry.core.Configuration;
+import harry.core.Run;
+import harry.ddl.SchemaGenerators;
+import harry.ddl.SchemaSpec;
+import harry.generators.JdkRandomEntropySource;
+import harry.model.Model;
+import harry.model.ModelTestBase;
+import harry.model.QuiescentChecker;
+import harry.operations.Query;
+import harry.reconciler.Reconciler;
+import harry.visitors.ReplayingVisitor;
+
+public class HistoryBuilderIntegrationTest extends ModelTestBase
+{
+ private final long seed = 1L;
+ private final int STEPS_PER_ITERATION = 1_000;
+ private final int MAX_PARTITIONS = 100;
+
+ protected Configuration.ModelConfiguration modelConfiguration()
Review Comment:
nit: `@Override`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "maedhroz (via GitHub)" <gi...@apache.org>.
maedhroz commented on code in PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24#discussion_r1417986968
##########
harry-integration/test/harry/model/ReconcilerIntegrationTest.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 harry.model;
+
+import java.util.Arrays;
+
+import org.junit.Test;
+
+import harry.ddl.ColumnSpec;
+import harry.ddl.SchemaSpec;
+import harry.dsl.ReplayingHistoryBuilder;
+import harry.generators.DataGenerators;
+
+public class ReconcilerIntegrationTest extends IntegrationTestBase
+{
+ private final long seed = 1; // 88
+
+
+ @Test
+ public void testTrackingWithStatics() throws Throwable
+ {
+ SchemaSpec schema = new SchemaSpec(KEYSPACE, "tbl1",
+ Arrays.asList(ColumnSpec.pk("pk1", ColumnSpec.int64Type)),
+ Arrays.asList(ColumnSpec.ck("ck1", ColumnSpec.int64Type)),
+ Arrays.asList(ColumnSpec.regularColumn("v1", ColumnSpec.int64Type),
+ ColumnSpec.regularColumn("v2", ColumnSpec.int64Type)),
+ Arrays.asList(ColumnSpec.staticColumn("static1", ColumnSpec.int64Type),
+ ColumnSpec.staticColumn("static2", ColumnSpec.int64Type)))
+ .trackLts();
+
+ beforeEach();
+ sut.schemaChange(schema.compile().cql());
+
+ ReplayingHistoryBuilder historyBuilder = new ReplayingHistoryBuilder(seed, 100, 1, schema, sut);
+ historyBuilder.visitPartition(1).insert(1,
+ new long[]{ DataGenerators.UNSET_DESCR, DataGenerators.UNSET_DESCR },
+ new long[]{ 1L, 1L });
+ historyBuilder.validate(1);
+
+ historyBuilder.visitPartition(2).insert(2,
+ new long[]{ 1L, 1L },
+ new long[]{ 1L, 1L });
+ historyBuilder.visitPartition(2).deleteRowRange(1, 3, true, true);
+ historyBuilder.validate(2);
+ }
+
+ @Test
+ public void testTrackingWithoutStatics() throws Throwable
+ {
+ SchemaSpec schema = new SchemaSpec(KEYSPACE, "tbl1",
+ Arrays.asList(ColumnSpec.pk("pk1", ColumnSpec.int64Type)),
+ Arrays.asList(ColumnSpec.ck("ck1", ColumnSpec.int64Type)),
+ Arrays.asList(ColumnSpec.regularColumn("v1", ColumnSpec.int64Type),
+ ColumnSpec.regularColumn("v2", ColumnSpec.int64Type)),
+ Arrays.asList())
+ .trackLts();
+ ;
Review Comment:
nit: remove `;`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org
Re: [PR] History Builder API 2.0 [cassandra-harry]
Posted by "ifesdjeen (via GitHub)" <gi...@apache.org>.
ifesdjeen merged PR #24:
URL: https://github.com/apache/cassandra-harry/pull/24
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org