SOLR-7183: Fix Locale blacklisting for Minikdc based tests.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1681915 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Anshum Gupta 2015-05-27 06:32:14 +00:00
parent 55fd17e90d
commit 79435ee7e1
7 changed files with 42 additions and 59 deletions

View File

@ -491,6 +491,9 @@ Other Changes
enable auto soft-commits for the bin/solr -e cloud example using the Config API. enable auto soft-commits for the bin/solr -e cloud example using the Config API.
(Timothy Potter) (Timothy Potter)
* SOLR-7183: Fix Locale blacklisting for Minikdc based tests. (Ishan Chattopadhyaya, hossman
via Anshum Gupta)
================== 5.1.0 ================== ================== 5.1.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

View File

@ -1,7 +1,10 @@
package org.apache.solr.cloud; package org.apache.solr.cloud;
import java.io.File; import java.io.File;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@ -119,4 +122,27 @@ public class KerberosTestUtil {
return krb5LoginModuleName; return krb5LoginModuleName;
} }
} }
/**
* These Locales don't generate dates that are compatibile with Hadoop MiniKdc.
*/
private final static List<String> brokenLanguagesWithMiniKdc =
Arrays.asList(
new Locale("th").getLanguage(),
new Locale("ja").getLanguage(),
new Locale("hi").getLanguage()
);
/**
*returns the currently set locale, and overrides it with {@link Locale#US} if it's
* currently something MiniKdc can not handle
*
* @see Locale#setDefault
*/
public static final Locale overrideLocaleIfNotSpportedByMiniKdc() {
Locale old = Locale.getDefault();
if (brokenLanguagesWithMiniKdc.contains(Locale.getDefault().getLanguage())) {
Locale.setDefault(Locale.US);
}
return old;
}
} }

View File

@ -3,8 +3,6 @@ package org.apache.solr.cloud;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import javax.security.auth.login.Configuration; import javax.security.auth.login.Configuration;
@ -52,12 +50,7 @@ public class SaslZkACLProviderTest extends SolrTestCaseJ4 {
.getLogger(SaslZkACLProviderTest.class); .getLogger(SaslZkACLProviderTest.class);
private static final Charset DATA_ENCODING = Charset.forName("UTF-8"); private static final Charset DATA_ENCODING = Charset.forName("UTF-8");
// These Locales don't generate dates that are compatibile with Hadoop MiniKdc.
protected final static List<String> brokenLocales =
Arrays.asList(
"th_TH_TH_#u-nu-thai",
"ja_JP_JP_#u-ca-japanese",
"hi_IN");
protected Locale savedLocale = null; protected Locale savedLocale = null;
protected ZkTestServer zkServer; protected ZkTestServer zkServer;
@ -77,10 +70,7 @@ public class SaslZkACLProviderTest extends SolrTestCaseJ4 {
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
if (brokenLocales.contains(Locale.getDefault().toString())) { savedLocale = KerberosTestUtil.overrideLocaleIfNotSpportedByMiniKdc();
savedLocale = Locale.getDefault();
Locale.setDefault(Locale.US);
}
log.info("####SETUP_START " + getTestName()); log.info("####SETUP_START " + getTestName());
createTempDir(); createTempDir();
@ -124,10 +114,7 @@ public class SaslZkACLProviderTest extends SolrTestCaseJ4 {
@Override @Override
public void tearDown() throws Exception { public void tearDown() throws Exception {
zkServer.shutdown(); zkServer.shutdown();
Locale.setDefault(savedLocale);
if (savedLocale != null) {
Locale.setDefault(savedLocale);
}
super.tearDown(); super.tearDown();
} }

View File

@ -23,9 +23,6 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule; import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
import org.apache.http.HttpException; import org.apache.http.HttpException;
@ -63,12 +60,6 @@ public class TestAuthenticationFramework extends TestMiniSolrCloudCluster {
static String requestUsername = MockAuthenticationPlugin.expectedUsername; static String requestUsername = MockAuthenticationPlugin.expectedUsername;
static String requestPassword = MockAuthenticationPlugin.expectedPassword; static String requestPassword = MockAuthenticationPlugin.expectedPassword;
protected final static List<String> brokenLocales =
Arrays.asList(
"th_TH_TH_#u-nu-thai",
"ja_JP_JP_#u-ca-japanese",
"hi_IN");
@Rule @Rule
public TestRule solrTestRules = RuleChain public TestRule solrTestRules = RuleChain
.outerRule(new SystemPropertiesRestoreRule()); .outerRule(new SystemPropertiesRestoreRule());
@ -80,9 +71,6 @@ public class TestAuthenticationFramework extends TestMiniSolrCloudCluster {
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {
if (brokenLocales.contains(Locale.getDefault().toString())) {
Locale.setDefault(Locale.US);
}
setupAuthenticationPlugin(); setupAuthenticationPlugin();
super.setUp(); super.setUp();
} }

View File

@ -19,8 +19,6 @@ package org.apache.solr.cloud;
import javax.security.auth.login.Configuration; import javax.security.auth.login.Configuration;
import java.io.File; import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
@ -62,14 +60,9 @@ public class TestMiniSolrCloudClusterKerberos extends TestMiniSolrCloudCluster {
REPLICATION_FACTOR = 2; REPLICATION_FACTOR = 2;
} }
protected final static List<String> brokenLocales =
Arrays.asList(
"th_TH_TH_#u-nu-thai",
"ja_JP_JP_#u-ca-japanese",
"hi_IN");
private MiniKdc kdc; private MiniKdc kdc;
private Locale savedLocale; // in case locale is broken and we need to fill in a working locale
@Rule @Rule
public TestRule solrTestRules = RuleChain public TestRule solrTestRules = RuleChain
.outerRule(new SystemPropertiesRestoreRule()); .outerRule(new SystemPropertiesRestoreRule());
@ -81,9 +74,7 @@ public class TestMiniSolrCloudClusterKerberos extends TestMiniSolrCloudCluster {
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {
if (brokenLocales.contains(Locale.getDefault().toString())) { savedLocale = KerberosTestUtil.overrideLocaleIfNotSpportedByMiniKdc();
Locale.setDefault(Locale.US);
}
super.setUp(); super.setUp();
setupMiniKdc(); setupMiniKdc();
} }
@ -171,6 +162,7 @@ public class TestMiniSolrCloudClusterKerberos extends TestMiniSolrCloudCluster {
if (kdc != null) { if (kdc != null) {
kdc.stop(); kdc.stop();
} }
Locale.setDefault(savedLocale);
super.tearDown(); super.tearDown();
} }
} }

