Skip to content

Commit

Permalink
quotes yo
Browse files Browse the repository at this point in the history
  • Loading branch information
mquinnfd committed Jul 21, 2024
1 parent a87f0e3 commit f6400f0
Showing 1 changed file with 61 additions and 62 deletions.
123 changes: 61 additions & 62 deletions locust/test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1850,68 +1850,67 @@ def t(self):
self.assertEqual(0, proc_worker.returncode)
self.assertIn("hello", worker_stdout)

# def test_distributed_with_locustfile_distribution_not_plain_filename(self):
# import shlex
# LOCUSTFILE_CONTENT = textwrap.dedent(
# """
# from locust import User, task, constant

# class User1(User):
# wait_time = constant(1)

# @task
# def t(self):
# pass
# """
# )
# with mock_locustfile(content=LOCUSTFILE_CONTENT) as mocked:
# with mock_locustfile() as mocked2:
# proc = subprocess.Popen(
# shlex.split(" ".join([
# "locust",
# "-f",
# f"{mocked.file_path},{mocked2.file_path}",
# "--headless",
# "--master",
# "-L",
# "debug",
# ])),
# stderr=STDOUT,
# stdout=PIPE,
# text=True,
# shell=True,
# )
# proc_worker = subprocess.Popen(
# " ".join([
# "locust",
# "-f",
# "-",
# "--masterhost",
# "localhost",
# "--worker",
# ]),
# stderr=STDOUT,
# stdout=PIPE,
# text=True,
# shell=True,
# )

# try:
# stdout = proc_worker.communicate(timeout=5)[0]
# self.assertIn(
# "Got error from master: locustfile must be a full path to a single locustfile for file distribution to work",
# stdout,
# )
# proc.kill()
# master_stdout = proc.communicate()[0]
# self.assertIn(
# "--locustfile must be a full path to a single locustfile for file distribution", master_stdout
# )
# except Exception:
# proc.kill()
# proc_worker.kill()
# stdout, worker_stderr = proc_worker.communicate()
# assert False, f"worker never finished: {stdout}"
def test_distributed_with_locustfile_distribution_not_plain_filename(self):
LOCUSTFILE_CONTENT = textwrap.dedent(
"""
from locust import User, task, constant
class User1(User):
wait_time = constant(1)
@task
def t(self):
pass
"""
)
with mock_locustfile(content=LOCUSTFILE_CONTENT) as mocked:
with mock_locustfile() as mocked2:
proc = subprocess.Popen(
" ".join([
"locust",
"-f",
f"'{mocked.file_path}, {mocked2.file_path}'",
"--headless",
"--master",
"-L",
"debug",
]),
stderr=STDOUT,
stdout=PIPE,
text=True,
shell=True,
)
proc_worker = subprocess.Popen(
" ".join([
"locust",
"-f",
"-",
"--masterhost",
"localhost",
"--worker",
]),
stderr=STDOUT,
stdout=PIPE,
text=True,
shell=True,
)

try:
stdout = proc_worker.communicate(timeout=5)[0]
self.assertIn(
"Got error from master: locustfile must be a full path to a single locustfile for file distribution to work",
stdout,
)
proc.kill()
master_stdout = proc.communicate()[0]
self.assertIn(
"--locustfile must be a full path to a single locustfile for file distribution", master_stdout
)
except Exception:
proc.kill()
proc_worker.kill()
stdout, worker_stderr = proc_worker.communicate()
assert False, f"worker never finished: {stdout}"

def test_json_schema(self):
LOCUSTFILE_CONTENT = textwrap.dedent(
Expand Down

0 comments on commit f6400f0

Please sign in to comment.