mirror of https://github.com/vacp2p/wakurtosis.git
Merge pull request #75 from logos-co/Alberto/parallelize_services
Alberto/parallelize services into master
This commit is contained in:
commit
d1f71453dd
|
@ -8,10 +8,10 @@
|
|||
"same_toml_configuration": false
|
||||
},
|
||||
"gennet": {
|
||||
"num_nodes": 121,
|
||||
"num_topics": 7,
|
||||
"num_nodes": 9,
|
||||
"num_topics": 1,
|
||||
"num_partitions": 1,
|
||||
"num_subnets": 5,
|
||||
"num_subnets": 1,
|
||||
"node_type_distribution": { "nwaku":100, "gowaku":0 },
|
||||
"node_type": "desktop",
|
||||
"network_type": "newmanwattsstrogatz",
|
||||
|
|
13
run.sh
13
run.sh
|
@ -31,12 +31,12 @@ eval $kurtosis_cmd
|
|||
echo -e "Enclave " $enclave_name " is up and running"
|
||||
|
||||
# Fetch the WSL service id and display the log of the simulation
|
||||
wsl_service_id=$(kurtosis enclave inspect wakurtosis 2>/dev/null | grep wsl- | awk '{print $1}')
|
||||
# kurtosis service logs wakurtosis $wsl_service_id
|
||||
echo -e "\n--> To see simulation logs run: kurtosis service logs wakurtosis $wsl_service_id <--"
|
||||
wsl_service_name=$(kurtosis enclave inspect wakurtosis | grep wsl | awk '{print $1}')
|
||||
# kurtosis service logs wakurtosis $wsl_service_name
|
||||
echo -e "\n--> To see simulation logs run: kurtosis service logs wakurtosis $wsl_service_name <--"
|
||||
|
||||
# Fetch the Grafana address & port
|
||||
grafana_host=$(kurtosis enclave inspect wakurtosis 2>/dev/null | grep grafana- | awk '{print $6}')
|
||||
grafana_host=$(kurtosis enclave inspect wakurtosis | grep grafana | awk '{print $6}')
|
||||
echo -e "\n--> Statistics in Grafana server at http://$grafana_host/ <--"
|
||||
|
||||
# echo "Output of kurtosis run command written in kurtosisrun_log.txt"
|
||||
|
@ -44,10 +44,11 @@ echo -e "\n--> Statistics in Grafana server at http://$grafana_host/ <--"
|
|||
### Wait for WSL to finish
|
||||
|
||||
# Get the container suffix for the running service
|
||||
cid_suffix="$(kurtosis enclave inspect $enclave_name | grep $wsl_service_id | cut -f 1 -d ' ')"
|
||||
enclave_preffix="$(kurtosis enclave inspect --full-uuids $enclave_name | grep UUID: | awk '{print $2}')"
|
||||
cid_suffix="$(kurtosis enclave inspect --full-uuids $enclave_name | grep $wsl_service_name | cut -f 1 -d ' ')"
|
||||
|
||||
# Construct the fully qualified container name that kurtosis created
|
||||
cid="$enclave_name--user-service--$cid_suffix"
|
||||
cid="$enclave_preffix--user-service--$cid_suffix"
|
||||
|
||||
# Wait for the container to halt; this will block
|
||||
echo "Waiting for simulation to finish ..."
|
||||
|
|
|
@ -22,21 +22,23 @@ def set_up_grafana(plan, prometheus_service):
|
|||
name="grafana_target"
|
||||
)
|
||||
|
||||
add_service_config = ServiceConfig(
|
||||
image=system_variables.GRAFANA_IMAGE,
|
||||
ports={
|
||||
system_variables.GRAFANA_PORT_ID: PortSpec(number=system_variables.GRAFANA_TCP_PORT,
|
||||
transport_protocol="TCP")
|
||||
},
|
||||
files={
|
||||
system_variables.CONTAINER_CONFIGURATION_GRAFANA: config_id,
|
||||
# customization_id: CUSTOMIZATION_GRAFANA,
|
||||
system_variables.CONTAINER_DASHBOARDS_GRAFANA: dashboard_id,
|
||||
system_variables.CONTAINER_DATASOURCES_GRAFANA: artifact_id
|
||||
}
|
||||
)
|
||||
|
||||
grafana_service = plan.add_service(
|
||||
service_name=system_variables.GRAFANA_SERVICE_ID,
|
||||
config=ServiceConfig(
|
||||
image=system_variables.GRAFANA_IMAGE,
|
||||
ports={
|
||||
system_variables.GRAFANA_PORT_ID: PortSpec(number=system_variables.GRAFANA_TCP_PORT,
|
||||
transport_protocol="TCP")
|
||||
},
|
||||
files={
|
||||
system_variables.CONTAINER_CONFIGURATION_GRAFANA: config_id,
|
||||
# customization_id: CUSTOMIZATION_GRAFANA,
|
||||
system_variables.CONTAINER_DASHBOARDS_GRAFANA: dashboard_id,
|
||||
system_variables.CONTAINER_DATASOURCES_GRAFANA: artifact_id
|
||||
}
|
||||
)
|
||||
service_name=system_variables.GRAFANA_SERVICE_NAME,
|
||||
config=add_service_config
|
||||
)
|
||||
|
||||
return grafana_service
|
||||
|
|
|
@ -16,23 +16,25 @@ def set_up_prometheus(plan, services):
|
|||
name="prometheus_config"
|
||||
)
|
||||
|
||||
add_service_config = ServiceConfig(
|
||||
image=system_variables.PROMETHEUS_IMAGE,
|
||||
ports={
|
||||
system_variables.PROMETHEUS_PORT_ID: PortSpec(
|
||||
number=system_variables.CONTAINER_PROMETHEUS_TCP_PORT, transport_protocol="TCP")
|
||||
},
|
||||
files={
|
||||
system_variables.CONTAINER_CONFIGURATION_LOCATION_PROMETHEUS: artifact_id,
|
||||
system_variables.CONTAINER_CONFIGURATION_LOCATION_PROMETHEUS_2: targets_artifact_id
|
||||
},
|
||||
cmd=[
|
||||
"--config.file=" + system_variables.CONTAINER_CONFIGURATION_LOCATION_PROMETHEUS +
|
||||
system_variables.CONTAINER_CONFIGURATION_FILE_NAME_PROMETHEUS
|
||||
]
|
||||
)
|
||||
|
||||
prometheus_service = plan.add_service(
|
||||
service_name=system_variables.PROMETHEUS_SERVICE_ID,
|
||||
config=ServiceConfig(
|
||||
image=system_variables.PROMETHEUS_IMAGE,
|
||||
ports={
|
||||
system_variables.PROMETHEUS_PORT_ID: PortSpec(
|
||||
number=system_variables.CONTAINER_PROMETHEUS_TCP_PORT, transport_protocol="TCP")
|
||||
},
|
||||
files={
|
||||
system_variables.CONTAINER_CONFIGURATION_LOCATION_PROMETHEUS: artifact_id,
|
||||
system_variables.CONTAINER_CONFIGURATION_LOCATION_PROMETHEUS_2: targets_artifact_id
|
||||
},
|
||||
cmd=[
|
||||
"--config.file=" + system_variables.CONTAINER_CONFIGURATION_LOCATION_PROMETHEUS +
|
||||
system_variables.CONTAINER_CONFIGURATION_FILE_NAME_PROMETHEUS
|
||||
]
|
||||
)
|
||||
service_name=system_variables.PROMETHEUS_SERVICE_NAME,
|
||||
config=add_service_config
|
||||
)
|
||||
|
||||
return prometheus_service
|
||||
|
|
|
@ -6,41 +6,39 @@ waku = import_module(system_variables.WAKU_MODULE)
|
|||
files = import_module(system_variables.FILE_HELPERS_MODULE)
|
||||
|
||||
|
||||
def add_nwaku_service(plan, nwakunode_name, use_general_configuration):
|
||||
def prepare_nwaku_service(plan, nwakunode_name, all_services, use_general_configuration):
|
||||
artifact_id, configuration_file = files.get_toml_configuration_artifact(plan, nwakunode_name,
|
||||
use_general_configuration,
|
||||
nwakunode_name)
|
||||
|
||||
plan.print("Configuration being used file is " + configuration_file)
|
||||
|
||||
nwaku_service = plan.add_service(
|
||||
service_name=nwakunode_name,
|
||||
config=ServiceConfig(
|
||||
image=system_variables.NWAKU_IMAGE,
|
||||
ports={
|
||||
system_variables.WAKU_RPC_PORT_ID: PortSpec(number=system_variables.WAKU_TCP_PORT,
|
||||
transport_protocol="TCP"),
|
||||
system_variables.PROMETHEUS_PORT_ID: PortSpec(
|
||||
number=system_variables.PROMETHEUS_TCP_PORT,
|
||||
transport_protocol="TCP"),
|
||||
system_variables.WAKU_LIBP2P_PORT_ID: PortSpec(
|
||||
number=system_variables.WAKU_LIBP2P_PORT,
|
||||
transport_protocol="TCP"),
|
||||
},
|
||||
files={
|
||||
system_variables.CONTAINER_NODE_CONFIG_FILE_LOCATION: artifact_id
|
||||
},
|
||||
entrypoint=system_variables.NWAKU_ENTRYPOINT,
|
||||
cmd=[
|
||||
"--config-file=" + system_variables.CONTAINER_NODE_CONFIG_FILE_LOCATION + "/" + configuration_file
|
||||
]
|
||||
)
|
||||
add_service_config = ServiceConfig(
|
||||
image=system_variables.NWAKU_IMAGE,
|
||||
ports={
|
||||
system_variables.WAKU_RPC_PORT_ID: PortSpec(number=system_variables.WAKU_TCP_PORT,
|
||||
transport_protocol="TCP"),
|
||||
system_variables.PROMETHEUS_PORT_ID: PortSpec(
|
||||
number=system_variables.PROMETHEUS_TCP_PORT,
|
||||
transport_protocol="TCP"),
|
||||
system_variables.WAKU_LIBP2P_PORT_ID: PortSpec(
|
||||
number=system_variables.WAKU_LIBP2P_PORT,
|
||||
transport_protocol="TCP"),
|
||||
},
|
||||
files={
|
||||
system_variables.CONTAINER_NODE_CONFIG_FILE_LOCATION: artifact_id
|
||||
},
|
||||
entrypoint=system_variables.NWAKU_ENTRYPOINT,
|
||||
cmd=[
|
||||
"--config-file=" + system_variables.CONTAINER_NODE_CONFIG_FILE_LOCATION + "/" + configuration_file
|
||||
]
|
||||
)
|
||||
|
||||
return nwaku_service
|
||||
all_services[nwakunode_name] = add_service_config
|
||||
|
||||
|
||||
def add_gowaku_service(plan, gowakunode_name, use_general_configuration):
|
||||
|
||||
def prepare_gowaku_service(plan, gowakunode_name, all_services, use_general_configuration):
|
||||
artifact_id, configuration_file = files.get_toml_configuration_artifact(plan, gowakunode_name,
|
||||
use_general_configuration,
|
||||
gowakunode_name)
|
||||
|
@ -48,34 +46,31 @@ def add_gowaku_service(plan, gowakunode_name, use_general_configuration):
|
|||
plan.print("Configuration being used file is " + configuration_file)
|
||||
plan.print("Entrypoint is "+ str(system_variables.GOWAKU_ENTRYPOINT))
|
||||
|
||||
gowaku_service = plan.add_service(
|
||||
service_name=gowakunode_name,
|
||||
config=ServiceConfig(
|
||||
image=system_variables.GOWAKU_IMAGE,
|
||||
ports={
|
||||
system_variables.WAKU_RPC_PORT_ID: PortSpec(number=system_variables.WAKU_TCP_PORT,
|
||||
transport_protocol="TCP"),
|
||||
system_variables.PROMETHEUS_PORT_ID: PortSpec(
|
||||
number=system_variables.PROMETHEUS_TCP_PORT,
|
||||
transport_protocol="TCP"),
|
||||
system_variables.WAKU_LIBP2P_PORT_ID: PortSpec(
|
||||
number=system_variables.WAKU_LIBP2P_PORT,
|
||||
transport_protocol="TCP"),
|
||||
},
|
||||
files={
|
||||
system_variables.CONTAINER_NODE_CONFIG_FILE_LOCATION: artifact_id
|
||||
},
|
||||
entrypoint=system_variables.GOWAKU_ENTRYPOINT,
|
||||
cmd=[
|
||||
"--config-file=" + system_variables.CONTAINER_NODE_CONFIG_FILE_LOCATION + "/" + configuration_file
|
||||
]
|
||||
)
|
||||
add_service_config = ServiceConfig(
|
||||
image=system_variables.GOWAKU_IMAGE,
|
||||
ports={
|
||||
system_variables.WAKU_RPC_PORT_ID: PortSpec(number=system_variables.WAKU_TCP_PORT,
|
||||
transport_protocol="TCP"),
|
||||
system_variables.PROMETHEUS_PORT_ID: PortSpec(
|
||||
number=system_variables.PROMETHEUS_TCP_PORT,
|
||||
transport_protocol="TCP"),
|
||||
system_variables.WAKU_LIBP2P_PORT_ID: PortSpec(
|
||||
number=system_variables.WAKU_LIBP2P_PORT,
|
||||
transport_protocol="TCP"),
|
||||
},
|
||||
files={
|
||||
system_variables.CONTAINER_NODE_CONFIG_FILE_LOCATION: artifact_id
|
||||
},
|
||||
entrypoint=system_variables.GOWAKU_ENTRYPOINT,
|
||||
cmd=[
|
||||
"--config-file=" + system_variables.CONTAINER_NODE_CONFIG_FILE_LOCATION + "/" + configuration_file
|
||||
]
|
||||
)
|
||||
|
||||
return gowaku_service
|
||||
all_services[gowakunode_name] = add_service_config
|
||||
|
||||
|
||||
def add_nomos_service(plan, test, test2):
|
||||
def prepare_nomos_service(plan, test, test2):
|
||||
plan.print("nomos")
|
||||
|
||||
|
||||
|
@ -103,35 +98,40 @@ def instantiate_services(plan, network_topology, use_general_configuration):
|
|||
rpc_node_protocol = services["nwaku_0"]["service_info"].ports["your_rpc_identifier"].protocol
|
||||
"""
|
||||
|
||||
services_information = {}
|
||||
all_services = {}
|
||||
|
||||
# Get up all nodes
|
||||
for service_id in network_topology.keys():
|
||||
image = network_topology[service_id]["image"]
|
||||
for service_name in network_topology.keys():
|
||||
image = network_topology[service_name]["image"]
|
||||
|
||||
service_builder, information_builder = service_dispatcher[image]
|
||||
service_builder = service_dispatcher[image]
|
||||
|
||||
service_information = service_builder(plan, service_id, use_general_configuration)
|
||||
service_builder(plan, service_name, all_services, use_general_configuration)
|
||||
|
||||
information_builder(plan, services_information, service_id, service_information)
|
||||
all_services_information = plan.add_services(
|
||||
configs = all_services
|
||||
)
|
||||
services_information = _add_waku_service_information(plan, all_services_information)
|
||||
|
||||
return services_information
|
||||
|
||||
|
||||
def _add_waku_service_information(plan, services_information, new_service_id, service_information):
|
||||
def _add_waku_service_information(plan, all_services_information):
|
||||
|
||||
new_service_information = {}
|
||||
new_services_information = {}
|
||||
|
||||
wakunode_peer_id = waku.get_wakunode_peer_id(plan, new_service_id, system_variables.WAKU_RPC_PORT_ID)
|
||||
for service_name in all_services_information:
|
||||
node_peer_id = waku.get_wakunode_peer_id(plan, service_name, system_variables.WAKU_RPC_PORT_ID)
|
||||
|
||||
new_service_information["peer_id"] = wakunode_peer_id
|
||||
new_service_information["service_info"] = service_information
|
||||
new_services_information[service_name] = {}
|
||||
new_services_information[service_name]["peer_id"] = node_peer_id
|
||||
new_services_information[service_name]["service_info"] = all_services_information[service_name]
|
||||
|
||||
services_information[new_service_id] = new_service_information
|
||||
return new_services_information
|
||||
|
||||
|
||||
service_dispatcher = {
|
||||
"go-waku": (add_gowaku_service, _add_waku_service_information),
|
||||
"nim-waku": (add_nwaku_service, _add_waku_service_information),
|
||||
"nomos": (add_nomos_service, "test")
|
||||
"go-waku": prepare_gowaku_service,
|
||||
"nim-waku": prepare_nwaku_service,
|
||||
"nomos": prepare_nomos_service
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ WAKU_LIBP2P_PORT_ID = "libp2p"
|
|||
WAKU_LIBP2P_PORT = 60000
|
||||
WAKU_SETUP_WAIT_TIME = "5"
|
||||
|
||||
WAKU_INTERCONNECTION_BATCH = 4
|
||||
|
||||
NODE_CONFIG_FILE_LOCATION = "github.com/logos-co/wakurtosis/config/topology_generated/"
|
||||
|
||||
CONTAINER_NODE_CONFIG_FILE_LOCATION = "/node/configuration_file/"
|
||||
|
@ -17,7 +19,7 @@ GOWAKU_ENTRYPOINT = ["/usr/bin/waku", "--rpc-address=0.0.0.0", "--metrics-server
|
|||
|
||||
# Prometheus Configuration
|
||||
PROMETHEUS_IMAGE = "prom/prometheus:latest"
|
||||
PROMETHEUS_SERVICE_ID = "prometheus"
|
||||
PROMETHEUS_SERVICE_NAME = "prometheus"
|
||||
PROMETHEUS_PORT_ID = "prometheus_tcp"
|
||||
PROMETHEUS_TCP_PORT = 8008
|
||||
PROMETHEUS_CONFIGURATION_PATH = "github.com/logos-co/wakurtosis/monitoring/prometheus.yml"
|
||||
|
@ -34,7 +36,7 @@ GRAFANA_CONFIGURATION_PATH = "github.com/logos-co/wakurtosis/monitoring/configur
|
|||
GRAFANA_CUSTOMIZATION_PATH = "github.com/logos-co/wakurtosis/monitoring/configuration/customizations/"
|
||||
GRAFANA_DASHBOARD_PATH = "github.com/logos-co/wakurtosis/monitoring/configuration/dashboards/"
|
||||
|
||||
GRAFANA_SERVICE_ID = "grafana"
|
||||
GRAFANA_SERVICE_NAME = "grafana"
|
||||
GRAFANA_PORT_ID = "grafana_tcp"
|
||||
GRAFANA_TCP_PORT = 3000
|
||||
|
||||
|
@ -46,7 +48,7 @@ CONTAINER_DATASOURCES_FILE_NAME_GRAFANA = "datasources.yaml"
|
|||
|
||||
# WSL Configuration
|
||||
WSL_IMAGE = "wsl:0.0.1"
|
||||
WSL_SERVICE_ID = "wsl"
|
||||
WSL_SERVICE_NAME = "wsl"
|
||||
WSL_CONFIG_PATH = "/wsl/config"
|
||||
WSL_TARGETS_PATH = "/wsl/targets"
|
||||
WSL_TOMLS_PATH = "/wsl/tomls"
|
||||
|
|
|
@ -7,7 +7,7 @@ waku = import_module(system_variables.WAKU_MODULE)
|
|||
|
||||
|
||||
def test_add_nwaku_service(plan):
|
||||
nwaku_test_service = node_builders.add_nwaku_service(plan, "nwaku_test", False)
|
||||
nwaku_test_service = node_builders.prepare_nwaku_service(plan, "nwaku_test", False)
|
||||
|
||||
test__add_waku_service_information(plan, nwaku_test_service)
|
||||
|
||||
|
@ -22,7 +22,7 @@ def test_add_nwaku_service(plan):
|
|||
|
||||
|
||||
def test_add_gowaku_service(plan):
|
||||
gowaku_test_service = node_builders.add_gowaku_service(plan, "gowaku_test", False)
|
||||
gowaku_test_service = node_builders.prepare_gowaku_service(plan, "gowaku_test", False)
|
||||
|
||||
plan.assert(value=str(gowaku_test_service.ports[system_variables.WAKU_RPC_PORT_ID].number),
|
||||
assertion="==", target_value=str(system_variables.WAKU_TCP_PORT))
|
||||
|
|
|
@ -10,34 +10,34 @@ node_builders = import_module(system_variables.NODE_BUILDERS_MODULE)
|
|||
# instead having to create one for each test, and in order to create a node we need access to "plan"
|
||||
# parameter, so we cannot have it as a global variable as it was intented.
|
||||
def test_waku_methods(plan):
|
||||
NWAKU_TEST_SERVICE_ID = "nwaku_global_test"
|
||||
NWAKU_TEST_SERVICE_ID_2 = "nwaku_test_2"
|
||||
NWAKU_TEST_SERVICE = node_builders.add_nwaku_service(plan, NWAKU_TEST_SERVICE_ID, False)
|
||||
NWAKU_TEST_SERVICE_2 = node_builders.add_nwaku_service(plan, NWAKU_TEST_SERVICE_ID_2, False)
|
||||
NWAKU_TEST_SERVICE_NAME = "nwaku_global_test"
|
||||
NWAKU_TEST_SERVICE_NAME_2 = "nwaku_test_2"
|
||||
NWAKU_TEST_SERVICE = node_builders.prepare_nwaku_service(plan, NWAKU_TEST_SERVICE_NAME, False)
|
||||
NWAKU_TEST_SERVICE_2 = node_builders.prepare_nwaku_service(plan, NWAKU_TEST_SERVICE_NAME_2, False)
|
||||
|
||||
test_send_json_rpc(plan, NWAKU_TEST_SERVICE_ID)
|
||||
test_get_wakunode_peer_id(plan, NWAKU_TEST_SERVICE_ID)
|
||||
test_send_json_rpc(plan, NWAKU_TEST_SERVICE_NAME)
|
||||
test_get_wakunode_peer_id(plan, NWAKU_TEST_SERVICE_NAME)
|
||||
test_create_waku_id(plan)
|
||||
test__merge_peer_ids(plan)
|
||||
test_connect_wakunode_to_peers(plan, NWAKU_TEST_SERVICE_ID)
|
||||
test_post_waku_v2_relay_v1_message(plan, NWAKU_TEST_SERVICE_ID)
|
||||
test_connect_wakunode_to_peers(plan, NWAKU_TEST_SERVICE_NAME)
|
||||
test_post_waku_v2_relay_v1_message(plan, NWAKU_TEST_SERVICE_NAME)
|
||||
test_get_waku_peers(plan)
|
||||
test_interconnect_waku_nodes(plan)
|
||||
|
||||
plan.remove_service(NWAKU_TEST_SERVICE_ID)
|
||||
plan.remove_service(NWAKU_TEST_SERVICE_ID_2)
|
||||
plan.remove_service(NWAKU_TEST_SERVICE_NAME)
|
||||
plan.remove_service(NWAKU_TEST_SERVICE_NAME_2)
|
||||
|
||||
def test_send_json_rpc(plan, service_id):
|
||||
def test_send_json_rpc(plan, service_name):
|
||||
waku_message = '{"payload": "0x1a2b3c4d5e6f", "timestamp": 1626813243}'
|
||||
params = "test, " + waku_message
|
||||
|
||||
# Automatically waits for 200
|
||||
waku.send_json_rpc(plan, service_id, system_variables.WAKU_RPC_PORT_ID,
|
||||
waku.send_json_rpc(plan, service_name, system_variables.WAKU_RPC_PORT_ID,
|
||||
system_variables.POST_RELAY_MESSAGE_METHOD, params)
|
||||
|
||||
|
||||
def test_get_wakunode_peer_id(plan, service_id):
|
||||
peer_id = waku.get_wakunode_peer_id(plan, service_id, system_variables.WAKU_RPC_PORT_ID)
|
||||
def test_get_wakunode_peer_id(plan, service_name):
|
||||
peer_id = waku.get_wakunode_peer_id(plan, service_name, system_variables.WAKU_RPC_PORT_ID)
|
||||
plan.print(peer_id)
|
||||
plan.assert(value=peer_id, assertion="==",
|
||||
target_value="16Uiu2HAm7ZPmRY3ECVz7fAJQdxEDrBw3ToneYgUryKDJPtz25R2n")
|
||||
|
@ -63,12 +63,12 @@ def test__merge_peer_ids(plan):
|
|||
target_value="[/ip4/1.1.1.1/tcp/1234/p2p/ASDFGHJKL,/ip4/2.2.2.2/tcp/1234/p2p/QWERTYUIOP]")
|
||||
|
||||
|
||||
def test_connect_wakunode_to_peers(plan, service_id):
|
||||
def test_connect_wakunode_to_peers(plan, service_name):
|
||||
# It will print an error but 200 code
|
||||
waku.connect_wakunode_to_peers(plan, service_id, system_variables.WAKU_RPC_PORT_ID, ["asd"])
|
||||
waku.connect_wakunode_to_peers(plan, service_name, system_variables.WAKU_RPC_PORT_ID, ["asd"])
|
||||
|
||||
def test_post_waku_v2_relay_v1_message(plan, service_id):
|
||||
waku.post_waku_v2_relay_v1_message_test(plan, service_id, "test")
|
||||
def test_post_waku_v2_relay_v1_message(plan, service_name):
|
||||
waku.post_waku_v2_relay_v1_message_test(plan, service_name, "test")
|
||||
|
||||
|
||||
def test_get_waku_peers(plan):
|
||||
|
@ -85,9 +85,9 @@ def test_interconnect_waku_nodes(plan):
|
|||
|
||||
waku.interconnect_waku_nodes(plan, topology, node_test_services)
|
||||
|
||||
for service_id in topology:
|
||||
neighbours = waku.get_waku_peers(plan, service_id)
|
||||
for service_name in topology:
|
||||
neighbours = waku.get_waku_peers(plan, service_name)
|
||||
plan.assert(value=neighbours, assertion="==", target_value=1)
|
||||
|
||||
for service_id in topology:
|
||||
plan.remove_service(service_id)
|
||||
for service_name in topology:
|
||||
plan.remove_service(service_name)
|
||||
|
|
|
@ -5,9 +5,9 @@ system_variables = import_module("github.com/logos-co/wakurtosis/src/system_vari
|
|||
files = import_module(system_variables.FILE_HELPERS_MODULE)
|
||||
|
||||
|
||||
def send_json_rpc(plan, service_id, port_id, method, params, extract={}):
|
||||
def send_json_rpc(plan, service_name, port_id, method, params, extract={}):
|
||||
recipe = PostHttpRequestRecipe(
|
||||
service_name=service_id,
|
||||
service_name=service_name,
|
||||
port_id=port_id,
|
||||
endpoint="",
|
||||
content_type="application/json",
|
||||
|
@ -23,10 +23,10 @@ def send_json_rpc(plan, service_id, port_id, method, params, extract={}):
|
|||
return response
|
||||
|
||||
|
||||
def get_wakunode_peer_id(plan, service_id, port_id):
|
||||
def get_wakunode_peer_id(plan, service_name, port_id):
|
||||
extract = {"peer_id": '.result.listenAddresses | .[0] | split("/") | .[-1]'}
|
||||
|
||||
response = send_json_rpc(plan, service_id, port_id,
|
||||
response = send_json_rpc(plan, service_name, port_id,
|
||||
system_variables.GET_WAKU_INFO_METHOD, "", extract)
|
||||
|
||||
plan.assert(value=response["code"], assertion="==", target_value = 200)
|
||||
|
@ -48,40 +48,40 @@ def _merge_peer_ids(peer_ids):
|
|||
return "[" + ",".join(peer_ids) + "]"
|
||||
|
||||
|
||||
def connect_wakunode_to_peers(plan, service_id, port_id, peer_ids):
|
||||
def connect_wakunode_to_peers(plan, service_name, port_id, peer_ids):
|
||||
method = system_variables.CONNECT_TO_PEER_METHOD
|
||||
params = _merge_peer_ids(peer_ids)
|
||||
|
||||
response = send_json_rpc(plan, service_id, port_id, method, params)
|
||||
response = send_json_rpc(plan, service_name, port_id, method, params)
|
||||
|
||||
plan.assert(value=response["code"], assertion="==", target_value = 200)
|
||||
|
||||
plan.print(response)
|
||||
|
||||
|
||||
def post_waku_v2_relay_v1_message_test(plan, service_id, topic):
|
||||
def post_waku_v2_relay_v1_message_test(plan, service_name, topic):
|
||||
waku_message = '{"payload": "0x1a2b3c4d5e6f", "timestamp": 1626813243}'
|
||||
params = '"' + topic + '"' + ", " + waku_message
|
||||
|
||||
response = send_json_rpc(plan, service_id, system_variables.WAKU_RPC_PORT_ID,
|
||||
response = send_json_rpc(plan, service_name, system_variables.WAKU_RPC_PORT_ID,
|
||||
system_variables.POST_RELAY_MESSAGE_METHOD, params)
|
||||
|
||||
plan.assert(value=response["code"], assertion="==", target_value = 200)
|
||||
|
||||
|
||||
def make_service_wait(plan,service_id, time):
|
||||
def make_service_wait(plan, service_name, time):
|
||||
exec_recipe = struct(
|
||||
service_id=service_id,
|
||||
service_name=service_name,
|
||||
command=["sleep", time]
|
||||
)
|
||||
plan.exec(exec_recipe)
|
||||
|
||||
|
||||
def get_waku_peers(plan, waku_service_id):
|
||||
def get_waku_peers(plan, waku_service_name):
|
||||
extract = {"peers": '.result | length'}
|
||||
|
||||
response = send_json_rpc(plan, waku_service_id, system_variables.WAKU_RPC_PORT_ID,
|
||||
system_variables.GET_PEERS_METHOD, "", extract)
|
||||
response = send_json_rpc(plan, waku_service_name, system_variables.WAKU_RPC_PORT_ID,
|
||||
system_variables.GET_PEERS_METHOD, "", extract)
|
||||
|
||||
plan.assert(value=response["code"], assertion="==", target_value=200)
|
||||
|
||||
|
@ -90,11 +90,13 @@ def get_waku_peers(plan, waku_service_id):
|
|||
|
||||
def interconnect_waku_nodes(plan, topology_information, services):
|
||||
# Interconnect them
|
||||
for waku_service_id in services.keys():
|
||||
peers = topology_information[waku_service_id]["static_nodes"]
|
||||
for waku_service_name in services.keys():
|
||||
peers = topology_information[waku_service_name]["static_nodes"]
|
||||
|
||||
peer_ids = [create_waku_id(services[peer]) for peer in peers]
|
||||
for i in range(0, len(peers), system_variables.WAKU_INTERCONNECTION_BATCH):
|
||||
x = i
|
||||
peer_ids = [create_waku_id(services[peer]) for peer in peers[x:x+system_variables.WAKU_INTERCONNECTION_BATCH]]
|
||||
|
||||
connect_wakunode_to_peers(plan, waku_service_id, system_variables.WAKU_RPC_PORT_ID, peer_ids)
|
||||
connect_wakunode_to_peers(plan, waku_service_name, system_variables.WAKU_RPC_PORT_ID, peer_ids)
|
||||
|
||||
|
||||
|
|
26
src/wsl.star
26
src/wsl.star
|
@ -57,20 +57,20 @@ def init(plan, services, wsl_config):
|
|||
# Create targets.json
|
||||
wsl_targets = create_targets(plan, services)
|
||||
|
||||
wsl_service = plan.add_service(
|
||||
service_name=system_variables.WSL_SERVICE_ID,
|
||||
config=ServiceConfig(
|
||||
image=system_variables.WSL_IMAGE,
|
||||
ports={},
|
||||
files={
|
||||
system_variables.WSL_CONFIG_PATH : wsl_config,
|
||||
system_variables.WSL_TARGETS_PATH : wsl_targets,
|
||||
system_variables.WSL_TOMLS_PATH : tomls_artifact
|
||||
},
|
||||
|
||||
cmd=["python3", "wsl.py"]
|
||||
|
||||
)
|
||||
add_service_config = ServiceConfig(
|
||||
image=system_variables.WSL_IMAGE,
|
||||
ports={},
|
||||
files={
|
||||
system_variables.WSL_CONFIG_PATH: wsl_config,
|
||||
system_variables.WSL_TARGETS_PATH: wsl_targets,
|
||||
system_variables.WSL_TOMLS_PATH: tomls_artifact
|
||||
},
|
||||
cmd=["python3", "wsl.py"]
|
||||
)
|
||||
wsl_service = plan.add_service(
|
||||
service_name=system_variables.WSL_SERVICE_NAME,
|
||||
config=add_service_config
|
||||
)
|
||||
|
||||
return wsl_service
|
||||
|
|
Loading…
Reference in New Issue