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/08/07 11:31:54 UTC

[GitHub] [ignite] anton-vinogradov opened a new pull request #8130: Cellular affinity test

anton-vinogradov opened a new pull request #8130:
URL: https://github.com/apache/ignite/pull/8130


   


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



[GitHub] [ignite] anton-vinogradov commented on a change in pull request #8130: Cellular affinity test

Posted by GitBox <gi...@apache.org>.
anton-vinogradov commented on a change in pull request #8130:
URL: https://github.com/apache/ignite/pull/8130#discussion_r467916416



##########
File path: modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/cellular_affinity_test/CellularAffinityBackupFilter.java
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.List;
+import java.util.Objects;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.lang.IgniteBiPredicate;
+
+/**
+ *
+ */
+public class CellularAffinityBackupFilter implements IgniteBiPredicate<ClusterNode, List<ClusterNode>> {
+    /** */
+    private static final long serialVersionUID = 1L;
+
+    /** Attribute name. */
+    private final String attrName;
+
+    /**
+     * @param attrName The attribute name for the attribute to compare.
+     */
+    public CellularAffinityBackupFilter(String attrName) {
+        this.attrName = attrName;
+    }
+
+    /**
+     * Defines a predicate which returns {@code true} if a node is acceptable for a backup
+     * or {@code false} otherwise. An acceptable node is one where its attribute value
+     * is exact match with previously selected nodes.  If an attribute does not
+     * exist on exactly one node of a pair, then the attribute does not match.  If the attribute
+     * does not exist both nodes of a pair, then the attribute matches.
+     *
+     * @param candidate          A node that is a candidate for becoming a backup node for a partition.
+     * @param previouslySelected A list of primary/backup nodes already chosen for a partition.
+     *                           The primary is first.
+     */
+    @Override public boolean apply(ClusterNode candidate, List<ClusterNode> previouslySelected) {
+        for (ClusterNode node : previouslySelected)
+            return Objects.equals(candidate.attribute(attrName), node.attribute(attrName));
+
+        return true;
+    }
+}

Review comment:
       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.

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



[GitHub] [ignite] anton-vinogradov commented on a change in pull request #8130: Cellular affinity test

Posted by GitBox <gi...@apache.org>.
anton-vinogradov commented on a change in pull request #8130:
URL: https://github.com/apache/ignite/pull/8130#discussion_r467966509



