Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use localstack in storage tests #260

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions storage/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,9 @@ services:
ports:
- "45678:8000"
s3:
image: "zenko/cloudserver:8.1.8"
image: "public.ecr.aws/localstack/localstack:4.0.0"
environment:
- "S3BACKEND=mem"
- SERVICES=s3
- ALLOW_NONSTANDARD_REGIONS=1
ports:
- "33333:8000"

# We've seen flakiness when this container doesn't start fast enough,
# and the first few tests to interact with S3 fail. This uses
# docker-compose healthchecks to check the container is returning
# a 401 Unauthorized before continuing.
# See https://docs.docker.com/compose/compose-file/#/healthcheck
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:33333"]
interval: 2s
timeout: 10s
retries: 5
- "33333:4566"
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ object S3Errors {
if exc.getMessage.startsWith("The specified bucket is not valid") =>
StoreReadError(exc)

case exc: S3Exception
if exc.getMessage.startsWith("The specified bucket does not exist") =>
StoreReadError(exc)

case exc: SdkClientException
if exc.getMessage.startsWith("Unable to execute HTTP request") =>
new StoreReadError(exc) with RetryableError
Expand All @@ -54,6 +58,9 @@ object S3Errors {
case exc: S3Exception
if exc.getMessage.startsWith("Object key is too long") =>
InvalidIdentifierFailure(exc)
case exc: S3Exception
if exc.getMessage.startsWith("Your key is too long") =>
InvalidIdentifierFailure(exc)

case exc => StoreWriteError(exc)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ trait DynamoHybridStoreTestCases[

value shouldBe a[StoreWriteError]
value.e.getMessage should startWith(
"The specified bucket is not valid")
"The specified bucket does not exist")
}
}
}
Expand Down Expand Up @@ -206,7 +206,7 @@ trait DynamoHybridStoreTestCases[
val value = result.left.value

value shouldBe a[InvalidIdentifierFailure]
value.e.getMessage should startWith("Object key is too long")
value.e.getMessage should include("key is too long")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ class S3StreamStoreTest
withStoreImpl(initialEntries = Map.empty) { store =>
val invalidLocation = createS3ObjectLocationWith(createInvalidBucket)
val err = store.get(invalidLocation).left.value
err shouldBe a[StoreReadError]
err shouldBe a[DoesNotExistError]

err.e shouldBe a[S3Exception]
err.e.getMessage should startWith("The specified bucket is not valid")
err.e.getMessage should startWith(
"The specified bucket does not exist")
}
}
}
Expand Down Expand Up @@ -102,7 +103,7 @@ class S3StreamStoreTest

val err = result.e
err shouldBe a[S3Exception]
err.getMessage should startWith("The specified bucket is not valid")
err.getMessage should startWith("The specified bucket does not exist")
}
}

Expand All @@ -121,7 +122,7 @@ class S3StreamStoreTest
val value = store.put(id)(entry).left.value

value shouldBe a[InvalidIdentifierFailure]
value.e.getMessage should startWith("Object key is too long")
value.e.getMessage should include("key is too long")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class S3TypedStoreTest
describe("S3TypedStore") {
it("errors if the object key is too long") {
withLocalS3Bucket { bucket =>
// Maximum length of an s3 key is 1024 bytes as of 25/06/2019
// Maximum length of a s3 key is 1024 bytes as of 25/06/2019
// https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html
val location = S3ObjectLocation(
bucket = bucket.name,
Expand All @@ -74,7 +74,7 @@ class S3TypedStoreTest
val value = store.put(location)(entry).left.value

value shouldBe a[InvalidIdentifierFailure]
value.e.getMessage should startWith("Object key is too long")
value.e.getMessage should include("key is too long")
}
}
}
Expand Down