Add script that runs tests as a Windows service#239
Add script that runs tests as a Windows service#239edwards-aws merged 3 commits intoOpenJobDescription:mainlinefrom
Conversation
Signed-off-by: Cody Edwards <edwards@amazon.com>
b1fd7a5 to
10e8dc8
Compare
| 1. `win32` doesn't work well in virtual environments, so it's more reliable to run with the system Python. The wheel file name will change depending the date and the version that the git branch is based off of. | ||
| 1. Install the service by running `python scripts\windows_service_test.py install --user-name <UserYouWantRunningTheService> --pytest-args="<AnyAdditionalPytestArgsYou'dWantToPassIn>"` | ||
| 1. Run the test in the service by running `python scripts\windows_service_test.py run` | ||
| 1. You'll find the test output in the root project directory under `test.log`, the tests will live right to the log file. |
There was a problem hiding this comment.
will live right to the log file.
right next? Might make a bit more sense to also swap it around. The user can specify the location of the tests, and the log file is created beside the tests that are run (not the other way around)
There was a problem hiding this comment.
I did bad grammar here. I'll fix
Signed-off-by: Cody Edwards <edwards@amazon.com>
69c2dec to
570952a
Compare
jusiskin
left a comment
There was a problem hiding this comment.
Looks good. Just a few non-critical suggested improvements but not merge-blocking.
| 2. Use the `scripts\windows_service_test.py` to test in the context of a service running session 0 | ||
| 1. `hatch build` | ||
| 1. `pip install --force-reinstall dist\openjd_sessions*.whl` | ||
| 1. `win32` doesn't work well in virtual environments, so it's more reliable to run with the system Python. The wheel file name will change depending the date and the version that the git branch is based off of. |
| 1. Install the service by running `python scripts\windows_service_test.py install --user-name <UserYouWantRunningTheService> --pytest-args="<AnyAdditionalPytestArgsYou'dWantToPassIn>"` | ||
| 1. Run the test in the service by running `python scripts\windows_service_test.py run` | ||
| 1. You'll find the test output in the root project directory under `test.log`, the tests will live right to the log file. |
There was a problem hiding this comment.
I wonder if we could combine these three steps into a single hatch command so you just run:
hatch run test-service --user-name <UserYouWantRunningTheService> --pytest-args="<AnyAdditionalPytestArgsYou'dWantToPassIn>"not strictly required, but just a nice convenience if it is not too much effort. Bonus points for cleaning up the log file after.
There was a problem hiding this comment.
I had considered that. I wanted to keep it as two different steps because it'd be annoying to have to input the password every time you run the tests. I don't think we want to clean up the log file after? Because you want to be able to see the test output after the run as well. The log file does get overwritten in every run.
There was a problem hiding this comment.
... it'd be annoying to have to input the password every time you run the tests
This is a good point.
I don't think we want to clean up the log file after? Because you want to be able to see the test output after the run as well.
My thinking was the caller could redirect to a file if they needed it kept around like you would normally when running pytest
Signed-off-by: Cody Edwards <edwards@amazon.com>
|



What was the problem/requirement? (What/Why)
We're missing any easy way to run the tests as a Windows service. This is important because Windows has some different behaviour in session 0
What was the solution? (How)
Add a script that installs the tests as a service, then runs them.
What is the impact of this change?
Contributors can now run tests easily in session 0 directly as a service.
How was this change tested?
Ran the tests with the script
Was this change documented?
Ya
Is this a breaking change?
Nope
Does this change impact security?
Nope
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.