some tweaks and fixes for integration tests

This commit is contained in:
meejah 2018-12-11 12:48:37 -07:00
parent 7b5783536b
commit 75fee995b6
4 changed files with 27 additions and 9 deletions

View File

@ -94,7 +94,7 @@ def test_remove_last_client(reactor):
@pytest.inlineCallbacks
def test_reject_storage_server(reactor, request, alice, storage_nodes):
def test_reject_storage_server(reactor, request, storage_nodes, temp_dir, introducer_furl, flog_gatherer):
gm_config = yield util.run_tahoe(
reactor, "grid-manager", "--config", "-", "create",
)
@ -115,6 +115,15 @@ def test_reject_storage_server(reactor, request, alice, storage_nodes):
)
assert sorted(json.loads(gm_config)['storage_servers'].keys()) == ['storage0', 'storage1']
# XXX FIXME need to shut-down and nuke carol when we're done this
# test (i.d. request.addfinalizer)
carol = yield util._create_node(
reactor, request, temp_dir, introducer_furl, flog_gatherer, "carol",
web_port="tcp:9982:interface=localhost",
storage=False,
)
print("inserting certificates")
# insert their certificates
for idx, storage in enumerate(storage_nodes[:2]):
@ -141,26 +150,28 @@ def test_reject_storage_server(reactor, request, alice, storage_nodes):
# now only two storage-servers have certificates .. configure
# alice to have the grid-manager certificate
config = configutil.get_config(join(alice._node_dir, "tahoe.cfg"))
# XXX FIXME remove this cert when test ends (fail or not!)
config = configutil.get_config(join(carol._node_dir, "tahoe.cfg"))
print(dir(config))
config.add_section("grid_managers")
config.set("grid_managers", "test", pubkey_bytes)
config.write(open(join(alice._node_dir, "tahoe.cfg"), "w"))
alice.signalProcess('TERM')
yield alice._protocol.exited
config.write(open(join(carol._node_dir, "tahoe.cfg"), "w"))
carol.signalProcess('TERM')
yield carol._protocol.exited
time.sleep(1)
alice = yield util._run_node(
reactor, alice._node_dir, request, None,
reactor, carol._node_dir, request, None,
)
time.sleep(5)
# try to put something into the grid, which should fail (because
# alice has happy=3 but should only find storage0, storage1 to be
# carol has happy=3 but should only find storage0, storage1 to be
# acceptable to upload to)
try:
yield util.run_tahoe(
reactor, "--node-directory", alice._node_dir,
reactor, "--node-directory", carol._node_dir,
"put", "-",
stdin="some content" * 200,
)

View File

@ -43,7 +43,7 @@ def test_upload_immutable(reactor, temp_dir, introducer_furl, flog_gatherer, sto
yield proto.done
assert False, "should raise exception"
except Exception as e:
assert isinstance(e, ProcessTerminated)
assert "UploadUnhappinessError" in str(e)
output = proto.output.getvalue()
assert "shares could be placed on only" in output

View File

@ -68,6 +68,9 @@ def _create_anonymous_node(reactor, name, control_port, request, temp_dir, flog_
web_port = "tcp:{}:interface=localhost".format(control_port + 2000)
if True:
if exists(node_dir):
print("nuking '{}'".format(node_dir))
shutil.rmtree(node_dir)
print("creating", node_dir)
mkdir(node_dir)
proto = util._DumpOutputProtocol(None)

View File

@ -4,6 +4,7 @@ from os import mkdir
from os.path import exists, join
from six.moves import StringIO
from functools import partial
from shutil import rmtree
from twisted.internet.defer import Deferred, succeed
from twisted.internet.protocol import ProcessProtocol
@ -200,6 +201,9 @@ def _create_node(reactor, request, temp_dir, introducer_furl, flog_gatherer, nam
if exists(node_dir):
created_d = succeed(None)
else:
if exists(node_dir):
print("nuking: {}".format(node_dir))
rmtree(node_dir)
print("creating", node_dir)
mkdir(node_dir)
done_proto = _ProcessExitedProtocol()