sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject [1/2] sqoop git commit: SQOOP-1591: Sqoop2: PostgreSQL integration tests
Date Wed, 04 Feb 2015 04:25:22 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 27d87b4f2 -> 332a7bdd8


http://git-wip-us.apache.org/repos/asf/sqoop/blob/332a7bdd/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestSubmissionHandling.java
----------------------------------------------------------------------
diff --git a/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestSubmissionHandling.java
b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestSubmissionHandling.java
new file mode 100644
index 0000000..b3d8e62
--- /dev/null
+++ b/repository/repository-postgresql/src/test/java/org/apache/sqoop/integration/repository/postgresql/TestSubmissionHandling.java
@@ -0,0 +1,353 @@
+/**
+ * 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.integration.repository.postgresql;
+
+import org.apache.sqoop.model.MConnector;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.model.MSubmission;
+import org.apache.sqoop.submission.SubmissionStatus;
+import org.apache.sqoop.submission.counter.Counter;
+import org.apache.sqoop.submission.counter.CounterGroup;
+import org.apache.sqoop.submission.counter.Counters;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import static junit.framework.Assert.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
+
+/**
+ *
+ */
+@Test(groups = "postgresql")
+public class TestSubmissionHandling extends PostgresqlTestCase {
+  public static final String CONNECTOR_A_NAME = "A";
+  public static final String CONNECTOR_A_CLASSNAME = "org.apache.sqoop.test.A";
+  public static final String CONNECTOR_A_VERSION = "1.0-test";
+  public static final String CONNECTOR_B_NAME = "B";
+  public static final String CONNECTOR_B_CLASSNAME = "org.apache.sqoop.test.B";
+  public static final String CONNECTOR_B_VERSION = "1.0-test";
+  public static final String LINK_A_NAME = "Link-A";
+  public static final String LINK_B_NAME = "Link-B";
+  public static final String JOB_A_NAME = "Job-A";
+  public static final String JOB_B_NAME = "Job-B";
+
+  @BeforeMethod(alwaysRun = true)
+  public void setUp() throws Exception {
+    super.setUp();
+
+    handler.registerDriver(getDriver(), provider.getConnection());
+    MConnector connectorA = getConnector(CONNECTOR_A_NAME, CONNECTOR_A_CLASSNAME, CONNECTOR_A_VERSION,
true, true);
+    MConnector connectorB = getConnector(CONNECTOR_B_NAME, CONNECTOR_B_CLASSNAME, CONNECTOR_B_VERSION,
true, true);
+    handler.registerConnector(connectorA, provider.getConnection());
+    handler.registerConnector(connectorB, provider.getConnection());
+    MLink linkA = getLink(LINK_A_NAME, connectorA);
+    MLink linkB = getLink(LINK_B_NAME, connectorB);
+    handler.createLink(linkA, provider.getConnection());
+    handler.createLink(linkB, provider.getConnection());
+    MJob jobA = getJob(JOB_A_NAME, connectorA, connectorB, linkA, linkB);
+    MJob jobB = getJob(JOB_B_NAME, connectorB, connectorA, linkB, linkA);
+    handler.createJob(jobA, provider.getConnection());
+    handler.createJob(jobB, provider.getConnection());
+  }
+
+  private void loadSubmissions() throws Exception {
+    MJob jobA = handler.findJob(JOB_A_NAME, provider.getConnection());
+    MJob jobB = handler.findJob(JOB_B_NAME, provider.getConnection());
+
+    MSubmission submissionA = getSubmission(jobA, SubmissionStatus.RUNNING);
+    submissionA.getCounters().getCounterGroup("test-1").addCounter(new Counter("counter-1"));
+    submissionA.getCounters().getCounterGroup("test-1").addCounter(new Counter("counter-2"));
+    submissionA.getCounters().getCounterGroup("test-1").getCounter("counter-1").setValue(300);
+    MSubmission submissionB = getSubmission(jobA, SubmissionStatus.SUCCEEDED);
+    MSubmission submissionC = getSubmission(jobB, SubmissionStatus.FAILED);
+    MSubmission submissionD = getSubmission(jobB, SubmissionStatus.UNKNOWN);
+    handler.createSubmission(submissionA, provider.getConnection());
+    handler.createSubmission(submissionB, provider.getConnection());
+    handler.createSubmission(submissionC, provider.getConnection());
+    handler.createSubmission(submissionD, provider.getConnection());
+  }
+
+  @Test
+  public void testFindSubmissionsUnfinished() throws Exception {
+    List<MSubmission> submissions;
+
+    submissions = handler.findUnfinishedSubmissions(provider.getConnection());
+    assertNotNull(submissions);
+    assertEquals(0, submissions.size());
+
+    loadSubmissions();
+
+    submissions = handler.findUnfinishedSubmissions(provider.getConnection());
+    assertNotNull(submissions);
+    assertEquals(1, submissions.size());
+  }
+
+  @Test
+  public void testExistsSubmission() throws Exception {
+    // There shouldn't be anything on empty repository
+    assertFalse(handler.existsSubmission(1, provider.getConnection()));
+    assertFalse(handler.existsSubmission(2, provider.getConnection()));
+    assertFalse(handler.existsSubmission(3, provider.getConnection()));
+    assertFalse(handler.existsSubmission(4, provider.getConnection()));
+    assertFalse(handler.existsSubmission(5, provider.getConnection()));
+
+    loadSubmissions();
+
+    assertTrue(handler.existsSubmission(1, provider.getConnection()));
+    assertTrue(handler.existsSubmission(2, provider.getConnection()));
+    assertTrue(handler.existsSubmission(3, provider.getConnection()));
+    assertTrue(handler.existsSubmission(4, provider.getConnection()));
+    assertFalse(handler.existsSubmission(5, provider.getConnection()));
+  }
+
+  @Test
+  public void testCreateSubmission() throws Exception {
+    Date creationDate = new Date();
+    Date updateDate = new Date();
+
+    CounterGroup firstGroup = new CounterGroup("ga");
+    CounterGroup secondGroup = new CounterGroup("gb");
+    firstGroup.addCounter(new Counter("ca", 100));
+    firstGroup.addCounter(new Counter("cb", 200));
+    secondGroup.addCounter(new Counter("ca", 300));
+    secondGroup.addCounter(new Counter("cd", 400));
+    Counters counters = new Counters();
+    counters.addCounterGroup(firstGroup);
+    counters.addCounterGroup(secondGroup);
+
+    MSubmission submission = new MSubmission();
+    submission.setJobId(1);
+    submission.setStatus(SubmissionStatus.RUNNING);
+    submission.setCreationDate(creationDate);
+    submission.setLastUpdateDate(updateDate);
+    submission.setExternalJobId("job-x");
+    submission.setExternalLink("http://somewhere");
+    submission.getError().setErrorSummary("RuntimeException");
+    submission.getError().setErrorDetails("Yeah it happens");
+    submission.setCounters(counters);
+
+    handler.createSubmission(submission, provider.getConnection());
+
+
+    assertEquals(1, submission.getPersistenceId());
+    Assert.assertEquals(provider.rowCount("SQOOP", "SQ_SUBMISSION"), 1);
+
+    List<MSubmission> submissions = handler.findUnfinishedSubmissions(provider.getConnection());
+    assertNotNull(submissions);
+    assertEquals(1, submissions.size());
+
+    submission = submissions.get(0);
+
+    assertEquals(1, submission.getJobId());
+    assertEquals(SubmissionStatus.RUNNING, submission.getStatus());
+    assertEquals(creationDate, submission.getCreationDate());
+    assertEquals(updateDate, submission.getLastUpdateDate());
+    assertEquals("job-x", submission.getExternalJobId());
+    assertEquals("http://somewhere", submission.getExternalLink());
+    assertEquals("RuntimeException", submission.getError().getErrorSummary());
+    assertEquals("Yeah it happens", submission.getError().getErrorDetails());
+
+    CounterGroup group;
+    Counter counter;
+    Counters retrievedCounters = submission.getCounters();
+    assertNotNull(retrievedCounters);
+
+    group = counters.getCounterGroup("ga");
+    assertNotNull(group);
+
+    counter = group.getCounter("ca");
+    assertNotNull(counter);
+    assertEquals(100, counter.getValue());
+
+    counter = group.getCounter("cb");
+    assertNotNull(counter);
+    assertEquals(200, counter.getValue());
+
+    group = counters.getCounterGroup("gb");
+    assertNotNull(group);
+
+    counter = group.getCounter("ca");
+    assertNotNull(counter);
+    assertEquals(300, counter.getValue());
+
+    counter = group.getCounter("cd");
+    assertNotNull(counter);
+    assertEquals(400, counter.getValue());
+
+    // Let's create second (simpler) connection
+    submission = new MSubmission(1, new Date(), SubmissionStatus.SUCCEEDED, "job-x");
+    handler.createSubmission(submission, provider.getConnection());
+
+    assertEquals(2, submission.getPersistenceId());
+    Assert.assertEquals(provider.rowCount("SQOOP", "SQ_SUBMISSION"), 2);
+  }
+
+  @Test
+  public void testUpdateSubmission() throws Exception {
+    loadSubmissions();
+
+    List<MSubmission> submissions = handler.findUnfinishedSubmissions(provider.getConnection());
+    assertNotNull(submissions);
+    assertEquals(1, submissions.size());
+
+    MSubmission submission = submissions.get(0);
+    submission.setStatus(SubmissionStatus.SUCCEEDED);
+
+    handler.updateSubmission(submission, provider.getConnection());
+
+    submissions = handler.findUnfinishedSubmissions(provider.getConnection());
+    assertNotNull(submissions);
+    assertEquals(0, submissions.size());
+  }
+
+  @Test
+  public void testCreateSubmissionExceptionDetailsMoreThanMaxLimit() throws Exception {
+
+    String externalLink = "http://somewheresomewheresomewheresomewheresomewheresomewheresomewheresomewheresomewheresomewheresomewheresom"
+        + "ewheresomewheresomewheresomewheresomewher";
+
+    String errorSummary = "RuntimeExceptionRuntimeExceptionRuntimeExceptionRuntimeExceptionRuntimeExceptionRuntimeExceptions"
+        + "RuntimeExceptionRuntimeExceptionRuntimeExceptiontests";
+    String errorDetail = "Yeah it happensYeah it happensYeah it happensYeah it happensYeah
it happensYeah"
+        + " it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah it
happensYeah it happensYeah it hap"
+        + "pensYeah it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah
it happensYeah it happensYea"
+        + "h it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah it
happensYeah it happensYeah it ha"
+        + "ppensYeah it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah
it happensYeah it happensYeah"
+        + " it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah it
happensYeah it happensYeah it happe"
+        + "nsYeah it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah
it happensYeah it happens";
+    MSubmission submission = new MSubmission();
+    submission.setJobId(1);
+    submission.setStatus(SubmissionStatus.RUNNING);
+    submission.setCreationDate(new Date());
+    submission.setLastUpdateDate(new Date());
+    submission.setExternalJobId("job-x");
+    submission.setExternalLink(externalLink + "more than 150");
+    submission.getError().setErrorSummary("RuntimeException");
+    submission.getError().setErrorDetails(errorDetail + "morethan750");
+    submission.getError().setErrorSummary(errorSummary + "morethan150");
+
+    handler.createSubmission(submission, provider.getConnection());
+    List<MSubmission> submissions = handler.findSubmissionsForJob(1, provider.getConnection());
+    assertNotNull(submissions);
+
+    assertEquals(errorDetail, submissions.get(0).getError().getErrorDetails());
+    assertEquals(errorSummary, submissions.get(0).getError().getErrorSummary());
+    assertEquals(externalLink, submissions.get(0).getExternalLink());
+
+  }
+
+  @Test
+  public void testUpdateSubmissionExceptionDetailsMoreThanMaxLimit() throws Exception {
+    loadSubmissions();
+
+    List<MSubmission> submissions = handler.findUnfinishedSubmissions(provider.getConnection());
+    assertNotNull(submissions);
+    assertEquals(1, submissions.size());
+
+    String errorSummary = "RuntimeExceptionRuntimeExceptionRuntimeExceptionRuntimeExceptionRuntimeExceptionRuntimeExceptions"
+        + "RuntimeExceptionRuntimeExceptionRuntimeExceptiontests";
+
+    String errorDetail = "Yeah it happensYeah it happensYeah it happensYeah it happensYeah
it happensYeah"
+        + " it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah it
happensYeah it happensYeah it hap"
+        + "pensYeah it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah
it happensYeah it happensYea"
+        + "h it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah it
happensYeah it happensYeah it ha"
+        + "ppensYeah it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah
it happensYeah it happensYeah"
+        + " it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah it
happensYeah it happensYeah it happe"
+        + "nsYeah it happensYeah it happensYeah it happensYeah it happensYeah it happensYeah
it happensYeah it happens";
+    MSubmission submission = submissions.get(0);
+    String externalLink = submission.getExternalLink();
+    submission.getError().setErrorDetails(errorDetail + "morethan750");
+    submission.getError().setErrorSummary(errorSummary + "morethan150");
+    submission.setExternalLink("cantupdate");
+
+    handler.updateSubmission(submission, provider.getConnection());
+
+    submissions = handler.findUnfinishedSubmissions(provider.getConnection());
+
+    assertNotNull(submissions);
+    assertEquals(errorDetail, submissions.get(0).getError().getErrorDetails());
+    assertEquals(errorSummary, submissions.get(0).getError().getErrorSummary());
+    // note we dont allow external link update
+    assertEquals(externalLink, submissions.get(0).getExternalLink());
+
+  }
+
+  @Test
+  public void testPurgeSubmissions() throws Exception {
+    loadSubmissions();
+    List<MSubmission> submissions;
+
+    submissions = handler.findUnfinishedSubmissions(provider.getConnection());
+    assertNotNull(submissions);
+    assertEquals(1, submissions.size());
+    Assert.assertEquals(provider.rowCount("SQOOP", "SQ_SUBMISSION"), 4);
+
+    Calendar calendar = Calendar.getInstance();
+    // 2012-01-03 05:05:05
+    calendar.set(2012, Calendar.JANUARY, 3, 5, 5, 5);
+    handler.purgeSubmissions(calendar.getTime(), provider.getConnection());
+
+    submissions = handler.findUnfinishedSubmissions(provider.getConnection());
+    assertNotNull(submissions);
+    assertEquals(1, submissions.size());
+    Assert.assertEquals(provider.rowCount("SQOOP", "SQ_SUBMISSION"), 4);
+
+    handler.purgeSubmissions(new Date(), provider.getConnection());
+
+    submissions = handler.findUnfinishedSubmissions(provider.getConnection());
+    assertNotNull(submissions);
+    assertEquals(0, submissions.size());
+    Assert.assertEquals(provider.rowCount("SQOOP", "SQ_SUBMISSION"), 0);
+
+    handler.purgeSubmissions(new Date(), provider.getConnection());
+
+    submissions = handler.findUnfinishedSubmissions(provider.getConnection());
+    assertNotNull(submissions);
+    assertEquals(0, submissions.size());
+    Assert.assertEquals(provider.rowCount("SQOOP", "SQ_SUBMISSION"), 0);
+  }
+
+  /**
+   * Test that by directly removing jobs we will also remove associated
+   * submissions and counters.
+   *
+   * @throws Exception
+   */
+  @Test
+  public void testDeleteJobs() throws Exception {
+    MJob jobA = handler.findJob(JOB_A_NAME, provider.getConnection());
+    MJob jobB = handler.findJob(JOB_B_NAME, provider.getConnection());
+
+    loadSubmissions();
+    Assert.assertEquals(provider.rowCount("SQOOP", "SQ_SUBMISSION"), 4);
+
+    handler.deleteJob(jobA.getPersistenceId(), provider.getConnection());
+    Assert.assertEquals(provider.rowCount("SQOOP", "SQ_SUBMISSION"), 2);
+
+    handler.deleteJob(jobB.getPersistenceId(), provider.getConnection());
+    Assert.assertEquals(provider.rowCount("SQOOP", "SQ_SUBMISSION"), 0);
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/332a7bdd/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/PostgresqlTestCase.java
----------------------------------------------------------------------
diff --git a/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/PostgresqlTestCase.java
b/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/PostgresqlTestCase.java
deleted file mode 100644
index 98ba7a3..0000000
--- a/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/PostgresqlTestCase.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * 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.repository.postgresql;
-
-import org.apache.sqoop.common.test.db.DatabaseProvider;
-import org.apache.sqoop.common.test.db.PostgreSQLProvider;
-import org.testng.SkipException;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-
-/**
- * Abstract class with convenience methods for testing postgresql repository.
- */
-abstract public class PostgresqlTestCase {
-
-  public static DatabaseProvider provider;
-  public static PostgresqlTestUtils utils;
-  public PostgresqlRepositoryHandler handler;
-
-  @BeforeClass(alwaysRun = true)
-  public void setUpClass() {
-    provider = new PostgreSQLProvider();
-    utils = new PostgresqlTestUtils(provider);
-  }
-
-  @BeforeMethod(alwaysRun = true)
-  public void setUp() throws Exception {
-    try {
-      provider.start();
-    } catch (RuntimeException e) {
-      throw new SkipException("Cannot connect to provider.", e);
-    }
-
-    handler = new PostgresqlRepositoryHandler();
-    handler.createOrUpgradeRepository(provider.getConnection());
-  }
-
-  @AfterMethod(alwaysRun = true)
-  public void tearDown() throws Exception {
-    provider.dropSchema("SQOOP");
-    provider.stop();
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/332a7bdd/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/PostgresqlTestUtils.java
----------------------------------------------------------------------
diff --git a/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/PostgresqlTestUtils.java
b/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/PostgresqlTestUtils.java
deleted file mode 100644
index 19fd6e7..0000000
--- a/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/PostgresqlTestUtils.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * 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.repository.postgresql;
-
-import org.apache.sqoop.common.test.db.DatabaseProvider;
-import org.apache.sqoop.repository.common.CommonRepoUtils;
-
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-public class PostgresqlTestUtils {
-
-  private DatabaseProvider provider;
-
-  public PostgresqlTestUtils(DatabaseProvider provider) {
-    this.provider = provider;
-  }
-
-  public void assertTableExists(String schema, String table) throws Exception {
-    DatabaseMetaData md = provider.getConnection().getMetaData();
-    ResultSet rs = md.getTables(null, schema, table, null);
-    while (rs.next()) {
-      if (rs.getString(3).equals(table)) {
-        return;
-      }
-    }
-
-    throw new AssertionError("Could not find table '" + table + "' part of schema '" + schema
+ "'");
-  }
-
-  public void assertForeignKey(String schema, String table, String column,
-                               String foreignKeyTable, String foreignKeyColumn) throws Exception
{
-    DatabaseMetaData md = provider.getConnection().getMetaData();
-    ResultSet rs = md.getCrossReference(null, schema, table, null, schema, foreignKeyTable);
-    while (rs.next()) {
-      if (rs.getString(4).equals(column) && rs.getString(8).equals(foreignKeyColumn))
{
-        return;
-      }
-    }
-
-    throw new AssertionError("Could not find '" + table + "." + column
-        + "' part of schema '" + schema + "' with reference to '" + table + "." + column
+ "'");
-  }
-
-  public void assertUniqueConstraints(String schema, String table, String... columns) throws
Exception {
-    Set<String> columnSet = new TreeSet<String>();
-    Map<String, Set<String>> indexColumnMap = new HashMap<String, Set<String>>();
-
-    for (String column : columns) {
-      columnSet.add(CommonRepoUtils.escapeColumnName(column));
-    }
-
-    DatabaseMetaData md = provider.getConnection().getMetaData();
-    ResultSet rs = md.getIndexInfo(null, schema, table, true, false);
-
-    // Get map of index => columns
-    while (rs.next()) {
-      String indexName = rs.getString(6);
-      String columnName = rs.getString(9);
-      if (!indexColumnMap.containsKey(indexName)) {
-        indexColumnMap.put(indexName, new TreeSet<String>());
-      }
-      indexColumnMap.get(indexName).add(columnName);
-    }
-
-    // Validate unique constraints
-    for (String index : indexColumnMap.keySet()) {
-      if (indexColumnMap.get(index).equals(columnSet)) {
-        return;
-      }
-    }
-
-    throw new AssertionError("Could not find unique constraint on table '" + table
-            + "' part of schema '" + schema + "' with reference to columns '" + columnSet
+ "'");
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/332a7bdd/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/TestStructure.java
----------------------------------------------------------------------
diff --git a/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/TestStructure.java
b/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/TestStructure.java
deleted file mode 100644
index 941bb69..0000000
--- a/repository/repository-postgresql/src/test/java/org/apache/sqoop/repository/postgresql/TestStructure.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * 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.repository.postgresql;
-
-import org.testng.annotations.Test;
-
-/**
- * Test connector methods on PostgreSQL repository.
- */
-public class TestStructure extends PostgresqlTestCase {
-
-  @Test
-  public void testTables() throws Exception {
-    utils.assertTableExists("SQOOP", "SQ_SYSTEM");
-    utils.assertTableExists("SQOOP", "SQ_DIRECTION");
-    utils.assertTableExists("SQOOP", "SQ_CONFIGURABLE");
-    utils.assertTableExists("SQOOP", "SQ_CONNECTOR_DIRECTIONS");
-    utils.assertTableExists("SQOOP", "SQ_CONFIG");
-    utils.assertTableExists("SQOOP", "SQ_CONNECTOR_DIRECTIONS");
-    utils.assertTableExists("SQOOP", "SQ_INPUT");
-    utils.assertTableExists("SQOOP", "SQ_LINK");
-    utils.assertTableExists("SQOOP", "SQ_JOB");
-    utils.assertTableExists("SQOOP", "SQ_LINK_INPUT");
-    utils.assertTableExists("SQOOP", "SQ_JOB_INPUT");
-    utils.assertTableExists("SQOOP", "SQ_SUBMISSION");
-    utils.assertTableExists("SQOOP", "SQ_COUNTER_GROUP");
-    utils.assertTableExists("SQOOP", "SQ_COUNTER");
-    utils.assertTableExists("SQOOP", "SQ_COUNTER_SUBMISSION");
-  }
-
-  @Test
-  public void testForeignKeys() throws Exception {
-    utils.assertForeignKey("SQOOP", "SQ_CONFIGURABLE", "SQC_ID", "SQ_CONNECTOR_DIRECTIONS",
"SQCD_CONNECTOR");
-    utils.assertForeignKey("SQOOP", "SQ_DIRECTION", "SQD_ID", "SQ_CONNECTOR_DIRECTIONS",
"SQCD_DIRECTION");
-    utils.assertForeignKey("SQOOP", "SQ_CONFIGURABLE", "SQC_ID", "SQ_CONFIG", "SQ_CFG_CONFIGURABLE");
-    utils.assertForeignKey("SQOOP", "SQ_CONFIG", "SQ_CFG_ID", "SQ_CONFIG_DIRECTIONS", "SQ_CFG_DIR_CONFIG");
-    utils.assertForeignKey("SQOOP", "SQ_DIRECTION", "SQD_ID", "SQ_CONFIG_DIRECTIONS", "SQ_CFG_DIR_DIRECTION");
-    utils.assertForeignKey("SQOOP", "SQ_CONFIG", "SQ_CFG_ID", "SQ_INPUT", "SQI_CONFIG");
-    utils.assertForeignKey("SQOOP", "SQ_CONFIGURABLE", "SQC_ID", "SQ_LINK", "SQ_LNK_CONFIGURABLE");
-    utils.assertForeignKey("SQOOP", "SQ_LINK", "SQ_LNK_ID", "SQ_JOB", "SQB_FROM_LINK");
-    utils.assertForeignKey("SQOOP", "SQ_LINK", "SQ_LNK_ID", "SQ_JOB", "SQB_TO_LINK");
-    utils.assertForeignKey("SQOOP", "SQ_LINK", "SQ_LNK_ID", "SQ_LINK_INPUT", "SQ_LNKI_LINK");
-    utils.assertForeignKey("SQOOP", "SQ_INPUT", "SQI_ID", "SQ_LINK_INPUT", "SQ_LNKI_INPUT");
-    utils.assertForeignKey("SQOOP", "SQ_JOB", "SQB_ID", "SQ_JOB_INPUT", "SQBI_JOB");
-    utils.assertForeignKey("SQOOP", "SQ_INPUT", "SQI_ID", "SQ_JOB_INPUT", "SQBI_INPUT");
-    utils.assertForeignKey("SQOOP", "SQ_JOB", "SQB_ID", "SQ_SUBMISSION", "SQS_JOB");
-    utils.assertForeignKey("SQOOP", "SQ_COUNTER", "SQR_ID", "SQ_COUNTER_SUBMISSION", "SQRS_COUNTER");
-    utils.assertForeignKey("SQOOP", "SQ_COUNTER_GROUP", "SQG_ID", "SQ_COUNTER_SUBMISSION",
"SQRS_GROUP");
-    utils.assertForeignKey("SQOOP", "SQ_SUBMISSION", "SQS_ID", "SQ_COUNTER_SUBMISSION", "SQRS_SUBMISSION");
-  }
-
-  @Test
-  public void testUniqueConstraints() throws Exception {
-    utils.assertUniqueConstraints("SQOOP", "SQ_CONFIGURABLE", "SQC_NAME");
-    utils.assertUniqueConstraints("SQOOP", "SQ_LINK", "SQ_LNK_NAME");
-    utils.assertUniqueConstraints("SQOOP", "SQ_JOB", "SQB_NAME");
-    utils.assertUniqueConstraints("SQOOP", "SQ_CONFIG", "SQ_CFG_NAME", "SQ_CFG_CONFIGURABLE",
"SQ_CFG_TYPE");
-    utils.assertUniqueConstraints("SQOOP", "SQ_INPUT", "SQI_NAME", "SQI_TYPE", "SQI_CONFIG");
-    utils.assertUniqueConstraints("SQOOP", "SQ_COUNTER", "SQR_NAME");
-    utils.assertUniqueConstraints("SQOOP", "SQ_COUNTER_GROUP", "SQG_NAME");
-  }
-}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/332a7bdd/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java b/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
index 1124cd3..2d28a9a 100644
--- a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
+++ b/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
@@ -17,6 +17,7 @@
  */
 package org.apache.sqoop.test.testcases;
 
+import static org.testng.Assert.fail;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.Assert.assertNotSame;
 
@@ -43,6 +44,9 @@ import org.apache.sqoop.validation.Status;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
 /**
  * Base test case suitable for connector testing.
  *
@@ -117,10 +121,6 @@ abstract public class ConnectorTestCase extends TomcatTestCase {
     provider.insertRow(getTableName(), values);
   }
 
-  protected long rowCount() {
-    return provider.rowCount(getTableName());
-  }
-
   /**
    * Fill link config based on currently active provider.
    *
@@ -199,7 +199,7 @@ abstract public class ConnectorTestCase extends TomcatTestCase {
    * @param conditions Conditions in config that are expected by the database provider
    * @param values Values that are expected in the table (with corresponding types)
    */
-  protected void assertRow(Object []conditions, Object ...values) {
+  protected void assertRow(Object[] conditions, Object ...values) {
     ProviderAsserts.assertRow(provider, getTableName(), conditions, values);
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/332a7bdd/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java
b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java
index 0b530b9..397ce6f 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/FromHDFSToRDBMSTest.java
@@ -68,7 +68,7 @@ public class FromHDFSToRDBMSTest extends ConnectorTestCase {
 
     executeJob(job);
 
-    assertEquals(4L, rowCount());
+    assertEquals(4L, provider.rowCount(null, getTableName()));
     assertRowInCities(1, "USA", "2004-10-23", "San Francisco");
     assertRowInCities(2, "USA", "2004-10-24", "Sunnyvale");
     assertRowInCities(3, "Czech Republic", "2004-10-25", "Brno");

http://git-wip-us.apache.org/repos/asf/sqoop/blob/332a7bdd/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java
b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java
index 1d09b82..f850777 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connector/jdbc/generic/TableStagedRDBMSTest.java
@@ -74,8 +74,8 @@ public class TableStagedRDBMSTest extends ConnectorTestCase {
 
     executeJob(job);
 
-    assertEquals(0L, provider.rowCount(stageTableName));
-    assertEquals(4L, rowCount());
+    assertEquals(0L, provider.rowCount(null, stageTableName));
+    assertEquals(4L, provider.rowCount(null, getTableName()));
     assertRowInCities(1, "USA", "2004-10-23", "San Francisco");
     assertRowInCities(2, "USA", "2004-10-24", "Sunnyvale");
     assertRowInCities(3, "Czech Republic", "2004-10-25", "Brno");


Mime
View raw message