mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-16 06:18:21 +00:00
Move check_magicfolder_smoke.py to proper integration tests
This introduces a py.test-based integration suite (currently just containing magic-folder end-to-end tests). Also adds a tox environment ("integration") to run them. The test setup is: - a "flogtool gather" instance - an Introducer - five Storage nodes - Alice and Bob client nodes - Alice and Bob have paired magic-folders
This commit is contained in:
32
integration/util.py
Normal file
32
integration/util.py
Normal file
@ -0,0 +1,32 @@
|
||||
import time
|
||||
from os.path import exists
|
||||
|
||||
|
||||
def await_file_contents(path, contents, timeout=10):
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < timeout:
|
||||
print(" waiting for '{}'".format(path))
|
||||
if exists(path):
|
||||
with open(path, 'r') as f:
|
||||
current = f.read()
|
||||
if current == contents:
|
||||
return True
|
||||
print(" file contents still mismatched")
|
||||
print(" wanted: {}".format(contents.replace('\n', ' ')))
|
||||
print(" got: {}".format(current.replace('\n', ' ')))
|
||||
time.sleep(1)
|
||||
if exists(path):
|
||||
raise Exception("Contents of '{}' mismatched after {}s".format(path, timeout))
|
||||
raise Exception("Didn't find '{}' after {}s".format(path, timeout))
|
||||
|
||||
|
||||
def await_file_vanishes(path, timeout=10):
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < timeout:
|
||||
print(" waiting for '{}' to vanish".format(path))
|
||||
if not exists(path):
|
||||
return
|
||||
time.sleep(1)
|
||||
raise Exception("'{}' still exists after {}s".format(path, timeout))
|
||||
|
||||
|
Reference in New Issue
Block a user