Skip to content

Commit

Permalink
add assert
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Dec 16, 2024
1 parent 1bcd882 commit ea4fd4b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
release/
/build
coverage.txt
trace.out
__pycache__
/dist
/vendor
Expand Down
39 changes: 23 additions & 16 deletions integration_tests/test_upgrade_recent.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import concurrent.futures
import subprocess
from concurrent.futures import ThreadPoolExecutor, as_completed
from pathlib import Path

import pytest
import requests
Expand Down Expand Up @@ -38,32 +39,38 @@ def call_check(url, address, concurrent):
],
"id": 1,
}
params = []
for _ in range(batch):
params.append(param)
params = [param for _ in range(batch)]
with ThreadPoolExecutor(concurrent) as executor:
tasks = [executor.submit(call, url, params) for _ in range(0, concurrent)]
results = [future.result() for future in as_completed(tasks)]
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 call_trace(url, tmp_path_factory):
res = requests.get(f"{url}/debug/pprof/trace?seconds=0.2")
assert res.status_code == 200, res
folder = tmp_path_factory.mktemp("trace")
trace = Path(folder / "trace.out")
syscall = Path(folder / "syscall.out")
with open(trace, "wb") as file:
file.write(res.content)
cmd = f"go tool trace -pprof=syscall {trace} > {syscall}"
subprocess.run(cmd, shell=True, check=True)
cmd = f"go tool pprof -top {syscall} | head -n 10"
res = subprocess.run(
cmd, shell=True, check=True, capture_output=True, text=True
).stdout
print(res)
assert "rocksdb" in res and "create_iterator" not in res, res


def test_cosmovisor_upgrade(custom_cronos):
def test_cosmovisor_upgrade(custom_cronos, tmp_path_factory):
c = custom_cronos
do_upgrade(c, "v1.4", c.cosmos_cli().block_height() + 15)
res = deploy_contract(c.w3, CONTRACTS["CheckpointOracle"])
with ThreadPoolExecutor() as exec:
futures = [
exec.submit(call_trace, c.pprof_endpoint()),
tasks = [
exec.submit(call_trace, c.pprof_endpoint(), tmp_path_factory),
exec.submit(call_check, c.w3_http_endpoint(), res.address, 100),
]
concurrent.futures.wait(futures)
[future.result() for future in as_completed(tasks)]

Check failure on line 76 in integration_tests/test_upgrade_recent.py

View workflow job for this annotation

GitHub Actions / integration_tests (upgrade)

test_cosmovisor_upgrade subprocess.CalledProcessError: Command 'go tool trace -pprof=syscall /tmp/pytest-of-runner/pytest-0/trace0/trace.out > /tmp/pytest-of-runner/pytest-0/trace0/syscall.out' returned non-zero exit status 127.

0 comments on commit ea4fd4b

Please sign in to comment.