def test_empty(self): nc = NodeConfig( node_index=0, data_address=gen_SocketAddress(), roles=set(), location_per_scope={}, name="", ) ns = NodeState(node_index=0) mnts = [] self._validate(NodeView(nc, ns, mnts), nc, ns, mnts)
def test_unix_socket(self): nc = NodeConfig( node_index=0, data_address=SocketAddress(address_family=SocketAddressFamily.UNIX, path="/path/to/unix.sock").to_thrift(), roles=set(), location_per_scope={}, name="", ) ns = NodeState(node_index=0) mnts = [] self._validate(NodeView(nc, ns, mnts), nc, ns, mnts)
def test_no_name(self): addr = gen_SocketAddress() self.assertEqual( NodeView( node_config=NodeConfig( node_index=0, data_address=addr, roles=set(), location_per_scope={}, name="", ), node_state=NodeState(node_index=0), maintenances=[], ).node_name, str(SocketAddress.from_thrift(addr)), )
def _gen_nodes(self) -> None: ts = int(datetime.now().timestamp()) self._ns_version = ts self._nc_version = ts self._nc_by_node_index = {} self._nc_by_name = {} self._ns_by_node_index = {} self._ns_by_name = {} # generate storage nodes for node_index in range(0, self.num_storage_nodes): loc = self._select_random_location() name = self.storage_node_name_tmpl.format( node_index=node_index, region=loc[LocationScope.REGION] ) nc = NodeConfig( node_index=node_index, data_address=gen_SocketAddress(), roles={Role.SEQUENCER, Role.STORAGE} if not self.disaggregated else {Role.STORAGE}, other_addresses=None, location=self._loc_to_str(loc), sequencer=SequencerConfig(weight=1) if not self.disaggregated else None, storage=StorageConfig( weight=1, num_shards=self.shards_per_storage_node ), location_per_scope=loc, name=name, ) ns = NodeState( node_index=node_index, daemon_state=ServiceState.ALIVE, sequencer_state=SequencerState( state=SequencingState.ENABLED, maintenance=None ) if not self.disaggregated else None, shard_states=[ ShardState( data_health=ShardDataHealth.HEALTHY, current_storage_state=ShardStorageState.READ_WRITE, current_operational_state=ShardOperationalState.ENABLED, maintenance=None, storage_state=StorageState.READ_WRITE, metadata_state=MetaDataStorageState.NONE, ) for _ in range(self.shards_per_storage_node) ], ) self._nc_by_node_index[node_index] = nc self._nc_by_name[name] = nc self._ns_by_node_index[node_index] = ns self._ns_by_name[name] = ns # generate sequencer nodes if self.disaggregated: for node_index in ( self.num_storage_nodes, self.num_storage_nodes + self.num_sequencer_nodes, ): loc = self._select_random_location() name = self.storage_node_name_tmpl.format( node_index=node_index, region=loc[LocationScope.REGION] ) nc = NodeConfig( node_index=node_index, data_address=gen_SocketAddress(), roles={Role.SEQUENCER}, other_addresses=None, location=self._loc_to_str(loc), sequencer=SequencerConfig(weight=1), storage=None, location_per_scope=loc, name=name, ) ns = NodeState( node_index=node_index, daemon_state=ServiceState.ALIVE, sequencer_state=SequencerState( state=SequencingState.ENABLED, maintenance=None ), shard_states=None, ) self._nc_by_node_index[node_index] = nc self._nc_by_name[name] = nc self._ns_by_node_index[node_index] = ns self._ns_by_name[name] = ns