##########
File path: modules/ducktests/tests/ignitetest/tests/cellular_affinity_test.py
##########
@@ -0,0 +1,123 @@
+# 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.
+
+"""
+This module contains Cellular Affinity tests.
+"""
+
+from ducktape.mark import parametrize
+from ducktape.mark.resource import cluster
+from jinja2 import Template
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.tests.utils.ignite_test import IgniteTest
+from ignitetest.tests.utils.version import DEV_BRANCH, IgniteVersion
+
+
+# pylint: disable=W0223
+class CellularAffinity(IgniteTest):
+    """
+    Tests Cellular Affinity scenarios.
+    """
+    NUM_NODES = 3
+
+    ATTRIBUTE = "CELL"
+
+    CACHE_NAME = "test-cache"
+
+    CONFIG_TEMPLATE = """
+            <property name="cacheConfiguration">
+                <list>
+                    <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                        <property name="affinity">
+                            <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
+                                <property name="affinityBackupFilter">
+                                    <bean class="org.apache.ignite.internal.ducktest.tests.cellular_affinity_test.CellularAffinityBackupFilter">
+                                        <constructor-arg value="{{ attr }}"/>
+                                    </bean>
+                                </property>
+                            </bean>
+                        </property>
+                        <property name="name" value="{{ cacheName }}"/>
+                        <property name="backups" value="{{ nodes }}"/> 
+                    </bean>
+                </list>
+            </property>
+        """
+
+    @staticmethod
+    def properties():
+        """
+        :return: Configuration properties.
+        """
+        return Template(CellularAffinity.CONFIG_TEMPLATE) \
+            .render(nodes=CellularAffinity.NUM_NODES,  # bigger than cell capacity (to handle single cell useless test)
+                    attr=CellularAffinity.ATTRIBUTE,
+                    cacheName=CellularAffinity.CACHE_NAME)
+
+    def __init__(self, test_context):
+        super(CellularAffinity, self).__init__(test_context=test_context)
+
+    def setUp(self):
+        pass
+
+    def teardown(self):
+        pass
+
+    @cluster(num_nodes=NUM_NODES * 3 + 1)
+    @parametrize(version=str(DEV_BRANCH))
+    def test(self, version):
+        """
+        Test Cellular Affinity scenario (partition distribution).
+        """
+        ignite_version = IgniteVersion(version)
+
+        ignites1 = IgniteService(
+            self.test_context,
+            num_nodes=CellularAffinity.NUM_NODES,
+            version=ignite_version,
+            properties=self.properties(),
+            jvm_opts=['-D' + CellularAffinity.ATTRIBUTE + '=1'])
+
+        ignites1.start()
+
+        ignites2 = IgniteService(
+            self.test_context,
+            num_nodes=CellularAffinity.NUM_NODES,
+            version=ignite_version,
+            properties=self.properties(),
+            jvm_opts=['-D' + CellularAffinity.ATTRIBUTE + '=2'])
+
+        ignites2.start()
+
+        ignites3 = IgniteService(
+            self.test_context,
+            num_nodes=CellularAffinity.NUM_NODES,
+            version=ignite_version,
+            properties=self.properties(),
+            jvm_opts=['-D' + CellularAffinity.ATTRIBUTE + '=XXX', '-DRANDOM=42'])
+
+        ignites3.start()
+
+        checker = IgniteApplicationService(
+            self.test_context,
+            java_class_name="org.apache.ignite.internal.ducktest.tests.cellular_affinity_test.DistributionChecker",
+            params={"cacheName": CellularAffinity.CACHE_NAME,
+                    "attr": CellularAffinity.ATTRIBUTE,
+                    "nodesPerCell": self.NUM_NODES},
+            version=ignite_version)
+
+        checker.start()

Review comment:
       For now, any application MUST return "IGNITE_APPLICATION_INITIALIZED" and "IGNITE_APPLICATION_FINISHED" (both), otherwise, it will fail with an error. 
   "IGNITE_APPLICATION_FINISHED" can be produced only in case of success:
   ```
       protected void markFinished() {
           assert !finished;
   
           log.info(APP_FINISHED); // "IGNITE_APPLICATION_FINISHED"
   
           finished = true;
       }
   ```
   
   Checker performs checks can be found inside java class, that assertion do we need here?




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



[GitHub] [ignite] anton-vinogradov commented on a change in pull request #8130: Cellular affinity test

Posted by GitBox <gi...@apache.org>.
anton-vinogradov commented on a change in pull request #8130:
URL: https://github.com/apache/ignite/pull/8130#discussion_r467966509



