-
Notifications
You must be signed in to change notification settings - Fork 72
tests/ccmcluster.py: make parse_cluster_status ignore lines that does not match #605
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
Conversation
ee206b2 to
902a029
Compare
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.
could improve the title a little bit:
tests/ccmcluster.py: ignore empty lines in parse_cluster_status()
EDIT: s/ccmlib/tests/.
| for line in stdout.split("\n")[2:]: | ||
| node, status = line.split(":") | ||
| chunks = line.split(":") | ||
| if len(chunks) != 2: |
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.
presumably it was an empty line which broke the test. an alternative is:
if not line:
# ignore empty lines
continue
node, status = line.split(":", 1)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.
presumably it was an empty line which broke the test. an alternative is:
tbh, I have no idea which line broke it, but it is better to make it as resiliant as possible.
if not line: # ignore empty lines continue node, status = line.split(":", 1)
This code will still fail if line does not contain ':'.
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, by looking at the error message, i think the offending line was empty.
as resiliant as possible.
i disagree. we program with a contract. "as resilient as possible" without a contract is error-prune, because we don't have a standard or contract for "as resilient as possible".
anyway, this is not that important in this context.
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.
just two nits. lgtm.
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.
LGTM
also it's tests/ccmcluster.py, which is kind of important context |
not match
It could fail with following error:
```
def parse_cluster_status(self, stdout):
"""
Output:
Cluster: 'CCMCluster-reloc'
---------------------------
node1: UP
return:
[(node1, UP)]
"""
nodes_status = []
for line in stdout.split("\n")[2:]:
> node, status = line.split(":")
E ValueError: not enough values to unpack (expected 2, got 1)
```
902a029 to
b849bb2
Compare
Updated. |
It could fail with following error: