You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2019/02/28 01:49:11 UTC

[GitHub] swagle commented on a change in pull request #527: HDDS-1093. Configuration tab in OM/SCM ui is not displaying the correct values

swagle commented on a change in pull request #527: HDDS-1093. Configuration tab in OM/SCM ui is not displaying the correct values
URL: https://github.com/apache/hadoop/pull/527#discussion_r261019552
 
 

 ##########
 File path: hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/conf/TestOzoneConfiguration.java
 ##########
 @@ -0,0 +1,171 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hdds.conf;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+public class TestOzoneConfiguration {
+
+  private Configuration conf;
+  final static String CONFIG = new File("./test-config-TestConfiguration.xml").getAbsolutePath();
+  final static String CONFIG_CORE = new File("./core-site.xml").getAbsolutePath();
+
+  private BufferedWriter out;
+
+  @Before
+  public void setUp() throws Exception {
+    conf = new OzoneConfiguration();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    if(out != null) {
+      out.close();
+    }
+    new File(CONFIG).delete();
+    new File(CONFIG_CORE).delete();
+  }
+
+  private void startConfig() throws IOException {
+    out.write("<?xml version=\"1.0\"?>\n");
+    out.write("<configuration>\n");
+  }
+
+  private void endConfig() throws IOException{
+    out.write("</configuration>\n");
+    out.flush();
+    out.close();
+  }
+
+  @Test
+  public void testGetAllPropertiesByTags() throws Exception {
+
+    try{
+      out = new BufferedWriter(new FileWriter(CONFIG));
+      startConfig();
+      appendProperty("hadoop.tags.system", "YARN,HDFS,NAMENODE");
+      appendProperty("hadoop.tags.custom", "MYCUSTOMTAG");
+      appendPropertyByTag("dfs.cblock.trace.io", "false", "YARN");
+      appendPropertyByTag("dfs.replication", "1", "HDFS");
+      appendPropertyByTag("dfs.namenode.logging.level", "INFO", "NAMENODE");
+      appendPropertyByTag("dfs.random.key", "XYZ", "MYCUSTOMTAG");
+      endConfig();
+
+      Path fileResource = new Path(CONFIG);
+      conf.addResource(fileResource);
+      assertEq(conf.getAllPropertiesByTag("MYCUSTOMTAG").getProperty("dfs.random.key"), "XYZ");
+    } finally {
+      out.close();
+    }
+    try {
 
 Review comment:
   Better to use try construct that closes the Closeable vs explicit close. syntactic sugar

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org