mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 02:01:31 +00:00
factor cleanup into api class
This commit is contained in:
parent
5a1183500e
commit
57fc078383
@ -26,7 +26,12 @@ from twisted.internet.defer import (
|
||||
succeed,
|
||||
)
|
||||
|
||||
from allmydata.client import _Client
|
||||
from ..client import (
|
||||
_Client,
|
||||
)
|
||||
from ..scripts.tahoe_stop import (
|
||||
COULD_NOT_STOP,
|
||||
)
|
||||
|
||||
class Expect(Protocol):
|
||||
def __init__(self):
|
||||
@ -134,6 +139,20 @@ class CLINodeAPI(object):
|
||||
# the test fails), the client should still terminate.
|
||||
self.exit_trigger_file.touch()
|
||||
|
||||
def cleanup(self):
|
||||
stopping = stop_and_wait(tahoe)
|
||||
stopping.addErrback(
|
||||
# Let it fail because the process has already exited.
|
||||
lambda err: (
|
||||
err.trap(ProcessTerminated)
|
||||
and self.assertEqual(
|
||||
err.value.exitCode,
|
||||
COULD_NOT_STOP,
|
||||
)
|
||||
)
|
||||
)
|
||||
return stopping
|
||||
|
||||
|
||||
class _WaitForEnd(ProcessProtocol):
|
||||
def __init__(self, ended):
|
||||
|
@ -41,9 +41,6 @@ from ._twisted_9607 import (
|
||||
from ..util.eliotutil import (
|
||||
inline_callbacks,
|
||||
)
|
||||
from ..scripts.tahoe_stop import (
|
||||
COULD_NOT_STOP,
|
||||
)
|
||||
|
||||
timeout = 240
|
||||
|
||||
@ -614,18 +611,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
|
||||
|
||||
tahoe = CLINodeAPI(reactor, FilePath(c1))
|
||||
# Set this up right now so we don't forget later.
|
||||
self.addCleanup(
|
||||
lambda: stop_and_wait(tahoe).addErrback(
|
||||
# Let it fail because the process has already exited.
|
||||
lambda err: (
|
||||
err.trap(ProcessTerminated)
|
||||
and self.assertEqual(
|
||||
err.value.exitCode,
|
||||
COULD_NOT_STOP,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
self.addCleanup(tahoe.cleanup)
|
||||
|
||||
out, err, rc_or_sig = yield self.run_bintahoe([
|
||||
"--quiet", "create-node", "--basedir", c1,
|
||||
|
Loading…
x
Reference in New Issue
Block a user