alamar commented on a change in pull request #5891: Ignite-10921
URL: https://github.com/apache/ignite/pull/5891#discussion_r250620395
 
 

 ##########
 File path: 
modules/core/src/test/java/org/apache/ignite/internal/ConsistentIdImplicitlyExplicitlyTest.java
 ##########
 @@ -0,0 +1,189 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.regex.Pattern;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Checks consistent id in various cases.
+ */
+@RunWith(JUnit4.class)
+public class ConsistentIdImplicitlyExplicitlyTest extends 
GridCommonAbstractTest {
+    /** Ipaddress with port pattern. */
+    private static final String IPADDRESS_WITH_PORT_PATTERN = 
"^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
+        
"([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
+        "([01]?\\d\\d?|2[0-4]\\d|25[0-5]):[1-9][0-9]+$";
+
+    /** Pattern. */
+    private static final Pattern ADDR_WITH_PORT_PATTERN = 
Pattern.compile(IPADDRESS_WITH_PORT_PATTERN);
+
+    /** Uuid as string pattern. */
+    private static final String UUID_STR_PATTERN = 
"[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}" +
+        "-[a-fA-F0-9]{12}";
+
+    /** Pattern. */
+    private static final Pattern UUID_PATTERN = 
Pattern.compile(UUID_STR_PATTERN);
+
+    /** Configured consistent id. */
+    private Serializable defConsistentId;
+
+    /** Persistence enabled. */
+    private boolean persistenceEnabled;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        return super.getConfiguration(igniteInstanceName)
+            .setConsistentId(defConsistentId)
+            .setDataStorageConfiguration(new DataStorageConfiguration()
+                .setDefaultDataRegionConfiguration(new 
DataRegionConfiguration()
+                    .setPersistenceEnabled(persistenceEnabled)
+                    .setMaxSize(200L * 1024 * 1024)));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        stopAllGrids();
+
+        cleanPersistenceDir();
+
+        defConsistentId = null;
+        persistenceEnabled = false;
+
+        System.clearProperty(IgniteSystemProperties.IGNITE_CONSISTENT_ID);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        stopAllGrids();
+
+        defConsistentId = null;
+
+        if (persistenceEnabled) {
+            cleanPersistenceDir();
+
+            persistenceEnabled = false;
+        }
+
+        System.clearProperty(IgniteSystemProperties.IGNITE_CONSISTENT_ID);
+    }
+
+    /**
+     * Consistent id not configurent, neither in {@link IgniteConfiguration} 
nor in JVM propery.
+     *
+     * @throws Exception if failed.
+     */
+    @Test
+    public void testConsistentIdNotConfigured() throws Exception {
+        Ignite ignite = startGrid(0);
+
+        assertNull(ignite.configuration().getConsistentId());
+
+        
assertTrue(ADDR_WITH_PORT_PATTERN.matcher(ignite.cluster().localNode().consistentId().toString()).find());
 
 Review comment:
   This is irrelevant since this test will be only ran once. Please change as 
adviced, save a few lines.
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to