-
Notifications
You must be signed in to change notification settings - Fork 20
Conversation
8792e49
to
24808db
Compare
import sys | ||
|
||
# due to locust sys.path manipulation, we need to re-add the project root. | ||
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you show me the relevant sys.path manipulation? Can we make a change to the project structure to avoid the need for this in every single locustfile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the offending lines are around https://github.com/locustio/locust/blob/master/locust/main.py#L293
I have to run so I can't elaborate further, but I remember stepping through and noticing that the project root was not in sys.path at the time of loading the locustfile module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pwnage101 when you get back: how were you running locust? From the project root?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the root. I'm beginning to remember what the exact sequence of events are:
- user provides
-f loadtests/lms
on the command line - locust splits the locustfile path into "loadtests" and "lms"
- locust adds "loadtests" to the sys.path
- locust calls
__import__("lms")
, triggering our helper imports
That method of importing the locustfile precludes the possibility of referencing anything above the loadtests directory without adding it manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. So it was working before because edx-load-tests
(the project root) was being added to sys.path. Putting the tests in a loadtests
directory causes edx-load-tests/loadtests
to be added to sys.path instead, so you need to manually add edx-load-tests
back to be able to use the helper imports.
I wonder why Locust imports the locustfile that way. If this line were to instead call __import__('loadtests.course_discovery')
, this sys.path hacking wouldn't be necessary.
@pwnage101 done with my pass. I've left comments inline. Not to belabor the point, but note how much cleaner the Invoke implementation is. |
@pwnage101 your original Makefile PR included a target that could be used to run tests. I don't see a corresponding task here. Is that intentional? |
Ah, I meant to write a comment about that. It didn't make sense to me to abstract locust invokation because we already use a large subset of its features in the way described by locust --help. However, it does occur to me that knowing to use
|
@pwnage101 yes, seems reasonable. |
24808db
to
7274e93
Compare
This is still WIP, but pushing up my progress so @cpennington and @jzoldak can have some visibility. |
@pwnage101 I do think it would be easier to review if as you suggested you split off "reorg the repo" and "implement paver" into 2 separate PRs. |
splitting. |
I realize this is two different things; if necessary I can split into two different PRs.
Reorganize tests: all the tests are now located beneath the
loadtests
directory, and the canonical locust invocation changed to:So this would be a breaking change since
-f lms
wouldn't work anymore.Implement paver: refer to the updated README.rst for detailed usage, but here's some output:
The primary motivation for doing this is so we can better insulate the locust ansible role from repository semantics.