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.
(Timothy Potter)
* SOLR-7183: Fix Locale blacklisting for Minikdc based tests. (Ishan Chattopadhyaya, hossman
via Anshum Gupta)
================== 5.1.0 ==================
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;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
@ -119,4 +122,27 @@ public class KerberosTestUtil {
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.IOException;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import javax.security.auth.login.Configuration;
@ -52,12 +50,7 @@ public class SaslZkACLProviderTest extends SolrTestCaseJ4 {
.getLogger(SaslZkACLProviderTest.class);
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 ZkTestServer zkServer;
@ -77,10 +70,7 @@ public class SaslZkACLProviderTest extends SolrTestCaseJ4 {
@Override
public void setUp() throws Exception {
super.setUp();
if (brokenLocales.contains(Locale.getDefault().toString())) {
savedLocale = Locale.getDefault();
Locale.setDefault(Locale.US);
}
savedLocale = KerberosTestUtil.overrideLocaleIfNotSpportedByMiniKdc();
log.info("####SETUP_START " + getTestName());
createTempDir();
@ -124,10 +114,7 @@ public class SaslZkACLProviderTest extends SolrTestCaseJ4 {
@Override
public void tearDown() throws Exception {
zkServer.shutdown();
if (savedLocale != null) {
Locale.setDefault(savedLocale);
}
super.tearDown();
}

View File

@ -23,9 +23,6 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
import org.apache.http.HttpException;
@ -63,12 +60,6 @@ public class TestAuthenticationFramework extends TestMiniSolrCloudCluster {
static String requestUsername = MockAuthenticationPlugin.expectedUsername;
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
public TestRule solrTestRules = RuleChain
.outerRule(new SystemPropertiesRestoreRule());
@ -80,9 +71,6 @@ public class TestAuthenticationFramework extends TestMiniSolrCloudCluster {
@Override
public void setUp() throws Exception {
if (brokenLocales.contains(Locale.getDefault().toString())) {
Locale.setDefault(Locale.US);
}
setupAuthenticationPlugin();
super.setUp();
}

View File

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

View File

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

View File

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