From c9f27b83e16fceeead6f0c29c967498632f78151 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Tue, 31 Dec 2019 20:08:19 -0500 Subject: [PATCH] split integration tests into three jobs --- .gitlab-ci.yml | 16 ++- INSTALL.md | 5 +- MANIFEST.in | 2 +- scripts/find_max_server_load.py | 2 +- scripts/test_claim_search.py | 6 +- .../{ => blockchain}/test_account_commands.py | 0 .../test_blockchain_reorganization.py | 0 .../{ => blockchain}/test_claim_commands.py | 0 .../test_internal_transaction_api.py | 0 .../{ => blockchain}/test_network.py | 0 .../{ => blockchain}/test_purchase_command.py | 0 .../{ => blockchain}/test_resolve_command.py | 0 .../test_transaction_commands.py | 0 .../{ => blockchain}/test_transactions.py | 0 .../{ => blockchain}/test_wallet_commands.py | 0 .../test_wallet_server_sessions.py | 0 .../integration/{ => datanetwork}/test_dht.py | 0 .../{ => datanetwork}/test_file_commands.py | 0 .../{ => datanetwork}/test_streaming.py | 0 tests/integration/{ => other}/test_chris45.py | 0 tests/integration/{ => other}/test_cli.py | 0 .../{ => other}/test_comment_commands.py | 0 .../{ => other}/test_exchange_rate_manager.py | 0 .../{ => other}/test_other_commands.py | 0 tests/integration/test_sync.py | 103 ------------------ tox.ini | 8 +- 26 files changed, 23 insertions(+), 119 deletions(-) rename tests/integration/{ => blockchain}/test_account_commands.py (100%) rename tests/integration/{ => blockchain}/test_blockchain_reorganization.py (100%) rename tests/integration/{ => blockchain}/test_claim_commands.py (100%) rename tests/integration/{ => blockchain}/test_internal_transaction_api.py (100%) rename tests/integration/{ => blockchain}/test_network.py (100%) rename tests/integration/{ => blockchain}/test_purchase_command.py (100%) rename tests/integration/{ => blockchain}/test_resolve_command.py (100%) rename tests/integration/{ => blockchain}/test_transaction_commands.py (100%) rename tests/integration/{ => blockchain}/test_transactions.py (100%) rename tests/integration/{ => blockchain}/test_wallet_commands.py (100%) rename tests/integration/{ => blockchain}/test_wallet_server_sessions.py (100%) rename tests/integration/{ => datanetwork}/test_dht.py (100%) rename tests/integration/{ => datanetwork}/test_file_commands.py (100%) rename tests/integration/{ => datanetwork}/test_streaming.py (100%) rename tests/integration/{ => other}/test_chris45.py (100%) rename tests/integration/{ => other}/test_cli.py (100%) rename tests/integration/{ => other}/test_comment_commands.py (100%) rename tests/integration/{ => other}/test_exchange_rate_manager.py (100%) rename tests/integration/{ => other}/test_other_commands.py (100%) delete mode 100644 tests/integration/test_sync.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4365c9507..92b387c8b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,11 +37,23 @@ test:unit: - make install tools - HOME=/tmp coverage run -p --source=lbry -m unittest discover -vv tests.unit -test:integration: +test:integration-datanetwork: stage: test script: - pip install coverage tox-travis - - tox + - tox -e datanetwork + +test:integration-blockchain: + stage: test + script: + - pip install coverage tox-travis + - tox -e blockchain + +test:integration-other: + stage: test + script: + - pip install coverage tox-travis + - tox -e other test:json-api: stage: test diff --git a/INSTALL.md b/INSTALL.md index 3d8220292..73ada9d50 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -88,9 +88,6 @@ To install on Windows: > lbry-venv\Scripts\activate Install packages: - > cd torba - > pip install -e . - > cd ../lbry > pip install -e . ``` @@ -99,7 +96,7 @@ To install on Windows: To run the unit tests from the repo directory: ``` - python -m unittest discover -s lbry tests.unit + python -m unittest discover tests.unit ``` ## Usage diff --git a/MANIFEST.in b/MANIFEST.in index 731c2743e..9f002cb6b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ include README.md include CHANGELOG.md include LICENSE -recursive-include torba *.txt *.py +recursive-include lbry *.txt *.py diff --git a/scripts/find_max_server_load.py b/scripts/find_max_server_load.py index a4134352d..11f0d5082 100644 --- a/scripts/find_max_server_load.py +++ b/scripts/find_max_server_load.py @@ -2,7 +2,7 @@ import time import asyncio import random from argparse import ArgumentParser -from torba.client.basenetwork import ClientSession +from lbry.wallet.client.basenetwork import ClientSession class AgentSmith(ClientSession): diff --git a/scripts/test_claim_search.py b/scripts/test_claim_search.py index 8dd5c47e9..a376d7bed 100644 --- a/scripts/test_claim_search.py +++ b/scripts/test_claim_search.py @@ -1,11 +1,11 @@ import asyncio -from torba.client.basenetwork import ClientSession -from torba.rpc.jsonrpc import RPCError +from lbry.wallet.client.basenetwork import ClientSession +from lbry.wallet.rpc.jsonrpc import RPCError import logging import json import sys -logging.getLogger('torba').setLevel(logging.CRITICAL) +logging.getLogger('lbry.wallet').setLevel(logging.CRITICAL) async def main(): diff --git a/tests/integration/test_account_commands.py b/tests/integration/blockchain/test_account_commands.py similarity index 100% rename from tests/integration/test_account_commands.py rename to tests/integration/blockchain/test_account_commands.py diff --git a/tests/integration/test_blockchain_reorganization.py b/tests/integration/blockchain/test_blockchain_reorganization.py similarity index 100% rename from tests/integration/test_blockchain_reorganization.py rename to tests/integration/blockchain/test_blockchain_reorganization.py diff --git a/tests/integration/test_claim_commands.py b/tests/integration/blockchain/test_claim_commands.py similarity index 100% rename from tests/integration/test_claim_commands.py rename to tests/integration/blockchain/test_claim_commands.py diff --git a/tests/integration/test_internal_transaction_api.py b/tests/integration/blockchain/test_internal_transaction_api.py similarity index 100% rename from tests/integration/test_internal_transaction_api.py rename to tests/integration/blockchain/test_internal_transaction_api.py diff --git a/tests/integration/test_network.py b/tests/integration/blockchain/test_network.py similarity index 100% rename from tests/integration/test_network.py rename to tests/integration/blockchain/test_network.py diff --git a/tests/integration/test_purchase_command.py b/tests/integration/blockchain/test_purchase_command.py similarity index 100% rename from tests/integration/test_purchase_command.py rename to tests/integration/blockchain/test_purchase_command.py diff --git a/tests/integration/test_resolve_command.py b/tests/integration/blockchain/test_resolve_command.py similarity index 100% rename from tests/integration/test_resolve_command.py rename to tests/integration/blockchain/test_resolve_command.py diff --git a/tests/integration/test_transaction_commands.py b/tests/integration/blockchain/test_transaction_commands.py similarity index 100% rename from tests/integration/test_transaction_commands.py rename to tests/integration/blockchain/test_transaction_commands.py diff --git a/tests/integration/test_transactions.py b/tests/integration/blockchain/test_transactions.py similarity index 100% rename from tests/integration/test_transactions.py rename to tests/integration/blockchain/test_transactions.py diff --git a/tests/integration/test_wallet_commands.py b/tests/integration/blockchain/test_wallet_commands.py similarity index 100% rename from tests/integration/test_wallet_commands.py rename to tests/integration/blockchain/test_wallet_commands.py diff --git a/tests/integration/test_wallet_server_sessions.py b/tests/integration/blockchain/test_wallet_server_sessions.py similarity index 100% rename from tests/integration/test_wallet_server_sessions.py rename to tests/integration/blockchain/test_wallet_server_sessions.py diff --git a/tests/integration/test_dht.py b/tests/integration/datanetwork/test_dht.py similarity index 100% rename from tests/integration/test_dht.py rename to tests/integration/datanetwork/test_dht.py diff --git a/tests/integration/test_file_commands.py b/tests/integration/datanetwork/test_file_commands.py similarity index 100% rename from tests/integration/test_file_commands.py rename to tests/integration/datanetwork/test_file_commands.py diff --git a/tests/integration/test_streaming.py b/tests/integration/datanetwork/test_streaming.py similarity index 100% rename from tests/integration/test_streaming.py rename to tests/integration/datanetwork/test_streaming.py diff --git a/tests/integration/test_chris45.py b/tests/integration/other/test_chris45.py similarity index 100% rename from tests/integration/test_chris45.py rename to tests/integration/other/test_chris45.py diff --git a/tests/integration/test_cli.py b/tests/integration/other/test_cli.py similarity index 100% rename from tests/integration/test_cli.py rename to tests/integration/other/test_cli.py diff --git a/tests/integration/test_comment_commands.py b/tests/integration/other/test_comment_commands.py similarity index 100% rename from tests/integration/test_comment_commands.py rename to tests/integration/other/test_comment_commands.py diff --git a/tests/integration/test_exchange_rate_manager.py b/tests/integration/other/test_exchange_rate_manager.py similarity index 100% rename from tests/integration/test_exchange_rate_manager.py rename to tests/integration/other/test_exchange_rate_manager.py diff --git a/tests/integration/test_other_commands.py b/tests/integration/other/test_other_commands.py similarity index 100% rename from tests/integration/test_other_commands.py rename to tests/integration/other/test_other_commands.py diff --git a/tests/integration/test_sync.py b/tests/integration/test_sync.py deleted file mode 100644 index 1ba24ac96..000000000 --- a/tests/integration/test_sync.py +++ /dev/null @@ -1,103 +0,0 @@ -import asyncio -import logging -from lbry.testcase import IntegrationTestCase, WalletNode -from lbry.constants import CENT - - -class SyncTests(IntegrationTestCase): - - VERBOSITY = logging.WARN - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.api_port = 5280 - self.started_nodes = [] - - async def asyncTearDown(self): - for node in self.started_nodes: - try: - await node.stop(cleanup=True) - except Exception as e: - print(e) - await super().asyncTearDown() - - async def make_wallet_node(self, seed=None): - self.api_port += 1 - wallet_node = WalletNode( - self.wallet_node.manager_class, - self.wallet_node.ledger_class, - port=self.api_port - ) - await wallet_node.start(self.conductor.spv_node, seed) - self.started_nodes.append(wallet_node) - return wallet_node - - async def test_nodes_with_same_account_stay_in_sync(self): - # destination node/account for receiving TXs - node0 = await self.make_wallet_node() - account0 = node0.account - # main node/account creating TXs - node1 = self.wallet_node - account1 = self.wallet_node.account - # mirror node/account, expected to reflect everything in main node as it happens - node2 = await self.make_wallet_node(account1.seed) - account2 = node2.account - - self.assertNotEqual(account0.id, account1.id) - self.assertEqual(account1.id, account2.id) - await self.assertBalance(account0, '0.0') - await self.assertBalance(account1, '0.0') - await self.assertBalance(account2, '0.0') - self.assertEqual(await account0.get_address_count(chain=0), 20) - self.assertEqual(await account1.get_address_count(chain=0), 20) - self.assertEqual(await account2.get_address_count(chain=0), 20) - self.assertEqual(await account1.get_address_count(chain=1), 6) - self.assertEqual(await account2.get_address_count(chain=1), 6) - - # check that main node and mirror node generate 5 address to fill gap - fifth_address = (await account1.receiving.get_addresses())[4] - await self.blockchain.send_to_address(fifth_address, 1.00) - await asyncio.wait([ - account1.ledger.on_address.first, - account2.ledger.on_address.first - ]) - self.assertEqual(await account1.get_address_count(chain=0), 25) - self.assertEqual(await account2.get_address_count(chain=0), 25) - await self.assertBalance(account1, '1.0') - await self.assertBalance(account2, '1.0') - - await self.blockchain.generate(1) - - # pay 0.01 from main node to receiving node, would have increased change addresses - address0 = (await account0.receiving.get_addresses())[0] - hash0 = self.ledger.address_to_hash160(address0) - tx = await account1.ledger.transaction_class.create( - [], - [self.ledger.transaction_class.output_class.pay_pubkey_hash(CENT, hash0)], - [account1], account1 - ) - await self.broadcast(tx) - await asyncio.wait([ - account0.ledger.wait(tx), - account1.ledger.wait(tx), - account2.ledger.wait(tx), - ]) - await self.blockchain.generate(1) - await asyncio.wait([ - account0.ledger.wait(tx), - account1.ledger.wait(tx), - account2.ledger.wait(tx), - ]) - self.assertEqual(await account0.get_address_count(chain=0), 21) - self.assertGreater(await account1.get_address_count(chain=1), 6) - self.assertGreater(await account2.get_address_count(chain=1), 6) - await self.assertBalance(account0, '0.01') - await self.assertBalance(account1, '0.989876') - await self.assertBalance(account2, '0.989876') - - await self.blockchain.generate(1) - - # create a new mirror node and see if it syncs to same balance from scratch - node3 = await self.make_wallet_node(account1.seed) - account3 = node3.account - await self.assertBalance(account3, '0.989876') diff --git a/tox.ini b/tox.ini index dd891d86d..3b446a241 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,3 @@ -[tox] -envlist = py37-integration - [testenv] deps = coverage @@ -9,11 +6,12 @@ extras = test changedir = {toxinidir}/tests setenv = HOME=/tmp - TORBA_LEDGER=lbry.wallet commands = pip install https://github.com/rogerbinns/apsw/releases/download/3.30.1-r1/apsw-3.30.1-r1.zip \ --global-option=fetch \ --global-option=--version --global-option=3.30.1 --global-option=--all \ --global-option=build --global-option=--enable --global-option=fts5 orchstr8 download - coverage run -p --source={envsitepackagesdir}/lbry -m unittest discover -vv integration {posargs} + blockchain: coverage run -p --source={envsitepackagesdir}/lbry -m unittest discover -vv integration.blockchain {posargs} + datanetwork: coverage run -p --source={envsitepackagesdir}/lbry -m unittest discover -vv integration.datanetwork {posargs} + other: coverage run -p --source={envsitepackagesdir}/lbry -m unittest discover -vv integration.other {posargs}