Skip to content

Commit f77e85a

Browse files
authored
Add endpointOverride S3 support (#5087)
1 parent e2deaa8 commit f77e85a

18 files changed

+647
-114
lines changed

extensions/parquet/table/src/test/java/io/deephaven/parquet/table/ParquetTableReadWriteTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import io.deephaven.engine.testutil.junit4.EngineCleanup;
2828
import io.deephaven.engine.util.BigDecimalUtils;
2929
import io.deephaven.engine.util.file.TrackedFileHandleFactory;
30-
import io.deephaven.extensions.s3.AwsCredentials;
30+
import io.deephaven.extensions.s3.Credentials;
3131
import io.deephaven.parquet.base.NullStatistics;
3232
import io.deephaven.parquet.base.InvalidParquetFileException;
3333
import io.deephaven.parquet.table.location.ParquetTableLocationKey;
@@ -583,13 +583,13 @@ public void testArrayColumns() {
583583
public void readSampleParquetFilesFromS3Test1() {
584584
Assume.assumeTrue("Skipping test because s3 testing disabled.", ENABLE_S3_TESTING);
585585
final S3Instructions s3Instructions = S3Instructions.builder()
586-
.awsRegionName("us-east-1")
586+
.regionName("us-east-1")
587587
.readAheadCount(1)
588588
.fragmentSize(5 * 1024 * 1024)
589589
.maxConcurrentRequests(50)
590590
.maxCacheSize(32)
591591
.readTimeout(Duration.ofSeconds(60))
592-
.credentials(AwsCredentials.defaultCredentials())
592+
.credentials(Credentials.defaultCredentials())
593593
.build();
594594
final ParquetInstructions readInstructions = new ParquetInstructions.Builder()
595595
.setSpecialInstructions(s3Instructions)
@@ -621,7 +621,7 @@ public void readSampleParquetFilesFromS3Test1() {
621621
public void readSampleParquetFilesFromS3Test2() {
622622
Assume.assumeTrue("Skipping test because s3 testing disabled.", ENABLE_S3_TESTING);
623623
final S3Instructions s3Instructions = S3Instructions.builder()
624-
.awsRegionName("us-east-2")
624+
.regionName("us-east-2")
625625
.readAheadCount(1)
626626
.fragmentSize(5 * 1024 * 1024)
627627
.maxConcurrentRequests(50)

extensions/s3/build.gradle

+32
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,38 @@ dependencies {
1818

1919
compileOnly depAnnotations
2020

21+
// For OSUtil
22+
testImplementation project(':Stats')
23+
2124
Classpaths.inheritAutoService(project)
2225
Classpaths.inheritImmutables(project)
26+
27+
Classpaths.inheritJUnitPlatform(project)
28+
Classpaths.inheritAssertJ(project)
29+
testImplementation 'org.junit.jupiter:junit-jupiter'
30+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
31+
32+
testImplementation "org.testcontainers:testcontainers:1.19.4"
33+
testImplementation "org.testcontainers:junit-jupiter:1.19.4"
34+
testImplementation "org.testcontainers:localstack:1.19.4"
35+
testImplementation "org.testcontainers:minio:1.19.4"
36+
37+
testRuntimeOnly project(':test-configs')
38+
testRuntimeOnly project(':log-to-slf4j')
39+
Classpaths.inheritSlf4j(project, 'slf4j-simple', 'testRuntimeOnly')
2340
}
41+
42+
test {
43+
useJUnitPlatform {
44+
excludeTags("testcontainers")
45+
}
46+
}
47+
48+
tasks.register('testOutOfBand', Test) {
49+
useJUnitPlatform {
50+
includeTags("testcontainers")
51+
}
52+
systemProperty 'testcontainers.localstack.image', project.property('testcontainers.localstack.image')
53+
systemProperty 'testcontainers.minio.image', project.property('testcontainers.minio.image')
54+
}
55+

extensions/s3/gradle.properties

+4
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
io.deephaven.project.ProjectType=JAVA_PUBLIC
2+
3+
# TODO(deephaven-core#5115): EPIC: Dependency management
4+
testcontainers.localstack.image=localstack/localstack:3.1.0
5+
testcontainers.minio.image=minio/minio:RELEASE.2024-02-04T22-36-13Z

extensions/s3/src/main/java/io/deephaven/extensions/s3/AwsCredentials.java

-15
This file was deleted.

extensions/s3/src/main/java/io/deephaven/extensions/s3/AwsSdkV2Credentials.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
77

8-
interface AwsSdkV2Credentials extends AwsCredentials {
8+
interface AwsSdkV2Credentials extends Credentials {
99

10-
AwsCredentialsProvider awsCredentialsProvider();
10+
AwsCredentialsProvider awsV2CredentialsProvider();
1111
}

extensions/s3/src/main/java/io/deephaven/extensions/s3/BasicCredentials.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@
1111
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
1212

1313
/**
14-
* AWS credentials provider that uses access key and secret key provided at construction.
14+
* Basic credentials that uses access key id and secret access key provided at construction.
1515
*/
1616
@Immutable
1717
@SimpleStyle
1818
abstract class BasicCredentials implements AwsSdkV2Credentials {
1919

20-
static BasicCredentials of(final String awsAccessKeyId, final String awsSecretAccessKey) {
21-
return ImmutableBasicCredentials.of(awsAccessKeyId, awsSecretAccessKey);
20+
static BasicCredentials of(final String accessKeyId, final String secretAccessKey) {
21+
return ImmutableBasicCredentials.of(accessKeyId, secretAccessKey);
2222
}
2323

2424
@Value.Parameter
25-
abstract String awsAccessKeyId();
25+
abstract String accessKeyId();
2626

2727
@Value.Redacted
2828
@Value.Parameter
29-
abstract String awsSecretAccessKey();
29+
abstract String secretAccessKey();
3030

31-
public AwsCredentialsProvider awsCredentialsProvider() {
32-
final AwsBasicCredentials awsCreds = AwsBasicCredentials.create(awsAccessKeyId(), awsSecretAccessKey());
33-
return StaticCredentialsProvider.create(awsCreds);
31+
@Override
32+
public final AwsCredentialsProvider awsV2CredentialsProvider() {
33+
return StaticCredentialsProvider.create(AwsBasicCredentials.create(accessKeyId(), secretAccessKey()));
3434
}
3535
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
3+
*/
4+
package io.deephaven.extensions.s3;
5+
6+
public interface Credentials {
7+
8+
/**
9+
* The default credentials.
10+
*
11+
* @see <a href="https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials-chain.html">Default
12+
* credentials provider chain</a>
13+
*/
14+
static Credentials defaultCredentials() {
15+
return DefaultCredentials.DEFAULT_CREDENTIALS;
16+
}
17+
18+
/**
19+
* Basic credentials with the specified access key id and secret access key.
20+
*
21+
* @param accessKeyId the access key id, used to identify the user
22+
* @param secretAccessKey the secret access key, used to authenticate the user
23+
*/
24+
static Credentials basicCredentials(final String accessKeyId, final String secretAccessKey) {
25+
return BasicCredentials.of(accessKeyId, secretAccessKey);
26+
}
27+
}

extensions/s3/src/main/java/io/deephaven/extensions/s3/DefaultCredentials.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ enum DefaultCredentials implements AwsSdkV2Credentials {
1414
DEFAULT_CREDENTIALS;
1515

1616
@Override
17-
public AwsCredentialsProvider awsCredentialsProvider() {
17+
public final AwsCredentialsProvider awsV2CredentialsProvider() {
1818
return DefaultCredentialsProvider.create();
1919
}
2020
}

0 commit comments

Comments
 (0)