bbotella commented on code in PR #240:
URL: 
https://github.com/apache/cassandra-analytics/pull/240#discussion_r4003618154


##########
cassandra-analytics-cdc/src/test/java/org/apache/cassandra/cdc/test/CdcTester.java:
##########
@@ -153,6 +157,7 @@ public static class Builder
         private boolean shouldCdcEventWriterFailOnProcessing = false;
         private CdcOptions cdcOptions;
         private CassandraSource cassandraSource = CassandraSource.DEFAULT;
+        private Random random = new Random();

Review Comment:
   Nit: Maybe moving this inside the builder to avoid instantiating Random if 
it is not needed? Just like we do with CdcOptions.



##########
cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/test/QTRandomTest.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.spark.utils.test;
+
+import java.util.ArrayDeque;
+import java.util.Deque;
+import java.util.Random;
+
+import org.junit.jupiter.api.Test;
+
+import org.quicktheories.core.DetatchedRandomnessSource;
+import org.quicktheories.core.RandomnessSource;
+import org.quicktheories.impl.Constraint;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class QTRandomTest
+{
+    @Test
+    public void sameSeedDrawProducesSameOutput()
+    {
+        Random first = new QTRandom(new FixedSequenceSource(42L));
+        Random second = new QTRandom(new FixedSequenceSource(42L));
+
+        for (int i = 0; i < 100; i++)
+        {
+            assertThat(second.nextLong()).isEqualTo(first.nextLong());
+        }
+    }
+
+    @Test
+    public void differentSeedDrawsProduceDifferentOutput()
+    {
+        Random first = new QTRandom(new FixedSequenceSource(1L));
+        Random second = new QTRandom(new FixedSequenceSource(2L));
+
+        assertThat(first.nextLong()).isNotEqualTo(second.nextLong());

Review Comment:
   This is "technically" flaky :-P
   
   But let's keep it as is. It would be REAL bad luck to hit 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: [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