Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding port setting for metrics to fuzz test run #517

Merged
merged 2 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VEGA_SIM_VEGA_TAG="086658a26128ce92a0a5aadfcec8dce484b20f3d"
VEGA_SIM_VEGA_TAG=aaa9b4eb0b8fba1e118e19fc90d81b74cd02092d
VEGA_SIM_CONSOLE_TAG=develop
VEGA_DEFAULT_KEY_NAME='Key 1'
VEGA_SIM_NETWORKS_INTERNAL_TAG=main
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pipeline {
disableConcurrentBuilds(abortPrevious: true)
}
parameters {
string( name: 'VEGA_VERSION', defaultValue: '086658a26128ce92a0a5aadfcec8dce484b20f3d',
string( name: 'VEGA_VERSION', defaultValue: 'aaa9b4eb0b8fba1e118e19fc90d81b74cd02092d',
description: 'Git branch, tag or hash of the vegaprotocol/vega repository')
string( name: 'VEGACAPSULE_VERSION', defaultValue: 'main',
description: 'Git branch, tag or hash of the vegaprotocol/vegacapsule repository')
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-fuzz-test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

python -m vega_sim.scenario.fuzzed_markets.run_fuzz_test --steps $1
python -m vega_sim.scenario.fuzzed_markets.run_fuzz_test ${@:1}
39 changes: 24 additions & 15 deletions vega_sim/null_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Ports(Enum):
CORE_REST = auto()
BROKER = auto()
METRICS = auto()
DATA_NODE_METRICS = auto()
PPROF = auto()
CONSOLE = auto()

Expand Down Expand Up @@ -179,13 +180,15 @@ class Ports(Enum):
lambda port: port,
),
],
Ports.METRICS: [
Ports.DATA_NODE_METRICS: [
PortUpdateConfig(
("config", "data-node", "config.toml"),
["Metrics"],
"Port",
lambda port: port,
),
],
Ports.METRICS: [
PortUpdateConfig(
("config", "node", "config.toml"),
["Metrics"],
Expand Down Expand Up @@ -722,15 +725,17 @@ def kill_docker_container() -> None:

class VegaServiceNull(VegaService):
PORT_TO_FIELD_MAP = {
Ports.WALLET: "wallet_port",
Ports.CONSOLE: "console_port",
Ports.CORE_GRPC: "vega_node_grpc_port",
Ports.CORE_REST: "vega_node_rest_port",
Ports.DATA_NODE_GRPC: "data_node_grpc_port",
Ports.DATA_NODE_REST: "data_node_rest_port",
Ports.DATA_NODE_METRICS: "data_node_metrics_port",
Ports.DATA_NODE_POSTGRES: "data_node_postgres_port",
Ports.DATA_NODE_REST: "data_node_rest_port",
Ports.FAUCET: "faucet_port",
Ports.METRICS: "metrics_port",
Ports.VEGA_NODE: "vega_node_port",
Ports.CORE_GRPC: "vega_node_grpc_port",
Ports.CORE_REST: "vega_node_rest_port",
Ports.CONSOLE: "console_port",
Ports.WALLET: "wallet_port",
}

def __init__(
Expand Down Expand Up @@ -834,29 +839,33 @@ def _check_started(self) -> None:

def _generate_port_config(self) -> Dict[Ports, int]:
return {
Ports.WALLET: self.wallet_port,
Ports.CONSOLE: self.console_port,
Ports.CORE_GRPC: self.vega_node_grpc_port,
Ports.CORE_REST: self.vega_node_rest_port,
Ports.DATA_NODE_GRPC: self.data_node_grpc_port,
Ports.DATA_NODE_REST: self.data_node_rest_port,
Ports.DATA_NODE_METRICS: self.data_node_metrics_port,
Ports.DATA_NODE_POSTGRES: self.data_node_postgres_port,
Ports.DATA_NODE_REST: self.data_node_rest_port,
Ports.FAUCET: self.faucet_port,
Ports.METRICS: self.metrics_port,
Ports.VEGA_NODE: self.vega_node_port,
Ports.CORE_GRPC: self.vega_node_grpc_port,
Ports.CORE_REST: self.vega_node_rest_port,
Ports.CONSOLE: self.console_port,
Ports.WALLET: self.wallet_port,
}

# set ports from port_config or alternatively find a free port
# to use
def _assign_ports(self, port_config: Optional[Dict[Ports, int]]):
self.wallet_port = 0
self.data_node_rest_port = 0
self.console_port = 0
self.data_node_grpc_port = 0
self.data_node_metrics_port = 0
self.data_node_postgres_port = 0
self.data_node_rest_port = 0
self.faucet_port = 0
self.vega_node_port = 0
self.metrics_port = 0
self.vega_node_grpc_port = 0
self.vega_node_port = 0
self.vega_node_rest_port = 0
self.console_port = 0
self.wallet_port = 0

for key, name in self.PORT_TO_FIELD_MAP.items():
if port_config is not None and key in port_config:
Expand Down
592 changes: 305 additions & 287 deletions vega_sim/proto/data_node/api/v2/trading_data_pb2.py

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions vega_sim/proto/data_node/api/v2/trading_data_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ def __init__(self, channel):
request_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ListFundingPeriodDataPointsRequest.SerializeToString,
response_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ListFundingPeriodDataPointsResponse.FromString,
)
self.ListFundingPayments = channel.unary_unary(
"/datanode.api.v2.TradingDataService/ListFundingPayments",
request_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ListFundingPaymentsRequest.SerializeToString,
response_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ListFundingPaymentsResponse.FromString,
)
self.GetPartyActivityStreak = channel.unary_unary(
"/datanode.api.v2.TradingDataService/GetPartyActivityStreak",
request_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.GetPartyActivityStreakRequest.SerializeToString,
Expand Down Expand Up @@ -1425,6 +1430,15 @@ def ListFundingPeriodDataPoints(self, request, context):
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")

def ListFundingPayments(self, request, context):
"""List funding payments for a party

Get a list of data points for a perpetual market's funding payment for a party.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")

def GetPartyActivityStreak(self, request, context):
"""List party activity streak

Expand Down Expand Up @@ -2052,6 +2066,11 @@ def add_TradingDataServiceServicer_to_server(servicer, server):
request_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ListFundingPeriodDataPointsRequest.FromString,
response_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ListFundingPeriodDataPointsResponse.SerializeToString,
),
"ListFundingPayments": grpc.unary_unary_rpc_method_handler(
servicer.ListFundingPayments,
request_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ListFundingPaymentsRequest.FromString,
response_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ListFundingPaymentsResponse.SerializeToString,
),
"GetPartyActivityStreak": grpc.unary_unary_rpc_method_handler(
servicer.GetPartyActivityStreak,
request_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.GetPartyActivityStreakRequest.FromString,
Expand Down Expand Up @@ -4815,6 +4834,35 @@ def ListFundingPeriodDataPoints(
metadata,
)

@staticmethod
def ListFundingPayments(
request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None,
):
return grpc.experimental.unary_unary(
request,
target,
"/datanode.api.v2.TradingDataService/ListFundingPayments",
data__node_dot_api_dot_v2_dot_trading__data__pb2.ListFundingPaymentsRequest.SerializeToString,
data__node_dot_api_dot_v2_dot_trading__data__pb2.ListFundingPaymentsResponse.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
)

@staticmethod
def GetPartyActivityStreak(
request,
Expand Down
290 changes: 147 additions & 143 deletions vega_sim/proto/vega/events/v1/events_pb2.py

Large diffs are not rendered by default.

658 changes: 330 additions & 328 deletions vega_sim/proto/vega/snapshot/v1/snapshot_pb2.py

Large diffs are not rendered by default.

402 changes: 201 additions & 201 deletions vega_sim/proto/vega/vega_pb2.py

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions vega_sim/scenario/fuzzed_markets/run_fuzz_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
import argparse

from vega_sim.null_service import VegaServiceNull
from vega_sim.null_service import VegaServiceNull, Ports

from vega_sim.scenario.constants import Network
from vega_sim.scenario.fuzzed_markets.scenario import FuzzingScenario
Expand All @@ -24,6 +24,8 @@ def _run(
console: bool = False,
output: bool = False,
output_dir: str = "fuzz_plots",
core_metrics_port: int = 2723,
data_node_metrics_port: int = 3651,
):
scenario = FuzzingScenario(
num_steps=steps,
Expand All @@ -40,6 +42,10 @@ def _run(
retain_log_files=True,
use_full_vega_wallet=False,
run_with_console=console,
port_config={
Ports.METRICS: core_metrics_port,
Ports.DATA_NODE_METRICS: data_node_metrics_port,
},
) as vega:
scenario.run_iteration(
vega=vega,
Expand Down Expand Up @@ -90,11 +96,19 @@ def _run(
action="store_true",
)
parser.add_argument("--console", action="store_true")
parser.add_argument("--core-metrics-port", default=2723, type=int)
parser.add_argument("--data-node-metrics-port", default=3651, type=int)
args = parser.parse_args()

logging.basicConfig(
level=logging.DEBUG if args.debug else logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)

_run(steps=args.steps, console=args.console, output=True)
_run(
steps=args.steps,
console=args.console,
output=True,
core_metrics_port=args.core_metrics_port,
data_node_metrics_port=args.data_node_metrics_port,
)
2 changes: 1 addition & 1 deletion vega_sim/vegahome/config/data-node/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ UlimitNOFile = 8192
Timeout = "5s"
Port = "TO_BE_SET"
Path = "/metrics"
Enabled = false
Enabled = true

[Transfers]
Level = "Info"
Expand Down
2 changes: 1 addition & 1 deletion vega_sim/vegahome/config/node/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ UlimitNOFile = 8192
Timeout = "5s"
Port = "TO_BE_SET"
Path = "/metrics"
Enabled = false
Enabled = true

[Governance]
Level = "Debug"
Expand Down