smiklosovic commented on code in PR #3374:
URL: https://github.com/apache/cassandra/pull/3374#discussion_r1838796303


##########
test/distributed/org/apache/cassandra/fuzz/snapshots/SnapshotsTest.java:
##########
@@ -0,0 +1,880 @@
+/*
+ * 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.fuzz.snapshots;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.UUID;
+
+import com.google.common.collect.MapDifference;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import org.junit.Assert;
+import org.junit.Test;
+
+import accord.utils.Property.Command;
+import accord.utils.RandomSource;
+import org.apache.cassandra.distributed.Cluster;
+import org.apache.cassandra.distributed.api.Feature;
+import org.apache.cassandra.distributed.api.IInvokableInstance;
+import org.apache.cassandra.distributed.api.IIsolatedExecutor;
+import 
org.apache.cassandra.distributed.api.IIsolatedExecutor.SerializableTriConsumer;
+import org.apache.cassandra.distributed.api.NodeToolResult;
+import org.apache.cassandra.fuzz.snapshots.SnapshotsTest.State.TestSnapshot;
+import org.apache.cassandra.io.util.File;
+import org.apache.cassandra.schema.KeyspaceMetadata;
+import org.apache.cassandra.schema.Keyspaces;
+import org.apache.cassandra.schema.Schema;
+import org.apache.cassandra.schema.TableMetadata;
+import org.apache.cassandra.service.snapshot.SnapshotManager;
+import org.apache.cassandra.service.snapshot.TableSnapshot;
+import org.apache.cassandra.utils.Generators;
+import org.apache.cassandra.utils.Pair;
+import org.quicktheories.core.RandomnessSource;
+import org.quicktheories.impl.JavaRandom;
+
+import static accord.utils.Property.commands;
+import static accord.utils.Property.stateful;
+import static com.google.common.collect.Sets.difference;
+import static java.lang.String.format;
+import static org.junit.Assert.assertEquals;
+
+public class SnapshotsTest
+{
+    @Test
+    public void fuzzySnapshotsTest()
+    {
+        stateful()
+        .withExamples(1)
+        .withSteps(1000)
+        .check(commands(() -> State::new, state -> new 
SnapshotsSut(state).start())
+               .add(10, new CreateKeyspaceCommand())
+               .add(5, new DropKeyspaceCommand())
+               .add(40, new CreateTableCommand())
+               .add(15, new DropTableCommand())
+               .add(500, new TakeSnapshotCommand())
+               .add(50, new ClearSnapshotCommand())
+               .destroyState(State::destroy)
+               .destroySut(SnapshotsSut::stop)
+               .build());
+    }
+
+    public static class State implements Serializable
+    {
+        public Map<String, List<String>> schema;
+        public Set<TestSnapshot> snapshots = new HashSet<>();
+        public Set<String> droppedSnapshots = new HashSet<>();
+        public Set<String> truncatedSnapshots = new HashSet<>();
+
+        public final RandomSource rs;
+        public final RandomnessSource randomnessSource;
+
+        public State(RandomSource rs)
+        {
+            this.rs = rs;
+            this.randomnessSource = new JavaRandom(rs.asJdkRandom());
+        }
+
+        public State populate(SnapshotsSut sut)
+        {
+            this.schema = sut.getSchema();
+            this.snapshots = sut.getSnapshots();
+            this.droppedSnapshots = sut.getSnapshotsOfDroppedTables();
+            this.truncatedSnapshots = sut.getSnapshotsOfTruncatedTables();
+            return this;
+        }
+
+        @Override
+        public boolean equals(Object o)
+        {
+            if (this == o) return true;
+            if (o == null || getClass() != o.getClass()) return false;
+            State state = (State) o;
+            return Objects.equals(schema, state.schema) &&
+                   Objects.equals(snapshots, state.snapshots) &&
+                   Objects.equals(droppedSnapshots, state.droppedSnapshots) &&
+                   Objects.equals(truncatedSnapshots, 
state.truncatedSnapshots);
+        }
+
+        @Override
+        public int hashCode()
+        {
+            return Objects.hash(schema, snapshots, droppedSnapshots, 
truncatedSnapshots);
+        }

Review Comment:
   not necessary



-- 
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-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to