-
Notifications
You must be signed in to change notification settings - Fork 36.7k
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
qa: Check return code when stopping nodes #9824
Conversation
Yes, makes sense to check that. utACK fac3af7 (also for 0.14) |
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.
Hey
@shyii I'm not sure what you're trying to do, but please don't abuse the code review system for sending idle messages. |
Concept ACK. We should definitely assert the return code on shutdown. This causes at least the following two tests to fail:
fundrawtransaction is failing because it's calling stop_nodes() on a subset of the running nodes: self.nodes[1].encryptwallet("test")
self.nodes.pop(1)
stop_nodes(self.nodes) The It can be fixed by just calling The failure in rpcbind_test.py is due to this: try:
# connect to node through non-loopback interface
node = get_rpc_proxy(rpc_url(0, "%s:%d" % (rpchost, rpcport)), 0)
node.getnetworkinfo()
finally:
node = None # make sure connection will be garbage collected and closed
stop_nodes(self.nodes) I don't think we need to wrap those calls in try/finallys since the I've pushed fixes for both of those failures to jnewbery@cbebbcf. Feel free to squash into your commit if you're happy with the changes. Generally, tracking And one question on code style: I know that assert_equal() is used all over the qa test directory. Why? Why is Why is In generally, |
I think the idea on the longer run is to move away from using bare assert everywhere and to something that resembles a real testing framework (maybe |
Thanks for the fixups, I will include them in this pull. I will also
adjust the code style of the second assertion.
In regard to your question:
assert_equal(a, b) is the lazy way to assert equality but still have a
somewhat useful assert message which includes both values that are
unequal.
assert as a statement should only be used with a single variable of
type boolean as expression or with an additional string that provides
further debug infos (such as the ones you mentioned above). I assume
no one uses the hand crafted strings because assertions are expected
to fire off basically never and the additional effort required to put
into crafting the string is not considered worthy. (In the rare case a
assertion fires, a developer is usually required to jump into the code
at that location anyway...)
…On Wed, Feb 22, 2017 at 8:49 PM, John Newbery ***@***.***> wrote:
Concept ACK. We should definitely assert the return code on shutdown.
This causes at least the following two tests to fail:
fundrawtransaction.py
rpcbind_test.py
fundrawtransaction is failing because it's calling stop_nodes() on a subset
of the running nodes:
self.nodes[1].encryptwallet("test")
self.nodes.pop(1)
stop_nodes(self.nodes)
The encryptwallet() RPC actually stops bitcoind. That means that node 1 is
still in the util module's global bitcoind_processes dictionary, so a call
to stop_nodes() hits your assert.
It can be fixed by just calling stop_node() for each of the nodes
individually.
The failure in rpcbind_test.py is due to this:
try:
# connect to node through non-loopback interface
node = get_rpc_proxy(rpc_url(0, "%s:%d" % (rpchost, rpcport)),
0)
node.getnetworkinfo()
finally:
node = None # make sure connection will be garbage collected and
closed
stop_nodes(self.nodes)
I don't think we need to wrap those calls in try/finallys since the
BitcoinTestFramework.main() method takes care of cleaning up the nodes for
us.
I've pushed fixes for both of those failures to ***@***.*** Feel free
to squash into your commit if you're happy with the changes.
Generally, tracking bitcoin_processes as a global dictionary in util.py
smells (any global variables in util.py smells). The nodes should be members
of TestFramework, and it should be the test framework's responsibility to
clean them up (and assert return codes) at the end of the test run.
And one question on code style: I know that assert_equal() is used all over
the qa test directory. Why? Why is
assert_equal(ret, 0)
preferred over
assert ret == 0, "unexpected return code %s" % ret?
Why is
assert_equal(len(bitcoind_processes.values()), 0)
preferred over
assert not bitcoind_processes, "bitcoind processes still running: %s" %
str(bitcoind_processes)?
In generally, assert seems to be treated as a function throughout the qa
directory instead of a statement. It would be nice if we could change that.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@laanwj @MarcoFalke thanks. Makes sense.
Sounds sensible. We're quite a long way off that though!
|
This includes work by jnewbery
fac3af7
to
fa4cd2e
Compare
fa4cd2e qa: Check return code when stopping nodes (MarcoFalke)
fa4cd2e qa: Check return code when stopping nodes (MarcoFalke)
fa4cd2e qa: Check return code when stopping nodes (MarcoFalke)
fa4cd2e qa: Check return code when stopping nodes (MarcoFalke)
We had a segfault slip through recently (#9817) because the test framework just ignores the return code.