def test_cache_config_from_sis_with_cl_update(self): ''' Test config from command line and SIS server. ''' test_commandline = "--port=4000 --directory=test_cache --torrentdir=test_torrent_dir " + \ "--downlimit=256 --uplimit=256 --spacelimit=4000 --conlimit=20 " + \ "--logfile=test_cache.log --id=34 --neighbour_selection=enable " + \ "--ranking_source=ip_pre --sis_url=http://localhost:8080/sis " + \ "--report_to=http://localhost:8444 --console --loglevel=DEBUG" cache_config = CacheConfiguration() used_sis = cache_config.update_from_cl(test_commandline.split(" ")) self.assertTrue(used_sis) self.assertEquals(4000, cache_config.get_port()) self.assertEquals("test_cache", cache_config.get_directory()) self.assertEquals("test_torrent_dir", cache_config.get_torrent_directory()) self.assertEquals(256, cache_config.get_download_limit()) self.assertEquals(256, cache_config.get_upload_limit()) self.assertEquals(4000, cache_config.get_space_limit()) self.assertEquals(20, cache_config.get_connection_limit()) self.assertEquals("test_cache.log", cache_config.get_logfile()) self.assertEquals(34, cache_config.get_id()) self.assertEquals(constants.NS_MODE_ENABLE, cache_config.get_ns_mode()) self.assertEquals(constants.RS_IP_PRE, cache_config.get_ranking_source()) self.assertEquals("http://localhost:8080/sis", cache_config.get_sis_url()) self.assertEquals("http://localhost:8080/sis/IoPEndpoint", cache_config.get_sis_iop_url()) self.assertEquals("http://localhost:8444", cache_config.get_report_to()) self.assertEquals(True, cache_config.has_cache_console())
def test_cache_config_from_sis_with_cl_update(self): ''' Test config from command line and SIS server. ''' test_commandline = "--port=4000 --directory=test_cache --torrentdir=test_torrent_dir " + \ "--downlimit=256 --uplimit=256 --spacelimit=4000 --conlimit=20 " + \ "--logfile=test_cache.log --id=34 --neighbour_selection=enable " + \ "--ranking_source=ip_pre --sis_url=http://localhost:8080/sis " + \ "--report_to=http://localhost:8444 --console --loglevel=DEBUG" cache_config = CacheConfiguration() used_sis = cache_config.update_from_cl(test_commandline.split(" ")) self.assertTrue(used_sis) self.assertEquals(4000, cache_config.get_port()) self.assertEquals("test_cache", cache_config.get_directory()) self.assertEquals("test_torrent_dir", cache_config.get_torrent_directory()) self.assertEquals(256, cache_config.get_download_limit()) self.assertEquals(256, cache_config.get_upload_limit()) self.assertEquals(4000, cache_config.get_space_limit()) self.assertEquals(20, cache_config.get_connection_limit()) self.assertEquals("test_cache.log", cache_config.get_logfile()) self.assertEquals(34, cache_config.get_id()) self.assertEquals(constants.NS_MODE_ENABLE, cache_config.get_ns_mode()) self.assertEquals(constants.RS_IP_PRE, cache_config.get_ranking_source()) self.assertEquals("http://localhost:8080/sis", cache_config.get_sis_url()) self.assertEquals("http://localhost:8080/sis/IoPEndpoint", cache_config.get_sis_iop_url()) self.assertEquals("http://localhost:8444", cache_config.get_report_to()) self.assertEquals(True, cache_config.has_cache_console())
ds['seeds_peers'][0], ds['seeds_peers'][1])) print >> sys.stderr,"\n" def on_exit(signal=None, func=None): if not local_reporter == None: local_reporter.write_stats() logger.warn("Session shutdown") session.shutdown() logger.warn("wait some time") time.sleep(1) # wait some time so session can stop gracefully logger.warn("sys exit (session shutdown takes too long?)") sys.exit() #___________________________________________________________________________________________________ # MAIN if __name__ == '__main__': LOG_FILE_NAME = "config/log_iop.conf" print "read logging config from file: ", LOG_FILE_NAME logging.config.fileConfig(LOG_FILE_NAME) cache_config = CacheConfiguration() cache_config.update_from_cl(sys.argv[1:]) if cache_config.get_logfile() is not None: print >>sys.stderr, "Using logfile: %s" % cache_config.get_logfile() common_utils.setup_cache_file_logger(cache_config.get_logfile()) cache = Cache(cache_config) Testbed_utils.set_exit_handler(on_exit) cache.run_forever()