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

Add more aspects to ReservedStateVersion test #110469

Merged
merged 7 commits into from
Jul 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Extend tests to actually calling a task
  • Loading branch information
thecoop committed Jul 4, 2024
commit 43f3cb291c897d2634264a7251e94a4fec268c4d
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.sameInstance;
import static org.hamcrest.Matchers.startsWith;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
Expand Down Expand Up @@ -426,6 +428,40 @@ public void testCheckMetadataVersion() {
assertFalse(
checkMetadataVersion("operator", operatorMetadata, new ReservedStateVersion(124L, Version.fromId(Version.CURRENT.id + 1)))
);

ClusterState state = ClusterState.builder(new ClusterName("test")).metadata(Metadata.builder().put(operatorMetadata)).build();
thecoop marked this conversation as resolved.
Show resolved Hide resolved
ReservedStateUpdateTask task = new ReservedStateUpdateTask(
"test",
new ReservedStateChunk(Map.of(), new ReservedStateVersion(124L, Version.CURRENT)),
List.of(),
Map.of(),
List.of(),
e -> {},
ActionListener.noop()
);
assertThat(task.execute(state), not(sameInstance(state)));

task = new ReservedStateUpdateTask(
"test",
new ReservedStateChunk(Map.of(), new ReservedStateVersion(123L, Version.CURRENT)),
List.of(),
Map.of(),
List.of(),
e -> {},
ActionListener.noop()
);
assertThat(task.execute(state), sameInstance(state));

task = new ReservedStateUpdateTask(
"test",
new ReservedStateChunk(Map.of(), new ReservedStateVersion(124L, Version.fromId(Version.CURRENT.id + 1))),
List.of(),
Map.of(),
List.of(),
e -> {},
ActionListener.noop()
);
assertThat(task.execute(state), sameInstance(state));
}

private ReservedClusterStateHandler<Map<String, Object>> makeHandlerHelper(String name, List<String> deps) {
Expand Down