Replaced most if not all instances of 'nodes' with 'number_of_nodes' #425
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I believe two major issues exist in the current gem:
nodes
argument is being improperly used when loading clusters, rather thannumber_of_nodes
running?
needs to match parameters from what was initialized to return a truthy value.For 1, let's take a quick look at the initialize method:
The initialize method is called when
Cluster.new
is called, which is in turn called in methodsstart
,stop
,running?
,wait_for_green
, among others. So whenever any of these methods get passed arguments, it in turn passes those same arguments to the initialize method. But looking above, we can see that initialize doesn't handle any sort ofarguments[:nodes]
, which I think was a relic of the arguments of previous generations of the gem.For 2, let's take a quick look at the two
running?
methods:So again, this will call the initializer, and then run the other
running?
method:Now lets take the following code
For one, as explained above, this wouldn't start a cluster with 1 node -- since
arguments[:nodes]
is not a thing, it defaults to the user'sTEST_CLUSTER_NODES
ENV variable, or 2.But this actually silently makes this code work -- when no parameters are given to the
running?
method, it will use the default arguments as well, which again is 2 nodes.When we fix this however, by changing it to the right code:
This makes the code fail, because when no parameters are passed to the
running?
method, when it calls theCluster.new
method it will again default without anumber_of_nodes
argument to 2, and then when it does the check in the otherrunning?
method, it will be:cluster_health['number_of_nodes']
will be 1, because we initialized it properly when we started it, butarguments[:number_of_nodes]
will be 2, because we didn't pass in an argument there and so it set it to the default.So in general, anytime we call the
running?
method, we need to make sure we pass it the same arguments we pass thestart
method, or it won't return the correct results I believe.Hope that makes sense, let me know what people's thoughts are.