You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/10/14 13:43:18 UTC

[GitHub] [ignite] timoninmaxim commented on a change in pull request #8352: IGNITE-13448 Ducktests selftest: time is synchronized on nodes

timoninmaxim commented on a change in pull request #8352:
URL: https://github.com/apache/ignite/pull/8352#discussion_r504687214



##########
File path: modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/smoke_test/ClockSyncCheckerApplication.java
##########
@@ -0,0 +1,141 @@
+/*
+ * 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.ducktest.tests.smoke_test;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import javax.cache.Cache;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.events.CacheEvent;
+import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
+import org.apache.ignite.internal.util.typedef.T2;
+
+import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT;
+
+/**
+ * Checks if clocks are synchronized between nodes.
+ */
+public class ClockSyncCheckerApplication extends IgniteAwareApplication {
+    /** */
+    private static final String TIMESTAMP_CACHE = "TimestampCache";
+
+    /** */
+    private static final String MAX_CLOCK_DIVERGENCY_MS_PARAM = "maxClockDivergencyMs";
+
+    /** */
+    private static final long WAIT_TIMEOUT_MS = 5000;
+
+    /**
+     * Client node sends requests to all servers by putting distributed cache entries.
+     * Receiver gets request through remote event filter and replies by writing with its local timestamp to cache.
+     * Client listens for replies with continuous query and checks the difference between clocks.
+     * <p>
+     * Cache event handler does not allow to modify entries being handled (even asynchronously),
+     * so request and reply have different keys, structured as 2-tuples:
+     * request = (targetNodeId, 0), reply = (targetNodeId, timestamp); values are not used.
+     * <p>
+     * Cache mode should be replicated in order to run remote listeners on all server nodes reliably.
+     */
+    @Override public void run(JsonNode jsonNode) throws Exception {
+        long maxClockDivergencyMs = jsonNode.get(MAX_CLOCK_DIVERGENCY_MS_PARAM).asLong();
+
+        IgniteCache<T2<UUID, Long>, Optional<Void>> cache = ignite.getOrCreateCache(
+            new CacheConfiguration<T2<UUID, Long>, Optional<Void>>(TIMESTAMP_CACHE)
+                .setCacheMode(CacheMode.REPLICATED));
+
+        cache.clear();
+
+        markInitialized();
+
+        ignite.cluster().forServers().nodes().forEach(server ->

Review comment:
       Looks like over complicated. Ducktape provide SSH account. So we can just use it for getting local time without start of ignite at all.
   
   Actually is it possible to configure local time for an Ignite instance?

##########
File path: modules/ducktests/tests/ignitetest/tests/smoke_test.py
##########
@@ -87,3 +87,28 @@ def test_zk_start_stop(self):
         zookeeper = ZookeeperService(self.test_context, num_nodes=3)
         zookeeper.start()
         zookeeper.stop()
+
+    @cluster(num_nodes=4)
+    @ignite_versions(str(DEV_BRANCH))
+    def test_ignite_clock_sync(self, ignite_version):

Review comment:
       It's not a smoke test of services. It checks that environment is configured correctly. So it's named as self tests. Actually there is a one test with the same goal - assertion_test. Let's rename it to smth like self_tests.py and move this test to the file.

##########
File path: modules/ducktests/tests/ignitetest/tests/smoke_test.py
##########
@@ -87,3 +87,28 @@ def test_zk_start_stop(self):
         zookeeper = ZookeeperService(self.test_context, num_nodes=3)
         zookeeper.start()
         zookeeper.stop()
+
+    @cluster(num_nodes=4)
+    @ignite_versions(str(DEV_BRANCH))
+    def test_ignite_clock_sync(self, ignite_version):
+        """
+        Tests that clocks are synchronized between nodes.
+        """
+        num_nodes = 4

Review comment:
       Why do you check only 4 nodes. We should check that every node in a cluster is configured correctly.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org