From 67abf3b2a7d2d2b417ae0a9304b7665e0e44308c Mon Sep 17 00:00:00 2001 From: Pier-Hugues Pellerin Date: Wed, 31 Oct 2018 13:24:23 -0400 Subject: [PATCH] Fix inherits environment variables (#8849) We were inheriting environment variables on windows only, this make sure the variables are inherited on unix too. Because the system module in metricbeat uses `lsof` since the environment variables were cleared the $PATH was not available so the binary was not found. fixes: #8848 --- libbeat/tests/system/beat/beat.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libbeat/tests/system/beat/beat.py b/libbeat/tests/system/beat/beat.py index ecceb017542..1c2db61108d 100644 --- a/libbeat/tests/system/beat/beat.py +++ b/libbeat/tests/system/beat/beat.py @@ -45,12 +45,11 @@ def __init__(self, args, outputfile, env={}): self.env = env def start(self): + # ensure that the environment is inherited to the subprocess. + variables = os.environ.copy() + variables = variables.update(self.env) if sys.platform.startswith("win"): - # ensure that the environment is inherited to the subprocess. - variables = os.environ.copy() - variables = variables.update(self.env) - self.proc = subprocess.Popen( self.args, stdin=self.stdin_read, @@ -66,7 +65,7 @@ def start(self): stdout=self.output, stderr=subprocess.STDOUT, bufsize=0, - env=self.env) + env=variables) # If a "No such file or directory" error points you here, run # "make metricbeat.test" on metricbeat folder return self.proc