mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-26 22:09:54 +00:00
Merge PR432: improve servers of happiness integration test
The node creation helper used by the integration tests is now more careful about how it tweaks additional configuration file fields. Previously, it could easily clobber certain settings. Now it should only introduce the specific changes it intends. Closes ticket:2895
This commit is contained in:
commit
7cad9e1b5d
integration
@ -1,10 +1,7 @@
|
||||
import sys
|
||||
import time
|
||||
import shutil
|
||||
from os import mkdir, unlink, listdir
|
||||
from os.path import join, exists
|
||||
from os.path import join
|
||||
|
||||
from twisted.internet import defer, reactor, task
|
||||
from twisted.internet import task
|
||||
from twisted.internet.error import ProcessTerminated
|
||||
|
||||
import util
|
||||
@ -15,13 +12,12 @@ import pytest
|
||||
@pytest.inlineCallbacks
|
||||
def test_upload_immutable(reactor, temp_dir, introducer_furl, flog_gatherer, storage_nodes, request):
|
||||
|
||||
# hmm, for some reason this still gets storage enabled ...
|
||||
process = yield util._create_node(
|
||||
yield util._create_node(
|
||||
reactor, request, temp_dir, introducer_furl, flog_gatherer, "edna",
|
||||
web_port="tcp:9983:interface=localhost",
|
||||
storage=False,
|
||||
needed=3,
|
||||
happy=10,
|
||||
happy=7,
|
||||
total=10,
|
||||
)
|
||||
|
||||
@ -34,7 +30,7 @@ def test_upload_immutable(reactor, temp_dir, introducer_furl, flog_gatherer, sto
|
||||
# upload a file, which should fail because we have don't have 7
|
||||
# storage servers (but happiness is set to 7)
|
||||
proto = util._CollectOutputProtocol()
|
||||
transport = reactor.spawnProcess(
|
||||
reactor.spawnProcess(
|
||||
proto,
|
||||
sys.executable,
|
||||
[
|
||||
|
@ -4,10 +4,16 @@ from os import mkdir
|
||||
from os.path import exists, join
|
||||
from StringIO import StringIO
|
||||
|
||||
from twisted.internet.defer import Deferred
|
||||
from twisted.internet.defer import Deferred, succeed
|
||||
from twisted.internet.protocol import ProcessProtocol
|
||||
from twisted.internet.error import ProcessExitedAlready, ProcessDone
|
||||
|
||||
from allmydata.util.configutil import (
|
||||
get_config,
|
||||
set_config,
|
||||
write_config,
|
||||
)
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@ -145,7 +151,9 @@ def _create_node(reactor, request, temp_dir, introducer_furl, flog_gatherer, nam
|
||||
node_dir = join(temp_dir, name)
|
||||
if web_port is None:
|
||||
web_port = ''
|
||||
if not exists(node_dir):
|
||||
if exists(node_dir):
|
||||
created_d = succeed(None)
|
||||
else:
|
||||
print("creating", node_dir)
|
||||
mkdir(node_dir)
|
||||
done_proto = _ProcessExitedProtocol()
|
||||
@ -156,6 +164,10 @@ def _create_node(reactor, request, temp_dir, introducer_furl, flog_gatherer, nam
|
||||
'--introducer', introducer_furl,
|
||||
'--hostname', 'localhost',
|
||||
'--listen', 'tcp',
|
||||
'--webport', web_port,
|
||||
'--shares-needed', unicode(needed),
|
||||
'--shares-happy', unicode(happy),
|
||||
'--shares-total', unicode(total),
|
||||
]
|
||||
if not storage:
|
||||
args.append('--no-storage')
|
||||
@ -169,33 +181,11 @@ def _create_node(reactor, request, temp_dir, introducer_furl, flog_gatherer, nam
|
||||
created_d = done_proto.done
|
||||
|
||||
def created(_):
|
||||
with open(join(node_dir, 'tahoe.cfg'), 'w') as f:
|
||||
f.write('''
|
||||
[node]
|
||||
nickname = %(name)s
|
||||
web.port = %(web_port)s
|
||||
web.static = public_html
|
||||
log_gatherer.furl = %(log_furl)s
|
||||
|
||||
[client]
|
||||
# Which services should this client connect to?
|
||||
introducer.furl = %(furl)s
|
||||
shares.needed = %(needed)d
|
||||
shares.happy = %(happy)d
|
||||
shares.total = %(total)d
|
||||
|
||||
''' % {
|
||||
'name': name,
|
||||
'furl': introducer_furl,
|
||||
'web_port': web_port,
|
||||
'log_furl': flog_gatherer,
|
||||
'needed': needed,
|
||||
'happy': happy,
|
||||
'total': total,
|
||||
})
|
||||
config_path = join(node_dir, 'tahoe.cfg')
|
||||
config = get_config(config_path)
|
||||
set_config(config, 'node', 'log_gatherer.furl', flog_gatherer)
|
||||
write_config(config_path, config)
|
||||
created_d.addCallback(created)
|
||||
else:
|
||||
created_d = defer.succeed(None)
|
||||
|
||||
d = Deferred()
|
||||
d.callback(None)
|
||||
@ -234,5 +224,3 @@ def await_file_vanishes(path, timeout=10):
|
||||
return
|
||||
time.sleep(1)
|
||||
raise Exception("'{}' still exists after {}s".format(path, timeout))
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user