mirror of https://github.com/vacp2p/wakurtosis.git
Moved dispatchers to other file
This commit is contained in:
parent
60998586c0
commit
d6cc337403
|
@ -0,0 +1,41 @@
|
|||
# System Imports
|
||||
vars = import_module("github.com/logos-co/wakurtosis/src/system_variables.star")
|
||||
|
||||
# Module Imports
|
||||
waku = import_module(vars.WAKU_MODULE)
|
||||
nomos = import_module(vars.NOMOS_MODULE)
|
||||
waku_builder = import_module(vars.WAKU_BUILDER_MODULE)
|
||||
nwaku_builder = import_module(vars.NWAKU_BUILDER_MODULE)
|
||||
gowaku_builder = import_module(vars.GOWAKU_BUILDER_MODULE)
|
||||
nomos_builder = import_module(vars.NOMOS_BUILDER_MODULE)
|
||||
|
||||
|
||||
service_builder_dispatcher = {
|
||||
vars.GENNET_GOWAKU_IMAGE_VALUE: gowaku_builder.prepare_gowaku_service,
|
||||
vars.GENNET_NWAKU_IMAGE_VALUE: nwaku_builder.prepare_nwaku_service,
|
||||
vars.GENNET_NOMOS_IMAGE_VALUE: nomos_builder.prepare_nomos_service
|
||||
}
|
||||
|
||||
service_info_dispatcher = {
|
||||
vars.GENNET_GOWAKU_IMAGE_VALUE: waku.get_wakunode_peer_id,
|
||||
vars.GENNET_NWAKU_IMAGE_VALUE: waku.get_wakunode_peer_id,
|
||||
vars.GENNET_NOMOS_IMAGE_VALUE: nomos.get_nomos_peer_id
|
||||
}
|
||||
|
||||
service_multiaddr_dispatcher = {
|
||||
vars.GENNET_GOWAKU_IMAGE_VALUE: waku.create_node_multiaddress,
|
||||
vars.GENNET_NWAKU_IMAGE_VALUE: waku.create_node_multiaddress,
|
||||
vars.GENNET_NOMOS_IMAGE_VALUE: nomos.create_node_multiaddress
|
||||
}
|
||||
|
||||
service_connect_dispatcher = {
|
||||
vars.GENNET_GOWAKU_IMAGE_VALUE: waku.connect_wakunode_to_peers,
|
||||
vars.GENNET_NWAKU_IMAGE_VALUE: waku.connect_wakunode_to_peers,
|
||||
vars.GENNET_NOMOS_IMAGE_VALUE: nomos.connect_nomos_to_peers
|
||||
}
|
||||
|
||||
ports_dispatcher = {
|
||||
vars.GENNET_GOWAKU_IMAGE_VALUE: waku_builder.add_waku_ports_info_to_topology,
|
||||
vars.GENNET_NWAKU_IMAGE_VALUE: waku_builder.add_waku_ports_info_to_topology,
|
||||
vars.GENNET_NOMOS_IMAGE_VALUE: nomos_builder.add_nomos_ports_info_to_topology
|
||||
}
|
|
@ -2,44 +2,8 @@
|
|||
vars = import_module("github.com/logos-co/wakurtosis/src/system_variables.star")
|
||||
|
||||
# Module Imports
|
||||
waku = import_module(vars.WAKU_MODULE)
|
||||
nomos = import_module(vars.NOMOS_MODULE)
|
||||
files = import_module(vars.FILE_HELPERS_MODULE)
|
||||
waku_builder = import_module(vars.WAKU_BUILDER_MODULE)
|
||||
nwaku_builder = import_module(vars.NWAKU_BUILDER_MODULE)
|
||||
gowaku_builder = import_module(vars.GOWAKU_BUILDER_MODULE)
|
||||
nomos_builder = import_module(vars.NOMOS_BUILDER_MODULE)
|
||||
|
||||
|
||||
service_builder_dispatcher = {
|
||||
vars.GENNET_GOWAKU_IMAGE_VALUE: gowaku_builder.prepare_gowaku_service,
|
||||
vars.GENNET_NWAKU_IMAGE_VALUE: nwaku_builder.prepare_nwaku_service,
|
||||
vars.GENNET_NOMOS_IMAGE_VALUE: nomos_builder.prepare_nomos_service
|
||||
}
|
||||
|
||||
service_info_dispatcher = {
|
||||
vars.GENNET_GOWAKU_IMAGE_VALUE: waku.get_wakunode_peer_id,
|
||||
vars.GENNET_NWAKU_IMAGE_VALUE: waku.get_wakunode_peer_id,
|
||||
vars.GENNET_NOMOS_IMAGE_VALUE: nomos.get_nomos_peer_id
|
||||
}
|
||||
|
||||
service_multiaddr_dispatcher = {
|
||||
vars.GENNET_GOWAKU_IMAGE_VALUE: waku.create_node_multiaddress,
|
||||
vars.GENNET_NWAKU_IMAGE_VALUE: waku.create_node_multiaddress,
|
||||
vars.GENNET_NOMOS_IMAGE_VALUE: nomos.create_node_multiaddress
|
||||
}
|
||||
|
||||
service_connect_dispatcher = {
|
||||
vars.GENNET_GOWAKU_IMAGE_VALUE: waku.connect_wakunode_to_peers,
|
||||
vars.GENNET_NWAKU_IMAGE_VALUE: waku.connect_wakunode_to_peers,
|
||||
vars.GENNET_NOMOS_IMAGE_VALUE: nomos.connect_nomos_to_peers
|
||||
}
|
||||
|
||||
ports_dispatcher = {
|
||||
vars.GENNET_GOWAKU_IMAGE_VALUE: waku_builder._add_waku_ports_info_to_topology,
|
||||
vars.GENNET_NWAKU_IMAGE_VALUE: waku_builder._add_waku_ports_info_to_topology,
|
||||
vars.GENNET_NOMOS_IMAGE_VALUE: nomos_builder._add_nomos_ports_info_to_topology
|
||||
}
|
||||
dispatchers = import_module(vars.DISPATCHERS_MODULE)
|
||||
|
||||
def instantiate_services(plan, network_topology, testing):
|
||||
"""
|
||||
|
@ -61,14 +25,13 @@ def instantiate_services(plan, network_topology, testing):
|
|||
},
|
||||
"node_1": {...}
|
||||
}
|
||||
|
||||
}
|
||||
"""
|
||||
all_services_configuration = {}
|
||||
|
||||
for service_id, nodes_in_service in network_topology[vars.GENNET_ALL_CONTAINERS_KEY].items():
|
||||
image = network_topology[vars.GENNET_NODES_KEY][nodes_in_service[0]][vars.GENNET_IMAGE_KEY]
|
||||
service_builder = service_builder_dispatcher[image]
|
||||
service_builder = dispatchers.service_builder_dispatcher[image]
|
||||
|
||||
# Get all config file names needed
|
||||
config_file_names = [network_topology[vars.GENNET_NODES_KEY][node][vars.GENNET_CONFIG_KEY]
|
||||
|
@ -81,7 +44,7 @@ def instantiate_services(plan, network_topology, testing):
|
|||
]
|
||||
|
||||
service_builder(nodes_in_service, all_services_configuration, config_file_names,
|
||||
config_files_artifact_ids, service_id)
|
||||
config_files_artifact_ids, service_id, network_topology)
|
||||
|
||||
all_services_information = plan.add_services(
|
||||
configs=all_services_configuration
|
||||
|
@ -97,8 +60,8 @@ def interconnect_nodes(plan, topology_information, interconnection_batch):
|
|||
for node_id in nodes_in_topology.keys():
|
||||
image = nodes_in_topology[node_id][vars.GENNET_IMAGE_KEY]
|
||||
peers = nodes_in_topology[node_id][vars.GENNET_STATIC_NODES_KEY]
|
||||
create_node_multiaddress = service_multiaddr_dispatcher[image]
|
||||
connect_node_to_peers = service_connect_dispatcher[image]
|
||||
create_node_multiaddress = dispatchers.service_multiaddr_dispatcher[image]
|
||||
connect_node_to_peers = dispatchers.service_connect_dispatcher[image]
|
||||
|
||||
for i in range(0, len(peers), interconnection_batch):
|
||||
peer_ids = [create_node_multiaddress(peer, nodes_in_topology[peer])
|
||||
|
@ -114,7 +77,7 @@ def _add_service_info_to_topology(plan, all_services_information, network_topolo
|
|||
node_rpc_port_id = vars.RPC_PORT_ID + "_" + node_id
|
||||
|
||||
image = network_topology[vars.GENNET_NODES_KEY][node_id][vars.GENNET_IMAGE_KEY]
|
||||
peer_id_getter = service_info_dispatcher[image]
|
||||
peer_id_getter = dispatchers.service_info_dispatcher[image]
|
||||
node_peer_id = peer_id_getter(plan, node_info[vars.GENNET_NODE_CONTAINER_KEY],
|
||||
node_rpc_port_id)
|
||||
|
||||
|
@ -123,5 +86,5 @@ def _add_service_info_to_topology(plan, all_services_information, network_topolo
|
|||
network_topology[vars.GENNET_NODES_KEY][node_id][vars.IP_KEY] = \
|
||||
all_services_information[node_info[vars.GENNET_NODE_CONTAINER_KEY]].ip_address
|
||||
|
||||
ports_adder = ports_dispatcher[node_info[vars.GENNET_IMAGE_KEY]]
|
||||
ports_adder = dispatchers.ports_dispatcher[node_info[vars.GENNET_IMAGE_KEY]]
|
||||
ports_adder(network_topology, all_services_information, node_info, node_id)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Waku Configuration
|
||||
NWAKU_IMAGE = "statusteam/nim-waku:nwaku-trace"
|
||||
NWAKU_IMAGE = "statusteam/nim-waku:nwaku-trace2"
|
||||
GOWAKU_IMAGE = "gowaku"
|
||||
|
||||
RPC_PORT_ID = "rpc"
|
||||
|
@ -74,6 +74,7 @@ CONTAINER_DATASOURCES_FILE_NAME_GRAFANA = "datasources.yaml"
|
|||
|
||||
# Gennet topology Keys
|
||||
GENNET_NODES_KEY = "nodes"
|
||||
GENNET_PORT_SHIFT_KEY = "port_shift"
|
||||
GENNET_ALL_CONTAINERS_KEY = "containers"
|
||||
GENNET_IMAGE_KEY = "image"
|
||||
GENNET_CONFIG_KEY = "node_config"
|
||||
|
@ -110,6 +111,7 @@ GET_PEERS_METHOD = "get_waku_v2_admin_v1_peers"
|
|||
# Import locations
|
||||
WAKU_MODULE = "github.com/logos-co/wakurtosis/src/waku.star"
|
||||
NODE_BUILDERS_MODULE = "github.com/logos-co/wakurtosis/src/node_builders/node_builders.star"
|
||||
DISPATCHERS_MODULE = "github.com/logos-co/wakurtosis/src/node_builders/dispatchers.star"
|
||||
WAKU_BUILDER_MODULE = "github.com/logos-co/wakurtosis/src/node_builders/types/waku_builder.star"
|
||||
NWAKU_BUILDER_MODULE = "github.com/logos-co/wakurtosis/src/node_builders/types/nwaku_builder.star"
|
||||
GOWAKU_BUILDER_MODULE = "github.com/logos-co/wakurtosis/src/node_builders/types/gowaku_builder.star"
|
||||
|
@ -123,10 +125,14 @@ WLS_MODULE = "github.com/logos-co/wakurtosis/src/wls.star"
|
|||
CALL_PROTOCOLS = "github.com/logos-co/wakurtosis/src/call_protocols.star"
|
||||
NOMOS_MODULE = "github.com/logos-co/wakurtosis/src/nomos.star"
|
||||
|
||||
|
||||
TEST_ARGUMENTS_MODULE = "github.com/logos-co/wakurtosis/src/tests/test_arguments_parser.star"
|
||||
TEST_FILES_MODULE = "github.com/logos-co/wakurtosis/src/tests/test_file_helpers.star"
|
||||
TEST_NODE_BUILDERS_MODULE = "github.com/logos-co/wakurtosis/src/tests/test_node_builders.star"
|
||||
TEST_WAKU_MODULE = "github.com/logos-co/wakurtosis/src/tests/test_waku_methods.star"
|
||||
TEST_NODE_BUILDERS_MODULE = "github.com/logos-co/wakurtosis/src/node_builders/tests/test_node_builders.star"
|
||||
TEST_WAKU_BUILDER_MODULE = "github.com/logos-co/wakurtosis/src/node_builders/types/tests/test_waku_builder.star"
|
||||
TEST_GOWAKU_BUILDER_MODULE = "github.com/logos-co/wakurtosis/src/node_builders/types/tests/test_gowaku_builder.star"
|
||||
TEST_NWAKU_BUILDER_MODULE = "github.com/logos-co/wakurtosis/src/node_builders/types/tests/test_nwaku_builder.star"
|
||||
|
||||
# Default main starlark arguments
|
||||
TOPOLOGIES_LOCATION = "github.com/logos-co/wakurtosis/config/topology_generated/"
|
||||
|
|
Loading…
Reference in New Issue