-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Replace InMemoryPersistedState with GatewayMetaState in CoordinatorTests #36897
Replace InMemoryPersistedState with GatewayMetaState in CoordinatorTests #36897
Conversation
Pinging @elastic/es-distributed |
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.
Looks good. I suggested a renaming and a nit. I'm going to run this for a few iterations on my CI machine to be sure before we merge it.
* Metadata upgrade is tested in {@link GatewayMetaStateTests} and different {@link ClusterStateUpdaters} in | ||
* {@link ClusterStateUpdatersTests}. | ||
*/ | ||
public class GatewayMetaStateUT extends GatewayMetaState { |
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.
Maybe MockGatewayMetaState
would be a better name?
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.
|
||
public GatewayMetaStateUT(Settings settings, NodeEnvironment nodeEnvironment, | ||
NamedXContentRegistry xContentRegistry, | ||
DiscoveryNode localNode) throws IOException { |
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.
nit: funny indentation.
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.
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.
Hmm, this change substantially adds to the time it takes to run these tests. I guess this is to be expected since we're hitting the disk and fsyncing and so on. I ran Gradle with these options:
:server:test -Dtests.class=org.elasticsearch.cluster.coordination.CoordinatorTests -Dtests.jvm.argline=-Dhppc.bitmixer=DETERMINISTIC -Dtests.iters=20 -Dtests.failfast=true
On master
, the second time through this took 514 sec. On this branch, it took 891 sec, 73% longer. Maybe we should only use a proper persistence layer rarely?
+1 on using it rarely |
@DaveCTurner I've addressed your comments and changed |
run gradle build tests 1 |
run gradle build tests 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.
Just a couple more nits.
try { | ||
persistedState = new MockPersistedState(settings, localNode); | ||
} catch (IOException e) { | ||
fail("Unable to create MockPersistedState"); |
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.
I think we would like to see the caught exception here:
fail("Unable to create MockPersistedState"); | |
throw new AssertionError("Unable to create MockPersistedState", e); |
|
||
MockPersistedState(Settings settings, DiscoveryNode localNode) throws IOException { | ||
if (rarely()) { | ||
NodeEnvironment nodeEnvironment = newNodeEnvironment(); |
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.
Nit: too much indent here?
CoordinatorTests now support restarts when GatewayMetaState is used
@DaveCTurner Can you please make the next pass? I've fixed nits and last merge with master introduced node restart in CoordinatorTests (40b303c), so now |
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, thanks @andrershov. Could you add a version label before merging?
test this please |
Conflicts in CoordinatorTests.java
run gradle build tests 2 |
1 similar comment
run gradle build tests 2 |
This PR replaces
InMemoryPersistedState
withGatewayMetaState
inCoordinatorTests
.When performing such a replacement the main question was: do we want to
emulate exceptions as we do today in
MockPersistedState
beforedelegating to
GatewayMetaState
or do we want these exceptions topropagate from the lower level, i.e. file system exceptions?
On the one hand, lower level exception propagation is already tested in
GatewayMetaStateTests
, so this won't improve the coverage.On the other hand, the benefit of low-level exceptions is to see how all these
components work in conjunction. Finally, we abandoned the idea of low-level
exceptions because we don't have a way to deal with
IOError
today inCoordinatorTests
, but hackingGatewayMetaState
not to throwIOError
seems unnatural.So
MockPersistedState
rarely throws an exception before delegating toGatewayMetaState
, which is not supposed to throw the exception.This commit required two changes:
GatewayMetaStateUT
to upper-level fromGatewayMetaStatePersistedStateTests
, because otherwise it's not easyto construct
GatewayMetaState
instance inCoordinatorTests
.STATE_NOT_RECOVERED_BLOCK
fromGatewayMetaState
constructor to
GatewayMetaState.applyClusterUpdaters
, becauseCoordinatorTests
class assume that there is no such block and most ofthem fail.
Other classes can be migrated from
InMemoryPersistedState
toGatewayMetaState
as well if requested by reviewers.