mirror of https://github.com/apache/cassandra
Fix flaky test DropAccordTableTest
patch by David Capwell; reviewed by Caleb Rackliffe for CASSANDRA-21397
This commit is contained in:
parent
bf711a0fc1
commit
bc6e4a2b63
|
|
@ -828,16 +828,19 @@ public final class AbstractTypeGenerators
|
|||
return userTypeGen(elementGen, sizeGen, ksGen, nameGen, BOOLEAN_GEN);
|
||||
}
|
||||
|
||||
private static ThreadLocal<String> OVERRIDE_KEYSPACE = new ThreadLocal<>();
|
||||
private static final ThreadLocal<String> OVERRIDE_KEYSPACE = new ThreadLocal<>();
|
||||
private static final ThreadLocal<Set<String>> SEEN_UDT_NAMES = new ThreadLocal<>();
|
||||
|
||||
public static void overrideUDTKeyspace(String ks)
|
||||
{
|
||||
OVERRIDE_KEYSPACE.set(ks);
|
||||
SEEN_UDT_NAMES.set(new HashSet<>());
|
||||
}
|
||||
|
||||
public static void clearUDTKeyspace()
|
||||
{
|
||||
OVERRIDE_KEYSPACE.remove();
|
||||
SEEN_UDT_NAMES.remove();
|
||||
}
|
||||
|
||||
public interface UserTypeFieldsGen
|
||||
|
|
@ -876,7 +879,11 @@ public final class AbstractTypeGenerators
|
|||
String ks = OVERRIDE_KEYSPACE.get();
|
||||
if (ks == null)
|
||||
ks = ksGen.generate(rnd);
|
||||
String name = nameGen.generate(rnd);
|
||||
Set<String> seenNames = SEEN_UDT_NAMES.get();
|
||||
Gen<String> localNameGen = nameGen;
|
||||
if (seenNames != null)
|
||||
localNameGen = Generators.filter(nameGen, seenNames::add);
|
||||
String name = localNameGen.generate(rnd);
|
||||
ByteBuffer nameBB = AsciiType.instance.decompose(name);
|
||||
|
||||
for (int i = 0; i < numElements; i++)
|
||||
|
|
|
|||
|
|
@ -1750,6 +1750,7 @@ public final class CassandraGenerators
|
|||
Set<UserType> udts = CassandraGenerators.extractUDTs(metadata);
|
||||
if (!udts.isEmpty())
|
||||
{
|
||||
List<UserType> ordered = new ArrayList<>();
|
||||
Deque<UserType> pending = new ArrayDeque<>(udts);
|
||||
Set<ByteBuffer> visited = new HashSet<>();
|
||||
while (!pending.isEmpty())
|
||||
|
|
@ -1759,8 +1760,22 @@ public final class CassandraGenerators
|
|||
subTypes.remove(next); // it includes self
|
||||
if (subTypes.isEmpty() || subTypes.stream().allMatch(t -> visited.contains(t.name)))
|
||||
{
|
||||
fn.accept(next);
|
||||
try
|
||||
{
|
||||
fn.accept(next);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unable to add type ").append(next.toCqlString(false, false, false));
|
||||
sb.append("\nHistory:");
|
||||
for (var udt : ordered)
|
||||
sb.append("\n\t").append(udt.toCqlString(false, false, false));
|
||||
AssertionError e = new AssertionError(sb.toString(), t);
|
||||
throw e;
|
||||
}
|
||||
visited.add(next.name);
|
||||
ordered.add(next);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue