This is an automated email from the ASF dual-hosted git repository.

dcapwell pushed a commit to branch cep-15-accord
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cep-15-accord by this push:
     new 3089226776 Accord: TableParamsTest is flakey due to bad generators and 
production validation logic missed the argument to String.format causing 
confusing errors
3089226776 is described below

commit 3089226776b47b2b0420faafbea2b545c0eefff7
Author: David Capwell <[email protected]>
AuthorDate: Thu Feb 6 15:12:59 2025 -0800

    Accord: TableParamsTest is flakey due to bad generators and production 
validation logic missed the argument to String.format causing confusing errors
    
    patch by David Capwell; reviewed by Blake Eggleston for CASSANDRA-20286
---
 .../fastpath/ParameterizedFastPathStrategy.java      |  2 +-
 .../org/apache/cassandra/schema/TableParamsTest.java | 20 ++++++++++----------
 .../cassandra/tcm/ClusterMetadataSerializerTest.java | 16 ++++++++--------
 .../apache/cassandra/utils/CassandraGenerators.java  |  7 ++++++-
 4 files changed, 25 insertions(+), 20 deletions(-)

diff --git 
a/src/java/org/apache/cassandra/service/accord/fastpath/ParameterizedFastPathStrategy.java
 
b/src/java/org/apache/cassandra/service/accord/fastpath/ParameterizedFastPathStrategy.java
index 8aef6abe6a..858c15b64d 100644
--- 
a/src/java/org/apache/cassandra/service/accord/fastpath/ParameterizedFastPathStrategy.java
+++ 
b/src/java/org/apache/cassandra/service/accord/fastpath/ParameterizedFastPathStrategy.java
@@ -146,7 +146,7 @@ public class ParameterizedFastPathStrategy implements 
FastPathStrategy
             else if (parts.length == 2)
                 return new WeightedDc(validateDC(parts[0]), 
validateWeight(parts[1]), false);
             else
-                throw cfe("Invalid dc weighting syntax %s, use <dc>:<weight>");
+                throw cfe("Invalid dc weighting syntax %s, use <dc>:<weight>", 
s);
         }
     }
 
diff --git a/test/unit/org/apache/cassandra/schema/TableParamsTest.java 
b/test/unit/org/apache/cassandra/schema/TableParamsTest.java
index e8bf30fe0a..9146264278 100644
--- a/test/unit/org/apache/cassandra/schema/TableParamsTest.java
+++ b/test/unit/org/apache/cassandra/schema/TableParamsTest.java
@@ -20,14 +20,14 @@ package org.apache.cassandra.schema;
 
 import org.junit.Test;
 
+import accord.utils.Gen;
 import org.apache.cassandra.io.util.DataOutputBuffer;
 import org.apache.cassandra.tcm.membership.NodeVersion;
 import org.apache.cassandra.tcm.serialization.AsymmetricMetadataSerializers;
 import org.apache.cassandra.utils.CassandraGenerators.TableParamsBuilder;
-import org.apache.cassandra.utils.FailingConsumer;
-import org.quicktheories.core.Gen;
+import org.apache.cassandra.utils.Generators;
 
-import static org.quicktheories.QuickTheory.qt;
+import static accord.utils.Property.qt;
 
 
 public class TableParamsTest
@@ -36,17 +36,17 @@ public class TableParamsTest
     public void serdeLatest()
     {
         DataOutputBuffer output = new DataOutputBuffer();
-        qt().forAll(tableParams()).checkAssert(FailingConsumer.orFail(params 
-> {
+        qt().forAll(tableParams()).check(params -> {
             AsymmetricMetadataSerializers.testSerde(output, 
TableParams.serializer, params, NodeVersion.CURRENT_METADATA_VERSION);
-        }));
+        });
     }
 
     private static Gen<TableParams> tableParams()
     {
-        return new TableParamsBuilder()
-               .withKnownMemtables()
-               .withTransactionalMode()
-               .withFastPathStrategy()
-               .build();
+        return Generators.toGen(new TableParamsBuilder()
+                                .withKnownMemtables()
+                                .withTransactionalMode()
+                                .withFastPathStrategy()
+                                .build());
     }
 }
\ No newline at end of file
diff --git 
a/test/unit/org/apache/cassandra/tcm/ClusterMetadataSerializerTest.java 
b/test/unit/org/apache/cassandra/tcm/ClusterMetadataSerializerTest.java
index 1117b4ab88..97553330de 100644
--- a/test/unit/org/apache/cassandra/tcm/ClusterMetadataSerializerTest.java
+++ b/test/unit/org/apache/cassandra/tcm/ClusterMetadataSerializerTest.java
@@ -20,6 +20,7 @@ package org.apache.cassandra.tcm;
 
 import org.junit.Test;
 
