28
28
import software .amazon .awssdk .services .s3 .model .PutObjectRequest ;
29
29
30
30
import java .io .IOException ;
31
+ import java .net .URI ;
31
32
import java .util .List ;
32
33
33
34
import static com .google .common .collect .Iterables .getOnlyElement ;
35
+ import static io .trino .testing .SystemEnvironmentUtils .isEnvSet ;
34
36
import static io .trino .testing .SystemEnvironmentUtils .requireEnv ;
35
37
import static org .assertj .core .api .Assertions .assertThat ;
36
38
@@ -41,6 +43,7 @@ public class TestS3FileSystemAwsS3
41
43
private String secretKey ;
42
44
private String region ;
43
45
private String bucket ;
46
+ private String endpoint ;
44
47
45
48
@ Override
46
49
protected void initEnvironment ()
@@ -50,6 +53,13 @@ protected void initEnvironment()
50
53
region = requireEnv ("AWS_REGION" );
51
54
52
55
bucket = requireEnv ("EMPTY_S3_BUCKET" );
56
+
57
+ if (isEnvSet ("AWS_ENDPOINT" )) {
58
+ endpoint = requireEnv ("AWS_ENDPOINT" );
59
+ }
60
+ else {
61
+ endpoint = "https://s3." + region + ".amazonaws.com" ;
62
+ }
53
63
}
54
64
55
65
@ Override
@@ -66,6 +76,7 @@ protected S3Client createS3Client()
66
76
.region (Region .of (region ))
67
77
.responseChecksumValidation (ResponseChecksumValidation .WHEN_REQUIRED )
68
78
.requestChecksumCalculation (RequestChecksumCalculation .WHEN_REQUIRED )
79
+ .endpointOverride (URI .create (endpoint ))
69
80
.build ();
70
81
}
71
82
@@ -76,6 +87,7 @@ protected S3FileSystemFactory createS3FileSystemFactory()
76
87
.setAwsAccessKey (accessKey )
77
88
.setAwsSecretKey (secretKey )
78
89
.setRegion (region )
90
+ .setEndpoint (endpoint )
79
91
.setSupportsExclusiveCreate (true )
80
92
.setStreamingPartSize (DataSize .valueOf ("5.5MB" )), new S3FileSystemStats ());
81
93
}
0 commit comments