diff --git a/src/java/com/cloudera/sqoop/manager/DirectPostgresqlManager.java b/src/java/com/cloudera/sqoop/manager/DirectPostgresqlManager.java index 5cf61d4b..6d3a378d 100644 --- a/src/java/com/cloudera/sqoop/manager/DirectPostgresqlManager.java +++ b/src/java/com/cloudera/sqoop/manager/DirectPostgresqlManager.java @@ -349,10 +349,8 @@ public void importTable(ImportJobContext context) } } - if (!DirectImportUtils.isLocalhost(hostname)) { - args.add("--host"); - args.add(hostname); - } + args.add("--host"); + args.add(hostname); if (port != -1) { args.add("--port"); diff --git a/src/test/com/cloudera/sqoop/SmokeTests.java b/src/test/com/cloudera/sqoop/SmokeTests.java index 9e68e74c..60c9bd99 100644 --- a/src/test/com/cloudera/sqoop/SmokeTests.java +++ b/src/test/com/cloudera/sqoop/SmokeTests.java @@ -35,7 +35,6 @@ import com.cloudera.sqoop.metastore.TestSavedJobs; import com.cloudera.sqoop.orm.TestClassWriter; import com.cloudera.sqoop.orm.TestParseMethods; -import com.cloudera.sqoop.util.TestDirectImportUtils; import junit.framework.Test; import junit.framework.TestSuite; @@ -74,7 +73,6 @@ public static Test suite() { suite.addTestSuite(TestBlobRef.class); suite.addTestSuite(TestClobRef.class); suite.addTestSuite(TestLargeObjectLoader.class); - suite.addTestSuite(TestDirectImportUtils.class); suite.addTestSuite(TestLobFile.class); suite.addTestSuite(TestExportUpdate.class); suite.addTestSuite(TestSavedJobs.class); diff --git a/src/test/com/cloudera/sqoop/manager/PostgresqlTest.java b/src/test/com/cloudera/sqoop/manager/PostgresqlTest.java index 2ac6bd37..5caac7a2 100644 --- a/src/test/com/cloudera/sqoop/manager/PostgresqlTest.java +++ b/src/test/com/cloudera/sqoop/manager/PostgresqlTest.java @@ -57,8 +57,14 @@ * following in /etc/postgresql/8.3/main/pg_hba.conf: * local all all trust * host all all 127.0.0.1/32 trust - * - * ... and comment out any other lines referencing 127.0.0.1. + * host all all ::1/128 trust + * + * ... and comment out any other lines referencing 127.0.0.1 or ::1. + * + * Also in the file /etc/postgresql/8.3/main/postgresql.conf, uncomment + * the line that starts with listen_addresses and set its value to '*' as + * follows + * listen_address = '*' * * For postgresql 8.1, this may be in /var/lib/pgsql/data, instead. You may * need to restart the postgresql service after modifying this file. @@ -107,7 +113,7 @@ public void setUp() { connection.setAutoCommit(false); st = connection.createStatement(); - // create the database table and populate it with data. + // create the database table and populate it with data. try { // Try to remove the table first. DROP TABLE IF EXISTS didn't diff --git a/src/test/com/cloudera/sqoop/util/TestDirectImportUtils.java b/src/test/com/cloudera/sqoop/util/TestDirectImportUtils.java deleted file mode 100644 index d29649f2..00000000 --- a/src/test/com/cloudera/sqoop/util/TestDirectImportUtils.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to Cloudera, Inc. under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. Cloudera, Inc. 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 com.cloudera.sqoop.util; - -import java.net.InetAddress; -import java.net.UnknownHostException; - -import junit.framework.TestCase; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Test that /etc/hosts is configured sanely. - * If this fails, then the postgresql direct tests will likely fail. - * - * In particular, 'localhost' needs to resolve to 127.0.0.1. - * The /etc/hosts file should contain a line like: - * - * 127.0.0.1 (yourhostnamehere) localhost - * - * e.g.: - * 127.0.0.1 aaron-laptop localhost - * 127.0.1.1 aaron-laptop - * ... - * - * If it doesn't have 'localhost' on that line, it'll fail. - */ -public class TestDirectImportUtils extends TestCase { - - public static final Log LOG = LogFactory.getLog( - TestDirectImportUtils.class.getName()); - - public void testLocalhost() throws UnknownHostException { - InetAddress localHostAddr = InetAddress.getLocalHost(); - LOG.info("Advertised localhost address: " + localHostAddr); - - InetAddress requestAddr = InetAddress.getByName("localhost"); - LOG.info("Requested localhost address: " + requestAddr); - - assertTrue("Requested addr does not identify as localhost. " - + "Check /etc/hosts (see TestDirectImportUtils comments)", - localHostAddr.equals(requestAddr)); - - assertTrue("Couldn't match 'localhost' to localhost; " - + "check /etc/hosts (see TestDirectImportUtils comments)", - DirectImportUtils.isLocalhost("localhost")); - } -} -