Changeset 07ffde3 in trunk
- Timestamp:
- 2021-11-05T15:13:23Z (3 years ago)
- Branches:
- master
- Children:
- 68a27b1, 7faec6e5, bea4cf1, fe6a2f6f
- Parents:
- 8383f6a (diff), b4bc95c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Jean-Paul Calderone <exarkun@…> (2021-11-05 15:13:23)
- git-committer:
- GitHub <noreply@…> (2021-11-05 15:13:23)
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/allmydata/scripts/common.py ¶
r8383f6a r07ffde3 142 142 if isinstance(furl, bytes): 143 143 furl = furl.decode("utf-8") 144 basedir.child(b"private").child(b"introducers.yaml").setContent( 144 private = basedir.child(b"private") 145 private.makedirs(ignoreExistingDirectory=True) 146 private.child(b"introducers.yaml").setContent( 145 147 safe_dump({ 146 148 "introducers": { -
TabularUnified src/allmydata/test/common.py ¶
r8383f6a r07ffde3 268 268 269 269 config = attr.ib(default=None) 270 reactor = attr.ib(default=None) 270 271 271 272 def setUp(self): 273 self.assigner = SameProcessStreamEndpointAssigner() 274 self.assigner.setUp() 275 272 276 def format_config_items(config): 273 277 return "\n".join( … … 293 297 self.introducer_furl, 294 298 ) 299 300 node_config = self.node_config.copy() 301 if "tub.port" not in node_config: 302 if "tub.location" in node_config: 303 raise ValueError( 304 "UseNode fixture does not support specifying tub.location " 305 "without tub.port" 306 ) 307 308 # Don't use the normal port auto-assignment logic. It produces 309 # collisions and makes tests fail spuriously. 310 tub_location, tub_endpoint = self.assigner.assign(self.reactor) 311 node_config.update({ 312 "tub.port": tub_endpoint, 313 "tub.location": tub_location, 314 }) 315 295 316 self.config = config_from_string( 296 317 self.basedir.asTextMode().path, … … 305 326 """.format( 306 327 storage_plugin=self.storage_plugin, 307 node_config=format_config_items( self.node_config),328 node_config=format_config_items(node_config), 308 329 plugin_config_section=plugin_config_section, 309 330 ) … … 317 338 318 339 def cleanUp(self): 319 pass340 self.assigner.tearDown() 320 341 321 342 -
TabularUnified src/allmydata/test/common_system.py ¶
r8383f6a r07ffde3 768 768 config = {} 769 769 770 except1 = set(range(self.numclients)) - {1} 770 allclients = set(range(self.numclients)) 771 except1 = allclients - {1} 771 772 feature_matrix = { 772 773 ("client", "nickname"): except1, 773 774 774 # client 1 has to auto-assign an address. 775 ("node", "tub.port"): except1, 776 ("node", "tub.location"): except1, 775 # Auto-assigning addresses is extremely failure prone and not 776 # amenable to automated testing in _this_ manner. 777 ("node", "tub.port"): allclients, 778 ("node", "tub.location"): allclients, 777 779 778 780 # client 0 runs a webserver and a helper … … 856 858 basedir = FilePath(self.getdir("client%d" % client_num)) 857 859 basedir.makedirs() 858 config = "[client]\n" 860 config = ( 861 "[node]\n" 862 "tub.location = {}\n" 863 "tub.port = {}\n" 864 "[client]\n" 865 ).format(*self.port_assigner.assign(reactor)) 866 859 867 if helper_furl: 860 868 config += "helper.furl = %s\n" % helper_furl -
TabularUnified src/allmydata/test/test_client.py ¶
r8383f6a r07ffde3 90 90 MemoryIntroducerClient, 91 91 get_published_announcements, 92 UseNode, 92 93 ) 93 94 from .matchers import ( … … 954 955 @defer.inlineCallbacks 955 956 def test_reloadable(self): 956 basedir = FilePath("test_client.Run.test_reloadable") 957 private = basedir.child("private") 958 private.makedirs() 957 from twisted.internet import reactor 958 959 959 dummy = "pb://wl74cyahejagspqgy4x5ukrvfnevlknt@127.0.0.1:58889/bogus" 960 write_introducer(basedir, "someintroducer", dummy) 961 basedir.child("tahoe.cfg").setContent(BASECONFIG. encode("ascii")) 962 c1 = yield client.create_client(basedir.path) 960 fixture = UseNode(None, None, FilePath(self.mktemp()), dummy, reactor=reactor) 961 fixture.setUp() 962 self.addCleanup(fixture.cleanUp) 963 964 c1 = yield fixture.create_node() 963 965 c1.setServiceParent(self.sparent) 964 966 … … 982 984 # reactor.stop, also instrument the shutdown event in an 983 985 # attribute that we can check.) 984 c2 = yield client.create_client(basedir.path)986 c2 = yield fixture.create_node() 985 987 c2.setServiceParent(self.sparent) 986 988 yield c2.disownServiceParent() -
TabularUnified src/allmydata/test/test_node.py ¶
r8383f6a r07ffde3 70 70 from .common import ( 71 71 ConstantAddresses, 72 SameProcessStreamEndpointAssigner, 73 UseNode, 72 74 ) 73 75 … … 81 83 82 84 # see https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2946 83 def testing_tub( config_data=''):85 def testing_tub(reactor, config_data=''): 84 86 """ 85 87 Creates a 'main' Tub for testing purposes, from config data 86 88 """ 87 from twisted.internet import reactor88 89 basedir = 'dummy_basedir' 89 90 config = config_from_string(basedir, 'DEFAULT_PORTNUMFILE_BLANK', config_data) … … 113 114 # conflict with another service to prove it. 114 115 self._available_port = 22 116 self.port_assigner = SameProcessStreamEndpointAssigner() 117 self.port_assigner.setUp() 118 self.addCleanup(self.port_assigner.tearDown) 115 119 116 120 def _test_location( … … 138 142 supply to the system under test as local addresses. 139 143 """ 144 from twisted.internet import reactor 145 140 146 basedir = self.mktemp() 141 147 create_node_dir(basedir, "testing") 148 if tub_port is None: 149 # Always configure a usable tub.port address instead of relying on 150 # the automatic port assignment. The automatic port assignment is 151 # prone to collisions and spurious test failures. 152 _, tub_port = self.port_assigner.assign(reactor) 153 142 154 config_data = "[node]\n" 143 if tub_port: 144 config_data += "tub.port = {}\n".format(tub_port) 155 config_data += "tub.port = {}\n".format(tub_port) 156 157 # If they wanted a certain location, go for it. This probably won't 158 # agree with the tub.port value we set but that only matters if 159 # anything tries to use this to establish a connection ... which 160 # nothing in this test suite will. 145 161 if tub_location is not None: 146 162 config_data += "tub.location = {}\n".format(tub_location) … … 150 166 lambda: local_addresses) 151 167 152 tub = testing_tub( config_data)168 tub = testing_tub(reactor, config_data) 153 169 154 170 class Foo(object): … … 432 448 @defer.inlineCallbacks 433 449 def test_logdir_is_str(self): 434 basedir = "test_node/test_logdir_is_str" 450 from twisted.internet import reactor 451 452 basedir = FilePath(self.mktemp()) 453 fixture = UseNode(None, None, basedir, "pb://introducer/furl", {}, reactor=reactor) 454 fixture.setUp() 455 self.addCleanup(fixture.cleanUp) 435 456 436 457 ns = Namespace() … … 441 462 self.patch(foolscap.logging.log, 'setLogDir', call_setLogDir) 442 463 443 create_node_dir(basedir, "nothing to see here") 444 yield client.create_client(basedir) 464 yield fixture.create_node() 445 465 self.failUnless(ns.called) 446 466 -
TabularUnified src/allmydata/test/web/test_introducer.py ¶
r8383f6a r07ffde3 84 84 """ 85 85 node.create_node_dir(basedir, "testing") 86 _, port_endpoint = port_assigner.assign(reactor) 86 main_tub_location, main_tub_endpoint = port_assigner.assign(reactor) 87 _, web_port_endpoint = port_assigner.assign(reactor) 87 88 with open(join(basedir, "tahoe.cfg"), "w") as f: 88 89 f.write( 89 90 "[node]\n" 90 "tub.location = 127.0.0.1:1\n" + 91 "web.port = {}\n".format(port_endpoint) 91 "tub.port = {main_tub_endpoint}\n" 92 "tub.location = {main_tub_location}\n" 93 "web.port = {web_port_endpoint}\n".format( 94 main_tub_endpoint=main_tub_endpoint, 95 main_tub_location=main_tub_location, 96 web_port_endpoint=web_port_endpoint, 97 ) 92 98 ) 93 99
Note: See TracChangeset
for help on using the changeset viewer.