DenisPolo commented on code in PR #355: URL: https://github.com/apache/ignite-extensions/pull/355#discussion_r3788429171
########## modules/auto-activation-ext/src/test/java/opt/apache/ignite/activation/AutoActivationTest.java: ########## @@ -0,0 +1,735 @@ +/* + * 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 opt.apache.ignite.activation; + +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import org.apache.ignite.IgniteException; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cluster.ClusterState; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.DataRegionConfiguration; +import org.apache.ignite.configuration.DataStorageConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.WALMode; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.plugin.PluginProvider; +import org.apache.ignite.testframework.ListeningTestLogger; +import org.apache.ignite.testframework.LogListener; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import static org.apache.ignite.cluster.ClusterState.ACTIVE; +import static org.apache.ignite.cluster.ClusterState.ACTIVE_READ_ONLY; +import static org.apache.ignite.cluster.ClusterState.INACTIVE; +import static org.apache.ignite.testframework.GridTestUtils.assertThrows; + +/** + * {@link AutoActivationPluginProvider} test + */ +public class AutoActivationTest extends GridCommonAbstractTest { + /** Listening test logger. */ + private final ListeningTestLogger listeningLog = new ListeningTestLogger(log); + + /** */ + private final LogListener lsnrAlreadyAct = LogListener + .matches("Auto activation skipped - cluster already activated").build(); + + /** */ + private final LogListener lsnrBaseline = LogListener + .matches("Auto activation skipped - baseline is not empty").build(); + + /** */ + private final LogListener lsnrActMeet = LogListener + .matches("Auto activation plugin set cluster state ACTIVE - activation condition meet").build(); + + /** */ + private final LogListener lsnrActNotMeet = LogListener + .matches("Auto activation skipped - activation condition not meet").build(); + + /** */ + private final String NODE_0 = "node_0"; + + /** */ + private final String NODE_1 = "node_1"; + + /** */ + private final String NODE_2 = "node_2"; + + /** */ + private final String NODE_3 = "node_3"; + + /** */ + private final String ATTR = "CELL"; + + /** */ + private final String ATTR_VAL1 = "CELL_01"; + + /** */ + private final String ATTR_VAL2 = "CELL_02"; + + /** */ + private final Set<String> nodesConsistentIds = Set.of(NODE_0, NODE_1, NODE_2); + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + stopAllGrids(); + + cleanPersistenceDir(); + + listeningLog.registerAllListeners(lsnrAlreadyAct, lsnrBaseline, lsnrActMeet, lsnrActNotMeet); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(true); + + cleanPersistenceDir(); + + listeningLog.clearListeners(); + + super.afterTest(); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + final IgniteConfiguration igniteConfiguration = super.getConfiguration(igniteInstanceName); + + switch (igniteInstanceName) { + case NODE_0: + igniteConfiguration.setConsistentId(NODE_0); + break; + + case NODE_1: + igniteConfiguration.setConsistentId(NODE_1); + break; + + case NODE_2: + igniteConfiguration.setConsistentId(NODE_2); + break; + + default: throw new IllegalArgumentException("Unknown node: " + igniteInstanceName); + } Review Comment: Oh, this is much better! Done -- 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]
