import pytest
from utils import GP, check_cmd_time, check_hdc_cmd, check_rate, get_local_path, get_remote_path, \
load_gp, check_unsupport_systems
def clear_env():
check_hdc_cmd("shell rm -rf data/local/tmp/it_*")
check_hdc_cmd("shell mkdir data/local/tmp/it_send_dir")
class TestShellPerformance:
@pytest.mark.L0
def test_shell_cmd_timecost_param_p(self):
check_hdc_cmd("shell \"touch /data/local/tmp/test_file\"")
assert check_cmd_time(
cmd="-p shell \"ls -al /data/local/tmp\"",
pattern="test_file",
duration=220,
times=50)
@pytest.mark.L0
def test_shell_cmd_timecost_param_none(self):
check_hdc_cmd("shell \"ps -ef | grep hdcd\"")
assert check_cmd_time(
cmd="shell \"echo 1\"",
pattern="1",
duration=None,
times=20)
@pytest.mark.L0
@check_unsupport_systems(["Linux", "Harmony", "Darwin"])
def test_shell_huge_cat(self):
assert check_hdc_cmd(f"file send {get_local_path('word_100M.txt')} {get_remote_path('it_word_100M.txt')}")
assert check_cmd_time(
cmd=f"shell cat {get_remote_path('it_word_100M.txt')}",
pattern=None,
duration=10000,
times=10)
class TestFilePerformance:
@pytest.mark.L0
@pytest.mark.repeat(1)
def test_rate(self):
clear_env()
assert check_rate(f"file send {get_local_path('large')} {get_remote_path('it_large')}", 18000)
assert check_rate(f"file recv {get_remote_path('it_large')} {get_local_path('large_recv')}", 18000)