Skip to content

Commit cccf287

Browse files
authored
Merge pull request #2594 from adobe/junie-ctd
Tests, maintenance, refactorings
2 parents b4e5b63 + 556ca51 commit cccf287

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1771
-2049
lines changed

.github/workflows/stale.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: stale.yml
2+
on:
3+
schedule:
4+
- cron: '0 0 * * *' # Run every day at midnight
5+
6+
permissions:
7+
issues: write
8+
pull-requests: write
9+
10+
jobs:
11+
close_stale_prs:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Close stale issues and pull requests
15+
uses: actions/stale@v9.1.0
16+
with:
17+
days-before-stale: 30
18+
days-before-close: 5
19+
stale-issue-message: 'This issue has been flagged as stale due to over 30 days of inactivity. If no updates or comments are made within the next 5 days, the system will automatically close it to maintain repository hygiene.'
20+
close-issue-message: 'This issue has been automatically closed due to prolonged inactivity. It was previously marked as stale after 30 days without activity and has now been closed following an additional 5-day grace period. If you believe this issue should be reopened, please provide a comment with relevant updates or justification.'
21+
stale-pr-message: 'This pull request has been marked as stale due to 30 days of inactivity. If no further updates or comments are made within the next 5 days, it will be automatically closed to maintain repository hygiene and reduce review backlog.'
22+
close-pr-message: 'This pull request has been automatically closed due to extended inactivity. It was previously flagged as stale after 30 days without activity and has now been closed following a 5-day grace period. If you believe this pull request is still relevant, feel free to reopen it or submit a new one with updated context.'

integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/AclIT.kt

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ internal class AclIT : S3TestBase() {
5757
s3Client.getObjectAcl {
5858
it.bucket(bucketName)
5959
it.key(sourceKey)
60-
}.also {
61-
assertThat(it.sdkHttpResponse().isSuccessful).isTrue()
62-
assertThat(it.owner().id()).isNotBlank()
63-
assertThat(it.owner().displayName()).isNotBlank()
64-
assertThat(it.grants().size).isEqualTo(1)
65-
assertThat(it.grants()[0].permission()).isEqualTo(FULL_CONTROL)
60+
}.also { resp ->
61+
assertThat(resp.sdkHttpResponse().isSuccessful).isTrue()
62+
assertThat(resp.owner().id()).isNotBlank()
63+
assertThat(resp.owner().displayName()).isNotBlank()
64+
assertThat(resp.grants()).hasSize(1)
65+
assertThat(resp.grants().first().permission()).isEqualTo(FULL_CONTROL)
6666
}
6767
}
6868

@@ -87,13 +87,13 @@ internal class AclIT : S3TestBase() {
8787
assertThat(it).hasSize(1)
8888
}
8989

90-
acl.grants()[0].also {
91-
assertThat(it.permission()).isEqualTo(FULL_CONTROL)
92-
}.grantee().also {
93-
assertThat(it).isNotNull
94-
assertThat(it.id()).isEqualTo(DEFAULT_OWNER.id)
95-
assertThat(it.displayName()).isEqualTo(DEFAULT_OWNER.displayName)
96-
assertThat(it.type()).isEqualTo(CANONICAL_USER)
90+
acl.grants().first().also { grant ->
91+
assertThat(grant.permission()).isEqualTo(FULL_CONTROL)
92+
}.grantee().also { grantee ->
93+
assertThat(grantee).isNotNull
94+
assertThat(grantee.id()).isEqualTo(DEFAULT_OWNER.id)
95+
assertThat(grantee.displayName()).isEqualTo(DEFAULT_OWNER.displayName)
96+
assertThat(grantee.type()).isEqualTo(CANONICAL_USER)
9797
}
9898
}
9999

