HADOOP-8699. some common testcases create core-site.xml in test-classes making other testcases to fail. (tucu)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1373206 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f41497c141
commit
fd8ce04dc5
@ -420,6 +420,9 @@ Branch-2 ( Unreleased changes )
|
|||||||
|
|
||||||
HADOOP-8660. TestPseudoAuthenticator failing with NPE. (tucu)
|
HADOOP-8660. TestPseudoAuthenticator failing with NPE. (tucu)
|
||||||
|
|
||||||
|
HADOOP-8699. some common testcases create core-site.xml in test-classes
|
||||||
|
making other testcases to fail. (tucu)
|
||||||
|
|
||||||
Release 2.0.0-alpha - 05-23-2012
|
Release 2.0.0-alpha - 05-23-2012
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.hadoop.http;
|
package org.apache.hadoop.http;
|
||||||
|
|
||||||
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
@ -37,6 +38,11 @@ public class HttpConfig {
|
|||||||
CommonConfigurationKeysPublic.HADOOP_SSL_ENABLED_DEFAULT);
|
CommonConfigurationKeysPublic.HADOOP_SSL_ENABLED_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
static void setSecure(boolean secure) {
|
||||||
|
sslEnabled = secure;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isSecure() {
|
public static boolean isSecure() {
|
||||||
return sslEnabled;
|
return sslEnabled;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,8 @@ import java.net.URL;
|
|||||||
* corresponding HTTPS URL.
|
* corresponding HTTPS URL.
|
||||||
*/
|
*/
|
||||||
public class TestSSLHttpServer extends HttpServerFunctionalTest {
|
public class TestSSLHttpServer extends HttpServerFunctionalTest {
|
||||||
|
private static final String CONFIG_SITE_XML = "sslhttpserver-site.xml";
|
||||||
|
|
||||||
private static final String BASEDIR =
|
private static final String BASEDIR =
|
||||||
System.getProperty("test.build.dir", "target/test-dir") + "/" +
|
System.getProperty("test.build.dir", "target/test-dir") + "/" +
|
||||||
TestSSLHttpServer.class.getSimpleName();
|
TestSSLHttpServer.class.getSimpleName();
|
||||||
@ -49,8 +51,10 @@ public class TestSSLHttpServer extends HttpServerFunctionalTest {
|
|||||||
private static HttpServer server;
|
private static HttpServer server;
|
||||||
private static URL baseUrl;
|
private static URL baseUrl;
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
|
HttpConfig.setSecure(true);
|
||||||
File base = new File(BASEDIR);
|
File base = new File(BASEDIR);
|
||||||
FileUtil.fullyDelete(base);
|
FileUtil.fullyDelete(base);
|
||||||
base.mkdirs();
|
base.mkdirs();
|
||||||
@ -66,11 +70,12 @@ public class TestSSLHttpServer extends HttpServerFunctionalTest {
|
|||||||
//we do this trick because the MR AppMaster is started in another VM and
|
//we do this trick because the MR AppMaster is started in another VM and
|
||||||
//the HttpServer configuration is not loaded from the job.xml but from the
|
//the HttpServer configuration is not loaded from the job.xml but from the
|
||||||
//site.xml files in the classpath
|
//site.xml files in the classpath
|
||||||
Writer writer = new FileWriter(classpathDir + "/core-site.xml");
|
Writer writer = new FileWriter(new File(classpathDir, CONFIG_SITE_XML));
|
||||||
conf.writeXml(writer);
|
conf.writeXml(writer);
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
||||||
conf.setInt(HttpServer.HTTP_MAX_THREADS, 10);
|
conf.setInt(HttpServer.HTTP_MAX_THREADS, 10);
|
||||||
|
conf.addResource(CONFIG_SITE_XML);
|
||||||
server = createServer("test", conf);
|
server = createServer("test", conf);
|
||||||
server.addServlet("echo", "/echo", TestHttpServer.EchoServlet.class);
|
server.addServlet("echo", "/echo", TestHttpServer.EchoServlet.class);
|
||||||
server.start();
|
server.start();
|
||||||
@ -83,7 +88,8 @@ public class TestSSLHttpServer extends HttpServerFunctionalTest {
|
|||||||
server.stop();
|
server.stop();
|
||||||
String classpathDir =
|
String classpathDir =
|
||||||
KeyStoreTestUtil.getClasspathDir(TestSSLHttpServer.class);
|
KeyStoreTestUtil.getClasspathDir(TestSSLHttpServer.class);
|
||||||
new File(classpathDir + "/core-site.xml").delete();
|
new File(classpathDir, CONFIG_SITE_XML).delete();
|
||||||
|
HttpConfig.setSecure(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,7 +104,9 @@ public class TestSSLHttpServer extends HttpServerFunctionalTest {
|
|||||||
private static String readOut(URL url) throws Exception {
|
private static String readOut(URL url) throws Exception {
|
||||||
StringBuilder out = new StringBuilder();
|
StringBuilder out = new StringBuilder();
|
||||||
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
|
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
|
||||||
SSLFactory sslf = new SSLFactory(SSLFactory.Mode.CLIENT, new Configuration());
|
Configuration conf = new Configuration();
|
||||||
|
conf.addResource(CONFIG_SITE_XML);
|
||||||
|
SSLFactory sslf = new SSLFactory(SSLFactory.Mode.CLIENT, conf);
|
||||||
sslf.init();
|
sslf.init();
|
||||||
conn.setSSLSocketFactory(sslf.createSSLSocketFactory());
|
conn.setSSLSocketFactory(sslf.createSSLSocketFactory());
|
||||||
InputStream in = conn.getInputStream();
|
InputStream in = conn.getInputStream();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user