5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-08 02:19:40 +08:00

SQOOP-2619. Sqoop2: Provide ability to run integration tests against real Sqoop 2 server

(Jarcec via Hari)
This commit is contained in:
Hari Shreedharan 2015-10-22 00:31:10 -07:00
parent 42d268bc9e
commit 6a10db0153
4 changed files with 99 additions and 2 deletions

View File

@ -21,6 +21,7 @@
import org.apache.log4j.Logger;
import org.apache.sqoop.test.minicluster.JettySqoopMiniCluster;
import org.apache.sqoop.test.minicluster.SqoopMiniCluster;
import org.apache.sqoop.test.minicluster.SqoopMiniClusterFactory;
/**
* Sqoop infrastructure provider.
@ -37,7 +38,7 @@ public SqoopInfrastructureProvider() {}
@Override
public void start() {
try {
instance = new JettySqoopMiniCluster(rootPath, hadoopConf);
instance = SqoopMiniClusterFactory.getSqoopMiniCluster(System.getProperties(), JettySqoopMiniCluster.class, rootPath, hadoopConf);
instance.start();
} catch (Exception e) {
LOG.error("Could not start Sqoop mini cluster.", e);

View File

@ -0,0 +1,59 @@
/**
* 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.
*/
package org.apache.sqoop.test.minicluster;
import org.apache.hadoop.conf.Configuration;
/**
*/
public class RealSqoopCluster extends SqoopMiniCluster {
private final static String SERVER_URL_KEY = "org.apache.sqoop.minicluster.real.server_url";
private String serverUrl;
public RealSqoopCluster(String temporaryPath) throws Exception {
super(temporaryPath);
serverUrl = System.getProperty(SERVER_URL_KEY);
if(serverUrl == null) {
throw new RuntimeException("Missing URL for real Sqoop 2 server: " + SERVER_URL_KEY);
}
}
public RealSqoopCluster(String temporaryPath, Configuration configuration) throws Exception {
this(temporaryPath);
// We're ignoring Hadoop configuration as we're running against real cluster
}
@Override
public void start() throws Exception {
// Void operation
}
@Override
public void stop() throws Exception {
// Void operation
}
@Override
public String getServerUrl() {
return serverUrl;
}
}

View File

@ -0,0 +1,38 @@
/**
* 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.
*/
package org.apache.sqoop.test.minicluster;
import org.apache.hadoop.conf.Configuration;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Properties;
/**
*/
public class SqoopMiniClusterFactory {
public static final String MINICLUSTER_CLASS_PROPERTY = "sqoop.minicluster.class";
public static SqoopMiniCluster getSqoopMiniCluster(Properties properties, Class<? extends SqoopMiniCluster> defaultClusterClass, String temporaryPath, Configuration configuration) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
String className = properties.getProperty(MINICLUSTER_CLASS_PROPERTY);
Class<?> klass = className == null ? defaultClusterClass : Class.forName(className);
Constructor konstructor = klass.getConstructor(String.class, Configuration.class);
return (SqoopMiniCluster)konstructor.newInstance(temporaryPath, configuration);
}
}

View File

@ -40,7 +40,6 @@ public void testVersion() {
VersionBean versionBean = versionRequest.read(getSqoopServerUrl());
assertEquals(versionBean.getBuildVersion(), VersionInfo.getBuildVersion());
assertEquals(versionBean.getBuildDate(), VersionInfo.getBuildDate());
assertEquals(versionBean.getSourceRevision(), VersionInfo.getSourceRevision());
assertEquals(versionBean.getSystemUser(), VersionInfo.getUser());
assertEquals(versionBean.getSourceRevision(), VersionInfo.getSourceRevision());