[TEST] More MetadataStateFormat tests#78577
Conversation
Add test about partial failure on multi-paths.
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
rjernst
left a comment
There was a problem hiding this comment.
The new tests look good to me. @henningandersen do you have any thoughts?
|
The CI failure is #78783, syncing with master should mute it. |
|
@elasticmachine run elasticsearch-ci/part-2 |
henningandersen
left a comment
There was a problem hiding this comment.
Thanks for improving our test coverage, Nikola. I left some smaller comments, otherwise this looks good.
| * @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 { |
There was a problem hiding this comment.
Can we make the visibility of this package private instead?
| } | ||
|
|
||
| private List<Path> findStateFilesByGeneration(final long generation, Path... locations) { | ||
| protected List<Path> findStateFilesByGeneration(final long generation, Path... locations) { |
There was a problem hiding this comment.
Can we make the visibility of this package private instead?
| } | ||
|
|
||
| private void throwDirectoryExceptionCheckPaths(Path dir) throws MockDirectoryWrapper.FakeIOException { | ||
| if (failurePaths != null && failurePaths.length > 0) { |
There was a problem hiding this comment.
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); | ||
| } |
There was a problem hiding this comment.
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))); | ||
| } | ||
| } |
There was a problem hiding this comment.
Can we also verify that format.loadLatestStage(..., paths) return null and that findMaxGenerationId return -1?
server/src/test/java/org/elasticsearch/gateway/MetadataStateFormatTests.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/gateway/MetadataStateFormatTests.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/elasticsearch/gateway/MetadataStateFormatTests.java
Outdated
Show resolved
Hide resolved
| 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)); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
…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
Thanks for reviewing this @henningandersen, great suggestions! I made the changes to address the review comments. |
server/src/test/java/org/elasticsearch/gateway/MetadataStateFormatTests.java
Outdated
Show resolved
Hide resolved
…rmatTests.java Co-authored-by: Henning Andersen <33268011+henningandersen@users.noreply.github.com>
- Add test about partial failure on multi-paths - Add test for deleteMetaState Co-authored-by: Henning Andersen <33268011+henningandersen@users.noreply.github.com>
* 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
* 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
Relates to #78475