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/11 07:51:20 UTC

[GitHub] [ignite] anton-vinogradov commented on a change in pull request #8127: Ignite ducktape control sh

anton-vinogradov commented on a change in pull request #8127:
URL: https://github.com/apache/ignite/pull/8127#discussion_r468391992



##########
File path: modules/ducktests/tests/ignitetest/tests/control_utility_test.py
##########
@@ -0,0 +1,235 @@
+# 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 control.sh utility tests.
+"""
+from ducktape.mark import parametrize
+from ducktape.mark.resource import cluster
+from ducktape.utils.util import wait_until
+from jinja2 import Template
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.utils.control_utility import ControlUtility, ControlUtilityError
+from ignitetest.tests.utils.ignite_test import IgniteTest
+from ignitetest.tests.utils.version import DEV_BRANCH, LATEST_2_8, IgniteVersion, LATEST_2_7, V_2_8_0
+
+
+# pylint: disable=W0223
+class BaselineTests(IgniteTest):
+    """
+    Tests baseline command
+    """
+    NUM_NODES = 3
+
+    CONFIG_TEMPLATE = """
+        {% if version > "2.9.0" %}
+            <property name="clusterStateOnStart" value="INACTIVE"/>
+        {%  else %}
+            <property name="activeOnStart" value="false"/>
+        {% endif %}
+        <property name="dataStorageConfiguration">
+            <bean class="org.apache.ignite.configuration.DataStorageConfiguration">
+                <property name="defaultDataRegionConfiguration">
+                    <bean class="org.apache.ignite.configuration.DataRegionConfiguration">
+                        <property name="persistenceEnabled" value="true"/>
+                        <property name="maxSize" value="#{100L * 1024 * 1024}"/>
+                    </bean>
+                </property>
+            </bean>
+        </property>
+    """
+
+    @staticmethod
+    def properties(version):
+        """
+        Render properties for ignite node configuration.
+        """
+        return Template(BaselineTests.CONFIG_TEMPLATE) \
+            .render(version=version)
+
+    def __init__(self, test_context):
+        super(BaselineTests, self).__init__(test_context)
+        self.servers = None
+
+    @cluster(num_nodes=NUM_NODES)
+    @parametrize(version=str(DEV_BRANCH))
+    @parametrize(version=str(LATEST_2_8))
+    @parametrize(version=str(LATEST_2_7))
+    def test_baseline_set(self, version):
+        """
+        Test baseline set.
+        """
+        blt_size = self.NUM_NODES - 2
+        self.servers = self.__start_ignite_nodes(version, blt_size)
+
+        control_utility = ControlUtility(self.servers, self.test_context)
+        control_utility.activate()
+
+        # Check baseline of activated cluster.
+        baseline = control_utility.baseline()
+        self.__check_baseline_size(baseline, blt_size)
+        self.__check_nodes_in_baseline(self.servers.nodes, baseline)
+
+        # Set baseline using list of conststent ids.
+        new_node = self.__start_ignite_nodes(version, 1)
+        control_utility.set_baseline(self.servers.nodes + new_node.nodes)
+        blt_size += 1
+
+        baseline = control_utility.baseline()
+        self.__check_baseline_size(baseline, blt_size)
+        self.__check_nodes_in_baseline(new_node.nodes, baseline)
+
+        # Set baseline using topology version.
+        new_node = self.__start_ignite_nodes(version, 1)
+        _, version, _ = control_utility.cluster_state()
+        control_utility.set_baseline(version)
+        blt_size += 1
+
+        baseline = control_utility.baseline()
+        self.__check_baseline_size(baseline, blt_size)
+        self.__check_nodes_in_baseline(new_node.nodes, baseline)
+
+    @cluster(num_nodes=NUM_NODES)
+    @parametrize(version=str(DEV_BRANCH))
+    @parametrize(version=str(LATEST_2_8))
+    @parametrize(version=str(LATEST_2_7))
+    def test_baseline_add_remove(self, version):
+        """
+        Test add and remove nodes from baseline.
+        """
+        blt_size = self.NUM_NODES - 1
+        self.servers = self.__start_ignite_nodes(version, blt_size)
+
+        control_utility = ControlUtility(self.servers, self.test_context)
+
+        control_utility.activate()
+
+        # Add node to baseline.
+        new_node = self.__start_ignite_nodes(version, 1)
+        control_utility.add_to_baseline(new_node.nodes)
+        blt_size += 1
+
+        baseline = control_utility.baseline()
+        self.__check_baseline_size(baseline, blt_size)
+        self.__check_nodes_in_baseline(new_node.nodes, baseline)
+
+        # Expected failure (remove of online node is not allowed).
+        try:
+            control_utility.remove_from_baseline(new_node.nodes)
+
+            assert False, "Remove of online node from baseline should fail!"
+        except ControlUtilityError:
+            pass
+
+        # Remove of offline node from baseline.
+        new_node.stop()
+
+        self.servers.await_event("Node left topology", timeout_sec=30, from_the_beginning=True)
+
+        control_utility.remove_from_baseline(new_node.nodes)
+        blt_size -= 1
+
+        baseline = control_utility.baseline()
+        self.__check_baseline_size(baseline, blt_size)
+        self.__check_nodes_not_in_baseline(new_node.nodes, baseline)
+
+    @cluster(num_nodes=NUM_NODES)
+    @parametrize(version=str(DEV_BRANCH))
+    @parametrize(version=str(LATEST_2_8))
+    @parametrize(version=str(LATEST_2_7))
+    def test_activate_deactivate(self, version):
+        """
+        Test activate and deactivate cluster.
+        """
+        self.servers = self.__start_ignite_nodes(version, self.NUM_NODES)
+
+        control_utility = ControlUtility(self.servers, self.test_context)
+
+        control_utility.activate()
+
+        state, _, _ = control_utility.cluster_state()
+
+        assert state.lower() == 'active', 'Unexpected state %s' % state
+
+        control_utility.deactivate()
+
+        state, _, _ = control_utility.cluster_state()
+
+        assert state.lower() == 'inactive', 'Unexpected state %s' % state
+
+    @cluster(num_nodes=NUM_NODES)
+    @parametrize(version=str(DEV_BRANCH))
+    @parametrize(version=str(LATEST_2_8))
+    def test_baseline_autoadjust(self, version):
+        """
+        Test activate and deactivate cluster.
+        """
+        if version < V_2_8_0:

Review comment:
       @timoninmaxim could explain how to do this properly in detail, if possible.




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