+import accord.utils.Gen;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.io.util.DataInputBuffer;
 import org.apache.cassandra.io.util.DataOutputBuffer;
@@ -30,11 +31,10 @@ import org.apache.cassandra.tcm.membership.NodeVersion;
 import org.apache.cassandra.tcm.serialization.AsymmetricMetadataSerializers;
 import org.apache.cassandra.tcm.serialization.Version;
 import org.apache.cassandra.utils.CassandraGenerators.ClusterMetadataBuilder;
+import org.apache.cassandra.utils.Generators;
 import org.assertj.core.api.Assertions;
-import org.quicktheories.core.Gen;
 
-import static org.apache.cassandra.utils.FailingConsumer.orFail;
-import static org.quicktheories.QuickTheory.qt;
+import static accord.utils.Property.qt;
 
 public class ClusterMetadataSerializerTest
 {
@@ -47,16 +47,16 @@ public class ClusterMetadataSerializerTest
     public void serdeLatest()
     {
         DataOutputBuffer output = new DataOutputBuffer();
-        qt().forAll(new 
ClusterMetadataBuilder().build()).checkAssert(orFail(cm -> {
+        qt().forAll(Generators.toGen(new 
ClusterMetadataBuilder().build())).check(cm -> {
             AsymmetricMetadataSerializers.testSerde(output, 
ClusterMetadata.serializer, cm, NodeVersion.CURRENT_METADATA_VERSION);
-        }));
+        });
     }
 
     @Test
     public void serdeWithoutAccord()
     {
         DataOutputBuffer output = new DataOutputBuffer();
-        Gen<ClusterMetadata> gen = new 
ClusterMetadataBuilder().build().assuming(cm -> {
+        Gen<ClusterMetadata> gen = Generators.toGen(new 
ClusterMetadataBuilder().build()).filter(cm -> {
             if 
(!cm.consensusMigrationState.equals(ConsensusMigrationState.EMPTY))
                 return true;
             if (!cm.accordStaleReplicas.equals(AccordStaleReplicas.EMPTY))
@@ -65,7 +65,7 @@ public class ClusterMetadataSerializerTest
                 return true;
             return false;
         });
-        qt().forAll(gen).checkAssert(orFail(cm -> {
+        qt().forAll(gen).check(cm -> {
             output.clear();
             Version version = Version.V2; // this is the version before accord
             long expectedSize = ClusterMetadata.serializer.serializedSize(cm, 
version);
@@ -78,6 +78,6 @@ public class ClusterMetadataSerializerTest
             
Assertions.assertThat(read.consensusMigrationState).isEqualTo(ConsensusMigrationState.EMPTY);
             
Assertions.assertThat(read.accordStaleReplicas).isEqualTo(AccordStaleReplicas.EMPTY);
             
Assertions.assertThat(read.accordFastPath).isEqualTo(AccordFastPath.EMPTY);
-        }));
+        });
     }
 }
diff --git a/test/unit/org/apache/cassandra/utils/CassandraGenerators.java 
b/test/unit/org/apache/cassandra/utils/CassandraGenerators.java
index 40903c5273..95e601ddfc 100644
--- a/test/unit/org/apache/cassandra/utils/CassandraGenerators.java
+++ b/test/unit/org/apache/cassandra/utils/CassandraGenerators.java
@@ -482,7 +482,12 @@ public final class CassandraGenerators
                         int size = SourceDSL.integers().between(1, 
Integer.MAX_VALUE).generate(rnd);
                         map.put(ParameterizedFastPathStrategy.SIZE, 
Integer.toString(size));
                         Set<String> names = new HashSet<>();
-                        Gen<String> nameGen = 
SourceDSL.strings().allPossible().ofLengthBetween(1, 10).assuming(s -> 
!s.trim().isEmpty());
+                        Gen<String> nameGen = 
SourceDSL.strings().allPossible().ofLengthBetween(1, 10)
+                                                       // If : is in the name 
then the parser will fail; we have validation to disalow this
+                                                       .map(s -> 
s.replace(":", "_"))
+                                                       // Names are used for 
DCs and those are seperated by ,
+                                                       .map(s -> 
s.replace(",", "_"))
+                                                       .assuming(s -> 
!s.trim().isEmpty());
                         int numNames = SourceDSL.integers().between(1, 
10).generate(rnd);
                         for (int i = 0; i < numNames; i++)
                         {


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

Reply via email to