@@ -108,7 +108,6 @@ internal class AclIT : S3TestBase() {
108108
val userName = "John Doe"
109109
val granteeId = "79a59df900b949e55d96a1e698fbacedfd6e09d98eacf8f8d5218e7cd47ef2ef"
110110
val granteeName = "Jane Doe"
111-
"jane@doe.com"
112111
s3Client.putObjectAcl {
113112
it.bucket(bucketName)
114113
it.key(sourceKey)

integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/AwsChunkedEncodingIT.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ internal class AwsChunkedEncodingIT : S3TestBase() {
5858
RequestBody.fromFile(UPLOAD_FILE)
5959
)
6060

61-
putObjectResponse.checksumSHA256().also {
62-
assertThat(it).isNotBlank
63-
assertThat(it).isEqualTo(expectedChecksum)
61+
putObjectResponse.checksumSHA256().also { checksum ->
62+
assertThat(checksum).isNotBlank()
63+
assertThat(checksum).isEqualTo(expectedChecksum)
6464
}
6565

6666
s3Client.getObject {
@@ -71,9 +71,9 @@ internal class AwsChunkedEncodingIT : S3TestBase() {
7171
assertThat(it.response().eTag()).isEqualTo(expectedEtag)
7272
assertThat(it.response().contentLength()).isEqualTo(UPLOAD_FILE_LENGTH)
7373
assertThat(it.response().contentEncoding()).isNotEqualTo("aws-chunked")
74-
it.response().checksumSHA256().also {
75-
assertThat(it).isNotBlank
76-
assertThat(it).isEqualTo(expectedChecksum)
74+
it.response().checksumSHA256().also { checksum ->
75+
assertThat(checksum).isNotBlank()
76+
assertThat(checksum).isEqualTo(expectedChecksum)
7777
}
7878
}
7979
}

integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/BucketIT.kt

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,25 @@ internal class BucketIT : S3TestBase() {
5656
val bucketName = bucketName(testInfo)
5757
s3Client.createBucket { it.bucket(bucketName) }
5858

59-
val bucketCreated = s3Client.waiter().waitUntilBucketExists { it.bucket(bucketName) }
60-
val bucketCreatedResponse = bucketCreated.matched().response().get()
59+
val bucketCreatedResponse = s3Client
60+
.waiter()
61+
.waitUntilBucketExists { it.bucket(bucketName) }
62+
.matched()
63+
.response()
64+
.get()
6165
assertThat(bucketCreatedResponse).isNotNull
6266

6367
//does not throw exception if bucket exists.
6468
s3Client.headBucket { it.bucket(bucketName) }
6569

6670
s3Client.deleteBucket { it.bucket(bucketName) }
67-
val bucketDeleted = s3Client.waiter().waitUntilBucketNotExists { it.bucket(bucketName) }
68-
bucketDeleted.matched().exception().get().also {
69-
assertThat(it).isNotNull
70-
assertThat(it).isInstanceOf(NoSuchBucketException::class.java)
71-
}
71+
val deletionException = s3Client
72+
.waiter()
73+
.waitUntilBucketNotExists { it.bucket(bucketName) }
74+
.matched()
75+
.exception()
76+
.get()
77+
assertThat(deletionException).isInstanceOf(NoSuchBucketException::class.java)
7278
}
7379

7480
/**
@@ -82,23 +88,27 @@ internal class BucketIT : S3TestBase() {
8288
val bucketName = bucketName(testInfo)
8389
val createBucketResponse = s3Client.createBucket {
8490
it.bucket(bucketName)
85-
it.createBucketConfiguration {
86-
it.locationConstraint("ap-southeast-5")
87-
it.bucket {
88-
it.dataRedundancy(DataRedundancy.SINGLE_AVAILABILITY_ZONE)
89-
it.type(BucketType.DIRECTORY)
91+
it.createBucketConfiguration { cfg ->
92+
cfg.locationConstraint("ap-southeast-5")
93+
cfg.bucket { b ->
94+
b.dataRedundancy(DataRedundancy.SINGLE_AVAILABILITY_ZONE)
95+
b.type(BucketType.DIRECTORY)
9096
}
91-
it.location {
92-
it.name("SomeName")
93-
it.type(LocationType.AVAILABILITY_ZONE)
97+
cfg.location { loc ->
98+
loc.name("SomeName")
99+
loc.type(LocationType.AVAILABILITY_ZONE)
94100
}
95101
}
96102
}
97103
assertThat(createBucketResponse.sdkHttpResponse().statusCode()).isEqualTo(200)
98104
assertThat(createBucketResponse.location()).isEqualTo("/$bucketName")
99105

100-
val bucketCreated = s3Client.waiter().waitUntilBucketExists { it.bucket(bucketName) }
101-
val bucketCreatedResponse = bucketCreated.matched().response().get()
106+
val bucketCreatedResponse = s3Client
107+
.waiter()
108+
.waitUntilBucketExists { it.bucket(bucketName) }
109+
.matched()
110+
.response()
111+
.get()
102112
assertThat(bucketCreatedResponse).isNotNull
103113

104114
//does not throw exception if bucket exists.
@@ -353,10 +363,13 @@ internal class BucketIT : S3TestBase() {
353363
val bucketName = bucketName(testInfo)
354364
s3Client.createBucket { it.bucket(bucketName) }
355365

356-
val bucketCreated = s3Client.waiter().waitUntilBucketExists { it.bucket(bucketName) }
357-
bucketCreated.matched().response().get().also {
358-
assertThat(it).isNotNull
359-
}
366+
val createdResponse = s3Client
367+
.waiter()
368+
.waitUntilBucketExists { it.bucket(bucketName) }
369+
.matched()
370+
.response()
371+
.get()
372+
assertThat(createdResponse).isNotNull
360373

361374
assertThatThrownBy {
362375
s3Client.createBucket { it.bucket(bucketName) }
@@ -389,11 +402,13 @@ internal class BucketIT : S3TestBase() {
389402
}
390403

391404
s3Client.deleteBucket { it.bucket(bucketName) }
392-
val bucketDeleted = s3Client.waiter().waitUntilBucketNotExists { it.bucket(bucketName) }
393-
bucketDeleted.matched().exception().get().also {
394-
assertThat(it).isNotNull
395-
assertThat(it).isInstanceOf(NoSuchBucketException::class.java)
396-
}
405+
val deletionException = s3Client
406+
.waiter()
407+
.waitUntilBucketNotExists { it.bucket(bucketName) }
408+
.matched()
409+
.exception()
410+
.get()
411+
assertThat(deletionException).isInstanceOf(NoSuchBucketException::class.java)
397412

398413
assertThatThrownBy {
399414
s3Client.deleteBucket(DeleteBucketRequest.builder().bucket(bucketName).build())
@@ -412,8 +427,11 @@ internal class BucketIT : S3TestBase() {
412427
val bucketName = bucketName(testInfo)
413428
s3Client.createBucket { it.bucket(bucketName) }
414429

415-
val bucketCreated = s3Client.waiter().waitUntilBucketExists { it.bucket(bucketName) }
416-
val bucketCreatedResponse = bucketCreated.matched().response()!!.get()
430+
val bucketCreatedResponse = s3Client
431+
.waiter()
432+
.waitUntilBucketExists { it.bucket(bucketName) }
433+
.matched()
434+
.response()!!.get()
417435
assertThat(bucketCreatedResponse).isNotNull
418436

419437
assertThatThrownBy {
@@ -433,10 +451,12 @@ internal class BucketIT : S3TestBase() {
433451
val bucketName = bucketName(testInfo)
434452
s3Client.createBucket { it.bucket(bucketName) }
435453

436-
val bucketCreated = s3Client.waiter().waitUntilBucketExists { it.bucket(bucketName) }
437-
bucketCreated.matched().response()!!.get().also {
438-
assertThat(it).isNotNull
439-
}
454+
val createdResponse = s3Client
455+
.waiter()
456+
.waitUntilBucketExists { it.bucket(bucketName) }
457+
.matched()
458+
.response()!!.get()
459+
assertThat(createdResponse).isNotNull
440460

441461
val configuration = BucketLifecycleConfiguration
442462
.builder()

integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/ConcurrencyIT.kt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,18 @@ internal class ConcurrencyIT : S3TestBase() {
4040
)
4141
fun `concurrent bucket puts, gets and deletes are successful`(testInfo: TestInfo) {
4242
val bucketName = givenBucket(testInfo)
43-
val runners = mutableListOf<Runner>()
43+
val runners = (1..100).map { Runner(bucketName, "test/key$it") }
4444
val pool = Executors.newFixedThreadPool(100)
45-
for (i in 1..100) {
46-
runners.add(Runner(bucketName, "test/key$i"))
47-
}
4845
val futures = pool.invokeAll(runners)
49-
assertThat(futures).hasSize(100).allSatisfy {
50-
assertThat(it.get()).isTrue
46+
assertThat(futures).hasSize(100).allSatisfy { future ->
47+
assertThat(future.get()).isTrue
5148
}
5249
assertThat(DONE.get()).isEqualTo(100)
5350
}
5451

5552
companion object {
56-
val LATCH = CountDownLatch(100)
57-
val DONE = AtomicInteger(0)
53+
private val LATCH = CountDownLatch(100)
54+
private val DONE = AtomicInteger(0)
5855
}
5956

6057
inner class Runner(val bucketName: String, val key: String) : Callable<Boolean> {
@@ -65,8 +62,8 @@ internal class ConcurrencyIT : S3TestBase() {
6562
it.bucket(bucketName)
6663
it.key(key)
6764
}, RequestBody.empty()
68-
).also {
69-
assertThat(it.eTag()).isNotBlank
65+
).let { response ->
66+
assertThat(response.eTag()).isNotBlank
7067
}
7168

7269
s3Client.getObject {
@@ -79,8 +76,8 @@ internal class ConcurrencyIT : S3TestBase() {
7976
s3Client.deleteObject {
8077
it.bucket(bucketName)
8178
it.key(key)
82-
}.also {
83-
assertThat(it.deleteMarker()).isTrue
79+
}.let { response ->
80+
assertThat(response.deleteMarker()).isTrue
8481
}
8582
DONE.incrementAndGet()
8683
return true

integration-tests/src/test/kotlin/com/adobe/testing/s3mock/its/CopyObjectIT.kt

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import software.amazon.awssdk.services.s3.model.MetadataDirective
3030
import software.amazon.awssdk.services.s3.model.S3Exception
3131
import software.amazon.awssdk.services.s3.model.ServerSideEncryption
3232
import software.amazon.awssdk.services.s3.model.StorageClass
33-
import java.io.File
3433
import java.time.Duration
3534
import java.time.Instant
3635
import java.time.temporal.ChronoUnit.SECONDS
@@ -58,8 +57,8 @@ internal class CopyObjectIT : S3TestBase() {
5857
it.sourceKey(sourceKey)
5958
it.destinationBucket(destinationBucketName)
6059
it.destinationKey(destinationKey)
61-
}.copyObjectResult().eTag().also {
62-
assertThat(it).isEqualTo(putObjectResult.eTag())
60+
}.copyObjectResult().eTag().let { eTag ->
61+
assertThat(eTag).isEqualTo(putObjectResult.eTag())
6362
}
6463

6564
s3Client.getObject {
@@ -91,8 +90,8 @@ internal class CopyObjectIT : S3TestBase() {
9190
it.sourceKey(sourceKey)
9291
it.destinationBucket(destinationBucketName)
9392
it.destinationKey(destinationKey)
94-
}.copyObjectResult().eTag().also {
95-
assertThat(it).isEqualTo(putObjectResult.eTag())
93+
}.copyObjectResult().eTag().let { eTag ->
94+
assertThat(eTag).isEqualTo(putObjectResult.eTag())
9695
}
9796

9897
s3Client.getObject {
@@ -120,8 +119,8 @@ internal class CopyObjectIT : S3TestBase() {
120119
it.destinationBucket(destinationBucketName)
121120
it.destinationKey(destinationKey)
122121
it.copySourceIfMatch(matchingEtag)
123-
}.copyObjectResult().eTag().also {
124-
assertThat(it).isEqualTo(putObjectResult.eTag())
122+
}.copyObjectResult().eTag().let { eTag ->
123+
assertThat(eTag).isEqualTo(putObjectResult.eTag())
125124
}
126125

127126
s3Client.getObject {
@@ -151,8 +150,8 @@ internal class CopyObjectIT : S3TestBase() {
151150
it.destinationKey(destinationKey)
152151
it.copySourceIfMatch(matchingEtag)
153152
it.copySourceIfUnmodifiedSince(now)
154-
}.copyObjectResult().eTag().also {
155-
assertThat(it).isEqualTo(putObjectResult.eTag())
153+
}.copyObjectResult().eTag().let { eTag ->
154+
assertThat(eTag).isEqualTo(putObjectResult.eTag())
156155
}
157156

158157
s3Client.getObject {
@@ -181,8 +180,8 @@ internal class CopyObjectIT : S3TestBase() {
181180
it.destinationBucket(destinationBucketName)
182181
it.destinationKey(destinationKey)
183182
it.copySourceIfModifiedSince(now)
184-
}.copyObjectResult().eTag().also {
185-
assertThat(it).isEqualTo(putObjectResult.eTag())
183+
}.copyObjectResult().eTag().let { eTag ->
184+
assertThat(eTag).isEqualTo(putObjectResult.eTag())
186185
}
187186

188187
s3Client.getObject {
@@ -238,8 +237,8 @@ internal class CopyObjectIT : S3TestBase() {
238237
it.destinationBucket(destinationBucketName)
239238
it.destinationKey(destinationKey)
240239
it.copySourceIfUnmodifiedSince(now)
241-
}.copyObjectResult().eTag().also {
242-
assertThat(it).isEqualTo(putObjectResult.eTag())
240+
}.copyObjectResult().eTag().let { eTag ->
241+
assertThat(eTag).isEqualTo(putObjectResult.eTag())
243242
}
244243

245244
s3Client.getObject {
@@ -266,8 +265,8 @@ internal class CopyObjectIT : S3TestBase() {
266265
it.destinationBucket(destinationBucketName)
267266
it.destinationKey(destinationKey)
268267
it.copySourceIfNoneMatch(noneMatchingEtag)
269-
}.copyObjectResult().eTag().also {
270-
assertThat(it).isEqualTo(putObjectResult.eTag())
268+
}.copyObjectResult().eTag().let { eTag ->
269+
assertThat(eTag).isEqualTo(putObjectResult.eTag())
271270
}
272271

273272
s3Client.getObject {

0 commit comments

Comments
 (0)