sashapolo commented on code in PR #795:
URL: https://github.com/apache/ignite-3/pull/795#discussion_r878741994
##########
modules/cluster-management/src/integrationTest/java/org/apache/ignite/internal/cluster/management/raft/ItCmgRaftServiceTest.java:
##########
@@ -240,18 +270,128 @@ void testClusterState() {
assertThat(node1.raftService.readClusterState(),
willCompleteSuccessfully());
assertThat(node2.raftService.readClusterState(),
willCompleteSuccessfully());
- ClusterState state = new ClusterState(List.of("foo"), List.of("bar"));
+ ClusterState state = new ClusterState(
+ List.of("foo"),
+ List.of("bar"),
+ IgniteProductVersion.CURRENT_VERSION,
+ new ClusterTag("cluster")
+ );
assertThat(node1.raftService.writeClusterState(state),
willCompleteSuccessfully());
assertThat(node1.raftService.readClusterState(), willBe(state));
assertThat(node2.raftService.readClusterState(), willBe(state));
- state = new ClusterState(List.of("baz"), List.of("quux"));
+ state = new ClusterState(
+ List.of("baz"),
+ List.of("quux"),
+ IgniteProductVersion.fromString("3.3.3"),
+ new ClusterTag("new cluster")
+ );
assertThat(node2.raftService.writeClusterState(state),
willCompleteSuccessfully());
assertThat(node1.raftService.readClusterState(), willBe(state));
assertThat(node2.raftService.readClusterState(), willBe(state));
}
+
+ /**
+ * Test validation of the Cluster Tag.
+ */
+ @Test
+ void testClusterTagValidation() {
+ Node node1 = cluster.get(0);
+ Node node2 = cluster.get(1);
+
+ ClusterState state = new ClusterState(
+ List.of("foo"),
+ List.of("bar"),
+ IgniteProductVersion.CURRENT_VERSION,
+ new ClusterTag("cluster")
+ );
+
+ assertThat(node1.raftService.writeClusterState(state),
willCompleteSuccessfully());
+
+ // empty tag
+ assertThat(node2.raftService.startJoinCluster(null),
willCompleteSuccessfully());
+
+ // correct tag
+ assertThat(node2.raftService.startJoinCluster(state.clusterTag()),
willCompleteSuccessfully());
+
+ // incorrect tag
+ assertThrowsWithCause(
+ () -> node2.raftService.startJoinCluster(new
ClusterTag("invalid")).get(10, TimeUnit.SECONDS),
+ IgniteInternalException.class,
+ "Join request denied, reason: Cluster tags do not match"
+ );
+ }
+
+ /**
+ * Test validation of Ignite Product Version upon join.
+ */
+ @Test
+ void testIgniteVersionValidation() {
+ CmgRaftService raftService = cluster.get(0).raftService;
+
+ ClusterState state = new ClusterState(
+ List.of("foo"),
+ List.of("bar"),
+ IgniteProductVersion.fromString("1.2.3"),
+ new ClusterTag("cluster")
+ );
+
+ assertThat(raftService.writeClusterState(state),
willCompleteSuccessfully());
+
+ assertThrowsWithCause(
+ () -> raftService.startJoinCluster(null).get(10,
TimeUnit.SECONDS),
+ IgniteInternalException.class,
+ String.format(
+ "Join request denied, reason: Ignite versions do not
match. Version: %s, version stored in CMG: 1.2.3",
+ IgniteProductVersion.CURRENT_VERSION
+ )
+ );
+ }
+
+ /**
+ * Test validation token logic.
+ */
+ @Test
+ void testValidationToken() {
+ CmgRaftService raftService = cluster.get(0).raftService;
+
+ ClusterState state = new ClusterState(
+ List.of("foo"),
+ List.of("bar"),
+ IgniteProductVersion.CURRENT_VERSION,
+ new ClusterTag("cluster")
+ );
+
+ assertThat(raftService.writeClusterState(state),
willCompleteSuccessfully());
+
+ CompletableFuture<UUID> joinFuture =
raftService.startJoinCluster(null);
+
+ assertThat(joinFuture, willCompleteSuccessfully());
+
+ // incorrect token
+ assertThrowsWithCause(
+ () ->
raftService.completeJoinCluster(UUID.randomUUID()).get(10, TimeUnit.SECONDS),
+ IgniteInternalException.class,
+ "JoinReady request denied, reason: Incorrect validation token"
+ );
+
+ UUID token = joinFuture.join();
+
+ // correct token
+ assertThat(raftService.completeJoinCluster(token),
willCompleteSuccessfully());
+
+ // token should be invalidated after a successful join
+ assertThrowsWithCause(
+ () -> raftService.completeJoinCluster(token).get(10,
TimeUnit.SECONDS),
+ IgniteInternalException.class,
+ String.format(
+ "JoinReady request denied, reason: Node \"%s\" has not
yet passed the validation step",
Review Comment:
This comment is no longer valid, because this logic has been rewritten
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]