Preserve environment when running koji commands
JIRA: RHELBLD-2479 Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
e628bb91ec
commit
a6a96e40db
@ -249,14 +249,15 @@ class KojiWrapper(object):
|
||||
If we are authenticated with a keytab, we need a fresh credentials
|
||||
cache to avoid possible race condition.
|
||||
"""
|
||||
env = os.environ.copy()
|
||||
if getattr(self.koji_module.config, "keytab", None):
|
||||
with util.temp_dir(prefix="krb_ccache") as tempdir:
|
||||
env = os.environ.copy()
|
||||
env["KRB5CCNAME"] = "DIR:%s" % tempdir
|
||||
env["PYTHONUNBUFFERED"] = "1"
|
||||
yield env
|
||||
else:
|
||||
yield {"PYTHONUNBUFFERED": "1"}
|
||||
env["PYTHONUNBUFFERED"] = "1"
|
||||
yield env
|
||||
|
||||
def run_runroot_cmd(self, command, log_file=None):
|
||||
"""Run koji runroot command and wait for results.
|
||||
|
@ -525,6 +525,7 @@ class LiveImageKojiWrapperTest(KojiWrapperBaseTestCase):
|
||||
)
|
||||
|
||||
|
||||
@mock.patch.dict("os.environ", {"FOO": "BAR"}, clear=True)
|
||||
class RunrootKojiWrapperTest(KojiWrapperBaseTestCase):
|
||||
def test_get_cmd_minimal(self):
|
||||
cmd = self.koji.get_runroot_cmd("tgt", "s390x", "date", use_shell=False)
|
||||
@ -625,7 +626,7 @@ class RunrootKojiWrapperTest(KojiWrapperBaseTestCase):
|
||||
mock.call(
|
||||
cmd,
|
||||
can_fail=True,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
env={"FOO": "BAR", "PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
logfile=None,
|
||||
show_cmd=True,
|
||||
@ -654,7 +655,7 @@ class RunrootKojiWrapperTest(KojiWrapperBaseTestCase):
|
||||
mock.call(
|
||||
cmd,
|
||||
can_fail=True,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
env={"FOO": "BAR", "PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
logfile=None,
|
||||
show_cmd=True,
|
||||
@ -663,7 +664,6 @@ class RunrootKojiWrapperTest(KojiWrapperBaseTestCase):
|
||||
],
|
||||
)
|
||||
|
||||
@mock.patch.dict("os.environ", {"FOO": "BAR"}, clear=True)
|
||||
@mock.patch("shutil.rmtree")
|
||||
@mock.patch("tempfile.mkdtemp")
|
||||
@mock.patch("pungi.wrappers.kojiwrapper.run")
|
||||
@ -698,6 +698,7 @@ class RunrootKojiWrapperTest(KojiWrapperBaseTestCase):
|
||||
)
|
||||
|
||||
|
||||
@mock.patch.dict("os.environ", {"FOO": "BAR"}, clear=True)
|
||||
class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
@mock.patch("pungi.wrappers.kojiwrapper.run")
|
||||
def test_minimal(self, run):
|
||||
@ -715,14 +716,13 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
env={"FOO": "BAR", "PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
@mock.patch.dict("os.environ", {"FOO": "BAR"}, clear=True)
|
||||
@mock.patch("pungi.util.temp_dir")
|
||||
@mock.patch("pungi.wrappers.kojiwrapper.run")
|
||||
def test_with_keytab(self, run, temp_dir):
|
||||
@ -769,7 +769,7 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile="logfile",
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
env={"FOO": "BAR", "PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
)
|
||||
@ -792,7 +792,7 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
env={"FOO": "BAR", "PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
)
|
||||
@ -815,7 +815,7 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
env={"FOO": "BAR", "PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
)
|
||||
@ -839,7 +839,7 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
env={"FOO": "BAR", "PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
),
|
||||
@ -868,7 +868,7 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
env={"FOO": "BAR", "PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
),
|
||||
@ -898,7 +898,7 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
env={"FOO": "BAR", "PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
),
|
||||
@ -941,7 +941,7 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
env={"FOO": "BAR", "PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
),
|
||||
@ -977,7 +977,7 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
env={"FOO": "BAR", "PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user