##########
File path: modules/ducktests/tests/ignitetest/tests/cellular_affinity_test.py
##########
@@ -0,0 +1,123 @@
+# 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.
+
+"""
+This module contains Cellular Affinity tests.
+"""
+
+from ducktape.mark import parametrize
+from ducktape.mark.resource import cluster
+from jinja2 import Template
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.tests.utils.ignite_test import IgniteTest
+from ignitetest.tests.utils.version import DEV_BRANCH, IgniteVersion
+
+
+# pylint: disable=W0223
+class CellularAffinity(IgniteTest):
+    """
+    Tests Cellular Affinity scenarios.
+    """
+    NUM_NODES = 3
+
+    ATTRIBUTE = "CELL"
+
+    CACHE_NAME = "test-cache"
+
+    CONFIG_TEMPLATE = """
+            <property name="cacheConfiguration">
+                <list>
+                    <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                        <property name="affinity">
+                            <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
+                                <property name="affinityBackupFilter">
+                                    <bean class="org.apache.ignite.internal.ducktest.tests.cellular_affinity_test.CellularAffinityBackupFilter">
+                                        <constructor-arg value="{{ attr }}"/>
+                                    </bean>
+                                </property>
+                            </bean>
+                        </property>
+                        <property name="name" value="{{ cacheName }}"/>
+                        <property name="backups" value="{{ nodes }}"/> 
+                    </bean>
+                </list>
+            </property>
+        """
+
+    @staticmethod
+    def properties():
+        """
+        :return: Configuration properties.
+        """
+        return Template(CellularAffinity.CONFIG_TEMPLATE) \
+            .render(nodes=CellularAffinity.NUM_NODES,  # bigger than cell capacity (to handle single cell useless test)
+                    attr=CellularAffinity.ATTRIBUTE,
+                    cacheName=CellularAffinity.CACHE_NAME)
+
+    def __init__(self, test_context):
+        super(CellularAffinity, self).__init__(test_context=test_context)
+
+    def setUp(self):
+        pass
+
+    def teardown(self):
+        pass
+
+    @cluster(num_nodes=NUM_NODES * 3 + 1)
+    @parametrize(version=str(DEV_BRANCH))
+    def test(self, version):
+        """
+        Test Cellular Affinity scenario (partition distribution).
+        """
+        ignite_version = IgniteVersion(version)
+
+        ignites1 = IgniteService(
+            self.test_context,
+            num_nodes=CellularAffinity.NUM_NODES,
+            version=ignite_version,
+            properties=self.properties(),
+            jvm_opts=['-D' + CellularAffinity.ATTRIBUTE + '=1'])
+
+        ignites1.start()
+
+        ignites2 = IgniteService(
+            self.test_context,
+            num_nodes=CellularAffinity.NUM_NODES,
+            version=ignite_version,
+            properties=self.properties(),
+            jvm_opts=['-D' + CellularAffinity.ATTRIBUTE + '=2'])
+
+        ignites2.start()
+
+        ignites3 = IgniteService(
+            self.test_context,
+            num_nodes=CellularAffinity.NUM_NODES,
+            version=ignite_version,
+            properties=self.properties(),
+            jvm_opts=['-D' + CellularAffinity.ATTRIBUTE + '=XXX', '-DRANDOM=42'])
+
+        ignites3.start()
+
+        checker = IgniteApplicationService(
+            self.test_context,
+            java_class_name="org.apache.ignite.internal.ducktest.tests.cellular_affinity_test.DistributionChecker",
+            params={"cacheName": CellularAffinity.CACHE_NAME,
+                    "attr": CellularAffinity.ATTRIBUTE,
+                    "nodesPerCell": self.NUM_NODES},
+            version=ignite_version)
+
+        checker.start()

Review comment:
       For now, any application MUST return "IGNITE_APPLICATION_INITIALIZED" and "IGNITE_APPLICATION_FINISHED" (both), otherwise, it will fail with an error. 
   "IGNITE_APPLICATION_FINISHED" can be produced only in case of success:
   ```
       protected void markFinished() {
           assert !finished;
   
           log.info(APP_FINISHED); // "IGNITE_APPLICATION_FINISHED"
   
           finished = true;
       }
   ```
   
   Checker performs checks can be found inside java class, that additional assertion do we need here?




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



[GitHub] [ignite] anton-vinogradov merged pull request #8130: Cellular affinity test

Posted by GitBox <gi...@apache.org>.
anton-vinogradov merged pull request #8130:
URL: https://github.com/apache/ignite/pull/8130


   


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



[GitHub] [ignite] anton-vinogradov commented on a change in pull request #8130: Cellular affinity test

Posted by GitBox <gi...@apache.org>.
anton-vinogradov commented on a change in pull request #8130:
URL: https://github.com/apache/ignite/pull/8130#discussion_r467968823



