forked from LBRYCommunity/lbry-sdk
update functional tests
This commit is contained in:
parent
edcb06a415
commit
37eaf634c4
3 changed files with 58 additions and 60 deletions
|
@ -39,6 +39,7 @@ DummyBlobAvailabilityTracker = mocks.BlobAvailabilityTracker
|
||||||
log_format = "%(funcName)s(): %(message)s"
|
log_format = "%(funcName)s(): %(message)s"
|
||||||
logging.basicConfig(level=logging.CRITICAL, format=log_format)
|
logging.basicConfig(level=logging.CRITICAL, format=log_format)
|
||||||
|
|
||||||
|
TEST_SKIP_STRING_ANDROID = "Test cannot pass on Android because multiprocessing is not supported at the OS level."
|
||||||
|
|
||||||
def require_system(system):
|
def require_system(system):
|
||||||
def wrapper(fn):
|
def wrapper(fn):
|
||||||
|
@ -103,13 +104,14 @@ class LbryUploader(object):
|
||||||
rate_limiter = RateLimiter()
|
rate_limiter = RateLimiter()
|
||||||
self.sd_identifier = StreamDescriptorIdentifier()
|
self.sd_identifier = StreamDescriptorIdentifier()
|
||||||
self.db_dir, self.blob_dir = mk_db_and_blob_dir()
|
self.db_dir, self.blob_dir = mk_db_and_blob_dir()
|
||||||
|
dht_node = FakeNode(peer_finder=peer_finder, peer_manager=peer_manager, udpPort=4445, peerPort=5553,
|
||||||
|
node_id="abcd", externalIP="127.0.0.1")
|
||||||
|
|
||||||
self.session = Session(
|
self.session = Session(
|
||||||
conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=self.db_dir, blob_dir=self.blob_dir,
|
conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=self.db_dir, blob_dir=self.blob_dir,
|
||||||
node_id="abcd", peer_finder=peer_finder, hash_announcer=hash_announcer,
|
node_id="abcd", peer_finder=peer_finder, hash_announcer=hash_announcer,
|
||||||
peer_port=5553, dht_node_port=4445, use_upnp=False, rate_limiter=rate_limiter, wallet=wallet,
|
peer_port=5553, dht_node_port=4445, rate_limiter=rate_limiter, wallet=wallet,
|
||||||
blob_tracker_class=DummyBlobAvailabilityTracker,
|
dht_node=dht_node, external_ip="127.0.0.1")
|
||||||
dht_node_class=FakeNode, is_generous=self.is_generous, external_ip="127.0.0.1")
|
|
||||||
self.lbry_file_manager = EncryptedFileManager(self.session, self.sd_identifier)
|
self.lbry_file_manager = EncryptedFileManager(self.session, self.sd_identifier)
|
||||||
if self.ul_rate_limit is not None:
|
if self.ul_rate_limit is not None:
|
||||||
self.session.rate_limiter.set_ul_limit(self.ul_rate_limit)
|
self.session.rate_limiter.set_ul_limit(self.ul_rate_limit)
|
||||||
|
@ -197,12 +199,10 @@ def start_lbry_reuploader(sd_hash, kill_event, dead_event,
|
||||||
|
|
||||||
db_dir, blob_dir = mk_db_and_blob_dir()
|
db_dir, blob_dir = mk_db_and_blob_dir()
|
||||||
session = Session(conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir,
|
session = Session(conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir,
|
||||||
node_id="abcd" + str(n), dht_node_port=4446, dht_node_class=FakeNode,
|
node_id="abcd" + str(n), dht_node_port=4446,
|
||||||
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
||||||
blob_dir=blob_dir, peer_port=peer_port,
|
blob_dir=blob_dir, peer_port=peer_port,
|
||||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet,
|
rate_limiter=rate_limiter, wallet=wallet,
|
||||||
blob_tracker_class=DummyBlobAvailabilityTracker,
|
|
||||||
is_generous=conf.ADJUSTABLE_SETTINGS['is_generous_host'][1],
|
|
||||||
external_ip="127.0.0.1")
|
external_ip="127.0.0.1")
|
||||||
|
|
||||||
lbry_file_manager = EncryptedFileManager(session, sd_identifier)
|
lbry_file_manager = EncryptedFileManager(session, sd_identifier)
|
||||||
|
@ -303,13 +303,14 @@ def start_blob_uploader(blob_hash_queue, kill_event, dead_event, slow, is_genero
|
||||||
|
|
||||||
db_dir, blob_dir = mk_db_and_blob_dir()
|
db_dir, blob_dir = mk_db_and_blob_dir()
|
||||||
|
|
||||||
|
dht_node = FakeNode(peer_finder=peer_finder, peer_manager=peer_manager, udpPort=4445, peerPort=5553,
|
||||||
|
node_id="abcd", externalIP="127.0.0.1")
|
||||||
|
|
||||||
session = Session(conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir, node_id="efgh",
|
session = Session(conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir, node_id="efgh",
|
||||||
peer_finder=peer_finder, hash_announcer=hash_announcer, dht_node_class=FakeNode,
|
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
||||||
blob_dir=blob_dir, peer_port=peer_port, dht_node_port=4446,
|
blob_dir=blob_dir, peer_port=peer_port, dht_node_port=4446,
|
||||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet,
|
rate_limiter=rate_limiter, wallet=wallet,
|
||||||
blob_tracker_class=DummyBlobAvailabilityTracker,
|
external_ip="127.0.0.1", dht_node=dht_node)
|
||||||
is_generous=conf.ADJUSTABLE_SETTINGS['is_generous_host'][1],
|
|
||||||
external_ip="127.0.0.1")
|
|
||||||
|
|
||||||
if slow is True:
|
if slow is True:
|
||||||
session.rate_limiter.set_ul_limit(2 ** 11)
|
session.rate_limiter.set_ul_limit(2 ** 11)
|
||||||
|
@ -478,15 +479,16 @@ class TestTransfer(TestCase):
|
||||||
hash_announcer = FakeAnnouncer()
|
hash_announcer = FakeAnnouncer()
|
||||||
rate_limiter = DummyRateLimiter()
|
rate_limiter = DummyRateLimiter()
|
||||||
sd_identifier = StreamDescriptorIdentifier()
|
sd_identifier = StreamDescriptorIdentifier()
|
||||||
|
dht_node = FakeNode(peer_finder=peer_finder, peer_manager=peer_manager, udpPort=4445, peerPort=5553,
|
||||||
|
node_id="abcd", externalIP="127.0.0.1")
|
||||||
|
|
||||||
db_dir, blob_dir = mk_db_and_blob_dir()
|
db_dir, blob_dir = mk_db_and_blob_dir()
|
||||||
self.session = Session(
|
self.session = Session(
|
||||||
conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir,
|
conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir,
|
||||||
node_id="abcd", peer_finder=peer_finder, hash_announcer=hash_announcer,
|
node_id="abcd", peer_finder=peer_finder, hash_announcer=hash_announcer,
|
||||||
blob_dir=blob_dir, peer_port=5553, dht_node_port=4445,
|
blob_dir=blob_dir, peer_port=5553, dht_node_port=4445,
|
||||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet,
|
rate_limiter=rate_limiter, wallet=wallet,
|
||||||
blob_tracker_class=DummyBlobAvailabilityTracker,
|
dht_node=dht_node, external_ip="127.0.0.1")
|
||||||
dht_node_class=FakeNode, is_generous=self.is_generous, external_ip="127.0.0.1")
|
|
||||||
|
|
||||||
self.lbry_file_manager = EncryptedFileManager(
|
self.lbry_file_manager = EncryptedFileManager(
|
||||||
self.session, sd_identifier)
|
self.session, sd_identifier)
|
||||||
|
@ -566,15 +568,16 @@ class TestTransfer(TestCase):
|
||||||
peer_finder = FakePeerFinder(5553, peer_manager, 2)
|
peer_finder = FakePeerFinder(5553, peer_manager, 2)
|
||||||
hash_announcer = FakeAnnouncer()
|
hash_announcer = FakeAnnouncer()
|
||||||
rate_limiter = DummyRateLimiter()
|
rate_limiter = DummyRateLimiter()
|
||||||
|
dht_node = FakeNode(peer_finder=peer_finder, peer_manager=peer_manager, udpPort=4445, peerPort=5553,
|
||||||
|
node_id="abcd", externalIP="127.0.0.1")
|
||||||
|
|
||||||
db_dir, blob_dir = mk_db_and_blob_dir()
|
db_dir, blob_dir = mk_db_and_blob_dir()
|
||||||
self.session = Session(
|
self.session = Session(
|
||||||
conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir, node_id="abcd",
|
conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir, node_id="abcd",
|
||||||
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
||||||
blob_dir=blob_dir, peer_port=5553, dht_node_port=4445, dht_node_class=FakeNode,
|
blob_dir=blob_dir, peer_port=5553, dht_node_port=4445,
|
||||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet,
|
rate_limiter=rate_limiter, wallet=wallet,
|
||||||
blob_tracker_class=DummyBlobAvailabilityTracker,
|
dht_node=dht_node, external_ip="127.0.0.1")
|
||||||
is_generous=conf.ADJUSTABLE_SETTINGS['is_generous_host'][1], external_ip="127.0.0.1")
|
|
||||||
|
|
||||||
d1 = self.wait_for_hash_from_queue(blob_hash_queue_1)
|
d1 = self.wait_for_hash_from_queue(blob_hash_queue_1)
|
||||||
d2 = self.wait_for_hash_from_queue(blob_hash_queue_2)
|
d2 = self.wait_for_hash_from_queue(blob_hash_queue_2)
|
||||||
|
@ -646,17 +649,17 @@ class TestTransfer(TestCase):
|
||||||
hash_announcer = FakeAnnouncer()
|
hash_announcer = FakeAnnouncer()
|
||||||
rate_limiter = DummyRateLimiter()
|
rate_limiter = DummyRateLimiter()
|
||||||
sd_identifier = StreamDescriptorIdentifier()
|
sd_identifier = StreamDescriptorIdentifier()
|
||||||
|
dht_node = FakeNode(peer_finder=peer_finder, peer_manager=peer_manager, udpPort=4445, peerPort=5553,
|
||||||
|
node_id="abcd", externalIP="127.0.0.1")
|
||||||
|
|
||||||
downloaders = []
|
downloaders = []
|
||||||
|
|
||||||
db_dir, blob_dir = mk_db_and_blob_dir()
|
db_dir, blob_dir = mk_db_and_blob_dir()
|
||||||
self.session = Session(conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir,
|
self.session = Session(conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir,
|
||||||
node_id="abcd", peer_finder=peer_finder, dht_node_port=4445, dht_node_class=FakeNode,
|
node_id="abcd", peer_finder=peer_finder, dht_node_port=4445,
|
||||||
hash_announcer=hash_announcer, blob_dir=blob_dir, peer_port=5553,
|
hash_announcer=hash_announcer, blob_dir=blob_dir, peer_port=5553,
|
||||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet,
|
rate_limiter=rate_limiter, wallet=wallet,
|
||||||
blob_tracker_class=DummyBlobAvailabilityTracker,
|
external_ip="127.0.0.1", dht_node=dht_node)
|
||||||
is_generous=conf.ADJUSTABLE_SETTINGS['is_generous_host'][1],
|
|
||||||
external_ip="127.0.0.1")
|
|
||||||
|
|
||||||
self.lbry_file_manager = EncryptedFileManager(self.session, sd_identifier)
|
self.lbry_file_manager = EncryptedFileManager(self.session, sd_identifier)
|
||||||
|
|
||||||
|
@ -758,13 +761,11 @@ class TestTransfer(TestCase):
|
||||||
sd_identifier = StreamDescriptorIdentifier()
|
sd_identifier = StreamDescriptorIdentifier()
|
||||||
|
|
||||||
db_dir, blob_dir = mk_db_and_blob_dir()
|
db_dir, blob_dir = mk_db_and_blob_dir()
|
||||||
self.session = Session(conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir, dht_node_class=FakeNode,
|
self.session = Session(conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir,
|
||||||
node_id="abcd", peer_finder=peer_finder, dht_node_port=4445,
|
node_id="abcd", peer_finder=peer_finder, dht_node_port=4445,
|
||||||
hash_announcer=hash_announcer, blob_dir=blob_dir,
|
hash_announcer=hash_announcer, blob_dir=blob_dir,
|
||||||
peer_port=5553, use_upnp=False, rate_limiter=rate_limiter,
|
peer_port=5553, rate_limiter=rate_limiter,
|
||||||
wallet=wallet, blob_tracker_class=DummyBlobAvailabilityTracker,
|
wallet=wallet, external_ip="127.0.0.1")
|
||||||
is_generous=conf.ADJUSTABLE_SETTINGS['is_generous_host'][1],
|
|
||||||
external_ip="127.0.0.1")
|
|
||||||
|
|
||||||
self.lbry_file_manager = EncryptedFileManager(
|
self.lbry_file_manager = EncryptedFileManager(
|
||||||
self.session, sd_identifier)
|
self.session, sd_identifier)
|
||||||
|
@ -842,3 +843,10 @@ class TestTransfer(TestCase):
|
||||||
d.addBoth(stop)
|
d.addBoth(stop)
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
if is_android():
|
||||||
|
test_lbry_transfer.skip = TEST_SKIP_STRING_ANDROID
|
||||||
|
test_last_blob_retrieval.skip = TEST_SKIP_STRING_ANDROID
|
||||||
|
test_double_download.skip = TEST_SKIP_STRING_ANDROID
|
||||||
|
test_multiple_uploaders.skip = TEST_SKIP_STRING_ANDROID
|
||||||
|
|
||||||
|
|
|
@ -53,13 +53,13 @@ class TestReflector(unittest.TestCase):
|
||||||
db_dir=self.db_dir,
|
db_dir=self.db_dir,
|
||||||
node_id="abcd",
|
node_id="abcd",
|
||||||
peer_finder=peer_finder,
|
peer_finder=peer_finder,
|
||||||
|
peer_manager=peer_manager,
|
||||||
blob_dir=self.blob_dir,
|
blob_dir=self.blob_dir,
|
||||||
peer_port=5553,
|
peer_port=5553,
|
||||||
dht_node_port=4444,
|
dht_node_port=4444,
|
||||||
use_upnp=False,
|
|
||||||
wallet=wallet,
|
wallet=wallet,
|
||||||
blob_tracker_class=mocks.BlobAvailabilityTracker,
|
|
||||||
external_ip="127.0.0.1",
|
external_ip="127.0.0.1",
|
||||||
|
dht_node=mocks.Node(),
|
||||||
hash_announcer=mocks.Announcer(),
|
hash_announcer=mocks.Announcer(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -73,13 +73,13 @@ class TestReflector(unittest.TestCase):
|
||||||
db_dir=self.server_db_dir,
|
db_dir=self.server_db_dir,
|
||||||
node_id="abcd",
|
node_id="abcd",
|
||||||
peer_finder=peer_finder,
|
peer_finder=peer_finder,
|
||||||
|
peer_manager=peer_manager,
|
||||||
blob_dir=self.server_blob_dir,
|
blob_dir=self.server_blob_dir,
|
||||||
peer_port=5554,
|
peer_port=5554,
|
||||||
dht_node_port=4443,
|
dht_node_port=4443,
|
||||||
use_upnp=False,
|
|
||||||
wallet=wallet,
|
wallet=wallet,
|
||||||
blob_tracker_class=mocks.BlobAvailabilityTracker,
|
|
||||||
external_ip="127.0.0.1",
|
external_ip="127.0.0.1",
|
||||||
|
dht_node=mocks.Node(),
|
||||||
hash_announcer=mocks.Announcer(),
|
hash_announcer=mocks.Announcer(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ DummyBlobAvailabilityTracker = mocks.BlobAvailabilityTracker
|
||||||
|
|
||||||
class TestStreamify(TestCase):
|
class TestStreamify(TestCase):
|
||||||
maxDiff = 5000
|
maxDiff = 5000
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
mocks.mock_conf_settings(self)
|
mocks.mock_conf_settings(self)
|
||||||
self.session = None
|
self.session = None
|
||||||
|
@ -37,6 +38,12 @@ class TestStreamify(TestCase):
|
||||||
self.is_generous = True
|
self.is_generous = True
|
||||||
self.db_dir = tempfile.mkdtemp()
|
self.db_dir = tempfile.mkdtemp()
|
||||||
self.blob_dir = os.path.join(self.db_dir, "blobfiles")
|
self.blob_dir = os.path.join(self.db_dir, "blobfiles")
|
||||||
|
self.dht_node = FakeNode()
|
||||||
|
self.wallet = FakeWallet()
|
||||||
|
self.peer_manager = PeerManager()
|
||||||
|
self.peer_finder = FakePeerFinder(5553, self.peer_manager, 2)
|
||||||
|
self.rate_limiter = DummyRateLimiter()
|
||||||
|
self.sd_identifier = StreamDescriptorIdentifier()
|
||||||
os.mkdir(self.blob_dir)
|
os.mkdir(self.blob_dir)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
@ -54,26 +61,17 @@ class TestStreamify(TestCase):
|
||||||
os.remove("test_file")
|
os.remove("test_file")
|
||||||
|
|
||||||
def test_create_stream(self):
|
def test_create_stream(self):
|
||||||
wallet = FakeWallet()
|
|
||||||
peer_manager = PeerManager()
|
|
||||||
peer_finder = FakePeerFinder(5553, peer_manager, 2)
|
|
||||||
hash_announcer = FakeAnnouncer()
|
|
||||||
rate_limiter = DummyRateLimiter()
|
|
||||||
sd_identifier = StreamDescriptorIdentifier()
|
|
||||||
|
|
||||||
self.session = Session(
|
self.session = Session(
|
||||||
conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=self.db_dir, node_id="abcd",
|
conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=self.db_dir, node_id="abcd", peer_finder=self.peer_finder,
|
||||||
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
blob_dir=self.blob_dir, peer_port=5553, rate_limiter=self.rate_limiter, wallet=self.wallet,
|
||||||
blob_dir=self.blob_dir, peer_port=5553,
|
external_ip="127.0.0.1", dht_node=self.dht_node
|
||||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet,
|
|
||||||
blob_tracker_class=DummyBlobAvailabilityTracker,
|
|
||||||
is_generous=self.is_generous, external_ip="127.0.0.1", dht_node_class=mocks.Node
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.lbry_file_manager = EncryptedFileManager(self.session, sd_identifier)
|
self.lbry_file_manager = EncryptedFileManager(self.session, self.sd_identifier)
|
||||||
|
|
||||||
d = self.session.setup()
|
d = self.session.setup()
|
||||||
d.addCallback(lambda _: add_lbry_file_to_sd_identifier(sd_identifier))
|
d.addCallback(lambda _: add_lbry_file_to_sd_identifier(self.sd_identifier))
|
||||||
d.addCallback(lambda _: self.lbry_file_manager.setup())
|
d.addCallback(lambda _: self.lbry_file_manager.setup())
|
||||||
|
|
||||||
def verify_equal(sd_info):
|
def verify_equal(sd_info):
|
||||||
|
@ -102,22 +100,14 @@ class TestStreamify(TestCase):
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def test_create_and_combine_stream(self):
|
def test_create_and_combine_stream(self):
|
||||||
wallet = FakeWallet()
|
|
||||||
peer_manager = PeerManager()
|
|
||||||
peer_finder = FakePeerFinder(5553, peer_manager, 2)
|
|
||||||
hash_announcer = FakeAnnouncer()
|
|
||||||
rate_limiter = DummyRateLimiter()
|
|
||||||
sd_identifier = StreamDescriptorIdentifier()
|
|
||||||
|
|
||||||
self.session = Session(
|
self.session = Session(
|
||||||
conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=self.db_dir, node_id="abcd",
|
conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=self.db_dir, node_id="abcd", peer_finder=self.peer_finder,
|
||||||
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
blob_dir=self.blob_dir, peer_port=5553, rate_limiter=self.rate_limiter, wallet=self.wallet,
|
||||||
blob_dir=self.blob_dir, peer_port=5553, dht_node_class=mocks.Node,
|
external_ip="127.0.0.1", dht_node=self.dht_node
|
||||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet,
|
|
||||||
blob_tracker_class=DummyBlobAvailabilityTracker, external_ip="127.0.0.1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.lbry_file_manager = EncryptedFileManager(self.session, sd_identifier)
|
self.lbry_file_manager = EncryptedFileManager(self.session, self.sd_identifier)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def create_stream():
|
def create_stream():
|
||||||
|
@ -132,7 +122,7 @@ class TestStreamify(TestCase):
|
||||||
self.assertEqual(hashsum.hexdigest(), "68959747edc73df45e45db6379dd7b3b")
|
self.assertEqual(hashsum.hexdigest(), "68959747edc73df45e45db6379dd7b3b")
|
||||||
|
|
||||||
d = self.session.setup()
|
d = self.session.setup()
|
||||||
d.addCallback(lambda _: add_lbry_file_to_sd_identifier(sd_identifier))
|
d.addCallback(lambda _: add_lbry_file_to_sd_identifier(self.sd_identifier))
|
||||||
d.addCallback(lambda _: self.lbry_file_manager.setup())
|
d.addCallback(lambda _: self.lbry_file_manager.setup())
|
||||||
d.addCallback(lambda _: create_stream())
|
d.addCallback(lambda _: create_stream())
|
||||||
return d
|
return d
|
||||||
|
|
Loading…
Reference in a new issue