Repository: incubator-hawq
Updated Branches:
  refs/heads/master b29dc418a -> 48c34ca64


HAWQ-1020. Fix bugs to let feature tests TestCommonLib.TestHdfsConfig and 
TestCommonLib.TestYanConfig run in concourse


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/48c34ca6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/48c34ca6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/48c34ca6

Branch: refs/heads/master
Commit: 48c34ca64f1b07e70e4068cb555d5124e6ebcd37
Parents: b29dc41
Author: Chunling Wang <[email protected]>
Authored: Thu Aug 25 14:11:16 2016 +0800
Committer: Chunling Wang <[email protected]>
Committed: Thu Aug 25 14:31:00 2016 +0800

----------------------------------------------------------------------
 src/test/feature/lib/hdfs_config.cpp  |  8 ++++----
 src/test/feature/lib/yarn_config.cpp  |  6 +++---
 src/test/feature/testlib/test_lib.cpp | 22 ++++++++++++++++++++--
 3 files changed, 27 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/48c34ca6/src/test/feature/lib/hdfs_config.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/hdfs_config.cpp 
b/src/test/feature/lib/hdfs_config.cpp
index ee72a17..cded21e 100644
--- a/src/test/feature/lib/hdfs_config.cpp
+++ b/src/test/feature/lib/hdfs_config.cpp
@@ -19,9 +19,9 @@ void HdfsConfig::runCommand(const string &command,
                             string &result) {
   string cmd = "";
   if (ishdfsuser) {
-    cmd = "sudo -u ";
+    cmd = "/usr/bin/sudo -Eu ";
     cmd.append(getHdfsUser());
-    cmd.append(" ");
+    cmd.append(" env \"PATH=$PATH\" ");
     cmd.append(command);
   } else {
     cmd = command;
@@ -154,7 +154,7 @@ int HdfsConfig::isTruncate() {
 
 string HdfsConfig::getHadoopHome() {
   string result = "";
-  runCommand("ps -ef|grep hadoop", true, result);
+  runCommand("ps -ef|grep hadoop", false, result);
   string hadoopHome = "";
   auto lines = hawq::test::split(result, '\n');
   for (size_t i=0; i<lines.size()-1; i++) {
@@ -185,7 +185,7 @@ bool HdfsConfig::getStandbyNamenode(string &standbynamenode,
 bool HdfsConfig::getHANamenode(const string &namenodetype,
                                string &namenode,
                                int &port) {
-  if (!isHA()) {
+  if (isHA() <= 0) {
     return false;
   }
   string namenodeService = "";

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/48c34ca6/src/test/feature/lib/yarn_config.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/lib/yarn_config.cpp 
b/src/test/feature/lib/yarn_config.cpp
index 0587362..ea4d3f0 100644
--- a/src/test/feature/lib/yarn_config.cpp
+++ b/src/test/feature/lib/yarn_config.cpp
@@ -19,9 +19,9 @@ void YarnConfig::runCommand(const string &command,
                             string &result) {
   string cmd = "";
   if (isyarnuser) {
-    cmd = "sudo -u ";
+    cmd = "/usr/bin/sudo -Eu ";
     cmd.append(getYarnUser());
-    cmd.append(" ");
+    cmd.append(" env \"PATH=$PATH\" ");
     cmd.append(command);
   } else {
     cmd = command;
@@ -184,7 +184,7 @@ bool YarnConfig::getStandbyRM(string &standbyRM,
 bool YarnConfig::getHARM(const string &RMtype,
                                string &RM,
                                int &port) {
-  if (!isHA()) {
+  if (isHA() <= 0) {
     return false;
   }
   string RMService = "";

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/48c34ca6/src/test/feature/testlib/test_lib.cpp
----------------------------------------------------------------------
diff --git a/src/test/feature/testlib/test_lib.cpp 
b/src/test/feature/testlib/test_lib.cpp
index 03a254f..6c828f6 100644
--- a/src/test/feature/testlib/test_lib.cpp
+++ b/src/test/feature/testlib/test_lib.cpp
@@ -64,6 +64,13 @@ TEST_F(TestCommonLib, TestHdfsConfig) {
   hc.isConfigKerberos();
   hc.isTruncate();
   std::string hadoopHome = hc.getHadoopHome();
+  /* grant privilege for $HADOOP_HOME/etc/hadoop/hdfs-site.xml */
+  std::string confPath = hadoopHome;
+  confPath.append("/etc/hadoop/hdfs-site.xml");
+  std::string cmd = "/usr/bin/sudo -Eu root env \"PATH=$PATH\" chmod 777 ";
+  cmd.append(confPath);
+  hawq::test::Command c(cmd);
+  std::string result = c.run().getResultOutput();
 
   std::string hostname = "";
   int port = 0;
@@ -87,8 +94,10 @@ TEST_F(TestCommonLib, TestHdfsConfig) {
 
   hc.isSafemode();
 
-  hc.getParameterValue("dfs.replication");
+  std::string defaultValue = hc.getParameterValue("dfs.replication");
   hc.setParameterValue("dfs.replication", "1");
+  hc.getParameterValue("dfs.replication");
+  hc.setParameterValue("dfs.replication", defaultValue);
 }
 
 TEST_F(TestCommonLib, TestYarnConfig) {
@@ -99,6 +108,13 @@ TEST_F(TestCommonLib, TestYarnConfig) {
   hc.isHA();
   hc.isConfigKerberos();
   std::string hadoopHome = hc.getHadoopHome();
+  /* grant privilege for $HADOOP_HOME/etc/hadoop/yarn-site.xml */
+  std::string confPath = hadoopHome;
+  confPath.append("/etc/hadoop/yarn-site.xml");
+  std::string cmd = "/usr/bin/sudo -Eu root env \"PATH=$PATH\" chmod 777 ";
+  cmd.append(confPath);
+  hawq::test::Command c(cmd);
+  std::string result = c.run().getResultOutput();
 
   std::string hostname = "";
   int port = 0;
@@ -120,8 +136,10 @@ TEST_F(TestCommonLib, TestYarnConfig) {
   portList.clear();
   hc.getActiveNodeManagers(hostList, portList);
 
-  hc.getParameterValue("yarn.scheduler.minimum-allocation-mb");
+  std::string defaultValue 
=hc.getParameterValue("yarn.scheduler.minimum-allocation-mb");
   hc.setParameterValue("yarn.scheduler.minimum-allocation-mb", "1024");
+  defaultValue =hc.getParameterValue("yarn.scheduler.minimum-allocation-mb");
+  hc.setParameterValue("yarn.scheduler.minimum-allocation-mb", defaultValue);
 }
 
 TEST_F(TestCommonLib, TestCommand) {

Reply via email to