瀏覽代碼

HPCC-22570 Regression Test Engine isSudoer() check generates false negative result on older (6.x) CentOS distro.

Implement more check and retry with simplified parameterlist

Remove an old, commeted out line.

Tested manually on Ubuntu 16.04, CentOS 6.x and 7.x

Signed-off-by: Attila Vamos <attila.vamos@gmail.com>
Attila Vamos 6 年之前
父節點
當前提交
1045ffa208
共有 2 個文件被更改,包括 13 次插入3 次删除
  1. 0 1
      testing/regress/hpcc/util/ecl/command.py
  2. 13 2
      testing/regress/hpcc/util/util.py

+ 0 - 1
testing/regress/hpcc/util/ecl/command.py

@@ -45,7 +45,6 @@ class ECLcmd(Shell):
         args.append('-fpickBestEngine=false')
         args.append('--target=' + engine)
         args.append('--cluster=' + cluster)
-        #args.append('--cluster=' + cluster + "_160")
         args.append('--port=' + self.config.espSocket)
         if self.config.useSsl.lower() == 'true':
             args.append('--ssl')

+ 13 - 2
testing/regress/hpcc/util/util.py

@@ -365,15 +365,26 @@ def isSudoer(testId = -1):
     retVal = False
     if 'linux' in sys.platform :
         tryCount = 5
+        cmd = "timeout -k 2 2 sudo id && echo Access granted || echo Access denied"
         while tryCount > 0:
-            myProc = subprocess.Popen(["timeout -k 2 2 sudo id && echo Access granted || echo Access denied"], shell=True, bufsize=8192, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+            tryCount -= 1
+            
+            myProc = subprocess.Popen([cmd], shell=True, bufsize=8192, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
             (myStdout,  myStderr) = myProc.communicate()
             result = "returncode:" + str(myProc.returncode) + ", stdout:\n'" + myStdout + "', stderr:\n'" + myStderr + "'."
             logging.debug("%3d. isSudoer() result is: '%s' (try count is:%d)", testId, result, tryCount)
+            
+            if 'timeout: invalid option' in myStderr:
+                logging.debug("%3d. isSudoer() result is: '%s'", testId, result)
+                cmd = "timeout 2 sudo id && echo Access granted || echo Access denied"
+                logging.debug("%3d. try is without '-k 2' parameter: '%s'", testId, cmd)
+                continue
+                
             if 'Access denied' not in myStdout:
                 retVal = True
                 break
-            tryCount -= 1
+
+
 
         if retVal == False:
             logging.debug("%3d. isSudoer() result is: '%s'", testId, result)