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

unit tests: add extra validations in integration tests #1990

Merged
merged 1 commit into from
Jan 28, 2022
Merged
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
12 changes: 11 additions & 1 deletion locust/test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_locustfile_can_be_set_in_config_file(self):
self.assertEqual("my_locust_file.py", options.locustfile)


class LocustProcessIntegrationTest(TestCase):
class ProcessIntegrationTest(TestCase):
def setUp(self):
super().setUp()
self.timeout = gevent.Timeout(10)
Expand All @@ -178,6 +178,8 @@ def test_help_arg(self):
self.assertIn("Logging options:", output)
self.assertIn("--skip-log-setup Disable Locust's logging setup.", output)


class StandaloneIntegrationTests(ProcessIntegrationTest):
def test_custom_arguments(self):
port = get_free_tcp_port()
with temporary_file(
Expand Down Expand Up @@ -726,6 +728,8 @@ def test_html_report_option(self):

self.assertNotIn("Download the Report", html_report_content, "Download report link found in HTML content")


class DistributedIntegrationTests(ProcessIntegrationTest):
def test_expect_workers(self):
with mock_locustfile() as mocked:
proc = subprocess.Popen(
Expand All @@ -747,6 +751,7 @@ def test_expect_workers(self):
stderr = stderr.decode("utf-8")
self.assertIn("Waiting for workers to be ready, 0 of 2 connected", stderr)
self.assertIn("Gave up waiting for workers to connect", stderr)
self.assertNotIn("Traceback", stderr)
self.assertEqual(1, proc.returncode)

def test_distributed_events(self):
Expand Down Expand Up @@ -812,6 +817,8 @@ def on_test_stop(environment, **kwargs):
self.assertIn("test_stop on master", stdout)
self.assertIn("test_stop on worker", stdout_worker)
self.assertIn("test_start on worker", stdout_worker)
self.assertNotIn("Traceback", stderr)
self.assertNotIn("Traceback", stderr_worker)
self.assertEqual(0, proc.returncode)
self.assertEqual(0, proc_worker.returncode)

Expand Down Expand Up @@ -875,7 +882,10 @@ def task2(self):
stdout = stdout.decode("utf-8")
stdout_worker, stderr_worker = proc_worker.communicate()
stdout_worker = stdout_worker.decode("utf-8")
stderr_worker = stderr_worker.decode("utf-8")
self.assertIn("task1", stdout_worker)
self.assertNotIn("task2", stdout_worker)
self.assertNotIn("Traceback", stderr)
self.assertNotIn("Traceback", stderr_worker)
self.assertEqual(0, proc.returncode)
self.assertEqual(0, proc_worker.returncode)