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



##########
File path: modules/ducktests/tests/ignitetest/services/ignite_app.py
##########
@@ -38,33 +41,54 @@ def __init__(self, context, config, java_class_name, 
params="", timeout_sec=60,
         self.servicejava_class_name = servicejava_class_name
         self.java_class_name = java_class_name
         self.timeout_sec = timeout_sec
-        self.stop_timeout_sec = 10
+        self.params = params
 
     def start(self):
         super().start()
 
         self.logger.info("Waiting for Ignite aware Application (%s) to 
start..." % self.java_class_name)
 
         self.await_event("Topology snapshot", self.timeout_sec, 
from_the_beginning=True)
-        
self.await_event("IGNITE_APPLICATION_INITIALIZED\\|IGNITE_APPLICATION_BROKEN", 
self.timeout_sec,
-                         from_the_beginning=True)
 
-        try:
-            self.await_event("IGNITE_APPLICATION_INITIALIZED", 1, 
from_the_beginning=True)
-        except Exception:
-            raise Exception("Java application execution failed. %s" % 
self.extract_result("ERROR")) from None
+        self.__check_status("IGNITE_APPLICATION_INITIALIZED", 
timeout=self.timeout_sec)
 
-    # pylint: disable=W0221
-    def stop_node(self, node, clean_shutdown=True, timeout_sec=20):
-        self.logger.info("%s Stopping node %s" % (self.__class__.__name__, 
str(node.account)))
-        node.account.kill_java_processes(self.servicejava_class_name, 
clean_shutdown=clean_shutdown, allow_fail=True)
+    def stop_async(self, clean_shutdown=True):
+        """
+        Stops node in async way.
+        """
+        self.logger.info("%s Stopping node %s" % (self.__class__.__name__, 
str(self.nodes[0].account)))
+        self.nodes[0].account.kill_java_processes(self.servicejava_class_name, 
clean_shutdown=clean_shutdown,
+                                                  allow_fail=True)
 
-        stopped = self.wait_node(node, timeout_sec=self.stop_timeout_sec)
+    def await_stopped(self, timeout_sec=10):
+        """
+        Awaits node stop finish.
+        """
+        stopped = self.wait_node(self.nodes[0], timeout_sec=timeout_sec)
         assert stopped, "Node %s: did not stop within the specified timeout of 
%s seconds" % \
-                        (str(node.account), str(self.stop_timeout_sec))
+                        (str(self.nodes[0].account), str(timeout_sec))
 
-        
self.await_event("IGNITE_APPLICATION_FINISHED\\|IGNITE_APPLICATION_BROKEN", 
from_the_beginning=True,
-                         timeout_sec=timeout_sec)
+        self.__check_status("IGNITE_APPLICATION_FINISHED", timeout=timeout_sec)
+
+    # pylint: disable=W0221
+    def stop_node(self, node, clean_shutdown=True, timeout_sec=10):
+        assert node == self.nodes[0]
+        self.stop_async(clean_shutdown)
+        self.await_stopped(timeout_sec)
+
+    def __check_status(self, desired, timeout=1):
+        self.await_event("%s\\|IGNITE_APPLICATION_BROKEN" % desired, timeout, 
from_the_beginning=True)
+
+        try:
+            self.await_event("IGNITE_APPLICATION_BROKEN", 1, 
from_the_beginning=True)

Review comment:
       Can we replace 1 with 0?

##########
File path: modules/ducktests/tests/ignitetest/services/ignite_app.py
##########
@@ -38,33 +41,54 @@ def __init__(self, context, config, java_class_name, 
params="", timeout_sec=60,
         self.servicejava_class_name = servicejava_class_name
         self.java_class_name = java_class_name
         self.timeout_sec = timeout_sec
-        self.stop_timeout_sec = 10
+        self.params = params

Review comment:
       How is it used?

##########
File path: modules/ducktests/tests/ignitetest/services/ignite_app.py
##########
@@ -38,33 +41,54 @@ def __init__(self, context, config, java_class_name, 
params="", timeout_sec=60,
         self.servicejava_class_name = servicejava_class_name
         self.java_class_name = java_class_name
         self.timeout_sec = timeout_sec
-        self.stop_timeout_sec = 10
+        self.params = params
 
     def start(self):
         super().start()
 
         self.logger.info("Waiting for Ignite aware Application (%s) to 
start..." % self.java_class_name)
 
         self.await_event("Topology snapshot", self.timeout_sec, 
from_the_beginning=True)
-        
self.await_event("IGNITE_APPLICATION_INITIALIZED\\|IGNITE_APPLICATION_BROKEN", 
self.timeout_sec,
-                         from_the_beginning=True)
 
-        try:
-            self.await_event("IGNITE_APPLICATION_INITIALIZED", 1, 
from_the_beginning=True)
-        except Exception:
-            raise Exception("Java application execution failed. %s" % 
self.extract_result("ERROR")) from None
+        self.__check_status("IGNITE_APPLICATION_INITIALIZED", 
timeout=self.timeout_sec)
 
-    # pylint: disable=W0221
-    def stop_node(self, node, clean_shutdown=True, timeout_sec=20):
-        self.logger.info("%s Stopping node %s" % (self.__class__.__name__, 
str(node.account)))
-        node.account.kill_java_processes(self.servicejava_class_name, 
clean_shutdown=clean_shutdown, allow_fail=True)
+    def stop_async(self, clean_shutdown=True):
+        """
+        Stops node in async way.
+        """
+        self.logger.info("%s Stopping node %s" % (self.__class__.__name__, 
str(self.nodes[0].account)))
+        self.nodes[0].account.kill_java_processes(self.servicejava_class_name, 
clean_shutdown=clean_shutdown,
+                                                  allow_fail=True)
 
-        stopped = self.wait_node(node, timeout_sec=self.stop_timeout_sec)
+    def await_stopped(self, timeout_sec=10):
+        """
+        Awaits node stop finish.
+        """
+        stopped = self.wait_node(self.nodes[0], timeout_sec=timeout_sec)
         assert stopped, "Node %s: did not stop within the specified timeout of 
%s seconds" % \
-                        (str(node.account), str(self.stop_timeout_sec))
+                        (str(self.nodes[0].account), str(timeout_sec))
 
-        
self.await_event("IGNITE_APPLICATION_FINISHED\\|IGNITE_APPLICATION_BROKEN", 
from_the_beginning=True,
-                         timeout_sec=timeout_sec)
+        self.__check_status("IGNITE_APPLICATION_FINISHED", timeout=timeout_sec)
+
+    # pylint: disable=W0221
+    def stop_node(self, node, clean_shutdown=True, timeout_sec=10):
+        assert node == self.nodes[0]
+        self.stop_async(clean_shutdown)
+        self.await_stopped(timeout_sec)
+
+    def __check_status(self, desired, timeout=1):
+        self.await_event("%s\\|IGNITE_APPLICATION_BROKEN" % desired, timeout, 
from_the_beginning=True)
+
+        try:
+            self.await_event("IGNITE_APPLICATION_BROKEN", 1, 
from_the_beginning=True)
+            raise Exception("Java application execution failed. %s" % 
self.extract_result("ERROR"))
+        except TimeoutError:
+            pass
+
+        try:
+            self.await_event(desired, 1, from_the_beginning=True)
+        except Exception:
+            raise Exception("Java application execution falied.") from None

Review comment:
       falied -> failed

##########
File path: 
modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/cellular_affinity_test/PreparedTxStreamer.java
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.cellular_affinity_test;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
+import 
org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.transactions.Transaction;
+
+/**
+ *
+ */
+public class PreparedTxStreamer extends IgniteAwareApplication {
+    /**
+     * {@inheritDoc}
+     */
+    @Override protected void run(JsonNode jsonNode) throws Exception {
+        final String cacheName = jsonNode.get("cacheName").asText();
+        final String attr = jsonNode.get("attr").asText();
+        final String cell = jsonNode.get("cell").asText();
+        final int txCnt = jsonNode.get("txCnt").asInt();
+
+        markInitialized();
+
+        waitForActivation();
+
+        IgniteCache<Integer, Integer> cache = 
ignite.getOrCreateCache(cacheName);
+
+        log.info("Starting Prepared Txs...");
+
+        Affinity<Integer> aff = ignite.affinity(cacheName);
+
+        int cnt = 0;
+        int i = -1; // Negative keys to have no intersection with load.
+
+        while (cnt != txCnt && !terminated()) {
+            Collection<ClusterNode> nodes = aff.mapKeyToPrimaryAndBackups(i);
+
+            Map<Object, Long> stat = nodes.stream().collect(
+                Collectors.groupingBy(n -> n.attributes().get(attr), 
Collectors.counting()));
+
+            assert 1 == stat.keySet().size() :
+                "Partition should be located on nodes from only one cell " +
+                    "[key=" + i + ", nodes=" + nodes.size() + ", stat=" + stat 
+ "]";
+
+            if (stat.containsKey(cell)) {
+                cnt++;
+
+                Transaction tx = ignite.transactions().txStart();
+
+                cache.put(i, i);
+
+                try {
+                    ((TransactionProxyImpl<?, ?>)tx).tx().prepare(true);
+                }
+                catch (IgniteCheckedException e) {

Review comment:
       `IgniteAwareApplication::start` already catch any exception and mark app 
as broken

##########
File path: 
modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/cellular_affinity_test/PreparedTxStreamer.java
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.cellular_affinity_test;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
+import 
org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.transactions.Transaction;
+
+/**
+ *

Review comment:
       Could you please provide a short brief of the class

##########
File path: 
modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/cellular_affinity_test/TxStreamer.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.cellular_affinity_test;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
+
+/**
+ *

Review comment:
       Could you please provide a short brief of the class

##########
File path: modules/ducktests/tests/ignitetest/services/utils/ignite_spec.py
##########
@@ -147,6 +146,8 @@ def __init__(self, modules, **kwargs):
         libs.append("log4j")
         libs = list(map(lambda m: self.path.module(m) + "/*", libs))
 
+        libs.append(IgnitePath(DEV_BRANCH).module("ducktests") + "/*")

Review comment:
       Why do you add ducktests to NodeSpec?

##########
File path: modules/ducktests/tests/ignitetest/services/ignite_app.py
##########
@@ -38,33 +41,54 @@ def __init__(self, context, config, java_class_name, 
params="", timeout_sec=60,
         self.servicejava_class_name = servicejava_class_name
         self.java_class_name = java_class_name
         self.timeout_sec = timeout_sec
-        self.stop_timeout_sec = 10
+        self.params = params
 
     def start(self):
         super().start()
 
         self.logger.info("Waiting for Ignite aware Application (%s) to 
start..." % self.java_class_name)
 
         self.await_event("Topology snapshot", self.timeout_sec, 
from_the_beginning=True)
-        
self.await_event("IGNITE_APPLICATION_INITIALIZED\\|IGNITE_APPLICATION_BROKEN", 
self.timeout_sec,
-                         from_the_beginning=True)
 
-        try:
-            self.await_event("IGNITE_APPLICATION_INITIALIZED", 1, 
from_the_beginning=True)
-        except Exception:
-            raise Exception("Java application execution failed. %s" % 
self.extract_result("ERROR")) from None
+        self.__check_status("IGNITE_APPLICATION_INITIALIZED", 
timeout=self.timeout_sec)
 
-    # pylint: disable=W0221
-    def stop_node(self, node, clean_shutdown=True, timeout_sec=20):
-        self.logger.info("%s Stopping node %s" % (self.__class__.__name__, 
str(node.account)))
-        node.account.kill_java_processes(self.servicejava_class_name, 
clean_shutdown=clean_shutdown, allow_fail=True)
+    def stop_async(self, clean_shutdown=True):
+        """
+        Stops node in async way.
+        """
+        self.logger.info("%s Stopping node %s" % (self.__class__.__name__, 
str(self.nodes[0].account)))
+        self.nodes[0].account.kill_java_processes(self.servicejava_class_name, 
clean_shutdown=clean_shutdown,
+                                                  allow_fail=True)
 
-        stopped = self.wait_node(node, timeout_sec=self.stop_timeout_sec)
+    def await_stopped(self, timeout_sec=10):
+        """
+        Awaits node stop finish.
+        """
+        stopped = self.wait_node(self.nodes[0], timeout_sec=timeout_sec)
         assert stopped, "Node %s: did not stop within the specified timeout of 
%s seconds" % \
-                        (str(node.account), str(self.stop_timeout_sec))
+                        (str(self.nodes[0].account), str(timeout_sec))
 
-        
self.await_event("IGNITE_APPLICATION_FINISHED\\|IGNITE_APPLICATION_BROKEN", 
from_the_beginning=True,
-                         timeout_sec=timeout_sec)
+        self.__check_status("IGNITE_APPLICATION_FINISHED", timeout=timeout_sec)
+
+    # pylint: disable=W0221
+    def stop_node(self, node, clean_shutdown=True, timeout_sec=10):
+        assert node == self.nodes[0]
+        self.stop_async(clean_shutdown)
+        self.await_stopped(timeout_sec)
+
+    def __check_status(self, desired, timeout=1):
+        self.await_event("%s\\|IGNITE_APPLICATION_BROKEN" % desired, timeout, 
from_the_beginning=True)
+
+        try:
+            self.await_event("IGNITE_APPLICATION_BROKEN", 1, 
from_the_beginning=True)

Review comment:
       Can we replace 1 with 0?

##########
File path: modules/ducktests/tests/ignitetest/services/ignite_app.py
##########
@@ -38,33 +41,54 @@ def __init__(self, context, config, java_class_name, 
params="", timeout_sec=60,
         self.servicejava_class_name = servicejava_class_name
         self.java_class_name = java_class_name
         self.timeout_sec = timeout_sec
-        self.stop_timeout_sec = 10
+        self.params = params

Review comment:
       How is it used?

##########
File path: modules/ducktests/tests/ignitetest/services/ignite_app.py
##########
@@ -38,33 +41,54 @@ def __init__(self, context, config, java_class_name, 
params="", timeout_sec=60,
         self.servicejava_class_name = servicejava_class_name
         self.java_class_name = java_class_name
         self.timeout_sec = timeout_sec
-        self.stop_timeout_sec = 10
+        self.params = params
 
     def start(self):
         super().start()
 
         self.logger.info("Waiting for Ignite aware Application (%s) to 
start..." % self.java_class_name)
 
         self.await_event("Topology snapshot", self.timeout_sec, 
from_the_beginning=True)
-        
self.await_event("IGNITE_APPLICATION_INITIALIZED\\|IGNITE_APPLICATION_BROKEN", 
self.timeout_sec,
-                         from_the_beginning=True)
 
-        try:
-            self.await_event("IGNITE_APPLICATION_INITIALIZED", 1, 
from_the_beginning=True)
-        except Exception:
-            raise Exception("Java application execution failed. %s" % 
self.extract_result("ERROR")) from None
+        self.__check_status("IGNITE_APPLICATION_INITIALIZED", 
timeout=self.timeout_sec)
 
-    # pylint: disable=W0221
-    def stop_node(self, node, clean_shutdown=True, timeout_sec=20):
-        self.logger.info("%s Stopping node %s" % (self.__class__.__name__, 
str(node.account)))
-        node.account.kill_java_processes(self.servicejava_class_name, 
clean_shutdown=clean_shutdown, allow_fail=True)
+    def stop_async(self, clean_shutdown=True):
+        """
+        Stops node in async way.
+        """
+        self.logger.info("%s Stopping node %s" % (self.__class__.__name__, 
str(self.nodes[0].account)))
+        self.nodes[0].account.kill_java_processes(self.servicejava_class_name, 
clean_shutdown=clean_shutdown,
+                                                  allow_fail=True)
 
-        stopped = self.wait_node(node, timeout_sec=self.stop_timeout_sec)
+    def await_stopped(self, timeout_sec=10):
+        """
+        Awaits node stop finish.
+        """
+        stopped = self.wait_node(self.nodes[0], timeout_sec=timeout_sec)
         assert stopped, "Node %s: did not stop within the specified timeout of 
%s seconds" % \
-                        (str(node.account), str(self.stop_timeout_sec))
+                        (str(self.nodes[0].account), str(timeout_sec))
 
-        
self.await_event("IGNITE_APPLICATION_FINISHED\\|IGNITE_APPLICATION_BROKEN", 
from_the_beginning=True,
-                         timeout_sec=timeout_sec)
+        self.__check_status("IGNITE_APPLICATION_FINISHED", timeout=timeout_sec)
+
+    # pylint: disable=W0221
+    def stop_node(self, node, clean_shutdown=True, timeout_sec=10):
+        assert node == self.nodes[0]
+        self.stop_async(clean_shutdown)
+        self.await_stopped(timeout_sec)
+
+    def __check_status(self, desired, timeout=1):
+        self.await_event("%s\\|IGNITE_APPLICATION_BROKEN" % desired, timeout, 
from_the_beginning=True)
+
+        try:
+            self.await_event("IGNITE_APPLICATION_BROKEN", 1, 
from_the_beginning=True)
+            raise Exception("Java application execution failed. %s" % 
self.extract_result("ERROR"))
+        except TimeoutError:
+            pass
+
+        try:
+            self.await_event(desired, 1, from_the_beginning=True)
+        except Exception:
+            raise Exception("Java application execution falied.") from None

Review comment:
       falied -> failed

##########
File path: 
modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/cellular_affinity_test/PreparedTxStreamer.java
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.cellular_affinity_test;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
+import 
org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.transactions.Transaction;
+
+/**
+ *
+ */
+public class PreparedTxStreamer extends IgniteAwareApplication {
+    /**
+     * {@inheritDoc}
+     */
+    @Override protected void run(JsonNode jsonNode) throws Exception {
+        final String cacheName = jsonNode.get("cacheName").asText();
+        final String attr = jsonNode.get("attr").asText();
+        final String cell = jsonNode.get("cell").asText();
+        final int txCnt = jsonNode.get("txCnt").asInt();
+
+        markInitialized();
+
+        waitForActivation();
+
+        IgniteCache<Integer, Integer> cache = 
ignite.getOrCreateCache(cacheName);
+
+        log.info("Starting Prepared Txs...");
+
+        Affinity<Integer> aff = ignite.affinity(cacheName);
+
+        int cnt = 0;
+        int i = -1; // Negative keys to have no intersection with load.
+
+        while (cnt != txCnt && !terminated()) {
+            Collection<ClusterNode> nodes = aff.mapKeyToPrimaryAndBackups(i);
+
+            Map<Object, Long> stat = nodes.stream().collect(
+                Collectors.groupingBy(n -> n.attributes().get(attr), 
Collectors.counting()));
+
+            assert 1 == stat.keySet().size() :
+                "Partition should be located on nodes from only one cell " +
+                    "[key=" + i + ", nodes=" + nodes.size() + ", stat=" + stat 
+ "]";
+
+            if (stat.containsKey(cell)) {
+                cnt++;
+
+                Transaction tx = ignite.transactions().txStart();
+
+                cache.put(i, i);
+
+                try {
+                    ((TransactionProxyImpl<?, ?>)tx).tx().prepare(true);
+                }
+                catch (IgniteCheckedException e) {

Review comment:
       `IgniteAwareApplication::start` already catch any exception and mark app 
as broken

##########
File path: 
modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/cellular_affinity_test/PreparedTxStreamer.java
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.cellular_affinity_test;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
+import 
org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.transactions.Transaction;
+
+/**
+ *

Review comment:
       Could you please provide a short brief of the class

##########
File path: 
modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/cellular_affinity_test/TxStreamer.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.cellular_affinity_test;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
+
+/**
+ *

Review comment:
       Could you please provide a short brief of the class

##########
File path: modules/ducktests/tests/ignitetest/services/utils/ignite_spec.py
##########
@@ -147,6 +146,8 @@ def __init__(self, modules, **kwargs):
         libs.append("log4j")
         libs = list(map(lambda m: self.path.module(m) + "/*", libs))
 
+        libs.append(IgnitePath(DEV_BRANCH).module("ducktests") + "/*")

Review comment:
       Why do you add ducktests to NodeSpec?

##########
File path: modules/ducktests/tests/ignitetest/services/ignite_app.py
##########
@@ -38,33 +41,54 @@ def __init__(self, context, config, java_class_name, 
params="", timeout_sec=60,
         self.servicejava_class_name = servicejava_class_name
         self.java_class_name = java_class_name
         self.timeout_sec = timeout_sec
-        self.stop_timeout_sec = 10
+        self.params = params
 
     def start(self):
         super().start()
 
         self.logger.info("Waiting for Ignite aware Application (%s) to 
start..." % self.java_class_name)
 
         self.await_event("Topology snapshot", self.timeout_sec, 
from_the_beginning=True)
-        
self.await_event("IGNITE_APPLICATION_INITIALIZED\\|IGNITE_APPLICATION_BROKEN", 
self.timeout_sec,
-                         from_the_beginning=True)
 
-        try:
-            self.await_event("IGNITE_APPLICATION_INITIALIZED", 1, 
from_the_beginning=True)
-        except Exception:
-            raise Exception("Java application execution failed. %s" % 
self.extract_result("ERROR")) from None
+        self.__check_status("IGNITE_APPLICATION_INITIALIZED", 
timeout=self.timeout_sec)
 
-    # pylint: disable=W0221
-    def stop_node(self, node, clean_shutdown=True, timeout_sec=20):
-        self.logger.info("%s Stopping node %s" % (self.__class__.__name__, 
str(node.account)))
-        node.account.kill_java_processes(self.servicejava_class_name, 
clean_shutdown=clean_shutdown, allow_fail=True)
+    def stop_async(self, clean_shutdown=True):
+        """
+        Stops node in async way.
+        """
+        self.logger.info("%s Stopping node %s" % (self.__class__.__name__, 
str(self.nodes[0].account)))
+        self.nodes[0].account.kill_java_processes(self.servicejava_class_name, 
clean_shutdown=clean_shutdown,
+                                                  allow_fail=True)
 
-        stopped = self.wait_node(node, timeout_sec=self.stop_timeout_sec)
+    def await_stopped(self, timeout_sec=10):
+        """
+        Awaits node stop finish.
+        """
+        stopped = self.wait_node(self.nodes[0], timeout_sec=timeout_sec)
         assert stopped, "Node %s: did not stop within the specified timeout of 
%s seconds" % \
-                        (str(node.account), str(self.stop_timeout_sec))
+                        (str(self.nodes[0].account), str(timeout_sec))
 
-        
self.await_event("IGNITE_APPLICATION_FINISHED\\|IGNITE_APPLICATION_BROKEN", 
from_the_beginning=True,
-                         timeout_sec=timeout_sec)
+        self.__check_status("IGNITE_APPLICATION_FINISHED", timeout=timeout_sec)
+
+    # pylint: disable=W0221
+    def stop_node(self, node, clean_shutdown=True, timeout_sec=10):
+        assert node == self.nodes[0]
+        self.stop_async(clean_shutdown)
+        self.await_stopped(timeout_sec)
+
+    def __check_status(self, desired, timeout=1):
+        self.await_event("%s\\|IGNITE_APPLICATION_BROKEN" % desired, timeout, 
from_the_beginning=True)
+
+        try:
+            self.await_event("IGNITE_APPLICATION_BROKEN", 1, 
from_the_beginning=True)

Review comment:
       Can we replace 1 with 0?

##########
File path: modules/ducktests/tests/ignitetest/services/ignite_app.py
##########
@@ -38,33 +41,54 @@ def __init__(self, context, config, java_class_name, 
params="", timeout_sec=60,
         self.servicejava_class_name = servicejava_class_name
         self.java_class_name = java_class_name
         self.timeout_sec = timeout_sec
-        self.stop_timeout_sec = 10
+        self.params = params

Review comment:
       How is it used?

##########
File path: modules/ducktests/tests/ignitetest/services/ignite_app.py
##########
@@ -38,33 +41,54 @@ def __init__(self, context, config, java_class_name, 
params="", timeout_sec=60,
         self.servicejava_class_name = servicejava_class_name
         self.java_class_name = java_class_name
         self.timeout_sec = timeout_sec
-        self.stop_timeout_sec = 10
+        self.params = params
 
     def start(self):
         super().start()
 
         self.logger.info("Waiting for Ignite aware Application (%s) to 
start..." % self.java_class_name)
 
         self.await_event("Topology snapshot", self.timeout_sec, 
from_the_beginning=True)
-        
self.await_event("IGNITE_APPLICATION_INITIALIZED\\|IGNITE_APPLICATION_BROKEN", 
self.timeout_sec,
-                         from_the_beginning=True)
 
-        try:
-            self.await_event("IGNITE_APPLICATION_INITIALIZED", 1, 
from_the_beginning=True)
-        except Exception:
-            raise Exception("Java application execution failed. %s" % 
self.extract_result("ERROR")) from None
+        self.__check_status("IGNITE_APPLICATION_INITIALIZED", 
timeout=self.timeout_sec)
 
-    # pylint: disable=W0221
-    def stop_node(self, node, clean_shutdown=True, timeout_sec=20):
-        self.logger.info("%s Stopping node %s" % (self.__class__.__name__, 
str(node.account)))
-        node.account.kill_java_processes(self.servicejava_class_name, 
clean_shutdown=clean_shutdown, allow_fail=True)
+    def stop_async(self, clean_shutdown=True):
+        """
+        Stops node in async way.
+        """
+        self.logger.info("%s Stopping node %s" % (self.__class__.__name__, 
str(self.nodes[0].account)))
+        self.nodes[0].account.kill_java_processes(self.servicejava_class_name, 
clean_shutdown=clean_shutdown,
+                                                  allow_fail=True)
 
-        stopped = self.wait_node(node, timeout_sec=self.stop_timeout_sec)
+    def await_stopped(self, timeout_sec=10):
+        """
+        Awaits node stop finish.
+        """
+        stopped = self.wait_node(self.nodes[0], timeout_sec=timeout_sec)
         assert stopped, "Node %s: did not stop within the specified timeout of 
%s seconds" % \
-                        (str(node.account), str(self.stop_timeout_sec))
+                        (str(self.nodes[0].account), str(timeout_sec))
 
-        
self.await_event("IGNITE_APPLICATION_FINISHED\\|IGNITE_APPLICATION_BROKEN", 
from_the_beginning=True,
-                         timeout_sec=timeout_sec)
+        self.__check_status("IGNITE_APPLICATION_FINISHED", timeout=timeout_sec)
+
+    # pylint: disable=W0221
+    def stop_node(self, node, clean_shutdown=True, timeout_sec=10):
+        assert node == self.nodes[0]
+        self.stop_async(clean_shutdown)
+        self.await_stopped(timeout_sec)
+
+    def __check_status(self, desired, timeout=1):
+        self.await_event("%s\\|IGNITE_APPLICATION_BROKEN" % desired, timeout, 
from_the_beginning=True)
+
+        try:
+            self.await_event("IGNITE_APPLICATION_BROKEN", 1, 
from_the_beginning=True)
+            raise Exception("Java application execution failed. %s" % 
self.extract_result("ERROR"))
+        except TimeoutError:
+            pass
+
+        try:
+            self.await_event(desired, 1, from_the_beginning=True)
+        except Exception:
+            raise Exception("Java application execution falied.") from None

Review comment:
       falied -> failed

##########
File path: 
modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/cellular_affinity_test/PreparedTxStreamer.java
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.cellular_affinity_test;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
+import 
org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.transactions.Transaction;
+
+/**
+ *
+ */
+public class PreparedTxStreamer extends IgniteAwareApplication {
+    /**
+     * {@inheritDoc}
+     */
+    @Override protected void run(JsonNode jsonNode) throws Exception {
+        final String cacheName = jsonNode.get("cacheName").asText();
+        final String attr = jsonNode.get("attr").asText();
+        final String cell = jsonNode.get("cell").asText();
+        final int txCnt = jsonNode.get("txCnt").asInt();
+
+        markInitialized();
+
+        waitForActivation();
+
+        IgniteCache<Integer, Integer> cache = 
ignite.getOrCreateCache(cacheName);
+
+        log.info("Starting Prepared Txs...");
+
+        Affinity<Integer> aff = ignite.affinity(cacheName);
+
+        int cnt = 0;
+        int i = -1; // Negative keys to have no intersection with load.
+
+        while (cnt != txCnt && !terminated()) {
+            Collection<ClusterNode> nodes = aff.mapKeyToPrimaryAndBackups(i);
+
+            Map<Object, Long> stat = nodes.stream().collect(
+                Collectors.groupingBy(n -> n.attributes().get(attr), 
Collectors.counting()));
+
+            assert 1 == stat.keySet().size() :
+                "Partition should be located on nodes from only one cell " +
+                    "[key=" + i + ", nodes=" + nodes.size() + ", stat=" + stat 
+ "]";
+
+            if (stat.containsKey(cell)) {
+                cnt++;
+
+                Transaction tx = ignite.transactions().txStart();
+
+                cache.put(i, i);
+
+                try {
+                    ((TransactionProxyImpl<?, ?>)tx).tx().prepare(true);
+                }
+                catch (IgniteCheckedException e) {

Review comment:
       `IgniteAwareApplication::start` already catch any exception and mark app 
as broken

##########
File path: 
modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/cellular_affinity_test/PreparedTxStreamer.java
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.cellular_affinity_test;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
+import 
org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.transactions.Transaction;
+
+/**
+ *

Review comment:
       Could you please provide a short brief of the class

##########
File path: 
modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/cellular_affinity_test/TxStreamer.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.cellular_affinity_test;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
+
+/**
+ *

Review comment:
       Could you please provide a short brief of the class

##########
File path: modules/ducktests/tests/ignitetest/services/utils/ignite_spec.py
##########
@@ -147,6 +146,8 @@ def __init__(self, modules, **kwargs):
         libs.append("log4j")
         libs = list(map(lambda m: self.path.module(m) + "/*", libs))
 
+        libs.append(IgnitePath(DEV_BRANCH).module("ducktests") + "/*")

Review comment:
       Why do you add ducktests to NodeSpec?




----------------------------------------------------------------
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:
[email protected]


Reply via email to