Skip to content

Commit 500bf2f

Browse files
committed
Fix S3 integration test workflow
1 parent 63cf2c2 commit 500bf2f

File tree

2 files changed

+53
-65
lines changed

2 files changed

+53
-65
lines changed

.github/workflows/object-storage-adapter-check.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ env:
4040
# Oracle JDK that are linux compatible and publicly available through direct download exist for all LTS versions
4141
SET_UP_INT_TEST_RUNTIME_NON_ORACLE_JDK: "${{ (github.event_name == 'workflow_dispatch' && !(inputs.INT_TEST_JAVA_RUNTIME_VERSION == '8' && inputs.INT_TEST_JAVA_RUNTIME_VENDOR == 'temurin') && !(inputs.INT_TEST_JAVA_RUNTIME_VENDOR == 'oracle')) && 'true' || 'false' }}"
4242
INT_TEST_GRADLE_OPTIONS_FOR_GROUP_COMMIT: '"-Dscalardb.consensus_commit.coordinator.group_commit.enabled=true" "-Dscalardb.consensus_commit.coordinator.group_commit.old_group_abort_timeout_millis=15000" --tests "**.ConsensusCommit**"'
43-
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }}
44-
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
43+
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }}
44+
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
4545
S3_REGION: ap-northeast-1
4646
S3_BUCKET_NAME: scalardb-test-bucket
4747

@@ -92,7 +92,7 @@ jobs:
9292
uses: gradle/actions/setup-gradle@v5
9393

9494
- name: Execute Gradle 'integrationTestObjectStorage' task
95-
run: ./gradlew integrationTestObjectStorage -Dscalardb.object_storage.storage=s3 -Dscalardb.object_storage.endpoint=${{ env.S3_REGION }}/${{ env.S3_BUCKET_NAME }} ${{ matrix.mode.group_commit_enabled && env.INT_TEST_GRADLE_OPTIONS_FOR_GROUP_COMMIT || '' }}
95+
run: ./gradlew integrationTestObjectStorage -Dscalardb.object_storage.storage=s3 -Dscalardb.object_storage.endpoint=${{ env.S3_REGION }}/${{ env.S3_BUCKET_NAME }} -Dscalardb.object_storage.username=${{ env.S3_ACCESS_KEY_ID }} -Dscalardb.object_storage.password=${{ env.S3_SECRET_ACCESS_KEY }} ${{ matrix.mode.group_commit_enabled && env.INT_TEST_GRADLE_OPTIONS_FOR_GROUP_COMMIT || '' }}
9696

9797
- name: Upload Gradle test reports
9898
if: always()

core/src/main/java/com/scalar/db/storage/objectstorage/s3/S3Wrapper.java

