You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/07/31 02:17:08 UTC

[GitHub] [flink] lirui-apache commented on a change in pull request #9237: [FLINK-13431][hive] NameNode HA configuration was not loaded when running HiveConnector on Yarn

lirui-apache commented on a change in pull request #9237: [FLINK-13431][hive] NameNode HA configuration was not loaded when running HiveConnector on Yarn
URL: https://github.com/apache/flink/pull/9237#discussion_r309015087
 
 

 ##########
 File path: flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/table/catalog/hive/factories/HiveCatalogFactoryTest.java
 ##########
 @@ -54,9 +65,49 @@ public void test() {
 		checkEquals(expectedCatalog, (HiveCatalog) actualCatalog);
 	}
 
+	@Test
+	public void testLoadHDFSConfigFromEnv() throws IOException {
+		final String k1 = "what is connector?";
+		final String v1 = "Hive";
+		final String catalogName = "HiveCatalog";
+
+		// set HADOOP_CONF_DIR env
+		final File hadoopConfDir = tempFolder.newFolder();
+		final File hdfsSiteFile = new File(hadoopConfDir, "hdfs-site.xml");
+		writeProperty(hdfsSiteFile, k1, v1);
+		final Map<String, String> originalEnv = System.getenv();
+		final Map<String, String> newEnv = new HashMap<>(originalEnv);
+		newEnv.put("HADOOP_CONF_DIR", hadoopConfDir.getAbsolutePath());
+		CommonTestUtils.setEnv(newEnv);
+
+		// create HiveCatalog use the Hadoop Configuration
+		final CatalogDescriptor catalogDescriptor = new HiveCatalogDescriptor();
+		final Map<String, String> properties = catalogDescriptor.toProperties();
+		final HiveCatalog hiveCatalog = (HiveCatalog) TableFactoryService.find(CatalogFactory.class, properties)
+			.createCatalog(catalogName, properties);
+		final HiveConf hiveConf = hiveCatalog.getHiveConf();
+		// set the Env back
+		CommonTestUtils.setEnv(originalEnv);
 
 Review comment:
   I'd suggest move this to a finally block, so that if this test case fails, it doesn't pollute env for other tests.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services