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 b7ae014
Showing 1 changed file with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,13 @@ 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());
if(envVar.equals("HIVE_HOME")){
System.out.println("DBUG: writing to: " + dir.getAbsolutePath());
}
Assume.assumeTrue(dir.mkdir());
dir.deleteOnExit();
System.setProperty(MetastoreConf.TEST_ENV_WORKAROUND + envVar, dir.getAbsolutePath());
Expand All @@ -98,19 +101,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 +224,15 @@ 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));
String found = conf.get("test.bool");
System.out.println(String.format("DBUG: readHiveSiteWithHiveHomeDir : Found:%s, for key:'test.bool'", found));
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 +247,16 @@ 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));
String found = conf.get("test.bool");
System.out.println(String.format("DBUG: readHiveMetastoreSiteWithHiveHomeDir : Found:%s, for key:'test.bool'", found));
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 b7ae014

Please sign in to comment.