-
Notifications
You must be signed in to change notification settings - Fork 8
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
Is it possible to customize the output of WSGI app from within a testcase? #71
Comments
What do you expect? |
Hi Benoit, Thanks for responding, I thought about overwriting the TestResultResponse class, but there might be a better way. By adding that, you can interconnect different hosts running hospital tests for example.
|
There may be some improvements around the context data passed to the {
"status": "fail",
"details": [
{
"test": "test_false (foo.bar)",
"status": "fail",
"context": "(<type 'exceptions.AssertionError'>, AssertionError(\"Failed to fetch URL http://localhost:8000/.\\nException was: HTTPConnectionPool(host='localhost', port=8000): Max retries exceeded with url: / (Caused by <class 'socket.error'>: [Errno 111] Connection refused)\",), <traceback object at 0x7f34ac5bde18>)"
}
],
"summary": {
"skip": 0,
"pass": 0,
"expected_failure": 0,
"error": 0,
"fail": 1,
"total": 1,
"unexpected_success": 0
}
} Note: the traceback in "context" is not really readable, see #72.
... but the fact is I'm not sure how we can easily do this. Using the assertion message? If you had a (nice) way to populate such a |
A second workaround could be related to the execution context running the healthchecks. |
This is a story on its own!
With such an architecture, on the "supervisor" (how would you name it?) you could easily have a result like that: {
"status": "pass",
"details": [
{
"test": "GET http://api.nu.nl/healthchecks returns HTTP 200 OK",
"status": "pass"
},
{
"test": "GET http://192.168.1.44:1515 returns HTTP 200 OK",
"status": "pass"
},
{
"test": "GET http://192.168.1.55 returns HTTP 200 OK",
"status": "pass"
}
],
"summary": {
"skip": 0,
"pass": 3,
"expected_failure": 0,
"error": 0,
"fail": 0,
"total": 3,
"unexpected_success": 0
}
} If we had some Would this fit your use case? That said, I also think the behaviour of such a "supervisor" should be:
I think we should have at least two levels of feedback:
With this idea in mind, I am not sure, at the moment, that a "supervisor" has to be able to concatenate results of every nodes, i.e. display details of each node. Whereas I think it has to be able to summarize results of each node, i.e. display fail/pass status of each node. If you need details about one node, isn't asking the node enough? |
And also, notice that we already can attach a custom message to assertions, but it is not easy to parse in the JSON output (it is a string, not a dictionary). |
@bartee: the comments/questions above are meant to have a better idea about your needs, so that we can focus on what really matters ;) |
Wooah, you've been busy! 👍 Interesting thoughts! After reading all this, I've gotten my hands dirty myself, and solved it for my usecase. First, I modified my testcase a bit, providing details:
After that, I've added two lines to the details-method of the HealthCheckApp- class:
That works like a charm. In that way, the supervisor can use those details.details of a test case to interconnect different hosts. And you don't have to change the signature of existing output (or parse a string into something you can work with :-)) Only downside I can see: I can imagine details.details being a bit of a confusing name. But on the other hand, there might be use cases out there where other kinds of test specs are necessary. I've already built a little supervisor-project myself. It's config based, checks a configured set of hosts for hospital-based output and puts that output into Redis. I yet have to plug it into my hosts-dashboard. Somewhere soon I'll put that little thing on my github. |
About that supervisor: https://github.com/bartee/hospital_supervisor |
See https://twitter.com/bartstroeken/status/467564038025932800
The text was updated successfully, but these errors were encountered: