mirror of
https://github.com/apache/sqoop.git
synced 2025-05-06 21:40:53 +08:00
SQOOP-1953: Sqoop2: Tomcat at beginning of Suite
(Abraham Elmahrek via Jarek Jarcec Cecho)
This commit is contained in:
parent
1857086722
commit
a59d69f6c4
2
pom.xml
2
pom.xml
@ -656,7 +656,7 @@ limitations under the License.
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.14</version>
|
||||
<version>2.18.1</version>
|
||||
<configuration>
|
||||
<forkCount>1</forkCount>
|
||||
<reuseForks>false</reuseForks>
|
||||
|
18
test/pom.xml
18
test/pom.xml
@ -196,6 +196,24 @@ limitations under the License.
|
||||
<suiteXmlFiles>
|
||||
<suiteXmlFile>src/test/resources/integration-tests-suite.xml</suiteXmlFile>
|
||||
</suiteXmlFiles>
|
||||
<properties>
|
||||
<suitename>integration-tests</suitename>
|
||||
</properties>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>upgrade-test</id>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
<phase>integration-test</phase>
|
||||
<configuration>
|
||||
<suiteXmlFiles>
|
||||
<suiteXmlFile>src/test/resources/upgrade-tests-suite.xml</suiteXmlFile>
|
||||
</suiteXmlFiles>
|
||||
<properties>
|
||||
<suitename>upgrade-tests</suitename>
|
||||
</properties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
@ -71,12 +71,18 @@ public void start() throws Exception {
|
||||
|
||||
prepareTemporaryPath();
|
||||
|
||||
// Source: http://cargo.codehaus.org/Functional+testing
|
||||
String tomcatPath = getTemporaryPath() + "/tomcat";
|
||||
String extractPath = tomcatPath + "/extract";
|
||||
String confPath = tomcatPath + "/conf";
|
||||
|
||||
// TODO(jarcec): We should parametrize those paths, version, etc...
|
||||
// Source: http://cargo.codehaus.org/Functional+testing
|
||||
Installer installer = new ZipURLInstaller(new URL("http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.36/bin/apache-tomcat-6.0.36.zip"));
|
||||
// Use null download path so that download path can be shared.
|
||||
Installer installer = new ZipURLInstaller(new URL("http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.36/bin/apache-tomcat-6.0.36.zip"), null, extractPath);
|
||||
installer.install();
|
||||
|
||||
LocalConfiguration configuration = (LocalConfiguration) new DefaultConfigurationFactory().createConfiguration("tomcat6x", ContainerType.INSTALLED, ConfigurationType.STANDALONE);
|
||||
LocalConfiguration configuration = (LocalConfiguration) new DefaultConfigurationFactory().createConfiguration("tomcat6x", ContainerType.INSTALLED, ConfigurationType.STANDALONE, confPath);
|
||||
container = (InstalledLocalContainer) new DefaultContainerFactory().createContainer("tomcat6x", ContainerType.INSTALLED, configuration);
|
||||
|
||||
// Set home to our installed tomcat instance
|
||||
@ -132,6 +138,9 @@ public void start() throws Exception {
|
||||
configuration.setProperty(ServletPropertySet.PORT, port.toString());
|
||||
|
||||
// Start Sqoop server
|
||||
LOG.info("Tomcat extract path: " + extractPath);
|
||||
LOG.info("Tomcat home path: " + installer.getHome());
|
||||
LOG.info("Tomcat config home path: " + confPath);
|
||||
LOG.info("Starting tomcat server on port " + port);
|
||||
container.start();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
import org.apache.sqoop.test.minicluster.TomcatSqoopMiniCluster;
|
||||
import org.apache.sqoop.test.utils.HdfsUtils;
|
||||
import org.testng.ITest;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.ITestContext;
|
||||
import org.testng.annotations.AfterSuite;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
@ -62,13 +62,11 @@ abstract public class TomcatTestCase implements ITest {
|
||||
/**
|
||||
* Temporary directory that will be used by the test.
|
||||
*
|
||||
* We will take TMP_PATH_BASE and append two subdirectories. First will be named
|
||||
* after fully qualified class name of current test class, second directory will
|
||||
* be named after current test method name. For example:
|
||||
* We will take TMP_PATH_BASE and append the test suite. For example:
|
||||
*
|
||||
* TMP_PATH_BASE/org.apache.sqoop.TestClass/testMethod/
|
||||
* TMP_PATH_BASE/TestConnectorsSuite
|
||||
*/
|
||||
private String tmpPath;
|
||||
private static String tmpPath;
|
||||
|
||||
/**
|
||||
* Hadoop cluster
|
||||
@ -83,12 +81,12 @@ abstract public class TomcatTestCase implements ITest {
|
||||
/**
|
||||
* Tomcat based Sqoop mini cluster
|
||||
*/
|
||||
private TomcatSqoopMiniCluster cluster;
|
||||
private static TomcatSqoopMiniCluster cluster;
|
||||
|
||||
/**
|
||||
* Sqoop client API.
|
||||
*/
|
||||
private SqoopClient client;
|
||||
private static SqoopClient client;
|
||||
|
||||
/**
|
||||
* Use the method name as the test name
|
||||
@ -97,11 +95,32 @@ public String getTestName() {
|
||||
return methodName;
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void setMethodName(Method method) throws Exception {
|
||||
methodName = method.getName();
|
||||
}
|
||||
|
||||
@BeforeSuite(alwaysRun = true)
|
||||
public void startHadoop() throws Exception {
|
||||
public void setupSuite(ITestContext context) throws Exception {
|
||||
tmpPath = HdfsUtils.joinPathFragments(TMP_PATH_BASE, context.getSuite().getName());
|
||||
|
||||
LOG.debug("Temporary Directory: " + getTemporaryPath());
|
||||
FileUtils.deleteDirectory(new File(getTemporaryPath()));
|
||||
|
||||
startHadoop();
|
||||
startSqoop();
|
||||
}
|
||||
|
||||
@AfterSuite(alwaysRun = true)
|
||||
public void tearDownSuite() throws Exception {
|
||||
stopSqoop();
|
||||
stopHadoop();
|
||||
}
|
||||
|
||||
protected void startHadoop() throws Exception {
|
||||
// Start Hadoop Clusters
|
||||
hadoopCluster = HadoopRunnerFactory.getHadoopCluster(System.getProperties(), HadoopMiniClusterRunner.class);
|
||||
hadoopCluster.setTemporaryPath(TMP_PATH_BASE);
|
||||
hadoopCluster.setTemporaryPath(getTemporaryPath());
|
||||
hadoopCluster.setConfiguration(hadoopCluster.prepareConfiguration(new JobConf()));
|
||||
hadoopCluster.start();
|
||||
|
||||
@ -110,16 +129,7 @@ public void startHadoop() throws Exception {
|
||||
LOG.debug("HDFS Client: " + hdfsClient);
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void startServer(Method method) throws Exception {
|
||||
methodName = method.getName();
|
||||
|
||||
// Get and set temporary path in hadoop cluster.
|
||||
tmpPath = HdfsUtils.joinPathFragments(TMP_PATH_BASE, getClass().getName(), getTestName());
|
||||
FileUtils.deleteDirectory(new File(tmpPath));
|
||||
|
||||
LOG.debug("Temporary Directory: " + tmpPath);
|
||||
|
||||
protected void startSqoop() throws Exception {
|
||||
// Start server
|
||||
cluster = createSqoopMiniCluster();
|
||||
cluster.start();
|
||||
@ -128,21 +138,17 @@ public void startServer(Method method) throws Exception {
|
||||
client = new SqoopClient(getServerUrl());
|
||||
}
|
||||
|
||||
@AfterMethod(alwaysRun = true)
|
||||
public void stopServer() throws Exception {
|
||||
protected void stopSqoop() throws Exception {
|
||||
cluster.stop();
|
||||
}
|
||||
|
||||
@AfterSuite(alwaysRun = true)
|
||||
public static void stopHadoop() throws Exception {
|
||||
protected void stopHadoop() throws Exception {
|
||||
hadoopCluster.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Sqoop MiniCluster instance that should be used for this test.
|
||||
*
|
||||
* This method will be executed only once prior each test execution.
|
||||
*
|
||||
* @return New instance of test mini cluster
|
||||
*/
|
||||
public TomcatSqoopMiniCluster createSqoopMiniCluster() throws Exception {
|
||||
@ -154,20 +160,28 @@ public TomcatSqoopMiniCluster createSqoopMiniCluster() throws Exception {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public SqoopClient getClient() {
|
||||
public static SqoopClient getClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
public SqoopMiniCluster getCluster() {
|
||||
public static void setClient(SqoopClient sqoopClient) {
|
||||
client = sqoopClient;
|
||||
}
|
||||
|
||||
public static SqoopMiniCluster getCluster() {
|
||||
return cluster;
|
||||
}
|
||||
|
||||
public String getTemporaryPath() {
|
||||
public static void setCluster(TomcatSqoopMiniCluster sqoopMiniClusterluster) {
|
||||
cluster = sqoopMiniClusterluster;
|
||||
}
|
||||
|
||||
public static String getTemporaryPath() {
|
||||
return tmpPath;
|
||||
}
|
||||
|
||||
public String getSqoopMiniClusterTemporaryPath() {
|
||||
return HdfsUtils.joinPathFragments(tmpPath, "sqoop-mini-cluster");
|
||||
public static String getSqoopMiniClusterTemporaryPath() {
|
||||
return HdfsUtils.joinPathFragments(getTemporaryPath(), "sqoop-mini-cluster");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,7 +189,7 @@ public String getSqoopMiniClusterTemporaryPath() {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getServerUrl() {
|
||||
public static String getServerUrl() {
|
||||
return cluster.getServerUrl();
|
||||
}
|
||||
|
||||
|
@ -18,10 +18,14 @@
|
||||
package org.apache.sqoop.integration.repository.derby.upgrade;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.sqoop.client.SqoopClient;
|
||||
import org.apache.sqoop.test.minicluster.TomcatSqoopMiniCluster;
|
||||
import org.apache.sqoop.test.testcases.TomcatTestCase;
|
||||
import org.apache.sqoop.test.utils.CompressionUtils;
|
||||
import org.apache.sqoop.test.utils.HdfsUtils;
|
||||
import org.testng.ITestContext;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
@ -120,18 +124,43 @@ protected Map<String, String> getRepositoryConfiguration() {
|
||||
public abstract Integer[] getDeleteJobIds();
|
||||
|
||||
public String getRepositoryPath() {
|
||||
return HdfsUtils.joinPathFragments(getTemporaryPath(), "repo");
|
||||
return HdfsUtils.joinPathFragments(getTemporaryTomcatPath(), "repo");
|
||||
}
|
||||
|
||||
public String getTemporaryTomcatPath() {
|
||||
return HdfsUtils.joinPathFragments(getTemporaryPath(), getClass().getCanonicalName(), getTestName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TomcatSqoopMiniCluster createSqoopMiniCluster() throws Exception {
|
||||
public void startSqoop() throws Exception {
|
||||
// Do nothing so that Sqoop isn't started before Suite.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopSqoop() throws Exception {
|
||||
// Do nothing so that Sqoop isn't stopped after Suite.
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
public void startSqoopMiniCluster(ITestContext context) throws Exception {
|
||||
// Prepare older repository structures
|
||||
InputStream tarballStream = getClass().getResourceAsStream(getPathToRepositoryTarball());
|
||||
assertNotNull(tarballStream);
|
||||
CompressionUtils.untarStreamToDirectory(tarballStream, getRepositoryPath());
|
||||
|
||||
// And use them for new Derby repo instance
|
||||
return new DerbySqoopMiniCluster(getRepositoryPath(), getSqoopMiniClusterTemporaryPath(), hadoopCluster.getConfiguration());
|
||||
setCluster(new DerbySqoopMiniCluster(getRepositoryPath(), getTemporaryTomcatPath() + "/sqoop-mini-cluster", hadoopCluster.getConfiguration()));
|
||||
|
||||
// Start server
|
||||
getCluster().start();
|
||||
|
||||
// Initialize Sqoop Client API
|
||||
setClient(new SqoopClient(getServerUrl()));
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
public void stopSqoopMiniCluster() throws Exception {
|
||||
getCluster().stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -26,12 +26,6 @@ limitations under the License.
|
||||
</packages>
|
||||
</test>
|
||||
|
||||
<test name="RepositoryTests">
|
||||
<packages>
|
||||
<package name="org.apache.sqoop.integration.repository.derby.upgrade"/>
|
||||
</packages>
|
||||
</test>
|
||||
|
||||
<test name="ServerTests">
|
||||
<packages>
|
||||
<package name="org.apache.sqoop.integration.server"/>
|
||||
|
29
test/src/test/resources/upgrade-tests-suite.xml
Normal file
29
test/src/test/resources/upgrade-tests-suite.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||
|
||||
<suite name="UpgradeTests" verbose="2" parallel="false">
|
||||
|
||||
<test name="RepositoryTests">
|
||||
<packages>
|
||||
<package name="org.apache.sqoop.integration.repository.derby.upgrade"/>
|
||||
</packages>
|
||||
</test>
|
||||
|
||||
</suite>
|
Loading…
Reference in New Issue
Block a user