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 2021/02/26 10:02:02 UTC

[GitHub] [ignite] anton-vinogradov commented on a change in pull request #8832: IGNITE-14228 Ducktape test of rebalance for in-memory mode

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



##########
File path: modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/DataModelGenerationApplication.java
##########
@@ -0,0 +1,94 @@
+/*
+ * 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;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.util.UUID;
+import java.util.concurrent.ThreadLocalRandom;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
+
+/**
+ *
+ */
+public class DataModelGenerationApplication extends IgniteAwareApplication {
+    /** {@inheritDoc} */
+    @Override protected void run(JsonNode jsonNode) throws Exception {
+        int cacheCnt = jsonNode.get("cacheCount").asInt();
+        int entryCnt = jsonNode.get("entryCount").asInt();
+        int entrySize = jsonNode.get("entrySize").asInt();
+
+        log.info("Creating " + cacheCnt + " caches each with " + entryCnt + " entries of " + entrySize + " bytes.");
+
+        for (int i = 1; i <= cacheCnt; i++)
+            generateCache(i, entryCnt, entrySize);
+
+        markSyncExecutionComplete();
+    }
+
+    /**
+     * @param cacheNo Cache number.
+     * @param entryCnt Entry count.
+     * @param entrySize Entry size.
+     */
+    private void generateCache(int cacheNo, int entryCnt, int entrySize) {
+        IgniteCache<Integer, DataModel> cache = ignite.createCache("test-cache-" + cacheNo);

Review comment:
       The better case is to provide type (factory/generator) via test params with some default.

##########
File path: modules/ducktests/tests/ignitetest/tests/rebalance_test.py
##########
@@ -0,0 +1,112 @@
+# 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.
+
+"""
+Module contains rebalance tests.
+"""
+
+from enum import IntEnum
+
+from ducktape.mark import matrix, defaults
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.services.utils.ignite_configuration import IgniteConfiguration
+from ignitetest.services.utils.ignite_configuration.discovery import from_ignite_cluster
+from ignitetest.utils import cluster, ignite_versions
+from ignitetest.utils.enum import constructible
+from ignitetest.utils.ignite_test import IgniteTest
+from ignitetest.utils.version import IgniteVersion, DEV_BRANCH, LATEST
+
+
+@constructible
+class Mode(IntEnum):
+    """
+    Rebalance mode.
+    """
+    IN_MEMORY = 0
+    PERSISTENT = 1
+
+
+@constructible
+class TriggerEvent(IntEnum):
+    """
+    Rebalance trigger event.
+    """
+    NODE_ENTER = 0
+    NODE_LEAVE = 1
+
+
+# pylint: disable=W0223
+class RebalanceTest(IgniteTest):
+    """
+    Tests rebalance scenarios.
+    """
+    NUM_NODES = 10
+    PRELOAD_TIMEOUT = 60
+    REBALANCE_TIMEOUT = 60
+
+    @cluster(num_nodes=NUM_NODES)
+    @ignite_versions(str(DEV_BRANCH), str(LATEST))
+    @defaults(initial_node_count=[2, 4, 8],
+              trigger_event=[TriggerEvent.NODE_ENTER, TriggerEvent.NODE_LEAVE],
+              mode=[Mode.IN_MEMORY], cache_count=[1], entry_count=[10000], entry_size=[1000])
+    def test_rebalance(self, ignite_version, initial_node_count, trigger_event,
+                       mode, cache_count, entry_count, entry_size):
+        """
+        Test performs rebalance test which consists of following steps:
+            * Start cluster.
+            * Put data to it via IgniteClientApp.
+            * Triggering a rebalance event (node enter or leave) and awaits for rebalance to finish.
+        """
+        node_config = IgniteConfiguration(version=IgniteVersion(ignite_version))
+
+        node_count = initial_node_count
+        if trigger_event is TriggerEvent.NODE_LEAVE:
+            node_count -= 1
+
+        ignites = IgniteService(self.test_context, config=node_config, num_nodes=node_count)
+        ignites.start()
+
+        ignite = IgniteService(self.test_context, node_config._replace(discovery_spi=from_ignite_cluster(ignites)),
+                               num_nodes=1)
+        if trigger_event is TriggerEvent.NODE_LEAVE:
+            ignite.start()

Review comment:
       you may just start enough nodes count by ignites.start(), which is faster than starting some and 1 after, and stop node by index.

##########
File path: modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/DataModelGenerationApplication.java
##########
@@ -0,0 +1,94 @@
+/*
+ * 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;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.util.UUID;
+import java.util.concurrent.ThreadLocalRandom;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
+
+/**
+ *
+ */
+public class DataModelGenerationApplication extends IgniteAwareApplication {

Review comment:
       Is this generate DataModel?

##########
File path: modules/ducktests/tests/ignitetest/tests/rebalance_test.py
##########
@@ -0,0 +1,112 @@
+# 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.
+
+"""
+Module contains rebalance tests.
+"""
+
+from enum import IntEnum
+
+from ducktape.mark import matrix, defaults
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.services.utils.ignite_configuration import IgniteConfiguration
+from ignitetest.services.utils.ignite_configuration.discovery import from_ignite_cluster
+from ignitetest.utils import cluster, ignite_versions
+from ignitetest.utils.enum import constructible
+from ignitetest.utils.ignite_test import IgniteTest
+from ignitetest.utils.version import IgniteVersion, DEV_BRANCH, LATEST
+
+
+@constructible
+class Mode(IntEnum):
+    """
+    Rebalance mode.
+    """
+    IN_MEMORY = 0
+    PERSISTENT = 1
+
+
+@constructible
+class TriggerEvent(IntEnum):
+    """
+    Rebalance trigger event.
+    """
+    NODE_ENTER = 0
+    NODE_LEAVE = 1
+
+
+# pylint: disable=W0223
+class RebalanceTest(IgniteTest):
+    """
+    Tests rebalance scenarios.
+    """
+    NUM_NODES = 10
+    PRELOAD_TIMEOUT = 60
+    REBALANCE_TIMEOUT = 60
+
+    @cluster(num_nodes=NUM_NODES)
+    @ignite_versions(str(DEV_BRANCH), str(LATEST))
+    @defaults(initial_node_count=[2, 4, 8],
+              trigger_event=[TriggerEvent.NODE_ENTER, TriggerEvent.NODE_LEAVE],
+              mode=[Mode.IN_MEMORY], cache_count=[1], entry_count=[10000], entry_size=[1000])
+    def test_rebalance(self, ignite_version, initial_node_count, trigger_event,
+                       mode, cache_count, entry_count, entry_size):
+        """
+        Test performs rebalance test which consists of following steps:
+            * Start cluster.
+            * Put data to it via IgniteClientApp.
+            * Triggering a rebalance event (node enter or leave) and awaits for rebalance to finish.

Review comment:
       We're not triggering event here, we're starting or stopping node which causes the rebalance :)

##########
File path: modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/DataModelGenerationApplication.java
##########
@@ -0,0 +1,94 @@
+/*
+ * 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;

Review comment:
       Use a test-related package instead.

##########
File path: modules/ducktests/tests/ignitetest/tests/rebalance_test.py
##########
@@ -0,0 +1,112 @@
+# 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.
+
+"""
+Module contains rebalance tests.
+"""
+
+from enum import IntEnum
+
+from ducktape.mark import matrix, defaults
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.services.utils.ignite_configuration import IgniteConfiguration
+from ignitetest.services.utils.ignite_configuration.discovery import from_ignite_cluster
+from ignitetest.utils import cluster, ignite_versions
+from ignitetest.utils.enum import constructible
+from ignitetest.utils.ignite_test import IgniteTest
+from ignitetest.utils.version import IgniteVersion, DEV_BRANCH, LATEST
+
+
+@constructible
+class Mode(IntEnum):
+    """
+    Rebalance mode.
+    """
+    IN_MEMORY = 0
+    PERSISTENT = 1
+
+
+@constructible
+class TriggerEvent(IntEnum):
+    """
+    Rebalance trigger event.
+    """
+    NODE_ENTER = 0
+    NODE_LEAVE = 1
+
+
+# pylint: disable=W0223
+class RebalanceTest(IgniteTest):
+    """
+    Tests rebalance scenarios.
+    """
+    NUM_NODES = 10
+    PRELOAD_TIMEOUT = 60
+    REBALANCE_TIMEOUT = 60
+
+    @cluster(num_nodes=NUM_NODES)
+    @ignite_versions(str(DEV_BRANCH), str(LATEST))
+    @defaults(initial_node_count=[2, 4, 8],
+              trigger_event=[TriggerEvent.NODE_ENTER, TriggerEvent.NODE_LEAVE],
+              mode=[Mode.IN_MEMORY], cache_count=[1], entry_count=[10000], entry_size=[1000])
+    def test_rebalance(self, ignite_version, initial_node_count, trigger_event,
+                       mode, cache_count, entry_count, entry_size):
+        """
+        Test performs rebalance test which consists of following steps:
+            * Start cluster.
+            * Put data to it via IgniteClientApp.
+            * Triggering a rebalance event (node enter or leave) and awaits for rebalance to finish.
+        """
+        node_config = IgniteConfiguration(version=IgniteVersion(ignite_version))
+
+        node_count = initial_node_count
+        if trigger_event is TriggerEvent.NODE_LEAVE:
+            node_count -= 1
+
+        ignites = IgniteService(self.test_context, config=node_config, num_nodes=node_count)
+        ignites.start()
+
+        ignite = IgniteService(self.test_context, node_config._replace(discovery_spi=from_ignite_cluster(ignites)),
+                               num_nodes=1)
+        if trigger_event is TriggerEvent.NODE_LEAVE:
+            ignite.start()
+
+        # This client just put some data to the cache.
+        app_config = node_config._replace(client_mode=True, discovery_spi=from_ignite_cluster(ignites))

Review comment:
       variable with single usage should be inlined

##########
File path: modules/ducktests/tests/ignitetest/tests/rebalance_test.py
##########
@@ -0,0 +1,112 @@
+# 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.
+
+"""
+Module contains rebalance tests.
+"""
+
+from enum import IntEnum
+
+from ducktape.mark import matrix, defaults
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.services.utils.ignite_configuration import IgniteConfiguration
+from ignitetest.services.utils.ignite_configuration.discovery import from_ignite_cluster
+from ignitetest.utils import cluster, ignite_versions
+from ignitetest.utils.enum import constructible
+from ignitetest.utils.ignite_test import IgniteTest
+from ignitetest.utils.version import IgniteVersion, DEV_BRANCH, LATEST
+
+
+@constructible
+class Mode(IntEnum):
+    """
+    Rebalance mode.
+    """
+    IN_MEMORY = 0
+    PERSISTENT = 1
+
+
+@constructible
+class TriggerEvent(IntEnum):
+    """
+    Rebalance trigger event.
+    """
+    NODE_ENTER = 0
+    NODE_LEAVE = 1

Review comment:
       The better case is to use naming from AI.
   JOIN/LEFT

##########
File path: modules/ducktests/tests/ignitetest/tests/rebalance_test.py
##########
@@ -0,0 +1,112 @@
+# 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.
+
+"""
+Module contains rebalance tests.
+"""
+
+from enum import IntEnum
+
+from ducktape.mark import matrix, defaults
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.services.utils.ignite_configuration import IgniteConfiguration
+from ignitetest.services.utils.ignite_configuration.discovery import from_ignite_cluster
+from ignitetest.utils import cluster, ignite_versions
+from ignitetest.utils.enum import constructible
+from ignitetest.utils.ignite_test import IgniteTest
+from ignitetest.utils.version import IgniteVersion, DEV_BRANCH, LATEST
+
+
+@constructible
+class Mode(IntEnum):
+    """
+    Rebalance mode.
+    """
+    IN_MEMORY = 0
+    PERSISTENT = 1

Review comment:
       Looks like a better case is to have data region settings instead of the magic enum values.
   Let's have two tests instead? BTW, avoid code duplication if possible.

##########
File path: modules/ducktests/tests/ignitetest/tests/rebalance_test.py
##########
@@ -0,0 +1,112 @@
+# 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.
+
+"""
+Module contains rebalance tests.
+"""
+
+from enum import IntEnum
+
+from ducktape.mark import matrix, defaults
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.services.utils.ignite_configuration import IgniteConfiguration
+from ignitetest.services.utils.ignite_configuration.discovery import from_ignite_cluster
+from ignitetest.utils import cluster, ignite_versions
+from ignitetest.utils.enum import constructible
+from ignitetest.utils.ignite_test import IgniteTest
+from ignitetest.utils.version import IgniteVersion, DEV_BRANCH, LATEST
+
+
+@constructible
+class Mode(IntEnum):
+    """
+    Rebalance mode.
+    """
+    IN_MEMORY = 0
+    PERSISTENT = 1
+
+
+@constructible
+class TriggerEvent(IntEnum):
+    """
+    Rebalance trigger event.
+    """
+    NODE_ENTER = 0
+    NODE_LEAVE = 1
+
+
+# pylint: disable=W0223
+class RebalanceTest(IgniteTest):
+    """
+    Tests rebalance scenarios.
+    """
+    NUM_NODES = 10
+    PRELOAD_TIMEOUT = 60
+    REBALANCE_TIMEOUT = 60

Review comment:
       Looks like 60 second is not enough for real testing.

##########
File path: modules/ducktests/tests/ignitetest/tests/rebalance_test.py
##########
@@ -0,0 +1,112 @@
+# 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.
+
+"""
+Module contains rebalance tests.
+"""
+
+from enum import IntEnum
+
+from ducktape.mark import matrix, defaults
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.services.utils.ignite_configuration import IgniteConfiguration
+from ignitetest.services.utils.ignite_configuration.discovery import from_ignite_cluster
+from ignitetest.utils import cluster, ignite_versions
+from ignitetest.utils.enum import constructible
+from ignitetest.utils.ignite_test import IgniteTest
+from ignitetest.utils.version import IgniteVersion, DEV_BRANCH, LATEST
+
+
+@constructible
+class Mode(IntEnum):
+    """
+    Rebalance mode.
+    """
+    IN_MEMORY = 0
+    PERSISTENT = 1
+
+
+@constructible
+class TriggerEvent(IntEnum):
+    """
+    Rebalance trigger event.
+    """
+    NODE_ENTER = 0
+    NODE_LEAVE = 1
+
+
+# pylint: disable=W0223
+class RebalanceTest(IgniteTest):
+    """
+    Tests rebalance scenarios.
+    """
+    NUM_NODES = 10
+    PRELOAD_TIMEOUT = 60
+    REBALANCE_TIMEOUT = 60
+
+    @cluster(num_nodes=NUM_NODES)
+    @ignite_versions(str(DEV_BRANCH), str(LATEST))
+    @defaults(initial_node_count=[2, 4, 8],
+              trigger_event=[TriggerEvent.NODE_ENTER, TriggerEvent.NODE_LEAVE],
+              mode=[Mode.IN_MEMORY], cache_count=[1], entry_count=[10000], entry_size=[1000])
+    def test_rebalance(self, ignite_version, initial_node_count, trigger_event,
+                       mode, cache_count, entry_count, entry_size):
+        """
+        Test performs rebalance test which consists of following steps:
+            * Start cluster.
+            * Put data to it via IgniteClientApp.
+            * Triggering a rebalance event (node enter or leave) and awaits for rebalance to finish.
+        """
+        node_config = IgniteConfiguration(version=IgniteVersion(ignite_version))
+
+        node_count = initial_node_count
+        if trigger_event is TriggerEvent.NODE_LEAVE:
+            node_count -= 1
+
+        ignites = IgniteService(self.test_context, config=node_config, num_nodes=node_count)
+        ignites.start()
+
+        ignite = IgniteService(self.test_context, node_config._replace(discovery_spi=from_ignite_cluster(ignites)),
+                               num_nodes=1)

Review comment:
       should be relocated to if's body

##########
File path: modules/ducktests/tests/ignitetest/tests/rebalance_test.py
##########
@@ -0,0 +1,112 @@
+# 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.
+
+"""
+Module contains rebalance tests.
+"""
+
+from enum import IntEnum
+
+from ducktape.mark import matrix, defaults
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.services.utils.ignite_configuration import IgniteConfiguration
+from ignitetest.services.utils.ignite_configuration.discovery import from_ignite_cluster
+from ignitetest.utils import cluster, ignite_versions
+from ignitetest.utils.enum import constructible
+from ignitetest.utils.ignite_test import IgniteTest
+from ignitetest.utils.version import IgniteVersion, DEV_BRANCH, LATEST
+
+
+@constructible
+class Mode(IntEnum):
+    """
+    Rebalance mode.
+    """
+    IN_MEMORY = 0
+    PERSISTENT = 1
+
+
+@constructible
+class TriggerEvent(IntEnum):
+    """
+    Rebalance trigger event.
+    """
+    NODE_ENTER = 0
+    NODE_LEAVE = 1
+
+
+# pylint: disable=W0223
+class RebalanceTest(IgniteTest):
+    """
+    Tests rebalance scenarios.
+    """
+    NUM_NODES = 10
+    PRELOAD_TIMEOUT = 60
+    REBALANCE_TIMEOUT = 60
+
+    @cluster(num_nodes=NUM_NODES)
+    @ignite_versions(str(DEV_BRANCH), str(LATEST))
+    @defaults(initial_node_count=[2, 4, 8],
+              trigger_event=[TriggerEvent.NODE_ENTER, TriggerEvent.NODE_LEAVE],
+              mode=[Mode.IN_MEMORY], cache_count=[1], entry_count=[10000], entry_size=[1000])
+    def test_rebalance(self, ignite_version, initial_node_count, trigger_event,
+                       mode, cache_count, entry_count, entry_size):
+        """
+        Test performs rebalance test which consists of following steps:
+            * Start cluster.
+            * Put data to it via IgniteClientApp.
+            * Triggering a rebalance event (node enter or leave) and awaits for rebalance to finish.
+        """
+        node_config = IgniteConfiguration(version=IgniteVersion(ignite_version))

Review comment:
       AFAIR, we may avoid explicit IgniteVersion creation here.

##########
File path: modules/ducktests/tests/ignitetest/tests/rebalance_test.py
##########
@@ -0,0 +1,112 @@
+# 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.
+
+"""
+Module contains rebalance tests.
+"""
+
+from enum import IntEnum
+
+from ducktape.mark import matrix, defaults
+
+from ignitetest.services.ignite import IgniteService
+from ignitetest.services.ignite_app import IgniteApplicationService
+from ignitetest.services.utils.ignite_configuration import IgniteConfiguration
+from ignitetest.services.utils.ignite_configuration.discovery import from_ignite_cluster
+from ignitetest.utils import cluster, ignite_versions
+from ignitetest.utils.enum import constructible
+from ignitetest.utils.ignite_test import IgniteTest
+from ignitetest.utils.version import IgniteVersion, DEV_BRANCH, LATEST
+
+
+@constructible
+class Mode(IntEnum):
+    """
+    Rebalance mode.
+    """
+    IN_MEMORY = 0
+    PERSISTENT = 1
+
+
+@constructible
+class TriggerEvent(IntEnum):
+    """
+    Rebalance trigger event.
+    """
+    NODE_ENTER = 0
+    NODE_LEAVE = 1
+
+
+# pylint: disable=W0223
+class RebalanceTest(IgniteTest):

Review comment:
       should this replace add_node_rebalance_test.py?

##########
File path: modules/ducktests/src/main/java/org/apache/ignite/internal/ducktest/tests/DataModelGenerationApplication.java
##########
@@ -0,0 +1,94 @@
+/*
+ * 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;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.util.UUID;
+import java.util.concurrent.ThreadLocalRandom;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication;
+
+/**
+ *
+ */
+public class DataModelGenerationApplication extends IgniteAwareApplication {
+    /** {@inheritDoc} */
+    @Override protected void run(JsonNode jsonNode) throws Exception {
+        int cacheCnt = jsonNode.get("cacheCount").asInt();
+        int entryCnt = jsonNode.get("entryCount").asInt();
+        int entrySize = jsonNode.get("entrySize").asInt();
+
+        log.info("Creating " + cacheCnt + " caches each with " + entryCnt + " entries of " + entrySize + " bytes.");
+
+        for (int i = 1; i <= cacheCnt; i++)
+            generateCache(i, entryCnt, entrySize);
+
+        markSyncExecutionComplete();
+    }
+
+    /**
+     * @param cacheNo Cache number.
+     * @param entryCnt Entry count.
+     * @param entrySize Entry size.
+     */
+    private void generateCache(int cacheNo, int entryCnt, int entrySize) {
+        IgniteCache<Integer, DataModel> cache = ignite.createCache("test-cache-" + cacheNo);
+
+        try (IgniteDataStreamer<Integer, DataModel> stmr = ignite.dataStreamer(cache.getName())) {
+            for (int i = 0; i < entryCnt; i++) {
+                stmr.addData(i, newDataModel(entrySize));
+
+                if (i % 10_000 == 0)
+                    log.info("Streamed " + i + " entries");
+            }
+        }
+    }
+
+    /**
+     * @param payloadSize Payload size.
+     */
+    private DataModel newDataModel(int payloadSize) {
+        String randomStr = UUID.randomUUID().toString();
+
+        byte[] payload = new byte[payloadSize - randomStr.length()];
+
+        ThreadLocalRandom.current().nextBytes(payload);

Review comment:
       Not sure it's necessary to fill data with random values.
   Random strings theoretically may affect rebalance speed because of JVM optimizations.
   But, byte array content may be just nulls?




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