Skip to content

Commit

Permalink
isolate test_keygen data
Browse files Browse the repository at this point in the history
This makes test_keygen use its own basedir, to avoid polluting the _trial_temp
directory for later tests.
  • Loading branch information
leif committed Jan 12, 2014
1 parent e1840f1 commit db43528
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/allmydata/key_generator.py
Expand Up @@ -6,7 +6,7 @@
from zope.interface import implements
from twisted.internet import reactor
from twisted.application import service
from allmydata.util import log
from allmydata.util import log, fileutil

from pycryptopp.publickey import rsa
from allmydata.interfaces import RIKeyGenerator
Expand Down Expand Up @@ -79,6 +79,7 @@ class KeyGeneratorService(service.MultiService):
def __init__(self, basedir='.', display_furl=True, default_key_size=2048):
service.MultiService.__init__(self)
self.basedir = basedir
fileutil.make_dirs(self.basedir)
self.tub = Tub(certFile=os.path.join(self.basedir, 'key_generator.pem'))
self.tub.setOption("expose-remote-exception-types", False)
self.tub.setServiceParent(self)
Expand Down
2 changes: 1 addition & 1 deletion src/allmydata/test/test_keygen.py
Expand Up @@ -43,7 +43,7 @@ def p(junk, msg):

#print 'starting key generator service'
keysize = TEST_RSA_KEY_SIZE
kgs = key_generator.KeyGeneratorService(display_furl=False, default_key_size=keysize)
kgs = key_generator.KeyGeneratorService(display_furl=False, default_key_size=keysize, basedir="key_generator_service")
kgs.key_generator.verbose = True
kgs.setServiceParent(self.parent)
kgs.key_generator.pool_size = 8
Expand Down

3 comments on commit db43528

@daira
Copy link

@daira daira commented on db43528 Jan 12, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@daira
Copy link

@daira daira commented on db43528 Jan 12, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, wait. Other node types don't automatically create their base directories, IIUC. So shouldn't the creation of the base directory be in the test (either directly or by calling tahoe create-key-generator) rather than in KeyGeneratorService?

@leif
Copy link
Owner Author

@leif leif commented on db43528 Jan 12, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other types do, if they call allmydata.node.Node.__init__ (which allmydata.client.Client does)

Please sign in to comment.