Skip to content
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

[TEST] More MetadataStateFormat tests #78577

Merged
merged 17 commits into from
Oct 7, 2021

Conversation

grcevski
Copy link
Contributor

@grcevski grcevski commented Oct 1, 2021

  • Add test about partial failure on multi-paths. Having stale metadata is expected and OK with cleanUp set to false
  • Add test for deleteMetaState

Relates to #78475

Add test about partial failure on multi-paths.
@grcevski grcevski marked this pull request as draft October 1, 2021 21:23
@grcevski grcevski added >test Issues or PRs that are addressing/adding tests :Core/Infra/Core Core issues without another label Team:Core/Infra Meta label for core/infra team labels Oct 6, 2021
@grcevski grcevski requested a review from rjernst October 6, 2021 18:45
@grcevski grcevski marked this pull request as ready for review October 6, 2021 18:47
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new tests look good to me. @henningandersen do you have any thoughts?

@rjernst
Copy link
Member

rjernst commented Oct 6, 2021

The CI failure is #78783, syncing with master should mute it.

@grcevski
Copy link
Contributor Author

grcevski commented Oct 6, 2021

@elasticmachine run elasticsearch-ci/part-2

Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving our test coverage, Nikola. I left some smaller comments, otherwise this looks good.

@@ -343,7 +343,7 @@ public void cleanupOldFiles(final long currentGeneration, Path... locations) {
* @return maximum id of state file or -1 if no such files are found
* @throws IOException if IOException occurs
*/
private long findMaxGenerationId(final String prefix, Path... locations) throws IOException {
protected long findMaxGenerationId(final String prefix, Path... locations) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the visibility of this package private instead?

@@ -362,7 +362,7 @@ private long findMaxGenerationId(final String prefix, Path... locations) throws
return maxId;
}

private List<Path> findStateFilesByGeneration(final long generation, Path... locations) {
protected List<Path> findStateFilesByGeneration(final long generation, Path... locations) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the visibility of this package private instead?

public void failRandomly() {
this.failureMode = FailureMode.FAIL_RANDOMLY;
}

private void throwDirectoryExceptionCheckPaths(Path dir) throws MockDirectoryWrapper.FakeIOException {
if (failurePaths != null && failurePaths.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need to be defensive here, I would prefer to have just null signal no paths.

assertEquals(firstPathId, format.findMaxGenerationId("foo-", paths[1]));
assertEquals(genId, format.findMaxGenerationId("foo-", badPath));
assertEquals(genId, firstPathId-1);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can also verify that we can find max genId and read state when supplying all paths (and get the new state out)?

for (Path path : paths) {
assertEquals(false, Files.exists(path.resolve(MetadataStateFormat.STATE_DIR_NAME)));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also verify that format.loadLatestStage(..., paths) return null and that findMaxGenerationId return -1?

corruptFile(stateFiles.get(1), logger);

// Ensure we find the corrupted metadata without the leader first state path
expectThrows(ElasticsearchException.class, () -> format.loadLatestStateWithGeneration(logger, xContentRegistry(), paths));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I follow this. I would think the state file in path 1 should still be available? Maybe add a comment plus verification of main part of exception message to ensure we hit the right exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! I'll clarify this bit. Since I cleaned up the old files, but caused the middle path to fail, there's only one stale state file left that is now corrupted and this is ensuring we detect the corrupted state.

Nikola Grcevski and others added 6 commits October 7, 2021 09:58
…rmatTests.java

Co-authored-by: Henning Andersen <33268011+henningandersen@users.noreply.github.com>
…rmatTests.java

Co-authored-by: Henning Andersen <33268011+henningandersen@users.noreply.github.com>
…sticsearch into tests/metadata_state_format
@grcevski
Copy link
Contributor Author

grcevski commented Oct 7, 2021

Thanks for improving our test coverage, Nikola. I left some smaller comments, otherwise this looks good.

Thanks for reviewing this @henningandersen, great suggestions! I made the changes to address the review comments.

@henningandersen henningandersen self-requested a review October 7, 2021 16:26
Copy link
Contributor

@henningandersen henningandersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

grcevski and others added 2 commits October 7, 2021 12:51
…rmatTests.java

Co-authored-by: Henning Andersen <33268011+henningandersen@users.noreply.github.com>
@grcevski grcevski merged commit 631e066 into elastic:master Oct 7, 2021
grcevski added a commit to grcevski/elasticsearch that referenced this pull request Oct 7, 2021
- Add test about partial failure on multi-paths
- Add test for deleteMetaState

Co-authored-by: Henning Andersen <33268011+henningandersen@users.noreply.github.com>
@grcevski grcevski deleted the tests/metadata_state_format branch October 7, 2021 20:48
grcevski added a commit that referenced this pull request Oct 7, 2021
Backport of: #78577

- Add test about partial failure on multi-paths
- Add test for deleteMetaState

Co-authored-by: Henning Andersen <33268011+henningandersen@users.noreply.github.com>
wjp719 added a commit to wjp719/elasticsearch that referenced this pull request Oct 9, 2021
* master:
  Fix DataTierTests package and add a validation test (elastic#78880)
  Fix split package org.elasticsearch.common.xcontent (elastic#78831)
  Store DataTier Preference directly on IndexMetadata (elastic#78668)
  [DOCS] Fixes typo in calendar API example (elastic#78867)
  Improve Node Shutdown Observability (elastic#78727)
  Convert encrypted snapshot license object to LicensedFeature (elastic#78731)
  Revert "Make nodePaths() singular (elastic#72514)" (elastic#78801)
  Fix incorrect generic type in PolicyStepsRegistry (elastic#78628)
  [DOCS] Fixes ML get calendars API (elastic#78808)
  Implement GET API for System Feature Upgrades (elastic#78642)
  [TEST] More MetadataStateFormat tests (elastic#78577)
  Add support for rest compatibility headers to the HLRC (elastic#78490)
  Un-ignoring tests after backporting fix (elastic#78830)
  Add node REPLACE shutdown implementation (elastic#76247)
  Wrap VersionPropertiesLoader in a BuildService to decouple build logic projects (elastic#78704)
  Adjust /_cat/templates not to request all metadata (elastic#78829)
  [DOCS] Fixes ML get scheduled events API (elastic#78809)
  Enable exit on out of memory error (elastic#71542)

# Conflicts:
#	server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java
weizijun added a commit to weizijun/elasticsearch that referenced this pull request Oct 11, 2021
* upstream/master: (250 commits)
  [Transform] HLRC cleanups (elastic#78909)
  [ML] Make ML indices hidden when the node becomes master (elastic#77416)
  Introduce a Few Settings Singleton Instances (elastic#78897)
  Simplify TestCluster extraJar configuration (elastic#78837)
  Add @OverRide annotations to methods in EnrichPlugin class (elastic#76873)
  Add v7 restCompat for invalidating API key with the id field (elastic#78664)
  EQL: Refine repeatable queries (elastic#78895)
  Fix DataTierTests package and add a validation test (elastic#78880)
  Fix split package org.elasticsearch.common.xcontent (elastic#78831)
  Store DataTier Preference directly on IndexMetadata (elastic#78668)
  [DOCS] Fixes typo in calendar API example (elastic#78867)
  Improve Node Shutdown Observability (elastic#78727)
  Convert encrypted snapshot license object to LicensedFeature (elastic#78731)
  Revert "Make nodePaths() singular (elastic#72514)" (elastic#78801)
  Fix incorrect generic type in PolicyStepsRegistry (elastic#78628)
  [DOCS] Fixes ML get calendars API (elastic#78808)
  Implement GET API for System Feature Upgrades (elastic#78642)
  [TEST] More MetadataStateFormat tests (elastic#78577)
  Add support for rest compatibility headers to the HLRC (elastic#78490)
  Un-ignoring tests after backporting fix (elastic#78830)
  ...

# Conflicts:
#	server/src/main/java/org/elasticsearch/ingest/IngestService.java
#	server/src/test/java/org/elasticsearch/ingest/IngestServiceTests.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label Team:Core/Infra Meta label for core/infra team >test Issues or PRs that are addressing/adding tests v8.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants