mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 22:56:15 +01:00
behave: Properly support @destructive tests
This commit is contained in:
parent
1839e834c6
commit
44eac57595
@ -20,8 +20,9 @@ def before_scenario(context, scenario):
|
||||
def after_scenario(context, scenario):
|
||||
if "destructive" in scenario.tags:
|
||||
# start a new container after a destructive test
|
||||
context.podman.kill()
|
||||
context.podman = podman.Podman(context)
|
||||
# we must use an existing podman instance defined in `before_all` due to context attribute life-cycle:
|
||||
# https://behave.readthedocs.io/en/stable/context_attributes.html
|
||||
context.podman.restart()
|
||||
context.osc.clear()
|
||||
common.check_exit_code(context)
|
||||
|
||||
|
@ -8,9 +8,7 @@ class Podman:
|
||||
self.context = context
|
||||
debug(context, "Podman.__init__()")
|
||||
self.container_id = None
|
||||
self.run()
|
||||
self.wait_on_systemd()
|
||||
self.port = self.get_port()
|
||||
self.start()
|
||||
|
||||
def __del__(self):
|
||||
try:
|
||||
@ -33,8 +31,8 @@ class Podman:
|
||||
debug(self.context, "> stderr:", proc.stderr)
|
||||
return proc
|
||||
|
||||
def run(self):
|
||||
debug(self.context, "Podman.run()")
|
||||
def start(self):
|
||||
debug(self.context, "Podman.start()")
|
||||
args = [
|
||||
"run",
|
||||
"--name", "obs-server-behave",
|
||||
@ -50,6 +48,8 @@ class Podman:
|
||||
proc = self._run(args)
|
||||
lines = proc.stdout.strip().splitlines()
|
||||
self.container_id = lines[-1]
|
||||
self.wait_on_systemd()
|
||||
self.port = self.get_port()
|
||||
|
||||
def kill(self):
|
||||
if not self.container_id:
|
||||
@ -59,6 +59,11 @@ class Podman:
|
||||
self._run(args)
|
||||
self.container_id = None
|
||||
|
||||
def restart(self):
|
||||
debug(self.context, "Podman.restart()")
|
||||
self.kill()
|
||||
self.start()
|
||||
|
||||
def wait_on_systemd(self):
|
||||
args = [
|
||||
"exec",
|
||||
|
Loading…
Reference in New Issue
Block a user