diff --git a/.gitignore b/.gitignore index b8392d8643..a266272446 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ release/ /build coverage.txt +trace.out __pycache__ /dist /vendor diff --git a/integration_tests/network.py b/integration_tests/network.py index f18be8156e..775d304c77 100644 --- a/integration_tests/network.py +++ b/integration_tests/network.py @@ -38,6 +38,10 @@ def w3_ws_endpoint(self, i=0): port = ports.evmrpc_ws_port(self.base_port(i)) return f"ws://localhost:{port}" + def pprof_endpoint(self, i=0): + port = ports.pprof_port(self.base_port(i)) + return f"http://localhost:{port}" + @property def w3(self): if self._w3 is None: diff --git a/integration_tests/test_upgrade_recent.py b/integration_tests/test_upgrade_recent.py index f41f720db1..e616c5288c 100644 --- a/integration_tests/test_upgrade_recent.py +++ b/integration_tests/test_upgrade_recent.py @@ -1,3 +1,4 @@ +import concurrent.futures from concurrent.futures import ThreadPoolExecutor, as_completed import pytest @@ -23,9 +24,8 @@ def call(url, params): return rsp.json() -def call_check(url, address): +def call_check(url, address, concurrent): batch = 10 - concurrent = 10 param = { "jsonrpc": "2.0", "method": "eth_call", @@ -47,10 +47,26 @@ def call_check(url, address): assert len(results) == concurrent +def call_trace(url): + res = requests.get(f"{url}/debug/pprof/trace?seconds=3") + if res.status_code == 200: + with open("trace.out", "wb") as file: + file.write(res.content) + print("saved trace.out") + else: + print(f"failed to retrieve data: {res.status_code}") + + def test_cosmovisor_upgrade(custom_cronos): c = custom_cronos cli = c.cosmos_cli() cli = do_upgrade(c, "v1.4", cli.block_height() + 15) res = deploy_contract(c.w3, CONTRACTS["CheckpointOracle"]) - url = c.w3_http_endpoint() - [call_check(url, res.address) for _ in range(10)] + url0 = c.pprof_endpoint() + url1 = c.w3_http_endpoint() + with ThreadPoolExecutor() as exec: + futures = [ + exec.submit(call_trace, url0), + exec.submit(call_check, url1, res.address, 100), + ] + concurrent.futures.wait(futures)