-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CASSANDRA-20286: Accord: TableParamsTest is flakey due to bad generators and production validation logic missed the argument to String.format causing confusing errors #3865
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,14 +20,14 @@ | |
|
||
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 -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. accord I plan to migrate all tests off of QuickTheories after we merge to trunk, and these are cep-15-accord only tests.... |
||
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()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
|
||
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.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 -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. accord I plan to migrate all tests off of QuickTheories after we merge to trunk, and these are cep-15-accord only tests.... |
||
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 -> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. accord |
||
if (!cm.consensusMigrationState.equals(ConsensusMigrationState.EMPTY)) | ||
return true; | ||
if (!cm.accordStaleReplicas.equals(AccordStaleReplicas.EMPTY)) | ||
|
@@ -65,7 +65,7 @@ public void serdeWithoutAccord() | |
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 void serdeWithoutAccord() | |
Assertions.assertThat(read.consensusMigrationState).isEqualTo(ConsensusMigrationState.EMPTY); | ||
Assertions.assertThat(read.accordStaleReplicas).isEqualTo(AccordStaleReplicas.EMPTY); | ||
Assertions.assertThat(read.accordFastPath).isEqualTo(AccordFastPath.EMPTY); | ||
})); | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -482,7 +482,12 @@ public TableParamsBuilder withFastPathStrategy() | |
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(",", "_")) | ||
Comment on lines
+487
to
+489
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are the real bug fixes.
These are generator bugs and not allowed from CQL layer... so switched to |
||
.assuming(s -> !s.trim().isEmpty()); | ||
int numNames = SourceDSL.integers().between(1, 10).generate(rnd); | ||
for (int i = 0; i < numNames; i++) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was the error we saw in UI, and its because
foo:bar:42
... thedc
had:
in the name, so hit this logic, but since, s
was missing it threw an issue with string formatting rather than the CFE we expected