Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.backup.repository.BackupRepository;
import org.junit.AfterClass;
import org.junit.Assume;
import org.junit.Test;

/** Unit tests for {@link GCSBackupRepository} that use an in-memory Storage object */
Expand Down Expand Up @@ -123,7 +124,7 @@ public void testCopyIndexFileToHandlesZeroByteReads() throws Exception {
GCSBackupRepository repo = createRepositoryWithStorage(realStorage);
URI sourceDir = repo.resolve(getBaseUri(), "backup");
BlobId blobId = BlobId.of(bucketName, sourceDir + "/source.dat");
realStorage.create(BlobInfo.newBuilder(blobId).build(), data);
createBlob(realStorage, blobId, data);

Storage zeroReturningStorage = createZeroReturningStorage(realStorage);
GCSBackupRepository proxyRepo = createRepositoryWithStorage(zeroReturningStorage);
Expand All @@ -150,7 +151,7 @@ public void testCopyIndexFileToCopiesFile() throws Exception {
GCSBackupRepository repo = createRepositoryWithStorage(realStorage);
URI sourceDir = repo.resolve(getBaseUri(), "backup");
BlobId blobId = BlobId.of(bucketName, sourceDir + "/source.dat");
realStorage.create(BlobInfo.newBuilder(blobId).build(), data);
createBlob(realStorage, blobId, data);

try (Directory dest = new ByteBuffersDirectory()) {
repo.copyIndexFileTo(sourceDir, "source.dat", dest, "dest.dat");
Expand All @@ -163,6 +164,27 @@ public void testCopyIndexFileToCopiesFile() throws Exception {
}
}

/**
* Creates a blob, skipping (rather than failing) the test if the current default locale trips the
* known FakeStorageRpc/RFC3339 date-parsing bug - see {@link
* LocalStorageGCSBackupRepository#initializeBackupLocation()} for the same pattern.
*/
private static void createBlob(Storage storage, BlobId blobId, byte[] data) {
try {
storage.create(BlobInfo.newBuilder(blobId).build(), data);
} catch (Exception e) {
final Throwable cause = e.getCause();
Assume.assumeFalse(
"This test uses a GCS mock library that is incompatible with the current default locale",
cause != null
&& e instanceof StorageException
&& cause.getMessage().contains("Invalid date/time format")
&& cause instanceof NumberFormatException);
Comment on lines +177 to +182
// Not the known locale incompatibility - a genuine failure, so don't swallow it.
throw new RuntimeException(e);
}
}

/** Storage proxy that fails on {@code reader} so we can assert copy errors are propagated. */
private static Storage createFailingStorage() {
Storage delegate = LocalStorageHelper.customOptions(false).getService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,14 @@ protected void initializeBackupLocation() {
createDirectory(baseLocationUri);
} catch (Exception e) {
final Throwable cause = e.getCause();
if (cause != null) {
assumeFalse(
"This test uses a GCS mock library that is incompatible with the current default locale",
e instanceof StorageException
&& cause.getMessage().contains("Invalid date/time format")
&& cause instanceof NumberFormatException);
}
assumeFalse(
"This test uses a GCS mock library that is incompatible with the current default locale",
cause != null
&& e instanceof StorageException
&& cause.getMessage().contains("Invalid date/time format")
&& cause instanceof NumberFormatException);
Comment on lines +101 to +104
// Not the known locale incompatibility - a genuine failure, so don't swallow it.
throw new RuntimeException(e);
}
}
}
Loading