rpuch commented on code in PR #4361: URL: https://github.com/apache/ignite-3/pull/4361#discussion_r1756220705
########## modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageMaintenanceTest.java: ########## @@ -0,0 +1,182 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.metastorage.impl; + +import static java.util.concurrent.CompletableFuture.allOf; +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.apache.ignite.internal.testframework.IgniteTestUtils.waitForCondition; +import static org.apache.ignite.internal.testframework.matchers.CompletableFutureExceptionMatcher.willTimeoutIn; +import static org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import org.apache.ignite.internal.configuration.testframework.ConfigurationExtension; +import org.apache.ignite.internal.hlc.HybridTimestamp; +import org.apache.ignite.internal.lang.ByteArray; +import org.apache.ignite.internal.lang.NodeStoppingException; +import org.apache.ignite.internal.metastorage.server.time.ClusterTime; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +@ExtendWith(ConfigurationExtension.class) +class ItMetaStorageMaintenanceTest extends ItMetaStorageMultipleNodesAbstractTest { + @Test + void becomeLonelyLeaderMakesNodeLeaderForcefully() throws Exception { + start3VotingNodes(); + + Node node0 = nodes.get(0); + + // Metastorage works. + assertThatMetastorageHasMajority(node0); + + // Stop the majority. + stopAllNodesBut0(); + + // Metastorage does not work anymore. + assertThatMetastorageHasNoMajority(node0); + + assertThat(node0.metaStorageManager.becomeLonelyLeader(true), willCompleteSuccessfully()); + + assertThatMetastorageHasMajority(node0); + } + + private void start3VotingNodes() throws NodeStoppingException { Review Comment: A node can be either a voting node or a learner. Here, it is important that there are more than 1 voting node, hence the explicit mention of 'voting'. This term comes from Raft, same as 'leader', and the test is about Raft-related concern, so it seems reasonable to use Raft terminology. -- 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]
