fix functional tests for windows

This commit is contained in:
Kay Kurokawa 2017-07-01 16:30:03 -04:00
parent 55c90e0657
commit 00b6808ded
2 changed files with 21 additions and 2 deletions

View file

@ -28,8 +28,9 @@ test_script:
- pylint lbrynet - pylint lbrynet
# disable tests for now so that appveyor can build the app # disable tests for now so that appveyor can build the app
- set PYTHONPATH=. - set PYTHONPATH=.
- trial tests/unit - trial tests
#- python -m twisted.trial tests # avoids having to set PYTHONPATH=. (see https://twistedmatrix.com/trac/ticket/9035) # TODO: integration tests do not work
#- python -m unittest discover tests/integration
#- rvm use 2.3.1 && gem install danger --version '~> 4.0' && danger #- rvm use 2.3.1 && gem install danger --version '~> 4.0' && danger

View file

@ -65,6 +65,19 @@ def use_epoll_on_linux():
sys.modules['twisted.internet.reactor'] = twisted.internet.reactor sys.modules['twisted.internet.reactor'] = twisted.internet.reactor
def init_conf_windows(settings={}):
"""
There is no fork on windows, so imports
are freshly initialized in new processes.
So conf needs to be intialized for new processes
"""
if os.name == 'nt':
original_settings = conf.settings
conf.settings = conf.Config(conf.FIXED_SETTINGS, conf.ADJUSTABLE_SETTINGS)
conf.settings.installation_id = conf.settings.get_installation_id()
conf.settings.update(settings)
class LbryUploader(object): class LbryUploader(object):
def __init__(self, sd_hash_queue, kill_event, dead_event, def __init__(self, sd_hash_queue, kill_event, dead_event,
file_size, ul_rate_limit=None, is_generous=False): file_size, ul_rate_limit=None, is_generous=False):
@ -84,6 +97,8 @@ class LbryUploader(object):
def start(self): def start(self):
use_epoll_on_linux() use_epoll_on_linux()
init_conf_windows()
from twisted.internet import reactor from twisted.internet import reactor
self.reactor = reactor self.reactor = reactor
logging.debug("Starting the uploader") logging.debug("Starting the uploader")
@ -98,6 +113,7 @@ class LbryUploader(object):
self.sd_identifier = StreamDescriptorIdentifier() self.sd_identifier = StreamDescriptorIdentifier()
db_dir = "server" db_dir = "server"
os.mkdir(db_dir) os.mkdir(db_dir)
self.session = Session( self.session = Session(
conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir, lbryid="abcd", conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir, lbryid="abcd",
peer_finder=peer_finder, hash_announcer=hash_announcer, peer_port=5553, peer_finder=peer_finder, hash_announcer=hash_announcer, peer_port=5553,
@ -182,6 +198,7 @@ class LbryUploader(object):
def start_lbry_reuploader(sd_hash, kill_event, dead_event, def start_lbry_reuploader(sd_hash, kill_event, dead_event,
ready_event, n, ul_rate_limit=None, is_generous=False): ready_event, n, ul_rate_limit=None, is_generous=False):
use_epoll_on_linux() use_epoll_on_linux()
init_conf_windows()
from twisted.internet import reactor from twisted.internet import reactor
logging.debug("Starting the uploader") logging.debug("Starting the uploader")
@ -295,6 +312,7 @@ def start_lbry_reuploader(sd_hash, kill_event, dead_event,
def start_blob_uploader(blob_hash_queue, kill_event, dead_event, slow, is_generous=False): def start_blob_uploader(blob_hash_queue, kill_event, dead_event, slow, is_generous=False):
use_epoll_on_linux() use_epoll_on_linux()
init_conf_windows()
from twisted.internet import reactor from twisted.internet import reactor
logging.debug("Starting the uploader") logging.debug("Starting the uploader")