##########
File path: modules/ducktests/tests/ignitetest/tests/cellular_affinity_test.py
##########
@@ -0,0 +1,123 @@
+# 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.
+
+"""
+This module contains Cellular Affinity tests.
+"""
+
+from ducktape.mark import parametrize
+from ducktape.mark.resource import cluster
+from jinja2 import Template
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.tests.utils.ignite_test import IgniteTest
+from ignitetest.tests.utils.version import DEV_BRANCH, IgniteVersion
+
+
+# pylint: disable=W0223
+class CellularAffinity(IgniteTest):
+    """
+    Tests Cellular Affinity scenarios.
+    """
+    NUM_NODES = 3
+
+    ATTRIBUTE = "CELL"
+
+    CACHE_NAME = "test-cache"
+
+    CONFIG_TEMPLATE = """
+            <property name="cacheConfiguration">
+                <list>
+                    <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                        <property name="affinity">
+                            <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
+                                <property name="affinityBackupFilter">
+                                    <bean class="org.apache.ignite.internal.ducktest.tests.cellular_affinity_test.CellularAffinityBackupFilter">
+                                        <constructor-arg value="{{ attr }}"/>
+                                    </bean>
+                                </property>
+                            </bean>
+                        </property>
+                        <property name="name" value="{{ cacheName }}"/>
+                        <property name="backups" value="{{ nodes }}"/> 
+                    </bean>
+                </list>
+            </property>
+        """
+
+    @staticmethod
+    def properties():
+        """
+        :return: Configuration properties.
+        """
+        return Template(CellularAffinity.CONFIG_TEMPLATE) \
+            .render(nodes=CellularAffinity.NUM_NODES,  # bigger than cell capacity (to handle single cell useless test)
+                    attr=CellularAffinity.ATTRIBUTE,
+                    cacheName=CellularAffinity.CACHE_NAME)
+
+    def __init__(self, test_context):
+        super(CellularAffinity, self).__init__(test_context=test_context)
+
+    def setUp(self):
+        pass
+
+    def teardown(self):
+        pass
+
+    @cluster(num_nodes=NUM_NODES * 3 + 1)
+    @parametrize(version=str(DEV_BRANCH))
+    def test(self, version):
+        """
+        Test Cellular Affinity scenario (partition distribution).
+        """
+        ignite_version = IgniteVersion(version)
+
+        ignites1 = IgniteService(

Review comment:
       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.

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



[GitHub] [ignite] anton-vinogradov commented on a change in pull request #8130: Cellular affinity test

Posted by GitBox <gi...@apache.org>.
anton-vinogradov commented on a change in pull request #8130:
URL: https://github.com/apache/ignite/pull/8130#discussion_r467966509



##########
File path: modules/ducktests/tests/ignitetest/tests/cellular_affinity_test.py
##########
@@ -0,0 +1,123 @@
+# 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.
+
+"""
+This module contains Cellular Affinity tests.
+"""
+
+from ducktape.mark import parametrize
+from ducktape.mark.resource import cluster
+from jinja2 import Template
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.tests.utils.ignite_test import IgniteTest
+from ignitetest.tests.utils.version import DEV_BRANCH, IgniteVersion
+
+
+# pylint: disable=W0223
+class CellularAffinity(IgniteTest):
+    """
+    Tests Cellular Affinity scenarios.
+    """
+    NUM_NODES = 3
+
+    ATTRIBUTE = "CELL"
+
+    CACHE_NAME = "test-cache"
+
+    CONFIG_TEMPLATE = """
+            <property name="cacheConfiguration">
+                <list>
+                    <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                        <property name="affinity">
+                            <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
+                                <property name="affinityBackupFilter">
+                                    <bean class="org.apache.ignite.internal.ducktest.tests.cellular_affinity_test.CellularAffinityBackupFilter">
+                                        <constructor-arg value="{{ attr }}"/>
+                                    </bean>
+                                </property>
+                            </bean>
+                        </property>
+                        <property name="name" value="{{ cacheName }}"/>
+                        <property name="backups" value="{{ nodes }}"/> 
+                    </bean>
+                </list>
+            </property>
+        """
+
+    @staticmethod
+    def properties():
+        """
+        :return: Configuration properties.
+        """
+        return Template(CellularAffinity.CONFIG_TEMPLATE) \
+            .render(nodes=CellularAffinity.NUM_NODES,  # bigger than cell capacity (to handle single cell useless test)
+                    attr=CellularAffinity.ATTRIBUTE,
+                    cacheName=CellularAffinity.CACHE_NAME)
+
+    def __init__(self, test_context):
+        super(CellularAffinity, self).__init__(test_context=test_context)
+
+    def setUp(self):
+        pass
+
+    def teardown(self):
+        pass
+
+    @cluster(num_nodes=NUM_NODES * 3 + 1)
+    @parametrize(version=str(DEV_BRANCH))
+    def test(self, version):
+        """
+        Test Cellular Affinity scenario (partition distribution).
+        """
+        ignite_version = IgniteVersion(version)
+
+        ignites1 = IgniteService(
+            self.test_context,
+            num_nodes=CellularAffinity.NUM_NODES,
+            version=ignite_version,
+            properties=self.properties(),
+            jvm_opts=['-D' + CellularAffinity.ATTRIBUTE + '=1'])
+
+        ignites1.start()
+
+        ignites2 = IgniteService(
+            self.test_context,
+            num_nodes=CellularAffinity.NUM_NODES,
+            version=ignite_version,
+            properties=self.properties(),
+            jvm_opts=['-D' + CellularAffinity.ATTRIBUTE + '=2'])
+
+        ignites2.start()
+
+        ignites3 = IgniteService(
+            self.test_context,
+            num_nodes=CellularAffinity.NUM_NODES,
+            version=ignite_version,
+            properties=self.properties(),
+            jvm_opts=['-D' + CellularAffinity.ATTRIBUTE + '=XXX', '-DRANDOM=42'])
+
+        ignites3.start()
+
+        checker = IgniteApplicationService(
+            self.test_context,
+            java_class_name="org.apache.ignite.internal.ducktest.tests.cellular_affinity_test.DistributionChecker",
+            params={"cacheName": CellularAffinity.CACHE_NAME,
+                    "attr": CellularAffinity.ATTRIBUTE,
+                    "nodesPerCell": self.NUM_NODES},
+            version=ignite_version)
+
+        checker.start()

Review comment:
       For now, any application MUST return "IGNITE_APPLICATION_INITIALIZED" and "IGNITE_APPLICATION_FINISHED" (both), otherwise, it will fail with an error. 
   "IGNITE_APPLICATION_FINISHED" can be produced only in case of success:
   ```
       protected void markFinished() {
           assert !finished;
   
           log.info(APP_FINISHED); // "IGNITE_APPLICATION_FINISHED"
   
           finished = true;
       }
   ```
   
   Checker perform checks can be fount inside java class, that assertion do we need here?




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



[GitHub] [ignite] ivandasch commented on a change in pull request #8130: Cellular affinity test

Posted by GitBox <gi...@apache.org>.
ivandasch commented on a change in pull request #8130:
URL: https://github.com/apache/ignite/pull/8130#discussion_r467019839



##########
File path: modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/cellular_affinity_test/CellularAffinityBackupFilter.java
##########
@@ -0,0 +1,59 @@
+/*
+ * 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.List;
+import java.util.Objects;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.lang.IgniteBiPredicate;
+
+/**
+ *
+ */
+public class CellularAffinityBackupFilter implements IgniteBiPredicate<ClusterNode, List<ClusterNode>> {
+    /** */
+    private static final long serialVersionUID = 1L;
+
+    /** Attribute name. */
+    private final String attrName;
+
+    /**
+     * @param attrName The attribute name for the attribute to compare.
+     */
+    public CellularAffinityBackupFilter(String attrName) {
+        this.attrName = attrName;
+    }
+
+    /**
+     * Defines a predicate which returns {@code true} if a node is acceptable for a backup
+     * or {@code false} otherwise. An acceptable node is one where its attribute value
+     * is exact match with previously selected nodes.  If an attribute does not
+     * exist on exactly one node of a pair, then the attribute does not match.  If the attribute
+     * does not exist both nodes of a pair, then the attribute matches.
+     *
+     * @param candidate          A node that is a candidate for becoming a backup node for a partition.
+     * @param previouslySelected A list of primary/backup nodes already chosen for a partition.
+     *                           The primary is first.
+     */
+    @Override public boolean apply(ClusterNode candidate, List<ClusterNode> previouslySelected) {
+        for (ClusterNode node : previouslySelected)
+            return Objects.equals(candidate.attribute(attrName), node.attribute(attrName));
+
+        return true;
+    }
+}

Review comment:
       Oops, missing newline

##########
File path: modules/ducktests/tests/ignitetest/tests/cellular_affinity_test.py
##########
@@ -0,0 +1,123 @@
+# 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.
+
+"""
+This module contains Cellular Affinity tests.
+"""
+
+from ducktape.mark import parametrize
+from ducktape.mark.resource import cluster
+from jinja2 import Template
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.tests.utils.ignite_test import IgniteTest
+from ignitetest.tests.utils.version import DEV_BRANCH, IgniteVersion
+
+
+# pylint: disable=W0223
+class CellularAffinity(IgniteTest):
+    """
+    Tests Cellular Affinity scenarios.
+    """
+    NUM_NODES = 3
+
+    ATTRIBUTE = "CELL"
+
+    CACHE_NAME = "test-cache"
+
+    CONFIG_TEMPLATE = """
+            <property name="cacheConfiguration">
+                <list>
+                    <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                        <property name="affinity">
+                            <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
+                                <property name="affinityBackupFilter">
+                                    <bean class="org.apache.ignite.internal.ducktest.tests.cellular_affinity_test.CellularAffinityBackupFilter">
+                                        <constructor-arg value="{{ attr }}"/>
+                                    </bean>
+                                </property>
+                            </bean>
+                        </property>
+                        <property name="name" value="{{ cacheName }}"/>
+                        <property name="backups" value="{{ nodes }}"/> 
+                    </bean>
+                </list>
+            </property>
+        """
+
+    @staticmethod
+    def properties():
+        """
+        :return: Configuration properties.
+        """
+        return Template(CellularAffinity.CONFIG_TEMPLATE) \
+            .render(nodes=CellularAffinity.NUM_NODES,  # bigger than cell capacity (to handle single cell useless test)
+                    attr=CellularAffinity.ATTRIBUTE,
+                    cacheName=CellularAffinity.CACHE_NAME)
+
+    def __init__(self, test_context):
+        super(CellularAffinity, self).__init__(test_context=test_context)
+
+    def setUp(self):
+        pass
+
+    def teardown(self):
+        pass
+
+    @cluster(num_nodes=NUM_NODES * 3 + 1)
+    @parametrize(version=str(DEV_BRANCH))
+    def test(self, version):
+        """
+        Test Cellular Affinity scenario (partition distribution).
+        """
+        ignite_version = IgniteVersion(version)
+
+        ignites1 = IgniteService(

Review comment:
       Smells like a copy-paste? I suppose that service start can be extracted in separate method (may be nested method is better?)

##########
File path: modules/ducktests/tests/ignitetest/tests/cellular_affinity_test.py
##########
@@ -0,0 +1,123 @@
+# 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.
+
+"""
+This module contains Cellular Affinity tests.
+"""
+
+from ducktape.mark import parametrize
+from ducktape.mark.resource import cluster
+from jinja2 import Template
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.tests.utils.ignite_test import IgniteTest
+from ignitetest.tests.utils.version import DEV_BRANCH, IgniteVersion
+
+
+# pylint: disable=W0223
+class CellularAffinity(IgniteTest):
+    """
+    Tests Cellular Affinity scenarios.
+    """
+    NUM_NODES = 3
+
+    ATTRIBUTE = "CELL"
+
+    CACHE_NAME = "test-cache"
+
+    CONFIG_TEMPLATE = """
+            <property name="cacheConfiguration">
+                <list>
+                    <bean class="org.apache.ignite.configuration.CacheConfiguration">
+                        <property name="affinity">
+                            <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
+                                <property name="affinityBackupFilter">
+                                    <bean class="org.apache.ignite.internal.ducktest.tests.cellular_affinity_test.CellularAffinityBackupFilter">
+                                        <constructor-arg value="{{ attr }}"/>
+                                    </bean>
+                                </property>
+                            </bean>
+                        </property>
+                        <property name="name" value="{{ cacheName }}"/>
+                        <property name="backups" value="{{ nodes }}"/> 
+                    </bean>
+                </list>
+            </property>
+        """
+
+    @staticmethod
+    def properties():
+        """
+        :return: Configuration properties.
+        """
+        return Template(CellularAffinity.CONFIG_TEMPLATE) \
+            .render(nodes=CellularAffinity.NUM_NODES,  # bigger than cell capacity (to handle single cell useless test)
+                    attr=CellularAffinity.ATTRIBUTE,
+                    cacheName=CellularAffinity.CACHE_NAME)
+
+    def __init__(self, test_context):
+        super(CellularAffinity, self).__init__(test_context=test_context)
+
+    def setUp(self):
+        pass
+
+    def teardown(self):
+        pass
+
+    @cluster(num_nodes=NUM_NODES * 3 + 1)
+    @parametrize(version=str(DEV_BRANCH))
+    def test(self, version):
+        """
+        Test Cellular Affinity scenario (partition distribution).
+        """
+        ignite_version = IgniteVersion(version)
+
+        ignites1 = IgniteService(
+            self.test_context,
+            num_nodes=CellularAffinity.NUM_NODES,
+            version=ignite_version,
+            properties=self.properties(),
+            jvm_opts=['-D' + CellularAffinity.ATTRIBUTE + '=1'])
+
+        ignites1.start()
+
+        ignites2 = IgniteService(
+            self.test_context,
+            num_nodes=CellularAffinity.NUM_NODES,
+            version=ignite_version,
+            properties=self.properties(),
+            jvm_opts=['-D' + CellularAffinity.ATTRIBUTE + '=2'])
+
+        ignites2.start()
+
+        ignites3 = IgniteService(
+            self.test_context,
+            num_nodes=CellularAffinity.NUM_NODES,
+            version=ignite_version,
+            properties=self.properties(),
+            jvm_opts=['-D' + CellularAffinity.ATTRIBUTE + '=XXX', '-DRANDOM=42'])
+
+        ignites3.start()
+
+        checker = IgniteApplicationService(
+            self.test_context,
+            java_class_name="org.apache.ignite.internal.ducktest.tests.cellular_affinity_test.DistributionChecker",
+            params={"cacheName": CellularAffinity.CACHE_NAME,
+                    "attr": CellularAffinity.ATTRIBUTE,
+                    "nodesPerCell": self.NUM_NODES},
+            version=ignite_version)
+
+        checker.start()

Review comment:
       Test without assertions or meauserements looks a little bit weird. May be assert smth in checker log? (log_monitor and wait_until, I mean)

##########
File path: modules/ducktests/tests/ignitetest/services/utils/ignite_aware.py
##########
@@ -47,10 +47,14 @@ class IgniteAwareService(BackgroundThreadService):
     }
 
     # pylint: disable=R0913
-    def __init__(self, context, num_nodes, modules, client_mode, version, properties):
+    def __init__(self, context, num_nodes, modules, client_mode, version, properties, jvm_options):
         super(IgniteAwareService, self).__init__(context, num_nodes)
 
-        self.jvm_options = context.globals.get("jvm_opts", "")
+        global_jvm_options = context.globals.get("jvm_opts", "")
+
+        service_jvm_options = " ".join(map(lambda x: '-J' + x, jvm_options)) if jvm_options else ""
+
+        self.jvm_options = " ".join(filter(None, [global_jvm_options, service_jvm_options]))

Review comment:
       Cool! 




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