mirror of
https://github.com/apache/sqoop.git
synced 2025-05-07 00:03:22 +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>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.14</version>
|
<version>2.18.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<forkCount>1</forkCount>
|
<forkCount>1</forkCount>
|
||||||
<reuseForks>false</reuseForks>
|
<reuseForks>false</reuseForks>
|
||||||
|
18
test/pom.xml
18
test/pom.xml
@ -196,6 +196,24 @@ limitations under the License.
|
|||||||
<suiteXmlFiles>
|
<suiteXmlFiles>
|
||||||
<suiteXmlFile>src/test/resources/integration-tests-suite.xml</suiteXmlFile>
|
<suiteXmlFile>src/test/resources/integration-tests-suite.xml</suiteXmlFile>
|
||||||
</suiteXmlFiles>
|
</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>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
@ -71,12 +71,18 @@ public void start() throws Exception {
|
|||||||
|
|
||||||
prepareTemporaryPath();
|
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...
|
// TODO(jarcec): We should parametrize those paths, version, etc...
|
||||||
// Source: http://cargo.codehaus.org/Functional+testing
|
// 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();
|
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);
|
container = (InstalledLocalContainer) new DefaultContainerFactory().createContainer("tomcat6x", ContainerType.INSTALLED, configuration);
|
||||||
|
|
||||||
// Set home to our installed tomcat instance
|
// Set home to our installed tomcat instance
|
||||||
@ -132,6 +138,9 @@ public void start() throws Exception {
|
|||||||
configuration.setProperty(ServletPropertySet.PORT, port.toString());
|
configuration.setProperty(ServletPropertySet.PORT, port.toString());
|
||||||
|
|
||||||
// Start Sqoop server
|
// 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);
|
LOG.info("Starting tomcat server on port " + port);
|
||||||
container.start();
|
container.start();
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
import org.apache.sqoop.test.minicluster.TomcatSqoopMiniCluster;
|
import org.apache.sqoop.test.minicluster.TomcatSqoopMiniCluster;
|
||||||
import org.apache.sqoop.test.utils.HdfsUtils;
|
import org.apache.sqoop.test.utils.HdfsUtils;
|
||||||
import org.testng.ITest;
|
import org.testng.ITest;
|
||||||
import org.testng.annotations.AfterMethod;
|
import org.testng.ITestContext;
|
||||||
import org.testng.annotations.AfterSuite;
|
import org.testng.annotations.AfterSuite;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.BeforeSuite;
|
import org.testng.annotations.BeforeSuite;
|
||||||
@ -62,13 +62,11 @@ abstract public class TomcatTestCase implements ITest {
|
|||||||
/**
|
/**
|
||||||
* Temporary directory that will be used by the test.
|
* Temporary directory that will be used by the test.
|
||||||
*
|
*
|
||||||
* We will take TMP_PATH_BASE and append two subdirectories. First will be named
|
* We will take TMP_PATH_BASE and append the test suite. For example:
|
||||||
* after fully qualified class name of current test class, second directory will
|
|
||||||
* be named after current test method name. For example:
|
|
||||||
*
|
*
|
||||||
* TMP_PATH_BASE/org.apache.sqoop.TestClass/testMethod/
|
* TMP_PATH_BASE/TestConnectorsSuite
|
||||||
*/
|
*/
|
||||||
private String tmpPath;
|
private static String tmpPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hadoop cluster
|
* Hadoop cluster
|
||||||
@ -83,12 +81,12 @@ abstract public class TomcatTestCase implements ITest {
|
|||||||
/**
|
/**
|
||||||
* Tomcat based Sqoop mini cluster
|
* Tomcat based Sqoop mini cluster
|
||||||
*/
|
*/
|
||||||
private TomcatSqoopMiniCluster cluster;
|
private static TomcatSqoopMiniCluster cluster;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sqoop client API.
|
* Sqoop client API.
|
||||||
*/
|
*/
|
||||||
private SqoopClient client;
|
private static SqoopClient client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use the method name as the test name
|
* Use the method name as the test name
|
||||||
@ -97,11 +95,32 @@ public String getTestName() {
|
|||||||
return methodName;
|
return methodName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BeforeMethod(alwaysRun = true)
|
||||||
|
public void setMethodName(Method method) throws Exception {
|
||||||
|
methodName = method.getName();
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeSuite(alwaysRun = true)
|
@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
|
// Start Hadoop Clusters
|
||||||
hadoopCluster = HadoopRunnerFactory.getHadoopCluster(System.getProperties(), HadoopMiniClusterRunner.class);
|
hadoopCluster = HadoopRunnerFactory.getHadoopCluster(System.getProperties(), HadoopMiniClusterRunner.class);
|
||||||
hadoopCluster.setTemporaryPath(TMP_PATH_BASE);
|
hadoopCluster.setTemporaryPath(getTemporaryPath());
|
||||||
hadoopCluster.setConfiguration(hadoopCluster.prepareConfiguration(new JobConf()));
|
hadoopCluster.setConfiguration(hadoopCluster.prepareConfiguration(new JobConf()));
|
||||||
hadoopCluster.start();
|
hadoopCluster.start();
|
||||||
|
|
||||||
@ -110,16 +129,7 @@ public void startHadoop() throws Exception {
|
|||||||
LOG.debug("HDFS Client: " + hdfsClient);
|
LOG.debug("HDFS Client: " + hdfsClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeMethod(alwaysRun = true)
|
protected void startSqoop() throws Exception {
|
||||||
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);
|
|
||||||
|
|
||||||
// Start server
|
// Start server
|
||||||
cluster = createSqoopMiniCluster();
|
cluster = createSqoopMiniCluster();
|
||||||
cluster.start();
|
cluster.start();
|
||||||
@ -128,21 +138,17 @@ public void startServer(Method method) throws Exception {
|
|||||||
client = new SqoopClient(getServerUrl());
|
client = new SqoopClient(getServerUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterMethod(alwaysRun = true)
|
protected void stopSqoop() throws Exception {
|
||||||
public void stopServer() throws Exception {
|
|
||||||
cluster.stop();
|
cluster.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterSuite(alwaysRun = true)
|
protected void stopHadoop() throws Exception {
|
||||||
public static void stopHadoop() throws Exception {
|
|
||||||
hadoopCluster.stop();
|
hadoopCluster.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Sqoop MiniCluster instance that should be used for this test.
|
* 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
|
* @return New instance of test mini cluster
|
||||||
*/
|
*/
|
||||||
public TomcatSqoopMiniCluster createSqoopMiniCluster() throws Exception {
|
public TomcatSqoopMiniCluster createSqoopMiniCluster() throws Exception {
|
||||||
@ -154,20 +160,28 @@ public TomcatSqoopMiniCluster createSqoopMiniCluster() throws Exception {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public SqoopClient getClient() {
|
public static SqoopClient getClient() {
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SqoopMiniCluster getCluster() {
|
public static void setClient(SqoopClient sqoopClient) {
|
||||||
|
client = sqoopClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SqoopMiniCluster getCluster() {
|
||||||
return cluster;
|
return cluster;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTemporaryPath() {
|
public static void setCluster(TomcatSqoopMiniCluster sqoopMiniClusterluster) {
|
||||||
|
cluster = sqoopMiniClusterluster;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getTemporaryPath() {
|
||||||
return tmpPath;
|
return tmpPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSqoopMiniClusterTemporaryPath() {
|
public static String getSqoopMiniClusterTemporaryPath() {
|
||||||
return HdfsUtils.joinPathFragments(tmpPath, "sqoop-mini-cluster");
|
return HdfsUtils.joinPathFragments(getTemporaryPath(), "sqoop-mini-cluster");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,7 +189,7 @@ public String getSqoopMiniClusterTemporaryPath() {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getServerUrl() {
|
public static String getServerUrl() {
|
||||||
return cluster.getServerUrl();
|
return cluster.getServerUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,10 +18,14 @@
|
|||||||
package org.apache.sqoop.integration.repository.derby.upgrade;
|
package org.apache.sqoop.integration.repository.derby.upgrade;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.apache.sqoop.client.SqoopClient;
|
||||||
import org.apache.sqoop.test.minicluster.TomcatSqoopMiniCluster;
|
import org.apache.sqoop.test.minicluster.TomcatSqoopMiniCluster;
|
||||||
import org.apache.sqoop.test.testcases.TomcatTestCase;
|
import org.apache.sqoop.test.testcases.TomcatTestCase;
|
||||||
import org.apache.sqoop.test.utils.CompressionUtils;
|
import org.apache.sqoop.test.utils.CompressionUtils;
|
||||||
import org.apache.sqoop.test.utils.HdfsUtils;
|
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.testng.annotations.Test;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
@ -120,18 +124,43 @@ protected Map<String, String> getRepositoryConfiguration() {
|
|||||||
public abstract Integer[] getDeleteJobIds();
|
public abstract Integer[] getDeleteJobIds();
|
||||||
|
|
||||||
public String getRepositoryPath() {
|
public String getRepositoryPath() {
|
||||||
return HdfsUtils.joinPathFragments(getTemporaryPath(), "repo");
|
return HdfsUtils.joinPathFragments(getTemporaryTomcatPath(), "repo");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTemporaryTomcatPath() {
|
||||||
|
return HdfsUtils.joinPathFragments(getTemporaryPath(), getClass().getCanonicalName(), getTestName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
// Prepare older repository structures
|
||||||
InputStream tarballStream = getClass().getResourceAsStream(getPathToRepositoryTarball());
|
InputStream tarballStream = getClass().getResourceAsStream(getPathToRepositoryTarball());
|
||||||
assertNotNull(tarballStream);
|
assertNotNull(tarballStream);
|
||||||
CompressionUtils.untarStreamToDirectory(tarballStream, getRepositoryPath());
|
CompressionUtils.untarStreamToDirectory(tarballStream, getRepositoryPath());
|
||||||
|
|
||||||
// And use them for new Derby repo instance
|
// 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
|
@Test
|
||||||
|
@ -26,12 +26,6 @@ limitations under the License.
|
|||||||
</packages>
|
</packages>
|
||||||
</test>
|
</test>
|
||||||
|
|
||||||
<test name="RepositoryTests">
|
|
||||||
<packages>
|
|
||||||
<package name="org.apache.sqoop.integration.repository.derby.upgrade"/>
|
|
||||||
</packages>
|
|
||||||
</test>
|
|
||||||
|
|
||||||
<test name="ServerTests">
|
<test name="ServerTests">
|
||||||
<packages>
|
<packages>
|
||||||
<package name="org.apache.sqoop.integration.server"/>
|
<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