Lines changed: 50 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,18 @@ public void insert(String key, String object) throws ObjectStorageWrapperExcepti
127127
AsyncRequestBody.fromString(object))
128128
.join();
129129
} catch (Exception e) {
130-
Throwable cause = e.getCause();
131-
if (cause instanceof S3Exception) {
132-
Optional<S3Exception> s3Exception = findS3Exception(e);
133-
if (s3Exception.isPresent()) {
134-
if (s3Exception.get().statusCode() == S3ErrorCode.CONFLICT.get()) {
135-
throw new ConflictOccurredException(
136-
String.format("Failed to insert the object with key '%s' due to conflict", key),
137-
s3Exception.get());
138-
}
139-
if (s3Exception.get().statusCode() == S3ErrorCode.PRECONDITION_FAILED.get()) {
140-
throw new PreconditionFailedException(
141-
String.format(
142-
"Failed to insert the object with key '%s' due to precondition failure", key),
143-
s3Exception.get());
144-
}
130+
Optional<S3Exception> s3Exception = findS3Exception(e);
131+
if (s3Exception.isPresent()) {
132+
if (s3Exception.get().statusCode() == S3ErrorCode.CONFLICT.get()) {
133+
throw new ConflictOccurredException(
134+
String.format("Failed to insert the object with key '%s' due to conflict", key),
135+
s3Exception.get());
136+
}
137+
if (s3Exception.get().statusCode() == S3ErrorCode.PRECONDITION_FAILED.get()) {
138+
throw new PreconditionFailedException(
139+
String.format(
140+
"Failed to insert the object with key '%s' due to precondition failure", key),
141+
s3Exception.get());
145142
}
146143
}
147144
throw new ObjectStorageWrapperException(
@@ -159,22 +156,19 @@ public void update(String key, String object, String version)
159156
AsyncRequestBody.fromString(object))
160157
.join();
161158
} catch (Exception e) {
162-
Throwable cause = e.getCause();
163-
if (cause instanceof S3Exception) {
164-
Optional<S3Exception> s3Exception = findS3Exception(e);
165-
if (s3Exception.isPresent()) {
166-
if (s3Exception.get().statusCode() == S3ErrorCode.CONFLICT.get()) {
167-
throw new ConflictOccurredException(
168-
String.format("Failed to update the object with key '%s' due to conflict", key),
169-
s3Exception.get());
170-
}
171-
if (s3Exception.get().statusCode() == S3ErrorCode.NOT_FOUND.get()
172-
|| s3Exception.get().statusCode() == S3ErrorCode.PRECONDITION_FAILED.get()) {
173-
throw new PreconditionFailedException(
174-
String.format(
175-
"Failed to update the object with key '%s' due to precondition failure", key),
176-
s3Exception.get());
177-
}
159+
Optional<S3Exception> s3Exception = findS3Exception(e);
160+
if (s3Exception.isPresent()) {
161+
if (s3Exception.get().statusCode() == S3ErrorCode.CONFLICT.get()) {
162+
throw new ConflictOccurredException(
163+
String.format("Failed to update the object with key '%s' due to conflict", key),
164+
s3Exception.get());
165+
}
166+
if (s3Exception.get().statusCode() == S3ErrorCode.NOT_FOUND.get()
167+
|| s3Exception.get().statusCode() == S3ErrorCode.PRECONDITION_FAILED.get()) {
168+
throw new PreconditionFailedException(
169+
String.format(
170+
"Failed to update the object with key '%s' due to precondition failure", key),
171+
s3Exception.get());
178172
}
179173
}
180174
throw new ObjectStorageWrapperException(
@@ -189,21 +183,18 @@ public void delete(String key) throws ObjectStorageWrapperException {
189183
.deleteObject(DeleteObjectRequest.builder().bucket(bucket).key(key).ifMatch("*").build())
190184
.join();
191185
} catch (Exception e) {
192-
Throwable cause = e.getCause();
193-
if (cause instanceof S3Exception) {
194-
Optional<S3Exception> s3Exception = findS3Exception(e);
195-
if (s3Exception.isPresent()) {
196-
if (s3Exception.get().statusCode() == S3ErrorCode.CONFLICT.get()) {
197-
throw new ConflictOccurredException(
198-
String.format("Failed to delete the object with key '%s' due to conflict", key),
199-
s3Exception.get());
200-
}
201-
if (s3Exception.get().statusCode() == S3ErrorCode.NOT_FOUND.get()) {
202-
throw new PreconditionFailedException(
203-
String.format(
204-
"Failed to delete the object with key '%s' due to precondition failure", key),
205-
s3Exception.get());
206-
}
186+
Optional<S3Exception> s3Exception = findS3Exception(e);
187+
if (s3Exception.isPresent()) {
188+
if (s3Exception.get().statusCode() == S3ErrorCode.CONFLICT.get()) {
189+
throw new ConflictOccurredException(
190+
String.format("Failed to delete the object with key '%s' due to conflict", key),
191+
s3Exception.get());
192+
}
193+
if (s3Exception.get().statusCode() == S3ErrorCode.NOT_FOUND.get()) {
194+
throw new PreconditionFailedException(
195+
String.format(
196+
"Failed to delete the object with key '%s' due to precondition failure", key),
197+
s3Exception.get());
207198
}
208199
}
209200
throw new ObjectStorageWrapperException(
@@ -219,22 +210,19 @@ public void delete(String key, String version) throws ObjectStorageWrapperExcept
219210
DeleteObjectRequest.builder().bucket(bucket).key(key).ifMatch(version).build())
220211
.join();
221212
} catch (Exception e) {
222-
Throwable cause = e.getCause();
223-
if (cause instanceof S3Exception) {
224-
Optional<S3Exception> s3Exception = findS3Exception(e);
225-
if (s3Exception.isPresent()) {
226-
if (s3Exception.get().statusCode() == S3ErrorCode.CONFLICT.get()) {
227-
throw new ConflictOccurredException(
228-
String.format("Failed to delete the object with key '%s' due to conflict", key),
229-
s3Exception.get());
230-
}
231-
if (s3Exception.get().statusCode() == S3ErrorCode.NOT_FOUND.get()
232-
|| s3Exception.get().statusCode() == S3ErrorCode.PRECONDITION_FAILED.get()) {
233-
throw new PreconditionFailedException(
234-
String.format(
235-
"Failed to delete the object with key '%s' due to precondition failure", key),
236-
s3Exception.get());
237-
}
213+
Optional<S3Exception> s3Exception = findS3Exception(e);
214+
if (s3Exception.isPresent()) {
215+
if (s3Exception.get().statusCode() == S3ErrorCode.CONFLICT.get()) {
216+
throw new ConflictOccurredException(
217+
String.format("Failed to delete the object with key '%s' due to conflict", key),
218+
s3Exception.get());
219+
}
220+
if (s3Exception.get().statusCode() == S3ErrorCode.NOT_FOUND.get()
221+
|| s3Exception.get().statusCode() == S3ErrorCode.PRECONDITION_FAILED.get()) {
222+
throw new PreconditionFailedException(
223+
String.format(
224+
"Failed to delete the object with key '%s' due to precondition failure", key),
225+
s3Exception.get());
238226
}
239227
}
240228
throw new ObjectStorageWrapperException(

0 commit comments

Comments
 (0)