maedhroz commented on a change in pull request #1382:
URL: https://github.com/apache/cassandra/pull/1382#discussion_r789236051



##########
File path: 
test/distributed/org/apache/cassandra/distributed/fuzz/HistoryBuilderIntegrationTest.java
##########
@@ -0,0 +1,213 @@
+/*
+ * 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 org.apache.cassandra.distributed.fuzz;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Random;
+import java.util.Set;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.datastax.driver.core.schemabuilder.SchemaBuilder;
+import harry.core.Configuration;
+import harry.core.Run;
+import harry.ddl.SchemaGenerators;
+import harry.ddl.SchemaSpec;
+import harry.dsl.HistoryBuilder;
+import harry.generators.Generator;
+import harry.generators.PcgRSUFast;
+import harry.generators.RandomGenerator;
+import harry.model.Model;
+import harry.model.OpSelectors;
+import harry.model.QuiescentChecker;
+import harry.model.clock.OffsetClock;
+import harry.model.sut.SystemUnderTest;
+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 FuzzTestBase
+{
+
+    private static Configuration configuration(int i, SchemaSpec schema)
+    {
+        return configuration.unbuild()
+                            .setDropSchema(false)
+                            .setCreateSchema(false)
+                            .setSeed(i)
+                            .setSUT(() -> new 
InJvmSut(HistoryBuilderIntegrationTest.cluster) {
+                                public Object[][] execute(String var1, 
ConsistencyLevel var2, Object... var3) {
+                                    System.out.println("statement = " + var1);
+                                    if (var1.contains("SELECT"))
+                                    {
+                                        Object[][] objects = 
super.execute(var1, var2, var3);
+
+                                        for (Object[] object : objects)
+                                        {
+                                            
System.out.println(Integer.toString(object.length) + " " + 
Arrays.toString(object));
+                                        }
+                                    }
+
+                                    Object[][] objects = super.execute(var1, 
var2, var3);
+
+                                    return objects;
+                                }
+                            })
+                            .setClock(() -> new OffsetClock(10000L))
+                            .setSchemaProvider(new 
HarryRunner.FixedSchemaProviderConfiguration(schema))
+                            .setPartitionDescriptorSelector((ignore) -> new 
HistoryBuilder.PdSelector())
+                            .setClusteringDescriptorSelector((builder) -> 
builder.setNumberOfModificationsDistribution(new 
Configuration.ConstantDistributionConfig(100_000))
+                                                                               
  .setRowsPerModificationDistribution(new 
Configuration.ConstantDistributionConfig(100_000)))
+                            .build();
+    }
+
+    @Test
+    public void testCassandraDsl()
+    {
+        test((history) -> {
+                 history.nextPartition()
+                        .simultaneously()
+                          .batch()
+                            .insert()
+                            .delete()
+                            .finish()
+                          .insert()
+                          .finish()
+                        .nextPartition()
+                        .sequentially()
+                        .randomOrder()
+                        .batch()
+                        .insert()
+                        .delete()
+                        .finish()
+                        .updates(5)
+                        .partitionDelete()
+                        .finish()
+                        .nextPartition()
+                        .sequentially()
+                        .randomOrder()
+                        .batch()
+                        .insert()
+                        .delete()
+                        .finish()
+                        .updates(10)
+                        .partitionDelete()
+                        .finish();
+             });
+    }
+
+    public void test(Consumer<HistoryBuilder> test)
+    {
+        Supplier<SchemaSpec> gen = 
SchemaGenerators.progression(SchemaGenerators.DEFAULT_SWITCH_AFTER);
+        for (int i = 0; i < SchemaGenerators.DEFAULT_RUNS; i++)
+        {
+            Configuration config = configuration(i, gen.get());
+            Run run = config.createRun();
+            cluster.schemaChange("DROP KEYSPACE IF EXISTS harry");
+            cluster.schemaChange("CREATE KEYSPACE harry WITH replication = 
{'class': 'SimpleStrategy', 'replication_factor': " + RF + "};");
+            run.sut.schemaChange(run.schemaSpec.compile().cql());
+            System.out.println("run.schemaSpec = " + 
run.schemaSpec.compile().cql());
+            HistoryBuilder history = new HistoryBuilder(run);
+
+            Set<Long> pds = new HashSet<>();
+            run.tracker.onLtsStarted((long lts) -> {
+                pds.add(run.pdSelector.pd(lts, run.schemaSpec));
+            });
+
+            ReplayingVisitor visitor = history.visitor(run);
+            test.accept(history);
+            visitor.replayAll();
+
+            Model model = new QuiescentChecker(run, new Reconciler(run,
+                                                                   
history::visitor));
+            QueryGenerator.TypedQueryGenerator queryGenerator = new 
QueryGenerator.TypedQueryGenerator(run);
+            Assert.assertFalse(pds.isEmpty());
+            for (Long pd : pds)
+            {
+                model.validate(Query.selectPartition(run.schemaSpec, 
pd,false));
+
+                int lts = new Random().nextInt((int) run.clock.peek());
+                for (int k = 0; k < 3; k++)
+                    queryGenerator.inflate(lts, k);
+            }
+        }
+    }
+
+    Configuration.ModelConfiguration modelConfiguration()

Review comment:
       unused




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to