Skip to content

Testing actions #2

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

Open
wants to merge 12 commits into
base: scylla-4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion .github/workflows/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v2

- name: Setup Python 2 (setup it)
uses: actions/setup-python@v2
with:
python-version: '2.x'

- name: Setup Python 3
uses: actions/setup-python@v2
Expand Down Expand Up @@ -131,6 +136,11 @@ jobs:
java-version: '8'
distribution: 'adopt'

- name: Setup Python 2 (cas it)
uses: actions/setup-python@v2
with:
python-version: '2.x'

- name: Setup Python 3
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -162,6 +172,13 @@ jobs:
name: ccm-logs-cassandra-${{ matrix.cassandra-version }}
path: /tmp/ccm*/ccm*/node*/logs/*

- name: Check python versions
run: |
python --version
echo "aaa"
python2 --version
python3 --version

scylla-integration-tests:
name: Scylla ITs
runs-on: ubuntu-latest
Expand All @@ -183,6 +200,11 @@ jobs:
java-version: '8'
distribution: 'adopt'

- name: Setup Python 2 (scylla test)
uses: actions/setup-python@v2
with:
python-version: '2.x'

- name: Setup Python 3
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -213,4 +235,11 @@ jobs:
if: ${{ failure() }}
with:
name: ccm-logs-scylla-${{ matrix.scylla-version }}
path: /tmp/ccm*/ccm*/node*/logs/*
path: /tmp/ccm*/ccm*/node*/logs/*

- name: Check python versions
run: |
python --version
echo "aaa"
python2 --version
python3 --version
12 changes: 12 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</dependency>
<dependency>
<groupId>org.reactivestreams</groupId>
<artifactId>reactive-streams</artifactId>
Expand Down Expand Up @@ -192,6 +196,14 @@
<artifactId>wiremock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk18on</artifactId>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public static Builder builder() {
private final AuthProvider authProvider;
private final SslEngineFactory sslEngineFactory;
private final InetSocketAddress cloudProxyAddress;
private final String scyllaCloudNodeDomain;
private final UUID startupClientId;
private final String startupApplicationName;
private final String startupApplicationVersion;
Expand All @@ -82,6 +83,7 @@ private ProgrammaticArguments(
@Nullable AuthProvider authProvider,
@Nullable SslEngineFactory sslEngineFactory,
@Nullable InetSocketAddress cloudProxyAddress,
@Nullable String scyllaCloudNodeDomain,
@Nullable UUID startupClientId,
@Nullable String startupApplicationName,
@Nullable String startupApplicationVersion,
Expand All @@ -99,6 +101,7 @@ private ProgrammaticArguments(
this.authProvider = authProvider;
this.sslEngineFactory = sslEngineFactory;
this.cloudProxyAddress = cloudProxyAddress;
this.scyllaCloudNodeDomain = scyllaCloudNodeDomain;
this.startupClientId = startupClientId;
this.startupApplicationName = startupApplicationName;
this.startupApplicationVersion = startupApplicationVersion;
Expand Down Expand Up @@ -163,6 +166,11 @@ public InetSocketAddress getCloudProxyAddress() {
return cloudProxyAddress;
}

@Nullable
public String getScyllaCloudNodeDomain() {
return scyllaCloudNodeDomain;
}

@Nullable
public UUID getStartupClientId() {
return startupClientId;
Expand Down Expand Up @@ -203,6 +211,7 @@ public static class Builder {
private AuthProvider authProvider;
private SslEngineFactory sslEngineFactory;
private InetSocketAddress cloudProxyAddress;
private String scyllaCloudNodeDomain;
private UUID startupClientId;
private String startupApplicationName;
private String startupApplicationVersion;
Expand Down Expand Up @@ -366,6 +375,14 @@ public Builder withCloudProxyAddress(@Nullable InetSocketAddress cloudAddress) {
return this;
}

@NonNull
public Builder withScyllaCloudProxyAddress(
@Nullable InetSocketAddress cloudAddress, String scyllaCloudNodeDomain) {
this.cloudProxyAddress = cloudAddress;
this.scyllaCloudNodeDomain = scyllaCloudNodeDomain;
return this;
}

@NonNull
public Builder withAuthProvider(@Nullable AuthProvider authProvider) {
this.authProvider = authProvider;
Expand Down Expand Up @@ -422,6 +439,7 @@ public ProgrammaticArguments build() {
authProvider,
sslEngineFactory,
cloudProxyAddress,
scyllaCloudNodeDomain,
startupClientId,
startupApplicationName,
startupApplicationVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,24 @@
import com.datastax.oss.driver.api.core.type.codec.registry.MutableCodecRegistry;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import com.datastax.oss.driver.internal.core.ContactPoints;
import com.datastax.oss.driver.internal.core.config.cloud.CloudConfig;
import com.datastax.oss.driver.internal.core.config.cloud.CloudConfigFactory;
import com.datastax.oss.driver.internal.core.config.scyllacloud.ConfigurationBundle;
import com.datastax.oss.driver.internal.core.config.scyllacloud.ScyllaCloudConnectionConfig;
import com.datastax.oss.driver.internal.core.config.typesafe.DefaultDriverConfigLoader;
import com.datastax.oss.driver.internal.core.context.DefaultDriverContext;
import com.datastax.oss.driver.internal.core.context.InternalDriverContext;
import com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint;
import com.datastax.oss.driver.internal.core.metadata.SniEndPoint;
import com.datastax.oss.driver.internal.core.session.DefaultSession;
import com.datastax.oss.driver.internal.core.util.concurrent.BlockingOperation;
import com.datastax.oss.driver.internal.core.util.concurrent.CompletableFutures;
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -95,7 +96,7 @@ public abstract class SessionBuilder<SelfT extends SessionBuilder, SessionT> {
protected DriverConfigLoader configLoader;
protected Set<EndPoint> programmaticContactPoints = new HashSet<>();
protected CqlIdentifier keyspace;
protected Callable<InputStream> cloudConfigInputStream;
protected Callable<InputStream> scyllaCloudConfigInputStream;

protected ProgrammaticArguments.Builder programmaticArgumentsBuilder =
ProgrammaticArguments.builder();
Expand Down Expand Up @@ -630,25 +631,11 @@ public SelfT withClassLoader(@Nullable ClassLoader classLoader) {
return self;
}

/**
* Configures this SessionBuilder for Cloud deployments by retrieving connection information from
* the provided {@link Path}.
*
* <p>To connect to a Cloud database, you must first download the secure database bundle from the
* DataStax Astra console that contains the connection information, then instruct the driver to
* read its contents using either this method or one if its variants.
*
* <p>For more information, please refer to the DataStax Astra documentation.
*
* @param cloudConfigPath Path to the secure connect bundle zip file.
* @see #withCloudSecureConnectBundle(URL)
* @see #withCloudSecureConnectBundle(InputStream)
*/
@NonNull
public SelfT withCloudSecureConnectBundle(@NonNull Path cloudConfigPath) {
public SelfT withScyllaCloudSecureConnectBundle(@NonNull Path cloudConfigPath) {
try {
URL cloudConfigUrl = cloudConfigPath.toAbsolutePath().normalize().toUri().toURL();
this.cloudConfigInputStream = cloudConfigUrl::openStream;
this.scyllaCloudConfigInputStream = cloudConfigUrl::openStream;
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Incorrect format of cloudConfigPath", e);
}
Expand All @@ -667,69 +654,22 @@ public SelfT withCodecRegistry(@Nullable MutableCodecRegistry codecRegistry) {
return self;
}

/**
* Configures this SessionBuilder for Cloud deployments by retrieving connection information from
* the provided {@link URL}.
*
* <p>To connect to a Cloud database, you must first download the secure database bundle from the
* DataStax Astra console that contains the connection information, then instruct the driver to
* read its contents using either this method or one if its variants.
*
* <p>For more information, please refer to the DataStax Astra documentation.
*
* @param cloudConfigUrl URL to the secure connect bundle zip file.
* @see #withCloudSecureConnectBundle(Path)
* @see #withCloudSecureConnectBundle(InputStream)
*/
@NonNull
public SelfT withCloudSecureConnectBundle(@NonNull URL cloudConfigUrl) {
this.cloudConfigInputStream = cloudConfigUrl::openStream;
public SelfT withScyllaCloudSecureConnectBundle(@NonNull URL cloudConfigUrl) {
this.scyllaCloudConfigInputStream = cloudConfigUrl::openStream;
return self;
}

/**
* Configures this SessionBuilder for Cloud deployments by retrieving connection information from
* the provided {@link InputStream}.
*
* <p>To connect to a Cloud database, you must first download the secure database bundle from the
* DataStax Astra console that contains the connection information, then instruct the driver to
* read its contents using either this method or one if its variants.
*
* <p>For more information, please refer to the DataStax Astra documentation.
*
* <p>Note that the provided stream will be consumed <em>and closed</em> when either {@link
* #build()} or {@link #buildAsync()} are called; attempting to reuse it afterwards will result in
* an error being thrown.
*
* @param cloudConfigInputStream A stream containing the secure connect bundle zip file.
* @see #withCloudSecureConnectBundle(Path)
* @see #withCloudSecureConnectBundle(URL)
*/
@NonNull
public SelfT withCloudSecureConnectBundle(@NonNull InputStream cloudConfigInputStream) {
this.cloudConfigInputStream = () -> cloudConfigInputStream;
public SelfT withScyllaCloudSecureConnectBundle(@NonNull InputStream cloudConfigInputStream) {
this.scyllaCloudConfigInputStream = () -> cloudConfigInputStream;
return self;
}

/**
* Configures this SessionBuilder to use the provided Cloud proxy endpoint.
*
* <p>Normally, this method should not be called directly; the normal and easiest way to configure
* the driver for Cloud deployments is through a {@linkplain #withCloudSecureConnectBundle(URL)
* secure connect bundle}.
*
* <p>Setting this option to any non-null address will make the driver use a special topology
* monitor tailored for Cloud deployments. This topology monitor assumes that the target cluster
* should be contacted through the proxy specified here, using SNI routing.
*
* <p>For more information, please refer to the DataStax Astra documentation.
*
* @param cloudProxyAddress The address of the Cloud proxy to use.
* @see <a href="https://en.wikipedia.org/wiki/Server_Name_Indication">Server Name Indication</a>
*/
@NonNull
public SelfT withCloudProxyAddress(@Nullable InetSocketAddress cloudProxyAddress) {
this.programmaticArgumentsBuilder.withCloudProxyAddress(cloudProxyAddress);
public SelfT withScyllaCloudProxyAddress(
@Nullable InetSocketAddress cloudProxyAddress, String nodeDomain) {
this.programmaticArgumentsBuilder.withScyllaCloudProxyAddress(cloudProxyAddress, nodeDomain);
return self;
}

Expand Down Expand Up @@ -857,16 +797,9 @@ protected final CompletionStage<CqlSession> buildDefaultSessionAsync() {
: defaultConfigLoader(programmaticArguments.getClassLoader());

DriverExecutionProfile defaultConfig = configLoader.getInitialConfig().getDefaultProfile();
if (cloudConfigInputStream == null) {
String configUrlString =
defaultConfig.getString(DefaultDriverOption.CLOUD_SECURE_CONNECT_BUNDLE, null);
if (configUrlString != null) {
cloudConfigInputStream = () -> getURL(configUrlString).openStream();
}
}
List<String> configContactPoints =
defaultConfig.getStringList(DefaultDriverOption.CONTACT_POINTS, Collections.emptyList());
if (cloudConfigInputStream != null) {
if (scyllaCloudConfigInputStream != null) {
if (!programmaticContactPoints.isEmpty() || !configContactPoints.isEmpty()) {
LOG.info(
"Both a secure connect bundle and contact points were provided. These are mutually exclusive. The contact points from the secure bundle will have priority.");
Expand All @@ -880,20 +813,27 @@ protected final CompletionStage<CqlSession> buildDefaultSessionAsync() {
LOG.info(
"Both a secure connect bundle and SSL options were provided. They are mutually exclusive. The SSL options from the secure bundle will have priority.");
}
CloudConfig cloudConfig =
new CloudConfigFactory().createCloudConfig(cloudConfigInputStream.call());
addContactEndPoints(cloudConfig.getEndPoints());
ScyllaCloudConnectionConfig cloudConfig =
ScyllaCloudConnectionConfig.fromInputStream(scyllaCloudConfigInputStream.call());
InetSocketAddress proxyAddress = cloudConfig.getCurrentDatacenter().getServer();
addContactEndPoints(
ImmutableList.of(
new SniEndPoint(proxyAddress, cloudConfig.getCurrentDatacenter().getNodeDomain())));

boolean localDataCenterDefined =
anyProfileHasDatacenterDefined(configLoader.getInitialConfig());
if (programmaticLocalDatacenter || localDataCenterDefined) {
LOG.info(
"Both a secure connect bundle and a local datacenter were provided. They are mutually exclusive. The local datacenter from the secure bundle will have priority.");
"Both a secure connect bundle and a local datacenter were provided. They are mutually exclusive. The currentContext datacenter name from the secure bundle will be ignored.");
} else {
programmaticArgumentsBuilder.clearDatacenters();
withLocalDatacenter(cloudConfig.getCurrentContext().getDatacenterName());
}
withLocalDatacenter(cloudConfig.getLocalDatacenter());
withSslEngineFactory(cloudConfig.getSslEngineFactory());
withCloudProxyAddress(cloudConfig.getProxyAddress());
ConfigurationBundle bundle = cloudConfig.createBundle();
withSslEngineFactory(bundle.getSSLEngineFactory());
withScyllaCloudProxyAddress(
proxyAddress, cloudConfig.getCurrentDatacenter().getNodeDomain());

programmaticArguments = programmaticArgumentsBuilder.build();
}

Expand All @@ -912,7 +852,6 @@ protected final CompletionStage<CqlSession> buildDefaultSessionAsync() {
(InternalDriverContext) buildContext(configLoader, programmaticArguments),
contactPoints,
keyspace);

} catch (Throwable t) {
// We construct the session synchronously (until the init() call), but async clients expect a
// failed future if anything goes wrong. So wrap any error from that synchronous part.
Expand All @@ -929,27 +868,6 @@ private boolean anyProfileHasDatacenterDefined(DriverConfig driverConfig) {
return false;
}

/**
* Returns URL based on the configUrl setting. If the configUrl has no protocol provided, the
* method will fallback to file:// protocol and return URL that has file protocol specified.
*
* @param configUrl url to config secure bundle
* @return URL with file protocol if there was not explicit protocol provided in the configUrl
* setting
*/
private URL getURL(String configUrl) throws MalformedURLException {
try {
return new URL(configUrl);
} catch (MalformedURLException e1) {
try {
return Paths.get(configUrl).toAbsolutePath().normalize().toUri().toURL();
} catch (MalformedURLException e2) {
e2.addSuppressed(e1);
throw e2;
}
}
}

/**
* This <b>must</b> return an instance of {@code InternalDriverContext} (it's not expressed
* directly in the signature to avoid leaking that type through the protected API).
Expand Down
Loading