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

Gh actions: Run tests on MacOS #2580

Merged
merged 6 commits into from
Feb 5, 2024
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 .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
matrix:
include:
- {name: Windows, python: '3.12', os: windows-latest, tox: fail_fast_test_main}
#- {name: Mac, python: '3.9', os: macos-latest, tox: py39}
- {name: Mac, python: '3.12', os: macos-latest, tox: fail_fast_test_main}
- { name: "ruff", python: "3.11", os: ubuntu-latest, tox: "ruff" }
- { name: "mypy", python: "3.10", os: ubuntu-latest, tox: "mypy" }
# run some integration tests and abort immediately if they fail, for faster feedback
Expand Down
21 changes: 14 additions & 7 deletions locust/test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ def tick(self):
self.assertIn('<body class="spawning">', response.text)
self.assertTrue(success, "got timeout and had to kill the process")

def test_autostart_mutliple_locustfiles_with_shape(self):
def test_autostart_multiple_locustfiles_with_shape(self):
port = get_free_tcp_port()
content = textwrap.dedent(
"""
Expand Down Expand Up @@ -806,9 +806,12 @@ def my_task(self):
text=True,
)
gevent.sleep(1.9)
response = requests.get(f"http://localhost:{port}/")
success = True
try:
response = requests.get(f"http://localhost:{port}/")
except ConnectionError:
succcess = False
try:
success = True
_, stderr = proc.communicate(timeout=5)
except subprocess.TimeoutExpired:
success = False
Expand Down Expand Up @@ -1932,7 +1935,7 @@ def test_processes_ctrl_c(self):
def test_workers_shut_down_if_master_is_gone(self):
content = """
from locust import HttpUser, task, constant, runners
runners.MASTER_HEARTBEAT_TIMEOUT = 3
runners.MASTER_HEARTBEAT_TIMEOUT = 2

class AnyUser(HttpUser):
host = "http://127.0.0.1:8089"
Expand Down Expand Up @@ -1970,14 +1973,15 @@ def my_task(self):
stdout=PIPE,
stderr=PIPE,
text=True,
start_new_session=True,
)
gevent.sleep(1)
master_proc.kill()
master_proc.wait()
try:
_, worker_stderr = worker_parent_proc.communicate(timeout=7)
except Exception:
worker_parent_proc.kill()
os.killpg(worker_parent_proc.pid, signal.SIGTERM)
_, worker_stderr = worker_parent_proc.communicate()
assert False, f"worker never finished: {worker_stderr}"

Expand Down Expand Up @@ -2011,16 +2015,19 @@ def test_processes_error_doesnt_blow_up_completely(self):
@unittest.skipIf(os.name == "nt", reason="--processes doesnt work on windows")
def test_processes_workers_quit_unexpected(self):
content = """
from locust import runners, events, User
from locust import runners, events, User, task
import sys
runners.HEARTBEAT_INTERVAL = 0.1

@events.test_start.add_listener
def on_test_start(environment, **_kwargs):
if isinstance(environment.runner, runners.WorkerRunner):
sys.exit(42)

class AnyUser(User):
pass
@task
def mytask(self):
pass
"""
with mock_locustfile(content=content) as mocked:
worker_proc = subprocess.Popen(
Expand Down
Loading