Changeset 425d16e in trunk
- Timestamp:
- 2019-08-09T03:03:39Z (6 years ago)
- Branches:
- master
- Children:
- ff23ad1
- Parents:
- 9b3d37e
- git-author:
- meejah <meejah@…> (2019-08-09 01:13:02)
- git-committer:
- meejah <meejah@…> (2019-08-09 03:03:39)
- Location:
- integration
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified integration/conftest.py ¶
r9b3d37e r425d16e 3 3 import sys 4 4 import shutil 5 import json 5 6 from time import sleep 6 7 from os import mkdir, listdir, environ … … 16 17 17 18 from twisted.python.procutils import which 19 from twisted.internet.defer import DeferredList 18 20 from twisted.internet.error import ( 19 21 ProcessExitedAlready, … … 33 35 _cleanup_tahoe_process, 34 36 _tahoe_runner_optional_coverage, 37 await_client_ready, 35 38 ) 36 39 … … 307 310 ) 308 311 def storage_nodes(reactor, temp_dir, introducer, introducer_furl, flog_gatherer, request): 309 nodes = []312 nodes_d = [] 310 313 # start all 5 nodes in parallel 311 314 for x in range(5): 312 315 name = 'node{}'.format(x) 313 316 # tub_port = 9900 + x 314 nodes.append( 315 pytest_twisted.blockon( 316 _create_node( 317 reactor, request, temp_dir, introducer_furl, flog_gatherer, name, 318 web_port=None, storage=True, 319 ) 317 nodes_d.append( 318 _create_node( 319 reactor, request, temp_dir, introducer_furl, flog_gatherer, name, 320 web_port=None, storage=True, 320 321 ) 321 322 ) 322 #nodes = pytest_twisted.blockon(DeferredList(nodes)) 323 nodes_status = pytest_twisted.blockon(DeferredList(nodes_d)) 324 nodes = [] 325 for ok, process in nodes_status: 326 assert ok, "Storage node creation failed: {}".format(process) 327 nodes.append(process) 323 328 return nodes 324 329 … … 339 344 ) 340 345 ) 346 await_client_ready(process) 341 347 return process 342 348 … … 357 363 ) 358 364 ) 365 await_client_ready(process) 359 366 return process 360 367 … … 369 376 # storage servers aren't "really" ready to roll yet (uploads fairly 370 377 # consistently fail if we don't hack in this pause...) 371 import time ; time.sleep(5)372 378 proto = _CollectOutputProtocol() 373 379 _tahoe_runner_optional_coverage( … … 410 416 magic_text = 'Completed initial Magic Folder scan successfully' 411 417 pytest_twisted.blockon(_run_node(reactor, node_dir, request, magic_text)) 418 await_client_ready(alice) 412 419 return invite 413 420 … … 447 454 magic_text = 'Completed initial Magic Folder scan successfully' 448 455 pytest_twisted.blockon(_run_node(reactor, bob_dir, request, magic_text)) 456 await_client_ready(bob) 449 457 return (join(temp_dir, 'magic-alice'), join(temp_dir, 'magic-bob')) 450 458 -
TabularUnified integration/util.py ¶
r9b3d37e r425d16e 1 1 import sys 2 2 import time 3 import json 3 4 from os import mkdir 4 5 from os.path import exists, join … … 430 431 431 432 433 def await_client_ready(process, timeout=10, liveness=60*2): 434 """ 435 Uses the status API to wait for a client-type node to be 436 'ready'. A client is deemed ready if: 437 - it answers http://<node_url>/statistics/?t-json/ 438 - there is at least one storage-server connected 439 - every storage-server has a "last_received_data" and it is 440 within the last `liveness` seconds 441 442 We will try for up to `timeout` seconds for the above conditions 443 to be true. Otherwise, an exception is raised 444 """ 445 start = time.time() 446 while (time.time() - start) < float(timeout): 447 time.sleep(1) 448 try: 449 data = web_get(process.node_dir, u"", params={u"t": u"json"}) 450 except ValueError as e: 451 print("waiting because '{}'".format(e)) 452 js = json.loads(data) 453 if len(js['servers']) == 0: 454 print("waiting because no servers at all") 455 continue 456 server_times = [ 457 server['last_received_data'] 458 for server in js['servers'] 459 ] 460 # if any times are null/None that server has never been 461 # contacted (so it's down still, probably) 462 if any([t is None for t in server_times]): 463 print("waiting because at least one server not contacted") 464 continue 465 466 # check that all times are 'recent enough' 467 if any([time.time() - t > liveness for t in server_times]): 468 print("waiting because at least one server too old") 469 continue 470 471 # we have a status with at least one server, and all servers 472 # have been contacted recently 473 return True 474 # we only fall out of the loop when we've timed out 475 raise RuntimeError( 476 "Waited {} seconds for {} to be 'ready' but it never was".format( 477 timeout, 478 process.node_dir, 479 ) 480 ) 481 482 432 483 def magic_folder_cli(request, reactor, node_dir, *argv): 433 484 return cli(request, reactor, node_dir, "magic-folder", *argv)
Note: See TracChangeset
for help on using the changeset viewer.