Skip to content

Commit b5e394d

Browse files
committed
HADOOP-16279 some changes to gabor's patch #0e6482dec21
* Tests for being in sync /not being in sync now compare etag and version IDs. Highlights we aren't always getting back version IDs. * Parameterized OOB test now includes auth flag in mehod name, for ease of debugging * minor: formatting Change-Id: I7ea062d6996c9ca00d036347c310e5d2e0fa60fe
1 parent 473b617 commit b5e394d

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/S3AFileSystem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public void initialize(URI name, Configuration originalConf)
389389
getMetadataStore(), allowAuthoritative);
390390
}
391391
initMultipartUploads(conf);
392-
if(hasMetadataStore()) {
392+
if (hasMetadataStore()) {
393393
long authDirTtl = conf.getTimeDuration(METADATASTORE_METADATA_TTL,
394394
DEFAULT_METADATASTORE_METADATA_TTL, TimeUnit.SECONDS);
395395
ttlTimeProvider = new S3Guard.TtlTimeProvider(authDirTtl);
@@ -2470,7 +2470,7 @@ S3AFileStatus innerGetFileStatus(final Path f,
24702470

24712471
// Check MetadataStore, if any.
24722472
PathMetadata pm = null;
2473-
if(hasMetadataStore()) {
2473+
if (hasMetadataStore()) {
24742474
pm = S3Guard.getWithTtl(metadataStore, path, ttlTimeProvider);
24752475
}
24762476
Set<Path> tombstones = Collections.emptySet();

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3GuardOutOfBandOperations.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public class ITestS3GuardOutOfBandOperations extends AbstractS3ATestBase {
126126
* Test array for parameterized test runs.
127127
* @return a list of parameter tuples.
128128
*/
129-
@Parameterized.Parameters
129+
@Parameterized.Parameters(name="auth={0}")
130130
public static Collection<Object[]> params() {
131131
return Arrays.asList(new Object[][]{
132132
{true}, {false}
@@ -516,7 +516,7 @@ public void deleteAfterTombstoneExpiryOobCreate() throws Exception {
516516
awaitFileStatus(rawFS, filePath);
517517

518518
// SET EXPIRY TIME, SO THE TOMBSTONE IS EXPIRED
519-
when(mockTimeProvider.getNow()).thenReturn(100L + 2*ttl);
519+
when(mockTimeProvider.getNow()).thenReturn(100L + 2 * ttl);
520520

521521
// DELETE IN GUARDED FS
522522
guardedFs.delete(filePath, true);
@@ -777,6 +777,38 @@ private void verifyFileStatusAsExpected(final String firstText,
777777
expectedLength, guardedLength);
778778
}
779779
}
780+
// check etag
781+
final S3AFileStatus rawS3AFileStatus = (S3AFileStatus) rawFileStatus;
782+
final S3AFileStatus guardedS3AFileStatus = (S3AFileStatus) guardedFileStatus;
783+
final S3AFileStatus origS3AFileStatus = (S3AFileStatus) origStatus;
784+
assertNotEquals(
785+
"raw status still no to date with changes" + stats,
786+
origS3AFileStatus.getETag(), rawS3AFileStatus.getETag());
787+
if (allowAuthoritative) {
788+
// expect the etag to be out of sync
789+
assertNotEquals(
790+
"etag in authoritative table with " + stats,
791+
rawS3AFileStatus.getETag(), guardedS3AFileStatus.getETag());
792+
} else {
793+
assertEquals(
794+
"etag in non-authoritative table with " + stats,
795+
rawS3AFileStatus.getETag(), guardedS3AFileStatus.getETag());
796+
}
797+
// version ID if not null
798+
final String rawVersionId = rawS3AFileStatus.getVersionId();
799+
if (rawVersionId != null) {
800+
final String guardedVersionId = guardedS3AFileStatus.getVersionId();
801+
if (allowAuthoritative) {
802+
// expect the versionID to be out of sync
803+
assertNotEquals(
804+
"version ID in authoritative table with " + stats,
805+
rawVersionId, guardedVersionId);
806+
} else {
807+
assertEquals(
808+
"version ID in non-=authoritative table with " + stats,
809+
rawVersionId, guardedVersionId);
810+
}
811+
}
780812
// Next: modification time.
781813
long rawModTime = rawFileStatus.getModificationTime();
782814
long guardedModTime = guardedFileStatus.getModificationTime();

0 commit comments

Comments
 (0)