mirror of
https://github.com/apache/sqoop.git
synced 2025-05-07 00:20:58 +08:00
SQOOP-2341: Sqoop2: Test repository infrastructure
(Syed Hashmi via Abraham Elmahrek)
This commit is contained in:
parent
ad632361bb
commit
d2cf56680a
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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.common.test.repository;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
This class encapsulates the logic around generating properties for using
|
||||
derby as repository provider in Integration Tests
|
||||
*/
|
||||
public class DerbyRepositoryProvider extends RepositoryProviderBase {
|
||||
@Override
|
||||
public Map<String,String> getPropertiesMap() {
|
||||
Map<String, String> properties = new HashMap<String, String>();
|
||||
|
||||
properties.put("org.apache.sqoop.repository.provider", "org.apache.sqoop.repository.JdbcRepositoryProvider");
|
||||
properties.put("org.apache.sqoop.repository.schema.immutable", "false");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.handler", "org.apache.sqoop.repository.derby.DerbyRepositoryHandler");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.transaction.isolation", "READ_COMMITTED");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.maximum.connections", "10");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.url=jdbc:derby:memory:myDB;create", "true");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.driver", "org.apache.derby.jdbc.EmbeddedDriver");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.user", "sa");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.password", "");
|
||||
|
||||
return properties;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* 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.common.test.repository;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PostgresqlRepositoryProvider extends RepositoryProviderBase {
|
||||
|
||||
private static final String DRIVER = "org.postgresql.Driver";
|
||||
|
||||
private static final String CONNECTION = System.getProperties().getProperty(
|
||||
"sqoop.repository.postgresql.jdbc.url",
|
||||
"jdbc:postgresql://localhost/test"
|
||||
);
|
||||
|
||||
private static final String USERNAME = System.getProperties().getProperty(
|
||||
"sqoop.repository.postgresql.username",
|
||||
"sqoop"
|
||||
);
|
||||
|
||||
private static final String PASSWORD = System.getProperties().getProperty(
|
||||
"sqoop.repository.postgresql.password",
|
||||
"sqoop"
|
||||
);
|
||||
|
||||
@Override
|
||||
public Map<String,String> getPropertiesMap() {
|
||||
Map<String, String> properties = new HashMap<String, String>();
|
||||
properties.put("org.apache.sqoop.repository.provider", "org.apache.sqoop.repository.JdbcRepositoryProvider");
|
||||
properties.put("org.apache.sqoop.repository.schema.immutable", "false");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.handler", "org.apache.sqoop.repository.postgresql.PostgresqlRepositoryHandler");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.transaction.isolation", "READ_COMMITTED");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.maximum.connections", "10");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.url", CONNECTION);
|
||||
properties.put("org.apache.sqoop.repository.jdbc.driver", DRIVER);
|
||||
properties.put("org.apache.sqoop.repository.jdbc.user", USERNAME);
|
||||
properties.put("org.apache.sqoop.repository.jdbc.password", PASSWORD);
|
||||
|
||||
return properties;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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.common.test.repository;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class RepositoryProviderBase {
|
||||
public abstract Map<String,String> getPropertiesMap();
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* 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.common.test.repository;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Instantiate the right class for handling repository specific properties
|
||||
*/
|
||||
public class RepositoryProviderFactory {
|
||||
|
||||
public static final String REPOSITORY_CLASS_PROPERTY = "sqoop.repository.handler.class";
|
||||
|
||||
public static Map<String, String> getRepositoryProperties() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
String className = System.getProperty(REPOSITORY_CLASS_PROPERTY);
|
||||
RepositoryProviderBase repoProvider;
|
||||
if(className == null) {
|
||||
repoProvider = new DerbyRepositoryProvider();
|
||||
} else {
|
||||
Class<?> klass = Class.forName(className);
|
||||
repoProvider = (RepositoryProviderBase) klass.newInstance();
|
||||
}
|
||||
return repoProvider.getPropertiesMap();
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.sqoop.core.ConfigurationConstants;
|
||||
import org.apache.sqoop.common.test.repository.RepositoryProviderFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -104,7 +105,7 @@ public String getLogPath() {
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
protected void prepareTemporaryPath() throws IOException {
|
||||
protected void prepareTemporaryPath() throws Exception {
|
||||
File tmpDir = new File(getTemporaryPath());
|
||||
File configDir = new File(getConfigurationPath());
|
||||
File logDir = new File(getLogPath());
|
||||
@ -168,20 +169,8 @@ protected Map<String, String> getLoggerConfiguration() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
protected Map<String, String> getRepositoryConfiguration() {
|
||||
Map<String, String> properties = new HashMap<String, String>();
|
||||
|
||||
properties.put("org.apache.sqoop.repository.provider", "org.apache.sqoop.repository.JdbcRepositoryProvider");
|
||||
properties.put("org.apache.sqoop.repository.schema.immutable", "false");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.handler", "org.apache.sqoop.repository.derby.DerbyRepositoryHandler");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.transaction.isolation", "READ_COMMITTED");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.maximum.connections", "10");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.url=jdbc:derby:memory:myDB;create", "true");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.driver", "org.apache.derby.jdbc.EmbeddedDriver");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.user", "sa");
|
||||
properties.put("org.apache.sqoop.repository.jdbc.password", "");
|
||||
|
||||
return properties;
|
||||
protected Map<String, String> getRepositoryConfiguration() throws Exception {
|
||||
return RepositoryProviderFactory.getRepositoryProperties();
|
||||
}
|
||||
|
||||
protected Map<String, String> getSubmissionEngineConfiguration() {
|
||||
|
Loading…
Reference in New Issue
Block a user