Bläddra i källkod

Merge pull request #12817 from AttilaVamos/HPCC-22570-fix-7.2.x

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

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 6 år sedan
förälder
incheckning
7acde86962
2 ändrade filer med 13 tillägg och 3 borttagningar
  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)