Skip to content

Commit 7aa3289

Browse files
committed
Upgrade S3Mock test container version
Upgrade S3Mock to a version supporting S3 conditional writes. Unfortunately, conditional multi-part writes do not work correctly in S3Mock.
1 parent 73f2792 commit 7aa3289

File tree

3 files changed

+46
-10
lines changed

3 files changed

+46
-10
lines changed

lib/trino-filesystem-s3/src/test/java/io/trino/filesystem/s3/TestS3FileSystemS3Mock.java

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,9 @@ public class TestS3FileSystemS3Mock
3636
private static final String BUCKET = "test-bucket";
3737

3838
@Container
39-
private static final S3MockContainer S3_MOCK = new S3MockContainer("3.0.1")
39+
private static final S3MockContainer S3_MOCK = new S3MockContainer("4.10.0")
4040
.withInitialBuckets(BUCKET);
4141

42-
@Override
43-
protected boolean supportsCreateExclusive()
44-
{
45-
return false; // not supported by s3-mock
46-
}
47-
4842
@Override
4943
protected String bucket()
5044
{
@@ -79,10 +73,23 @@ protected S3FileSystemFactory createS3FileSystemFactory()
7973
.setPathStyleAccess(true)
8074
.setStreamingPartSize(streamingPartSize)
8175
.setSignerType(S3FileSystemConfig.SignerType.AwsS3V4Signer)
82-
.setSupportsExclusiveCreate(false),
76+
.setSupportsExclusiveCreate(true),
8377
new S3FileSystemStats());
8478
}
8579

80+
@Test
81+
@Override
82+
public void testOutputFile()
83+
{
84+
// this is S3Mock bug, see https://github.com/adobe/S3Mock/issues/2790
85+
assertThatThrownBy(super::testOutputFile)
86+
.hasMessageContaining("""
87+
Expecting actual throwable to be an instance of:
88+
java.nio.file.FileAlreadyExistsException
89+
but was:
90+
java.io.IOException: software.amazon.awssdk.services.s3.model.S3Exception: (Service: S3, Status Code: 304""");
91+
}
92+
8693
@Test
8794
@Override
8895
public void testPreSignedUris()
@@ -91,4 +98,22 @@ public void testPreSignedUris()
9198
assertThatThrownBy(super::testPreSignedUris)
9299
.hasMessageContaining("Expecting code to raise a throwable");
93100
}
101+
102+
@Test
103+
@Override
104+
public void testPaths()
105+
{
106+
// this is S3Mock bug, see https://github.com/adobe/S3Mock/issues/2788
107+
assertThatThrownBy(super::testPaths)
108+
.hasMessageContaining("S3 HEAD request failed for file: s3://test-bucket/test/.././/file");
109+
}
110+
111+
@Test
112+
@Override
113+
public void testReadingEmptyFile()
114+
{
115+
// this is S3Mock bug, see https://github.com/adobe/S3Mock/issues/2789
116+
assertThatThrownBy(super::testReadingEmptyFile)
117+
.hasMessageContaining("Failed to open S3 file: s3://test-bucket/inputStream/");
118+
}
94119
}

lib/trino-filesystem/src/test/java/io/trino/filesystem/AbstractTestTrinoFileSystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ public void testInputFile()
580580
}
581581

582582
@Test
583-
void testOutputFile()
583+
public void testOutputFile()
584584
throws IOException
585585
{
586586
// an output file cannot be created at the root of the file system

lib/trino-hdfs/src/test/java/io/trino/filesystem/hdfs/TestHdfsFileSystemS3Mock.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.apache.hadoop.fs.Path;
3636
import org.junit.jupiter.api.AfterEach;
3737
import org.junit.jupiter.api.BeforeAll;
38+
import org.junit.jupiter.api.Test;
3839
import org.testcontainers.junit.jupiter.Container;
3940
import org.testcontainers.junit.jupiter.Testcontainers;
4041

@@ -44,6 +45,7 @@
4445

4546
import static java.util.Collections.emptySet;
4647
import static org.assertj.core.api.Assertions.assertThat;
48+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
4749

4850
@Testcontainers
4951
public class TestHdfsFileSystemS3Mock
@@ -52,7 +54,7 @@ public class TestHdfsFileSystemS3Mock
5254
private static final String BUCKET = "test-bucket";
5355

5456
@Container
55-
private static final S3MockContainer S3_MOCK = new S3MockContainer("3.0.1")
57+
private static final S3MockContainer S3_MOCK = new S3MockContainer("4.10.0")
5658
.withInitialBuckets(BUCKET);
5759

5860
private HdfsEnvironment hdfsEnvironment;
@@ -147,4 +149,13 @@ protected void verifyFileSystemIsEmpty()
147149
throw new UncheckedIOException(e);
148150
}
149151
}
152+
153+
@Test
154+
@Override
155+
public void testPaths()
156+
{
157+
// this is S3Mock bug, see https://github.com/adobe/S3Mock/issues/2788
158+
assertThatThrownBy(super::testPaths)
159+
.hasMessageFindingMatch("Status Code: 400; Error Code: 400 .*\\Q(Bucket: test-bucket, Key: test/.././/file)");
160+
}
150161
}

0 commit comments

Comments
 (0)