View File

@ -18,10 +18,9 @@ package org.apache.solr.cloud;
*/ */
import javax.security.auth.login.Configuration; import javax.security.auth.login.Configuration;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.apache.commons.io.Charsets; import org.apache.commons.io.Charsets;
@ -49,20 +48,14 @@ public class TestSolrCloudWithKerberos extends AbstractFullDistribZkTestBase {
static final int TIMEOUT = 10000; static final int TIMEOUT = 10000;
private MiniKdc kdc; private MiniKdc kdc;
protected final static List<String> brokenLocales = private Locale savedLocale; // in case locale is broken and we need to fill in a working locale
Arrays.asList(
"th_TH_TH_#u-nu-thai",
"ja_JP_JP_#u-ca-japanese",
"hi_IN");
Configuration originalConfig = Configuration.getConfiguration(); Configuration originalConfig = Configuration.getConfiguration();
@Override @Override
public void distribSetUp() throws Exception { public void distribSetUp() throws Exception {
//SSLTestConfig.setSSLSystemProperties(); //SSLTestConfig.setSSLSystemProperties();
if (brokenLocales.contains(Locale.getDefault().toString())) { savedLocale = KerberosTestUtil.overrideLocaleIfNotSpportedByMiniKdc();
Locale.setDefault(Locale.US);
}
// Use just one jetty // Use just one jetty
this.sliceCount = 0; this.sliceCount = 0;
this.fixShardCount(1); this.fixShardCount(1);
@ -198,6 +191,7 @@ public class TestSolrCloudWithKerberos extends AbstractFullDistribZkTestBase {
kdc.stop(); kdc.stop();
} }
//SSLTestConfig.clearSSLSystemProperties(); //SSLTestConfig.clearSSLSystemProperties();
Locale.setDefault(savedLocale);
super.distribTearDown(); super.distribTearDown();
} }
} }

View File

@ -20,7 +20,6 @@ package org.apache.solr.cloud;
import javax.security.auth.login.Configuration; import javax.security.auth.login.Configuration;
import java.io.File; import java.io.File;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Properties; import java.util.Properties;
@ -76,14 +75,9 @@ public class TestSolrCloudWithKerberosAlt extends LuceneTestCase {
REPLICATION_FACTOR = 1; REPLICATION_FACTOR = 1;
} }
protected final static List<String> brokenLocales =
Arrays.asList(
"th_TH_TH_#u-nu-thai",
"ja_JP_JP_#u-ca-japanese",
"hi_IN");
private MiniKdc kdc; private MiniKdc kdc;
private Locale savedLocale; // in case locale is broken and we need to fill in a working locale
@Rule @Rule
public TestRule solrTestRules = RuleChain public TestRule solrTestRules = RuleChain
.outerRule(new SystemPropertiesRestoreRule()); .outerRule(new SystemPropertiesRestoreRule());
@ -95,9 +89,7 @@ public class TestSolrCloudWithKerberosAlt extends LuceneTestCase {
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {
if (brokenLocales.contains(Locale.getDefault().toString())) { savedLocale = KerberosTestUtil.overrideLocaleIfNotSpportedByMiniKdc();
Locale.setDefault(Locale.US);
}
super.setUp(); super.setUp();
setupMiniKdc(); setupMiniKdc();
HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer()); HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
@ -237,6 +229,7 @@ public class TestSolrCloudWithKerberosAlt extends LuceneTestCase {
if (kdc != null) { if (kdc != null) {
kdc.stop(); kdc.stop();
} }
Locale.setDefault(savedLocale);
super.tearDown(); super.tearDown();
} }
} }