Skip to content

Commit be9e49b

Browse files
committed
Add test support for ccm Scylla Cloud clusters
This amounts to enabling support for using "--sni-proxy" and "--sni-port" flags and probing for path to generated Scylla Cloud configuration file.
1 parent c89ae9d commit be9e49b

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/CcmBridge.java

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import com.datastax.oss.driver.api.core.Version;
2525
import com.datastax.oss.driver.shaded.guava.common.base.Joiner;
26+
import com.datastax.oss.driver.shaded.guava.common.base.Preconditions;
2627
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap;
2728
import com.datastax.oss.driver.shaded.guava.common.collect.Maps;
2829
import com.datastax.oss.driver.shaded.guava.common.io.Resources;
@@ -179,6 +180,8 @@ public class CcmBridge implements AutoCloseable {
179180
private final List<String> dseWorkloads;
180181
private final String jvmArgs;
181182

183+
private final int sniProxyPort;
184+
182185
private CcmBridge(
183186
Path configDirectory,
184187
int[] nodes,
@@ -188,7 +191,8 @@ private CcmBridge(
188191
List<String> dseConfigurationRawYaml,
189192
List<String> createOptions,
190193
Collection<String> jvmArgs,
191-
List<String> dseWorkloads) {
194+
List<String> dseWorkloads,
195+
int sniProxyPort) {
192196
this.configDirectory = configDirectory;
193197
if (nodes.length == 1) {
194198
// Hack to ensure that the default DC is always called 'dc1': pass a list ('-nX:0') even if
@@ -216,6 +220,7 @@ private CcmBridge(
216220
}
217221
this.jvmArgs = allJvmArgs.toString();
218222
this.dseWorkloads = dseWorkloads;
223+
this.sniProxyPort = sniProxyPort;
219224
}
220225

221226
// Copied from Netty's PlatformDependent to avoid the dependency on Netty
@@ -290,6 +295,14 @@ private String getCcmVersionString(Version version) {
290295
return version.toString();
291296
}
292297

298+
public String getScyllaCloudConfigPathString() {
299+
return configDirectory.toFile().getAbsolutePath() + "/" + CLUSTER_NAME + "/config_data.yaml";
300+
}
301+
302+
public String getIpPrefix() {
303+
return ipPrefix;
304+
}
305+
293306
public void create() {
294307
if (created.compareAndSet(false, true)) {
295308
if (INSTALL_DIRECTORY != null) {
@@ -359,7 +372,12 @@ public void reloadCore(int node, String keyspace, String table, boolean reindex)
359372
public void start() {
360373
if (started.compareAndSet(false, true)) {
361374
try {
362-
execute("start", jvmArgs, "--wait-for-binary-proto");
375+
execute(
376+
"start",
377+
jvmArgs,
378+
"--wait-for-binary-proto",
379+
(sniProxyPort >= 0 ? "--sni-proxy" : ""),
380+
(sniProxyPort > 0 ? "--sni-port=" + sniProxyPort : ""));
363381
} catch (RuntimeException re) {
364382
// if something went wrong starting CCM, see if we can also dump the error
365383
executeCheckLogError();
@@ -510,6 +528,8 @@ public static class Builder {
510528

511529
private final Path configDirectory;
512530

531+
private int sniProxyPort = -1;
532+
513533
private Builder() {
514534
try {
515535
this.configDirectory = Files.createTempDirectory("ccm");
@@ -614,6 +634,14 @@ public Builder withDseWorkloads(String... workloads) {
614634
return this;
615635
}
616636

637+
/** Enable SNI proxy and use given port number. Port 0 means any port. */
638+
public Builder withSniProxy(int port) {
639+
Preconditions.checkArgument(port >= 0);
640+
Preconditions.checkArgument(port <= 65535);
641+
this.sniProxyPort = port;
642+
return this;
643+
}
644+
617645
public CcmBridge build() {
618646
return new CcmBridge(
619647
configDirectory,
@@ -624,7 +652,8 @@ public CcmBridge build() {
624652
dseRawYaml,
625653
createOptions,
626654
jvmArgs,
627-
dseWorkloads);
655+
dseWorkloads,
656+
sniProxyPort);
628657
}
629658
}
630659
}

test-infra/src/main/java/com/datastax/oss/driver/api/testinfra/ccm/CustomCcmRule.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ public Builder withSslAuth() {
112112
return this;
113113
}
114114

115+
public Builder withSniProxy(int port) {
116+
bridgeBuilder.withSniProxy(port);
117+
return this;
118+
}
119+
115120
public CustomCcmRule build() {
116121
return new CustomCcmRule(bridgeBuilder.build());
117122
}

0 commit comments

Comments
 (0)