def testParsing(self): files = [ 'test/local_cluster.yaml', 'test/migration_1.yaml', 'test/migration_2.yaml', 'test/migration_3.yaml', 'examples/cluster.yaml', 'examples/local_cluster.yaml', 'examples/standalone.yaml' ] for f in files: print filepath = paths.path(f) with open(filepath) as specfile: loaded_representation = yaml.load(specfile) timestamp = timestamper.from_seconds(os.path.getmtime(filepath)) helper_loaded_configuration = try_load_file(filepath) manually_loaded_configuration = Configuration(loaded_representation, timestamp) self.assertEqual(manually_loaded_configuration.representation(), helper_loaded_configuration.representation()) self.assertEqual(manually_loaded_configuration.timestamp, helper_loaded_configuration.timestamp) self.assertEqual(Configuration(helper_loaded_configuration.representation(), helper_loaded_configuration.timestamp).representation(), helper_loaded_configuration.representation())
def launch_echoserver(port, handshake=None): path = paths.path('test/utils/channel_echoserver.py') if handshake: challenge, response = handshake cmd = '%s %s %d %d -c "%s" -r "%s"' % (sys.executable, path, port, port, challenge, response) else: cmd = '%s %s %d %d' % (sys.executable, path, port, port) return subprocess.Popen(cmd, shell=True)
def testClient(self): cfg_filepath = 'test/local_cluster.yaml' cfg = configuration.try_load_file(paths.path(cfg_filepath)) coordinator_server = CoordinatorServer(cfg.master_coordinator_id, paths.path(cfg_filepath)) coordinator_server_task = coio.stackless.tasklet(coordinator_server.serve)() coio.stackless.schedule() self.new_configuration = None self.new_timestamp = None client = CoordinatorClient(coordinators=[cfg.master_coordinator], callbacks=[self.callback]) client.start() for i in xrange(0, 1000): coio.sleep(0.01) if self.new_configuration or self.new_timestamp: break assert cfg.representation() == self.new_configuration.representation() print 'Fetched configuration: ', self.new_configuration print 'Timestamp: ', self.new_timestamp coordinator_server_task.kill()
def testPersistence(self): files = [ 'test/local_cluster.yaml', 'test/migration_1.yaml', 'test/migration_2.yaml', 'test/migration_3.yaml', 'examples/cluster.yaml', 'examples/local_cluster.yaml', 'examples/standalone.yaml' ] for f in files: configuration_directory = self.tempdir() cache = ConfigurationCache(configuration_directory, 'test') filepath = paths.path(f) cfg = configuration.try_load_file(filepath) for i in xrange(0, 10): cfg.timestamp = timestamper.now() cache.cache_configuration(cfg) read_configuration = cache.get_configuration() self.assertEqual(read_configuration.representation(), cfg.representation()) self.assertEqual(read_configuration.timestamp, cfg.timestamp)
def __init__(self, node_id, store_file=None, explicit_configuration=None, coordinator_addresses=[], var_directory='var', configuration_update_interval=300): super(NodeServer, self).__init__() if __debug__: logging.debug('node_id = %s, store_file = %s, explicit_configuration = %s, coordinators = %s, var_directory = %s', node_id, store_file, explicit_configuration, coordinator_addresses, var_directory) self.id = node_id self.node = None var_directory = paths.path(var_directory) store_file = store_file or os.path.join(var_directory, 'data', '%s.tcb' % self.id) self.__store = Store(store_file) self.__store.open() self.__node_clients = {} self.__internal_cluster_client = service.MulticastClient(InternalNodeServiceProtocol()) configuration_directory = os.path.join(var_directory, 'etc') self.__repair_task = None self.__background_repair_enabled = False self.__background_repair_interval_seconds = None self.__read_repair_enabled = False self.__configuration = None self.__configuration_controller = ConfigurationController('nodeserver-%s' % self.id, coordinator_addresses, explicit_configuration, configuration_directory, self.__update_configuration, configuration_update_interval)
Run EVLA_pipe_restore.py before this script. """ logprint("Starting EVLA_pipe_testimage_lines.py", logfileout="logs/testimage_lines.log") import os import sys from warnings import warn from tasks import clean from CASA_functions import set_imagermode, set_imagesize, set_cellsize, has_field from paths import image_script_path, path execfile(path("imaging_cleanup.py", image_script_path)) # This script should still be usable if the user didn't enable imaging at the # beginning. In this case, sources will be empty. Prompt the user at this # point. if len(imaging_sources) == 0: print( "No sources given. Input which field(s) should be imaged (mosaics" " can be created by giving a common name for the set; i.e., 'M33'" " for 'M33LP1', 'M33LP2', etc)" ) print("Multiple images can be created by separating the list w/ commas" " (i.e., '3C48, M33')") imaging_sources = raw_input("Input fields to be imaged: ") # Remove whitespaces then split by commas imaging_sources = imaging_sources.replace(" ", "").split(",")