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

pbench-results-push: Backport of #3348 and #3378 to b0.72 #3377

Conversation

ndokos
Copy link
Member

@ndokos ndokos commented Apr 11, 2023

Cherry-pick the two commits from the above PRs into b0.72.
No changes were necessary and no conflicts arose.

  • 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).

  • Parametrize the "normal" test

Add the connection error test to the parametrized set and eliminate some (now) redundant tests.

@ndokos ndokos self-assigned this Apr 11, 2023
dbutenhof
dbutenhof previously approved these changes Apr 11, 2023
Copy link
Member

@webbnh webbnh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some concerns. I don't know whether these issues were present in the main PR, but perhaps I just missed them. (I do remember commenting on the obsolete comment lines....)

Looking at test_results_push.py, I believe that there are now two redundant tests which should be removed (there might be others that I didn't catch...), and I think the default response status code is broken (which leaves me wondering why the tests are passing), which brought to light the fact that a few of the tests shouldn't be setting up responses at all.

If these issues are present in main, they should probably be fixed there, first, and then this PR should be updated. However, if this PR is just bringing b0.72 up to the currently questionable state of main, then I suppose it's OK.

So, I'm neither approving nor blocking this merge...I'll leave it up to you.

lib/pbench/test/unit/agent/task/test_copy_result_tb.py Outdated Show resolved Hide resolved
lib/pbench/test/unit/agent/task/test_results_push.py Outdated Show resolved Hide resolved
lib/pbench/test/unit/agent/task/test_results_push.py Outdated Show resolved Hide resolved
lib/pbench/test/unit/agent/task/test_results_push.py Outdated Show resolved Hide resolved
@ndokos ndokos marked this pull request as draft April 12, 2023 04:37
@ndokos ndokos force-pushed the pbench-results-push-backport-0.72 branch from 6a05d61 to daa6e63 Compare April 12, 2023 20:17
@ndokos ndokos marked this pull request as ready for review April 12, 2023 20:19
@ndokos ndokos changed the title pbench-results-push: Backport of #3348 to b0.72 pbench-results-push: Backport of #3348 and #3378 to b0.72 Apr 12, 2023
webbnh
webbnh previously approved these changes Apr 12, 2023
Copy link
Member

@webbnh webbnh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I do have one awkward question.

lib/pbench/test/unit/agent/task/test_results_push.py Outdated Show resolved Hide resolved
ndokos added 2 commits April 12, 2023 22:29
…istributed-system-analysis#3378 to b0.72

Cherry-pick the two commits from the above PRs into b0.72.
No changes were necessary and no conflicts arose.

* 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).

* Parametrize the "normal" test in test_push_results.py

Add the connection error test to the parametrized set and
eliminate some (now) redundant tests.
test_multiple_meta_args() should not have been deleted.
@ndokos ndokos force-pushed the pbench-results-push-backport-0.72 branch from f43e073 to 2d44db7 Compare April 13, 2023 02:33
@ndokos ndokos requested a review from webbnh April 13, 2023 15:33
Copy link
Member

@webbnh webbnh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ndokos ndokos merged commit 9053af1 into distributed-system-analysis:b0.72 Apr 13, 2023
@ndokos ndokos deleted the pbench-results-push-backport-0.72 branch April 13, 2023 17:56
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 this pull request may close these issues.

3 participants