Skip to content

Commit e5d2aaf

Browse files
committed
fix: enable disabled s3 e2e tests & update tests after default checksums
1 parent 7e033d9 commit e5d2aaf

File tree

5 files changed

+6
-57
lines changed

5 files changed

+6
-57
lines changed

services/s3/e2eTest/src/PaginatorTest.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import org.junit.jupiter.api.AfterAll
1919
import org.junit.jupiter.api.BeforeAll
2020
import org.junit.jupiter.api.Test
2121
import org.junit.jupiter.api.TestInstance
22-
import kotlin.test.Ignore
2322
import kotlin.test.assertContentEquals
2423
import kotlin.time.Duration.Companion.seconds
2524

@@ -41,10 +40,7 @@ class PaginatorTest {
4140
S3TestUtils.deleteBucketAndAllContents(client, testBucket)
4241
}
4342

44-
// FIXME: Enable test
45-
// Seeing: S3Exception: Checksum Type mismatch occurred, expected checksum Type: null, actual checksum Type: crc32
4643
// ListParts has a strange pagination termination condition via [IsTerminated]. Verify it actually works correctly.
47-
@Ignore
4844
@Test
4945
fun testListPartsPagination() = runBlocking {
5046
val chunk = "!".repeat(5 * 1024 * 1024).encodeToByteArray() // Parts must be at least 5MB

services/s3/e2eTest/src/S3ChecksumTest.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package aws.sdk.kotlin.e2etest
33
import aws.sdk.kotlin.e2etest.S3TestUtils.deleteBucketContents
44
import aws.sdk.kotlin.e2etest.S3TestUtils.deleteMultiPartUploads
55
import aws.sdk.kotlin.e2etest.S3TestUtils.getAccountId
6-
import aws.sdk.kotlin.e2etest.S3TestUtils.getBucketByName
6+
import aws.sdk.kotlin.e2etest.S3TestUtils.getTestBucket
77
import aws.sdk.kotlin.e2etest.S3TestUtils.responseCodeFromPut
88
import aws.sdk.kotlin.services.s3.*
99
import aws.sdk.kotlin.services.s3.model.*
@@ -24,14 +24,13 @@ import kotlin.time.Duration.Companion.seconds
2424
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
2525
class S3ChecksumTest {
2626
private val client = S3Client { region = "us-west-2" }
27-
private val testBucket = "s3-test-bucket-ci-motorcade"
27+
private lateinit var testBucket: String
2828
private fun testKey(): String = "test-object" + UUID.randomUUID()
2929

3030
@BeforeAll
3131
private fun setUp(): Unit = runBlocking {
3232
val accountId = getAccountId()
33-
// FIXME: Use randomly generated bucket instead of hardcoded one
34-
getBucketByName(client, testBucket, "us-west-2", accountId)
33+
testBucket = getTestBucket(client, "us-west-2", accountId)
3534
}
3635

3736
@AfterAll

services/s3/e2eTest/src/S3ExpressTest.kt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class S3ExpressTest {
136136
}
137137

138138
@Test
139-
fun testUploadPartContainsNoDefaultChecksum() = runTest {
139+
fun testUploadPartContainsCRC32Checksum() = runTest {
140140
val testBucket = testBuckets.first()
141141
val testObject = "I-will-be-uploaded-in-parts-!"
142142

@@ -153,7 +153,7 @@ class S3ExpressTest {
153153
var eTagPartTwo: String?
154154

155155
client.withConfig {
156-
interceptors += NoChecksumValidatingInterceptor()
156+
interceptors += CRC32ChecksumValidatingInterceptor()
157157
}.use { validatingClient ->
158158
eTagPartOne = validatingClient.uploadPart {
159159
bucket = testBucket
@@ -210,13 +210,4 @@ class S3ExpressTest {
210210
}
211211
}
212212
}
213-
214-
private class NoChecksumValidatingInterceptor : HttpInterceptor {
215-
override fun readBeforeTransmit(context: ProtocolRequestInterceptorContext<Any, HttpRequest>) {
216-
val headers = context.protocolRequest.headers
217-
if (headers.contains(S3_EXPRESS_SESSION_TOKEN_HEADER)) {
218-
assertFalse(headers.names().any { it.startsWith("x-amz-checksum-") })
219-
}
220-
}
221-
}
222213
}

services/s3/e2eTest/src/S3IntegrationTest.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,6 @@ class S3BucketOpsIntegrationTest {
188188
}
189189
}
190190

191-
// FIXME: Enable test
192-
// Seeing: S3Exception: Checksum Type mismatch occurred, expected checksum Type: null, actual checksum Type: crc32
193-
@Ignore
194191
@Test
195192
fun testMultipartUpload(): Unit = runBlocking {
196193
s3WithAllEngines { s3 ->

services/s3/e2eTest/src/S3TestUtils.kt

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ object S3TestUtils {
3434
const val DEFAULT_REGION = "us-west-2"
3535

3636
// The E2E test account only has permission to operate on buckets with the prefix "s3-test-bucket-"
37-
// Non-checksum E2E tests will use and delete hardcoded bucket required for checksum tests if TEST_BUCKET_PREFIX="s3-test-bucket-" via `deleteBucketAndAllContents`
38-
// TODO: Change back to "s3-test-bucket-"
39-
private const val TEST_BUCKET_PREFIX = "s3-test-bucket-temp-"
37+
private const val TEST_BUCKET_PREFIX = "s3-test-bucket-"
4038

4139
private const val S3_MAX_BUCKET_NAME_LENGTH = 63 // https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html
4240
private const val S3_EXPRESS_DIRECTORY_BUCKET_SUFFIX = "--x-s3"
@@ -100,38 +98,6 @@ object S3TestUtils {
10098
testBucket
10199
}
102100

103-
suspend fun getBucketByName(
104-
client: S3Client,
105-
targetBucket: String,
106-
region: String? = null,
107-
accountId: String? = null,
108-
): Unit = withTimeout(60.seconds) {
109-
try {
110-
val targetBucketRegion = client
111-
.headBucket {
112-
this.bucket = targetBucket
113-
expectedBucketOwner = accountId
114-
}.bucketRegion
115-
116-
if (targetBucketRegion != region) {
117-
throw RuntimeException(
118-
"The requested bucket ($targetBucket) already exists in another region than the one requested ($region)",
119-
)
120-
}
121-
} catch (e: Throwable) {
122-
println("Creating S3 bucket: $targetBucket")
123-
124-
client.createBucket {
125-
bucket = targetBucket
126-
createBucketConfiguration {
127-
locationConstraint = BucketLocationConstraint.fromValue(region ?: client.config.region!!)
128-
}
129-
}
130-
131-
client.waitUntilBucketExists { bucket = targetBucket }
132-
}
133-
}
134-
135101
suspend fun getTestDirectoryBucket(client: S3Client, suffix: String) = withTimeout(60.seconds) {
136102
var testBucket = client.listBuckets()
137103
.buckets

0 commit comments

Comments
 (0)