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

Testing fixes for test_results_push.py #3374

Closed
ndokos opened this issue Apr 10, 2023 · 1 comment · Fixed by #3378
Closed

Testing fixes for test_results_push.py #3374

ndokos opened this issue Apr 10, 2023 · 1 comment · Fixed by #3378
Assignees

Comments

@ndokos
Copy link
Member

ndokos commented Apr 10, 2023

There are some existing issues and some arising from PR #3348 that should be addressed in the pbench-results-push tests (see test_resuls_push.py):

  • Some tests (e.g. the tests that test exceptions) can be subsumed under the parametrization of add_http_mock_response with suitable changes so that the latter can accept an exception as well as a string for the message). That will eliminate add_connectionerr_mock_response and the individual tests that use it.

  • It might be better to specify the numeric value (400) rather than a symbolic name that happens to have the same value when deciding how to format the error message.

  • See also this suggestion for modifying the parametrization of the tests.

@ndokos ndokos self-assigned this Apr 10, 2023
ndokos added a commit that referenced this issue Apr 10, 2023
* Do not use the file logger at all in python commands.

The logger only uses the default Streamhandler now which outputs to stderr.

* - copy_result_tb: return the response to the PUT request

copy_result_tb returns the response from the server. The callers
are responsible for interpreting it. However, it can still raise an
exception (e.g. on connection error).

- push.py: construct a reasonable message out of the response and check
if the HTTP status is 201: we exit with 0 if so.

Otherwise, if the status is OK (i.e. < 400), then we exit with 0 but
print a message with a reasonably self-explanatory status on
stderr. We expect that we will only ever get two OK responses: a 201
which indicates a successful PUT with a newly created dataset and 200
which indicates a duplicate dataset.

In all non-OK cases, we output the message on stderr and exit with 1.

- move.py: check the response - if not OK (>= 400) raise exception.


* Fix the monkeypatching in test_copy_result_tb.py

Monkeypatching pathlib components (.exists() and .open()) causes
pytest to blow up. Limit the scope by using `monkeypatch.context()'
so that it is only applied to the objects under test (and not e.g.
to what is used in checking assertions).

* Use symbolic constant instead of explicit 201

* Parametrize the "normal" test

This is just the first step - see issue #3374 for some more work along these lines.
ndokos added a commit to ndokos/pbench that referenced this issue Apr 11, 2023
…b0.72

* Do not use the file logger at all in python commands.

The logger only uses the default Streamhandler now which outputs to stderr.

* - copy_result_tb: return the response to the PUT request

copy_result_tb returns the response from the server. The callers
are responsible for interpreting it. However, it can still raise an
exception (e.g. on connection error).

- push.py: construct a reasonable message out of the response and check
if the HTTP status is 201: we exit with 0 if so.

Otherwise, if the status is OK (i.e. < 400), then we exit with 0 but
print a message with a reasonably self-explanatory status on
stderr. We expect that we will only ever get two OK responses: a 201
which indicates a successful PUT with a newly created dataset and 200
which indicates a duplicate dataset.

In all non-OK cases, we output the message on stderr and exit with 1.

- move.py: check the response - if not OK (>= 400) raise exception.

* Fix the monkeypatching in test_copy_result_tb.py

Monkeypatching pathlib components (.exists() and .open()) causes
pytest to blow up. Limit the scope by using `monkeypatch.context()'
so that it is only applied to the objects under test (and not e.g.
to what is used in checking assertions).

* Use symbolic constant instead of explicit 201

* Parametrize the "normal" test

This is just the first step - see issue distributed-system-analysis#3374 for some more work along these lines.
@ndokos
Copy link
Member Author

ndokos commented Apr 11, 2023

ndokos added a commit to ndokos/pbench that referenced this issue Apr 12, 2023
Fixes distributed-system-analysis#3374

This is a continuation of distributed-system-analysis#3348, implementing fixes to the
pbench_results_push tests. The main one is to subsume some exception
tests under the parametrized "normal" case and eliminate redundant
tests.
ndokos added a commit that referenced this issue Apr 12, 2023
* Fix various problems in the pbench_results_push tests

Fixes #3374

This is a continuation of #3348, implementing fixes to the
pbench_results_push tests. The main one is to subsume some exception
tests under the parametrized "normal" case and eliminate redundant
tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant