Skip to content

Commit 257ad88

Browse files
committed
checkpoint but need to give up, java is fighting mixed case too much
1 parent ee3f980 commit 257ad88

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

test/distributed/org/apache/cassandra/distributed/test/cql3/InetSingleNodeTableWalkTest.java

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
package org.apache.cassandra.distributed.test.cql3;
2020

21+
import java.net.Inet6Address;
2122
import java.net.InetAddress;
23+
import java.net.UnknownHostException;
2224
import javax.annotation.Nullable;
2325

2426
import accord.utils.Property;
@@ -31,6 +33,7 @@
3133
import org.apache.cassandra.utils.FastByteOperations;
3234
import org.apache.cassandra.utils.Generators;
3335
import org.quicktheories.core.Gen;
36+
import org.quicktheories.generators.SourceDSL;
3437

3538
public class InetSingleNodeTableWalkTest extends SingleNodeTableWalkTest
3639
{
@@ -54,9 +57,7 @@ protected void preCheck(Property.StatefulBuilder builder)
5457
{
5558
// if a failing seed is detected, populate here
5659
// Example: builder.withSeed(42L);
57-
// builder.withSeed(3985593186746556237L);
58-
59-
builder.withSeed(-7293505339069640960L); // ipv6 allow fitering missing partition
60+
builder.withSeed(3985593186746556237L);
6061
}
6162

6263
@Override
@@ -73,8 +74,8 @@ private enum Mode { ipv4, ipv6, mixed }
7374
protected InetState createState(RandomSource rs, Cluster cluster)
7475
{
7576
// Mode mode = rs.pick(Mode.values());
76-
Mode mode = rs.pick(Mode.ipv4, Mode.ipv6);
77-
// Mode mode = Mode.mixed;
77+
// Mode mode = rs.pick(Mode.ipv4, Mode.ipv6);
78+
Mode mode = Mode.mixed;
7879
Gen<InetAddress> gen;
7980
switch (mode)
8081
{
@@ -85,7 +86,21 @@ protected InetState createState(RandomSource rs, Cluster cluster)
8586
gen = Generators.INET_6_ADDRESS_UNRESOLVED_GEN;
8687
break;
8788
case mixed:
88-
gen = Generators.INET_ADDRESS_UNRESOLVED_GEN;
89+
var bool = SourceDSL.booleans().all();
90+
gen = rnd -> {
91+
if (bool.generate(rnd)) return Generators.INET_6_ADDRESS_UNRESOLVED_GEN.generate(rnd);
92+
InetAddress ipv4 = Generators.INET_4_ADDRESS_UNRESOLVED_GEN.generate(rnd);
93+
// lets convert to ipv6
94+
byte[] address = normalize(ipv4.getAddress());
95+
try
96+
{
97+
return Inet6Address.getByAddress(null, address, -1);
98+
}
99+
catch (UnknownHostException e)
100+
{
101+
throw new AssertionError(e);
102+
}
103+
};
89104
break;
90105
default:
91106
throw new UnsupportedOperationException(mode.name());
@@ -113,4 +128,18 @@ public String toString()
113128
return "Mode: " + mode + "\n" + super.toString();
114129
}
115130
}
131+
132+
public static byte[] normalize(byte[] address)
133+
{
134+
if (address.length == 16) return address;
135+
// migrate ipv4 to ipv6
136+
byte[] ipv6 = new byte[16];
137+
ipv6[10] = (byte)0xff;
138+
ipv6[11] = (byte)0xff;
139+
ipv6[12] = address[0];
140+
ipv6[13] = address[1];
141+
ipv6[14] = address[2];
142+
ipv6[15] = address[3];
143+
return ipv6;
144+
}
116145
}

0 commit comments

Comments
 (0)