You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by aw...@apache.org on 2020/04/17 23:10:22 UTC
[kudu] branch master updated: test: fix HMS plugin test
This is an automated email from the ASF dual-hosted git repository.
awong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 2800155 test: fix HMS plugin test
2800155 is described below
commit 2800155f6a61c11f3493ccd472eebc626c4dc56c
Author: Andrew Wong <aw...@cloudera.com>
AuthorDate: Fri Apr 17 02:29:37 2020 -0700
test: fix HMS plugin test
Running TestKuduMetastorePlugin with a version of Hive that includes
3ab174d82ffc2bd27432c0b04433be3bd7db5c6a raises a different exception
than expected. This patch changes the test to set an appropiate location
for Hive tables.
Such a version of hive would yield errors like:
08:56:19.427 [ERROR - pool-11-thread-2] (RetryingHMSHandler.java:201) MetaException(message:An external table's location should not be located within managed warehouse root directory, table:table,location:/tmp/hive6879897156513669203/warehouse/table,managed warehouse:/tmp/hive6879897156513669203/warehouse)
...indicating the need for us to denote a different location. I went
with the location used in d96f8fca55, which fixed a similar issue.
Change-Id: I8ea8e3d6f2513f6ec3439b2e947e3564c4c53590
Reviewed-on: http://gerrit.cloudera.org:8080/15747
Reviewed-by: Grant Henke <gr...@apache.org>
Tested-by: Kudu Jenkins
Reviewed-by: Hao Hao <ha...@cloudera.com>
---
.../hive/metastore/TestKuduMetastorePlugin.java | 74 ++++++++++++++++------
1 file changed, 54 insertions(+), 20 deletions(-)
diff --git a/java/kudu-hive/src/test/java/org/apache/kudu/hive/metastore/TestKuduMetastorePlugin.java b/java/kudu-hive/src/test/java/org/apache/kudu/hive/metastore/TestKuduMetastorePlugin.java
index 0558746..d9103ae 100644
--- a/java/kudu-hive/src/test/java/org/apache/kudu/hive/metastore/TestKuduMetastorePlugin.java
+++ b/java/kudu-hive/src/test/java/org/apache/kudu/hive/metastore/TestKuduMetastorePlugin.java
@@ -178,8 +178,10 @@ public class TestKuduMetastorePlugin {
client.createTable(table);
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains(
- "non-Kudu table entry must not contain a table ID property"));
+ assertTrue(
+ e.getMessage(),
+ e.getMessage().contains(
+ "non-Kudu table entry must not contain a table ID property"));
}
// A Kudu table without a Kudu table ID.
@@ -189,7 +191,8 @@ public class TestKuduMetastorePlugin {
client.createTable(table, masterContext());
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains("Kudu table entry must contain a table ID property"));
+ assertTrue(e.getMessage(),
+ e.getMessage().contains("Kudu table entry must contain a table ID property"));
}
// A Kudu table without master context.
@@ -198,7 +201,8 @@ public class TestKuduMetastorePlugin {
client.createTable(table);
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains("Kudu tables may not be created through Hive"));
+ assertTrue(e.getMessage(),
+ e.getMessage().contains("Kudu tables may not be created through Hive"));
}
// A Kudu table without a master address.
@@ -208,8 +212,10 @@ public class TestKuduMetastorePlugin {
client.createTable(table, masterContext());
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains(
- "Kudu table entry must contain a Master addresses property"));
+ assertTrue(
+ e.getMessage(),
+ e.getMessage().contains(
+ "Kudu table entry must contain a Master addresses property"));
}
// Check that creating a valid table is accepted.
@@ -253,7 +259,8 @@ public class TestKuduMetastorePlugin {
client.alter_table(table.getDbName(), table.getTableName(), newTable);
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains("Kudu table ID does not match the existing HMS entry"));
+ assertTrue(e.getMessage(),
+ e.getMessage().contains("Kudu table ID does not match the existing HMS entry"));
}
// Check that altering the Kudu table with a different table ID while
@@ -273,8 +280,10 @@ public class TestKuduMetastorePlugin {
client.alter_table(table.getDbName(), table.getTableName(), alteredTable);
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains(
- "Kudu table entry must contain a Kudu storage handler property"));
+ assertTrue(
+ e.getMessage(),
+ e.getMessage().contains(
+ "Kudu table entry must contain a Kudu storage handler property"));
}
// Try to alter the Kudu table to a different type.
@@ -289,7 +298,8 @@ public class TestKuduMetastorePlugin {
client.alter_table(table.getDbName(), table.getTableName(), alteredTable);
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains("Kudu table type may not be altered"));
+ assertTrue(e.getMessage(),
+ e.getMessage().contains("Kudu table type may not be altered"));
}
// Alter the Kudu table to a different type by setting the external property fails.
@@ -299,7 +309,8 @@ public class TestKuduMetastorePlugin {
client.alter_table(table.getDbName(), table.getTableName(), alteredTable);
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains("Kudu table type may not be altered"));
+ assertTrue(e.getMessage(),
+ e.getMessage().contains("Kudu table type may not be altered"));
}
// Alter the Kudu table to the same type by setting the table property works.
@@ -327,16 +338,27 @@ public class TestKuduMetastorePlugin {
// Alter the Kudu table to a different type by setting the purge property fails.
try {
Table alteredTable = table.deepCopy();
+ // Also change the location to avoid MetastoreDefaultTransformer validation
+ // that exists in some Hive versions.
+ alteredTable.getSd().setLocation(String.format("%s/%s/%s",
+ clientConf.get(HiveConf.ConfVars.METASTOREWAREHOUSE.varname),
+ table.getDbName(), table.getTableName()));
alteredTable.putToParameters(KuduMetastorePlugin.EXTERNAL_PURGE_KEY, "TRUE");
client.alter_table(table.getDbName(), table.getTableName(), alteredTable);
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains("Kudu table type may not be altered"));
+ assertTrue(e.getMessage(),
+ e.getMessage().contains("Kudu table type may not be altered"));
}
// Alter the Kudu table to an external type with the master context succeeds.
{
Table alteredTable = table.deepCopy();
+ // Also change the location to avoid MetastoreDefaultTransformer validation
+ // that exists in some Hive versions.
+ alteredTable.getSd().setLocation(String.format("%s/%s/%s",
+ clientConf.get(HiveConf.ConfVars.METASTOREWAREHOUSE.varname),
+ table.getDbName(), table.getTableName()));
alteredTable.setTableType(TableType.EXTERNAL_TABLE.toString());
alteredTable.putToParameters(KuduMetastorePlugin.EXTERNAL_TABLE_KEY, "TRUE");
alteredTable.putToParameters(KuduMetastorePlugin.EXTERNAL_PURGE_KEY, "TRUE");
@@ -346,11 +368,17 @@ public class TestKuduMetastorePlugin {
// Check that adding a column fails.
table.getSd().addToCols(new FieldSchema("b", "int", ""));
+ // Also change the location to avoid MetastoreDefaultTransformer validation
+ // that exists in some Hive versions.
+ table.getSd().setLocation(String.format("%s/%s/%s",
+ clientConf.get(HiveConf.ConfVars.METASTOREWAREHOUSE.varname),
+ table.getDbName(), table.getTableName()));
try {
client.alter_table(table.getDbName(), table.getTableName(), table);
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains("Kudu table columns may not be altered through Hive"));
+ assertTrue(e.getMessage(),
+ e.getMessage().contains("Kudu table columns may not be altered through Hive"));
}
// Check that adding a column succeeds with the master event property set.
@@ -394,8 +422,9 @@ public class TestKuduMetastorePlugin {
client.alter_table(table.getDbName(), table.getTableName(), alteredTable);
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains(
- "non-Kudu table entry must not contain a table ID property"));
+ assertTrue(e.getMessage(),
+ e.getMessage().contains(
+ "non-Kudu table entry must not contain a table ID property"));
}
// Try to alter the table and set a Kudu storage handler.
@@ -406,8 +435,10 @@ public class TestKuduMetastorePlugin {
client.alter_table(table.getDbName(), table.getTableName(), alteredTable);
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains(
- "non-Kudu table entry must not contain the Kudu storage handler"));
+ assertTrue(
+ e.getMessage(),
+ e.getMessage().contains(
+ "non-Kudu table entry must not contain the Kudu storage handler"));
}
// Check that altering the table succeeds.
@@ -491,7 +522,8 @@ public class TestKuduMetastorePlugin {
envContext);
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains("Kudu table ID does not match the HMS entry"));
+ assertTrue(e.getMessage(),
+ e.getMessage().contains("Kudu table ID does not match the HMS entry"));
}
} finally {
// Dropping a Kudu table without context should succeed.
@@ -519,7 +551,8 @@ public class TestKuduMetastorePlugin {
envContext);
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains("Kudu table ID does not match the non-Kudu HMS entry"));
+ assertTrue(e.getMessage(),
+ e.getMessage().contains("Kudu table ID does not match the non-Kudu HMS entry"));
} finally {
client.dropTable(table.getDbName(), table.getTableName());
}
@@ -536,7 +569,8 @@ public class TestKuduMetastorePlugin {
envContext);
fail();
} catch (TException e) {
- assertTrue(e.getMessage().contains("Kudu table ID does not match the non-Kudu HMS entry"));
+ assertTrue(e.getMessage(),
+ e.getMessage().contains("Kudu table ID does not match the non-Kudu HMS entry"));
} finally {
client.dropTable(table.getDbName(), table.getTableName());
}