Ejemplo n.º 1
0
def test_shared_mem_buffer(vis_data, comet_broker):
    # start kotekan writer in a thread, to read before it's done (it will delete the shm on exit)
    threading.Thread(target=vis_data.run).start()
    ds_manager = Manager("localhost", comet_broker)
    sleep(2)
    reader = []
    view_size = [2, 8, 17]

    for i in range(len(view_size)):
        reader.append(
            shared_memory_buffer.SharedMemoryReader(fname_buf, view_size[i],
                                                    ds_manager))

    for i in range(len(reader)):
        assert reader[i].num_time == params_writer_stage["num_samples"]
        assert reader[i].num_freq == len(params_fakevis["freq_ids"])

    i = 0
    visraw = [None] * len(view_size)
    with pytest.raises(shared_memory_buffer.SharedMemoryError):
        # Give this some extra time, because maybe it's just reading nothing a few times, but make
        # sure it eventually raises because the shared memory got removed by the writer.
        while i <= params["total_frames"] * 2:
            sleep(0.5)
            for j in range(len(reader)):
                visraw[j] = reader[j].update()
                assert visraw[j].num_time == reader[j].view_size
                check_visraw(visraw[j])
            i += 1
    assert i >= params["total_frames"] / 2
Ejemplo n.º 2
0
 def _register_config(self):
     # Register config with comet broker
     try:
         enable_comet = self.config["comet_broker"]["enabled"]
     except KeyError as e:
         raise ConfigError("Missing config value 'comet_broker/enabled'.") from e
     if enable_comet:
         try:
             comet_host = self.config["comet_broker"]["host"]
             comet_port = self.config["comet_broker"]["port"]
         except KeyError as exc:
             raise InternalError(
                 "Failure registering initial config with comet broker: 'comet_broker/{}' "
                 "not defined in config.".format(exc)
             ) from exc
         comet = Manager(comet_host, comet_port)
         try:
             comet.register_start(datetime.datetime.utcnow(), __version__)
             comet.register_config(self.config)
         except CometError as exc:
             raise InternalError(
                 "Comet failed registering CoCo startup and initial config: {}".format(
                     exc
                 )
             ) from exc
     else:
         logger.warning("Config registration DISABLED. This is only OK for testing.")
Ejemplo n.º 3
0
 def register_config(self, config):
     # Register config with comet broker
     try:
         enable_comet = config["use_dataset_broker"]
     except KeyError:
         logger.error(
             "Missing config value 'dataset_manager/use_dataset_broker'.")
         exit(1)
     if enable_comet:
         try:
             comet_host = config["ds_broker_host"]
             comet_port = config["ds_broker_port"]
         except KeyError as exc:
             logger.error(
                 "Failure registering initial config with comet broker: '{}' not defined in "
                 "config.".format(exc[0]))
             exit(1)
         comet = Manager(comet_host, comet_port)
         try:
             comet.register_start(self.startup_time, self.git_version)
             comet.register_config(config)
         except CometError as exc:
             logger.error(
                 "Comet failed registering initial config: {}".format(exc))
             exit(1)
     else:
         logger.warning(
             "Config registration DISABLED. This is only OK for testing.")
Ejemplo n.º 4
0
def manager_and_dataset():
    manager = Manager("localhost", PORT)

    ds = manager.register_start(now, version, CONFIG, register_datasets=True)
    root_ds = manager.get_dataset(ds.id).base_dataset_id
    return manager, ds, root_ds
Ejemplo n.º 5
0
def manager_low_timeout():
    """Start manager that uses low-timeout broker."""
    manager = Manager("localhost", PORT_LOW_TIMEOUT)

    manager.register_start(now, version, CONFIG)
    return manager
Ejemplo n.º 6
0
def manager_and_dataset():
    manager = Manager("localhost", PORT)

    ds = manager.register_start(now, version, CONFIG, register_datasets=True)
    return manager, ds
Ejemplo n.º 7
0
def manager_new():
    manager = Manager("localhost", PORT)

    assert manager.register_start(now, version, CONFIG) is None
    return manager
Ejemplo n.º 8
0
def manager():
    manager = Manager("localhost", PORT)

    manager.register_start(now, version)
    manager.register_config(CONFIG)
    return manager