mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-24 02:51:18 +00:00
add a .restart() to Client and StorageServer
This commit is contained in:
parent
c5fb2b5a8b
commit
c9de1ee757
@ -48,6 +48,7 @@ from util import (
|
|||||||
_cleanup_tahoe_process,
|
_cleanup_tahoe_process,
|
||||||
_tahoe_runner_optional_coverage,
|
_tahoe_runner_optional_coverage,
|
||||||
TahoeProcess,
|
TahoeProcess,
|
||||||
|
await_client_ready,
|
||||||
)
|
)
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
@ -155,8 +156,14 @@ class StorageServer(object):
|
|||||||
validator=attr.validators.provides(IProcessProtocol)
|
validator=attr.validators.provides(IProcessProtocol)
|
||||||
)
|
)
|
||||||
|
|
||||||
# XXX needs a restart() probably .. or at least a stop() and
|
@inlineCallbacks
|
||||||
# start()
|
def restart(self, reactor, request):
|
||||||
|
self.process.transport.signalProcess('TERM')
|
||||||
|
yield self.protocol.exited
|
||||||
|
self.process = yield _run_node(
|
||||||
|
reactor, self.process.node_dir, request, None,
|
||||||
|
)
|
||||||
|
self.protocol = self.process.transport._protocol
|
||||||
|
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
@ -190,6 +197,14 @@ class Client(object):
|
|||||||
validator=attr.validators.provides(IProcessProtocol)
|
validator=attr.validators.provides(IProcessProtocol)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@inlineCallbacks
|
||||||
|
def restart(self, reactor, request):
|
||||||
|
self.process.transport.signalProcess('TERM')
|
||||||
|
yield self.protocol.exited
|
||||||
|
x = yield _run_node(
|
||||||
|
reactor, self.process.node_dir, request, None,
|
||||||
|
)
|
||||||
|
|
||||||
# XXX add stop / start / restart
|
# XXX add stop / start / restart
|
||||||
# ...maybe "reconfig" of some kind?
|
# ...maybe "reconfig" of some kind?
|
||||||
|
|
||||||
@ -373,6 +388,7 @@ class Grid(object):
|
|||||||
total=total,
|
total=total,
|
||||||
)
|
)
|
||||||
self.clients[name] = client
|
self.clients[name] = client
|
||||||
|
yield await_client_ready(client.process)
|
||||||
returnValue(client)
|
returnValue(client)
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,8 +133,6 @@ def test_reject_storage_server(reactor, request, temp_dir, flog_gatherer, port_a
|
|||||||
)
|
)
|
||||||
assert json.loads(gm_config)['storage_servers'].keys() == ['storage0']
|
assert json.loads(gm_config)['storage_servers'].keys() == ['storage0']
|
||||||
|
|
||||||
diana = yield grid.add_client("diana", needed=2, happy=2, total=2)
|
|
||||||
|
|
||||||
print("inserting certificate")
|
print("inserting certificate")
|
||||||
cert = yield util.run_tahoe(
|
cert = yield util.run_tahoe(
|
||||||
reactor, request, "grid-manager", "--config", "-", "sign", "storage0",
|
reactor, request, "grid-manager", "--config", "-", "sign", "storage0",
|
||||||
@ -150,29 +148,20 @@ def test_reject_storage_server(reactor, request, temp_dir, flog_gatherer, port_a
|
|||||||
config.write(f)
|
config.write(f)
|
||||||
|
|
||||||
# re-start this storage server
|
# re-start this storage server
|
||||||
storage0.process.transport.signalProcess('TERM')
|
yield storage0.restart(reactor, request)
|
||||||
yield storage0.protocol.exited
|
|
||||||
yield util._run_node(
|
|
||||||
reactor, storage0.process.node_dir, request, None,
|
|
||||||
)
|
|
||||||
|
|
||||||
yield util.await_client_ready(diana.process, servers=2)
|
|
||||||
|
|
||||||
# now only one storage-server has the certificate .. configure
|
# now only one storage-server has the certificate .. configure
|
||||||
# diana to have the grid-manager certificate
|
# diana to have the grid-manager certificate
|
||||||
|
|
||||||
|
diana = yield grid.add_client("diana", needed=2, happy=2, total=2)
|
||||||
|
|
||||||
config = configutil.get_config(join(diana.process.node_dir, "tahoe.cfg"))
|
config = configutil.get_config(join(diana.process.node_dir, "tahoe.cfg"))
|
||||||
config.add_section("grid_managers")
|
config.add_section("grid_managers")
|
||||||
config.set("grid_managers", "test", ed25519.string_from_verifying_key(gm_pubkey))
|
config.set("grid_managers", "test", ed25519.string_from_verifying_key(gm_pubkey))
|
||||||
with open(join(diana.process.node_dir, "tahoe.cfg"), "w") as f:
|
with open(join(diana.process.node_dir, "tahoe.cfg"), "w") as f:
|
||||||
config.write(f)
|
config.write(f)
|
||||||
diana.process.transport.signalProcess('TERM')
|
|
||||||
yield diana.protocol.exited
|
|
||||||
|
|
||||||
diana = yield util._run_node(
|
yield diana.restart(reactor, request)
|
||||||
reactor, diana.process.node_dir, request, None,
|
|
||||||
)
|
|
||||||
yield util.await_client_ready(diana.process, servers=2)
|
|
||||||
|
|
||||||
# try to put something into the grid, which should fail (because
|
# try to put something into the grid, which should fail (because
|
||||||
# diana has happy=2 but should only find storage0 to be acceptable
|
# diana has happy=2 but should only find storage0 to be acceptable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user