diff --git hcatalog/streaming/src/test/org/apache/hive/hcatalog/streaming/TestStreaming.java hcatalog/streaming/src/test/org/apache/hive/hcatalog/streaming/TestStreaming.java index c0af533..a85a2b8 100644 --- hcatalog/streaming/src/test/org/apache/hive/hcatalog/streaming/TestStreaming.java +++ hcatalog/streaming/src/test/org/apache/hive/hcatalog/streaming/TestStreaming.java @@ -19,6 +19,7 @@ package org.apache.hive.hcatalog.streaming; import junit.framework.Assert; + import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.RawLocalFileSystem; @@ -137,7 +138,6 @@ public FileStatus getFileStatus(Path path) throws IOException { @Rule public TemporaryFolder dbFolder = new TemporaryFolder(); - public TestStreaming() throws Exception { partitionVals = new ArrayList(2); partitionVals.add(PART1_CONTINENT); diff --git metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnDbUtil.java metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnDbUtil.java index 37808ce..193d35c 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnDbUtil.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnDbUtil.java @@ -25,6 +25,7 @@ import java.sql.SQLTransactionRollbackException; import java.sql.Statement; import java.util.Properties; +import java.util.UUID; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -64,12 +65,15 @@ public static void prepDb() throws Exception { // out of date with it. I'm open to any suggestions on how to make this // read the file in a build friendly way. + // Create a UUID for the test to avoid a table collision + String tableUUID = UUID.randomUUID().toString(); + Connection conn = null; Statement stmt = null; try { conn = getConnection(); stmt = conn.createStatement(); - stmt.execute("CREATE TABLE TXNS (" + + stmt.execute("CREATE TABLE TXNS_"+tableUUID+"(" + " TXN_ID bigint PRIMARY KEY," + " TXN_STATE char(1) NOT NULL," + " TXN_STARTED bigint NOT NULL," + @@ -77,19 +81,19 @@ public static void prepDb() throws Exception { " TXN_USER varchar(128) NOT NULL," + " TXN_HOST varchar(128) NOT NULL)"); - stmt.execute("CREATE TABLE TXN_COMPONENTS (" + + stmt.execute("CREATE TABLE TXN_COMPONENTS_"+tableUUID+" (" + " TC_TXNID bigint REFERENCES TXNS (TXN_ID)," + " TC_DATABASE varchar(128) NOT NULL," + " TC_TABLE varchar(128)," + " TC_PARTITION varchar(767))"); - stmt.execute("CREATE TABLE COMPLETED_TXN_COMPONENTS (" + + stmt.execute("CREATE TABLE COMPLETED_TXN_COMPONENTS_"+tableUUID+" (" + " CTC_TXNID bigint," + " CTC_DATABASE varchar(128) NOT NULL," + " CTC_TABLE varchar(128)," + " CTC_PARTITION varchar(767))"); - stmt.execute("CREATE TABLE NEXT_TXN_ID (" + " NTXN_NEXT bigint NOT NULL)"); - stmt.execute("INSERT INTO NEXT_TXN_ID VALUES(1)"); - stmt.execute("CREATE TABLE HIVE_LOCKS (" + + stmt.execute("CREATE TABLE NEXT_TXN_ID_"+tableUUID+" (" + " NTXN_NEXT bigint NOT NULL)"); + stmt.execute("INSERT INTO NEXT_TXN_ID_"+tableUUID+" VALUES(1)"); + stmt.execute("CREATE TABLE HIVE_LOCKS_"+tableUUID+" (" + " HL_LOCK_EXT_ID bigint NOT NULL," + " HL_LOCK_INT_ID bigint NOT NULL," + " HL_TXNID bigint," + @@ -103,12 +107,12 @@ public static void prepDb() throws Exception { " HL_USER varchar(128) NOT NULL," + " HL_HOST varchar(128) NOT NULL," + " PRIMARY KEY(HL_LOCK_EXT_ID, HL_LOCK_INT_ID))"); - stmt.execute("CREATE INDEX HL_TXNID_INDEX ON HIVE_LOCKS (HL_TXNID)"); + stmt.execute("CREATE INDEX HL_TXNID_INDEX ON HIVE_LOCKS_"+tableUUID+" (HL_TXNID)"); - stmt.execute("CREATE TABLE NEXT_LOCK_ID (" + " NL_NEXT bigint NOT NULL)"); - stmt.execute("INSERT INTO NEXT_LOCK_ID VALUES(1)"); + stmt.execute("CREATE TABLE NEXT_LOCK_ID_"+tableUUID+" (" + " NL_NEXT bigint NOT NULL)"); + stmt.execute("INSERT INTO NEXT_LOCK_ID_"+tableUUID+" VALUES(1)"); - stmt.execute("CREATE TABLE COMPACTION_QUEUE (" + + stmt.execute("CREATE TABLE COMPACTION_QUEUE_"+tableUUID+" (" + " CQ_ID bigint PRIMARY KEY," + " CQ_DATABASE varchar(128) NOT NULL," + " CQ_TABLE varchar(128) NOT NULL," + @@ -119,8 +123,8 @@ public static void prepDb() throws Exception { " CQ_START bigint," + " CQ_RUN_AS varchar(128))"); - stmt.execute("CREATE TABLE NEXT_COMPACTION_QUEUE_ID (NCQ_NEXT bigint NOT NULL)"); - stmt.execute("INSERT INTO NEXT_COMPACTION_QUEUE_ID VALUES(1)"); + stmt.execute("CREATE TABLE NEXT_COMPACTION_QUEUE_ID_"+tableUUID+" (NCQ_NEXT bigint NOT NULL)"); + stmt.execute("INSERT INTO NEXT_COMPACTION_QUEUE_ID_"+tableUUID+" VALUES(1)"); conn.commit(); } catch (SQLException e) {