Skip to content

Commit

Permalink
Test Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
stevesamson committed Jul 3, 2024
1 parent c7bd3c5 commit 8ef3c04
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,7 @@ public static void setLongVar(Configuration conf, ConfVars var, long val) {
* @return value, or default value if value not in config file
*/
public static boolean getBoolVar(Configuration conf, ConfVars var) {
assert var.defaultVal.getClass() == Boolean.class;
// assert var.defaultVal.getClass() == Boolean.class;
String val = conf.get(var.varname);
return val == null ? conf.getBoolean(var.hiveName, (Boolean)var.defaultVal) : Boolean.valueOf(val);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void run() {

}
}
private void createConfFile(String fileName, boolean inConf, String envVar,
private String createConfFile(String fileName, boolean inConf, String envVar,
Map<String, String> properties) throws IOException {
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File dir = new File(tmpDir, randomFileName());
Expand All @@ -98,19 +98,30 @@ private void createConfFile(String fileName, boolean inConf, String envVar,
File confFile = new File(dir, fileName);
confFile.deleteOnExit();
FileWriter writer = new FileWriter(confFile);
StringBuilder sb = new StringBuilder("<configuration>\n");
writer.write("<configuration>\n");
for (Map.Entry<String, String> entry : properties.entrySet()) {
sb.append(" <property>\n");
writer.write(" <property>\n");
writer.write(" <name>");
sb.append(" <name>");
writer.write(entry.getKey());
sb.append(entry.getKey());
writer.write("</name>\n");
sb.append("</name>\n");
writer.write(" <value>");
sb.append(" <value>");
writer.write(entry.getValue());
sb.append(entry.getValue());
writer.write("</value>\n");
sb.append("</value>\n");
writer.write(" </property>\n");
sb.append(" </property>\n");
}
writer.write("</configuration>\n");
sb.append("</configuration>\n");
writer.close();
return sb.toString();
}

private String randomFileName() {
Expand Down Expand Up @@ -210,11 +221,13 @@ public void readHiveSiteWithHiveConfDir() throws IOException {

@Test
public void readHiveSiteWithHiveHomeDir() throws IOException {
createConfFile("hive-site.xml", true, "HIVE_HOME", instaMap(
String confStr = createConfFile("hive-site.xml", true, "HIVE_HOME", instaMap(
"test.bool", "false"
));
conf = MetastoreConf.newMetastoreConf();
Assert.assertFalse(MetastoreConf.getBoolVar(conf, ConfVars.BOOLEAN_TEST_ENTRY));
boolean outcome = MetastoreConf.getBoolVar(conf, ConfVars.BOOLEAN_TEST_ENTRY);
System.out.println(String.format("DBUG: Check for Key:%s, Expected:%s in %s Actual:%s", ConfVars.BOOLEAN_TEST_ENTRY,"false", confStr, outcome));
Assert.assertFalse(outcome);
}

@Test
Expand All @@ -229,11 +242,14 @@ public void readHiveMetastoreSiteWithHiveConfDir() throws IOException {

@Test
public void readHiveMetastoreSiteWithHiveHomeDir() throws IOException {
createConfFile("hivemetastore-site.xml", true, "HIVE_HOME", instaMap(
String confStr = createConfFile("hivemetastore-site.xml", true, "HIVE_HOME", instaMap(
"test.bool", "false"
));

conf = MetastoreConf.newMetastoreConf();
Assert.assertFalse(MetastoreConf.getBoolVar(conf, ConfVars.BOOLEAN_TEST_ENTRY));
boolean outcome = MetastoreConf.getBoolVar(conf, ConfVars.BOOLEAN_TEST_ENTRY);
System.out.println(String.format("DBUG: Check for Key:%s, Expected:%s in %s Actual:%s", ConfVars.BOOLEAN_TEST_ENTRY,"false", confStr, outcome));
Assert.assertFalse(outcome);
}

@Test
Expand Down

0 comments on commit 8ef3c04

Please sign in to comment.