This is an automated email from the ASF dual-hosted git repository.

gerlowskija pushed a commit to branch branch_9_0
in repository https://gitbox.apache.org/repos/asf/solr.git

commit 11c07ba6d3486ab807b65aa983a660561dd8cf83
Author: Jason Gerlowski <[email protected]>
AuthorDate: Mon Jan 24 14:13:11 2022 -0500

    SOLR-15501: Fix longstanding GCS test issue
    
    A library we use to stub out GCS in tests only works in a limited set of
    locales.  We'd been working around this problem by maintaining a list of
    the 'incompatible' locales and skipping the tests if any of the known
    bad ones were in use.  This worked much of the time but often failed
    because the list of incompatible locales was incomplete and Jenkins jobs
    were constantly finding fails with different seeds.
    
    This commit replaces this approach with a different one - have the test
    catch the locale-specific error and skip the test at that point.  This
    should clean up the sporadic failures that pop up now and then in Jenkins
    builds.
---
 .../org/apache/solr/gcs/GCSBackupRepositoryTest.java    | 17 -----------------
 .../org/apache/solr/gcs/GCSIncrementalBackupTest.java   |  5 -----
 .../solr/gcs/LocalStorageGCSBackupRepository.java       | 11 ++++++++++-
 3 files changed, 10 insertions(+), 23 deletions(-)

diff --git 
a/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/GCSBackupRepositoryTest.java
 
b/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/GCSBackupRepositoryTest.java
index 5cba2ad..4676ef7 100644
--- 
a/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/GCSBackupRepositoryTest.java
+++ 
b/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/GCSBackupRepositoryTest.java
@@ -17,19 +17,15 @@
 
 package org.apache.solr.gcs;
 
-import com.google.common.collect.Lists;
 import org.apache.solr.cloud.api.collections.AbstractBackupRepositoryTest;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.backup.repository.BackupRepository;
 import org.junit.AfterClass;
-import org.junit.BeforeClass;
 import org.junit.Test;
 
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 
 import static org.apache.solr.common.params.CoreAdminParams.BACKUP_LOCATION;
@@ -41,19 +37,6 @@ import static 
org.apache.solr.gcs.GCSConfigParser.GCS_CREDENTIAL_ENV_VAR_NAME;
  */
 public class GCSBackupRepositoryTest extends AbstractBackupRepositoryTest {
 
-    // Locale langs unsupported by google-cloud-nio's 'Storage' drop-in.  May 
need added to as Jenkins finds fails.
-    // (Note that the issue here is in the test-stub, actual GCS use is fine 
with these locales).
-    private static final List<String> INCOMPATIBLE_LOCALE_LANGS = 
Lists.newArrayList("ar", "dz", "uz", "ne", "mzn", "pa",
-            "sd", "mr", "ig", "as", "fa", "my", "bn", "lrc", "ur", "ks", "th", 
"ckb", "ja", "ps", "hi");
-
-    @BeforeClass
-    public static void ensureCompatibleLocale() {
-        final String defaultLang = Locale.getDefault().getLanguage();
-
-        assumeFalse("This test uses a GCS mock library that is incompatible 
with the current default locale " + defaultLang,
-                INCOMPATIBLE_LOCALE_LANGS.contains(defaultLang));
-    }
-
     @AfterClass
     public static void tearDownClass() throws Exception {
         LocalStorageGCSBackupRepository.clearStashedStorage();
diff --git 
a/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/GCSIncrementalBackupTest.java
 
b/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/GCSIncrementalBackupTest.java
index f89e10a..b567252 100644
--- 
a/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/GCSIncrementalBackupTest.java
+++ 
b/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/GCSIncrementalBackupTest.java
@@ -69,11 +69,6 @@ public class GCSIncrementalBackupTest extends 
AbstractIncrementalBackupTest {
     private static String backupLocation;
 
     @BeforeClass
-    public static void ensureCompatibleLocale() {
-        GCSBackupRepositoryTest.ensureCompatibleLocale();
-    }
-
-    @BeforeClass
     public static void setupClass() throws Exception {
 
         configureCluster(NUM_SHARDS)// nodes
diff --git 
a/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/LocalStorageGCSBackupRepository.java
 
b/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/LocalStorageGCSBackupRepository.java
index 21426bb..30d0df1 100644
--- 
a/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/LocalStorageGCSBackupRepository.java
+++ 
b/solr/modules/gcs-repository/src/test/org/apache/solr/gcs/LocalStorageGCSBackupRepository.java
@@ -19,6 +19,7 @@ package org.apache.solr.gcs;
 
 import com.google.cloud.storage.BlobId;
 import com.google.cloud.storage.Storage;
+import com.google.cloud.storage.StorageException;
 import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper;
 import com.google.common.collect.Lists;
 
@@ -29,6 +30,8 @@ import java.util.Collection;
 import java.util.List;
 import java.util.stream.Collectors;
 
+import static org.apache.lucene.util.LuceneTestCase.assumeFalse;
+
 public class LocalStorageGCSBackupRepository extends GCSBackupRepository {
 
   protected static Storage stashedStorage = null;
@@ -98,7 +101,13 @@ public class LocalStorageGCSBackupRepository extends 
GCSBackupRepository {
       final URI baseLocationUri = createDirectoryURI(baseLocation);
       createDirectory(baseLocationUri);
     } catch (Exception e) {
-      throw new RuntimeException(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);
+      }
     }
   }
 }

Reply via email to