From 221cb97073b2a0bafe644d709a4c7c7bd3f803bc Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 6 Jul 2023 00:52:09 +0200 Subject: test: add one more stress test --- test/py/test_repo.py | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/test/py/test_repo.py b/test/py/test_repo.py index 2c995e1..782240b 100644 --- a/test/py/test_repo.py +++ b/test/py/test_repo.py @@ -3,6 +3,8 @@ # For details, see https://github.com/egor-tensin/cimple. # Distributed under the MIT License. +from multiprocessing import Process + import pytest from lib.process import LoggingEvent @@ -23,32 +25,46 @@ class LoggingEventRunComplete(LoggingEvent): super().set() -def _test_repo_internal(server_and_workers, test_repo, client, numof_runs): +def _test_repo_internal(server_and_workers, test_repo, client, numof_processes, runs_per_process): + numof_runs = numof_processes * runs_per_process + server, workers = server_and_workers event = LoggingEventRunComplete(numof_runs) # Count the number of times the server receives the "run complete" message. server.logger.add_event(event) - for i in range(numof_runs): - client.run('run', test_repo.path, 'HEAD') + def client_runner(): + for i in range(runs_per_process): + client.run('run', test_repo.path, 'HEAD') + + processes = [Process(target=client_runner) for i in range(numof_processes)] + for proc in processes: + proc.start() + for proc in processes: + proc.join() event.wait() assert numof_runs == test_repo.count_ci_output_files() -def test_repo(server_and_workers, test_repo, client): - _test_repo_internal(server_and_workers, test_repo, client, 1) +def test_repo_1_client_1_run(server_and_workers, test_repo, client): + _test_repo_internal(server_and_workers, test_repo, client, 1, 1) -def test_repo_2(server_and_workers, test_repo, client): - _test_repo_internal(server_and_workers, test_repo, client, 2) +def test_repo_1_client_2_runs(server_and_workers, test_repo, client): + _test_repo_internal(server_and_workers, test_repo, client, 1, 2) -def test_repo_10(server_and_workers, test_repo, client): - _test_repo_internal(server_and_workers, test_repo, client, 10) +def test_repo_1_client_10_runs(server_and_workers, test_repo, client): + _test_repo_internal(server_and_workers, test_repo, client, 1, 10) + + +@pytest.mark.stress +def test_repo_1_client_2000_runs(server_and_workers, test_repo, client): + _test_repo_internal(server_and_workers, test_repo, client, 1, 2000) @pytest.mark.stress -def test_repo_2000(server_and_workers, test_repo, client): - _test_repo_internal(server_and_workers, test_repo, client, 2000) +def test_repo_4_clients_500_runs(server_and_workers, test_repo, client): + _test_repo_internal(server_and_workers, test_repo, client, 4, 500) -- cgit v1.2.3