Skip to content

Commit

Permalink
CADC-13452 int-test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jburke-cadc committed Sep 13, 2024
1 parent fe7f48e commit 7234013
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ public void testUnsupportedDataType() throws Exception {
Assert.fail("unexpected exception: " + unexpected);
}
}

@Ignore
@Test
public void testPrintTableMetadata() {
Expand Down Expand Up @@ -396,14 +397,14 @@ public void testPrintTableMetadata() {
}
}
}
}

// cleanup
try {
tableCreator.dropTable(testTable);
log.debug("dropped table: " + testTable);
} catch (Exception ignore) {
log.debug("database-cleanup-after-test failed for " + testTable);
// cleanup
try {
tableCreator.dropTable(testTable);
log.debug("dropped table: " + testTable);
} catch (Exception ignore) {
log.debug("database-cleanup-after-test failed for " + testTable);
}
}
} catch (Exception unexpected) {
log.error("unexpected exception", unexpected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ public class TableIngesterTest {
private static final Logger log = Logger.getLogger(TableIngesterTest.class);

static {
Log4jInit.setLevel("ca.nrc.cadc.tap.db", Level.DEBUG);
Log4jInit.setLevel("ca.nrc.cadc.tap.schema", Level.DEBUG);
Log4jInit.setLevel("ca.nrc.cadc.tap.db", Level.INFO);
Log4jInit.setLevel("ca.nrc.cadc.tap.schema", Level.INFO);
}

private final DataSource dataSource;
private final TapSchemaDAO tapSchemaDAO;
private final String TEST_SCHEMA = "tap_schema";
private final String TEST_SCHEMA = "int_test_schema";

public TableIngesterTest() {
// create a datasource and register with JNDI
Expand Down Expand Up @@ -271,13 +271,13 @@ public void testPrintTableMetadata() {
try {
tableCreator.dropTable(testTable);
} catch (Exception ignore) {
log.debug("database-cleanup-before-test failed for " + testTable);
log.info("database-cleanup-before-test failed for " + testTable);
}

// create test table in the database
TableDesc ingestTable = getTableDesc(TEST_SCHEMA, testTable);
tableCreator.createTable(ingestTable);
log.debug("created database table: " + testTable);
log.info("created database table: " + testTable);

List<String> columnInfo = new ArrayList<String>() {{
add("DATA_TYPE");
Expand All @@ -302,14 +302,11 @@ public void testPrintTableMetadata() {
}};

try (Connection connection = dataSource.getConnection()) {
// create two indexes on the table
// create an index on the table
JdbcTemplate jdbc = new JdbcTemplate(dataSource);
String index1 = "CREATE UNIQUE INDEX c0_idx ON int_test_schema.testPrintTableMetadata (c0)";
log.debug("sql:\n" + index1);
jdbc.execute(index1);
String index2 = "CREATE UNIQUE INDEX c6_idx ON int_test_schema.testPrintTableMetadata (c6)";
log.debug("sql:\n" + index2);
jdbc.execute(index2);
String index = "CREATE UNIQUE INDEX a11_idx ON int_test_schema.testPrintTableMetadata (a11)";
log.info("sql:\n" + index);
jdbc.execute(index);

log.info("column metadata");
DatabaseMetaData metaData = connection.getMetaData();
Expand All @@ -333,14 +330,14 @@ public void testPrintTableMetadata() {
}
}
}
}

// cleanup
try {
tableCreator.dropTable(testTable);
log.debug("dropped table: " + testTable);
} catch (Exception ignore) {
log.debug("database-cleanup-after-test failed for " + testTable);
// cleanup
try {
tableCreator.dropTable(testTable);
log.info("dropped table: " + testTable);
} catch (Exception ignore) {
log.info("database-cleanup-after-test failed for " + testTable);
}
}
} catch (Exception unexpected) {
log.error("unexpected exception", unexpected);
Expand All @@ -355,8 +352,8 @@ TableDesc getTableDesc(String schemaName, String tableName) throws Exception {
tableDesc.getColumnDescs().add(new ColumnDesc(tableName, "e9", TapDataType.CIRCLE));
tableDesc.getColumnDescs().add(new ColumnDesc(tableName, "e10", TapDataType.POLYGON));
// arrays
tableDesc.getColumnDescs().add(new ColumnDesc(tableName, "a11", new TapDataType("short", "*", null)));
tableDesc.getColumnDescs().add(new ColumnDesc(tableName, "a12", new TapDataType("int", "*", null)));
tableDesc.getColumnDescs().add(new ColumnDesc(tableName, "a11", new TapDataType("short", "8", null)));
tableDesc.getColumnDescs().add(new ColumnDesc(tableName, "a12", new TapDataType("int", "*12", null)));
tableDesc.getColumnDescs().add(new ColumnDesc(tableName, "a13", new TapDataType("long", "*", null)));
tableDesc.getColumnDescs().add(new ColumnDesc(tableName, "a14", new TapDataType("float", "*", null)));
tableDesc.getColumnDescs().add(new ColumnDesc(tableName, "a15", new TapDataType("double", "*", null)));
Expand Down

0 comments on commit 7234013

Please sign in to comment.