SwirMix commented on a change in pull request #8362: URL: https://github.com/apache/ignite/pull/8362#discussion_r509112197
########## File path: modules/ducktests/tests/ignitetest/tests/client_in_out_test.py ########## @@ -0,0 +1,173 @@ +# 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 client tests +""" +import time +from ducktape.mark import parametrize +from ignitetest.services.ignite import IgniteService +from ignitetest.services.ignite_app import IgniteApplicationService +from ignitetest.services.utils.control_utility import ControlUtility +from ignitetest.services.utils.ignite_configuration.cache import CacheConfiguration +from ignitetest.services.utils.ignite_configuration import IgniteConfiguration +from ignitetest.utils import ignite_versions +from ignitetest.utils.ignite_test import IgniteTest +from ignitetest.utils.version import DEV_BRANCH, V_2_8_1, IgniteVersion + + +# pylint: disable=W0223 +class ClientTest(IgniteTest): + """ + cluster - cluster size + CACHE_NAME - name of the cache to create for the test. + PACING - the frequency of the operation on clients (ms). + JAVA_CLIENT_CLASS_NAME - running classname. + client_work_time - clients working time (s). + iteration_count - the number of iterations of starting and stopping client nodes (s). + static_clients - the number of permanently employed clients. + temp_client - number of clients who come log in and out. + """ + + CACHE_NAME = "simple-tx-cache" + PACING = 10 + JAVA_CLIENT_CLASS_NAME = "org.apache.ignite.internal.ducktest.tests.start_stop_client.IgniteCachePutClient" + + @ignite_versions(str(V_2_8_1), str(DEV_BRANCH)) + @parametrize(cluster=7, + static_clients=2, + temp_client=3, + iteration_count=3, + client_work_time=30) + # pylint: disable=R0913 + def test_ignite_start_stop_nodes(self, ignite_version, + cluster, static_clients, temp_client, iteration_count, client_work_time): + """ + Start and stop clients node test without kill java process. + Check topology. + """ + self.ignite_start_stop(ignite_version, False, cluster, static_clients, + temp_client, iteration_count, client_work_time) + + @ignite_versions(str(V_2_8_1), str(DEV_BRANCH)) + @parametrize(cluster=7, + static_clients=2, + temp_client=3, + iteration_count=3, + client_work_time=30) + # pylint: disable=R0913 + def test_ignite_kill_start_nodes(self, ignite_version, + cluster, static_clients, temp_client, iteration_count, client_work_time): + """ + Start and kill client nodes, Check topology + """ + self.ignite_start_stop(ignite_version, True, cluster, static_clients, + temp_client, iteration_count, client_work_time) + + # pylint: disable=R0914 + # pylint: disable=R0913 + def ignite_start_stop(self, ignite_version, kill_temp_nodes, + cluster, static_clients_num, temp_client, iteration_count, client_work_time): + """ + Test for starting and stopping fat clients. + """ + + servers_count = cluster - static_clients_num - temp_client + + current_top_v = servers_count + # Topology version after test. + fin_top_ver = servers_count + (2 * static_clients_num) + (2 * iteration_count * temp_client) + + server_cfg = IgniteConfiguration( + version=IgniteVersion(ignite_version), + caches=[CacheConfiguration(name=self.CACHE_NAME, backups=1, atomicity_mode='TRANSACTIONAL')] + ) + + ignite = IgniteService(self.test_context, server_cfg, num_nodes=servers_count) + control_utility = ControlUtility(ignite, self.test_context) + + client_cfg = server_cfg._replace(client_mode=True) + + static_clients = IgniteApplicationService( + self.test_context, + client_cfg, + java_class_name=self.JAVA_CLIENT_CLASS_NAME, + num_nodes=static_clients_num, + params={"cacheName": self.CACHE_NAME, + "pacing": self.PACING}) + + temp_clients = IgniteApplicationService( + self.test_context, + client_cfg, + java_class_name=self.JAVA_CLIENT_CLASS_NAME, + num_nodes=temp_client, + params={"cacheName": self.CACHE_NAME, + "pacing": self.PACING}) + + ignite.start() + + static_clients.start() + + current_top_v += static_clients_num + check_topology(control_utility, current_top_v) + + # Start / stop temp_clients node. Check cluster. + for i in range(iteration_count): + self.logger.debug(f'Starting iteration: {i}.') + + temp_clients.start() + current_top_v += temp_client + + static_clients.await_event(f'ver={current_top_v}, locNode=', timeout_sec=80, + from_the_beginning=True, backoff_sec=1) + check_topology(control_utility, current_top_v) + + temp_clients.await_event(f'clients={static_clients_num + temp_client}', + timeout_sec=80, + from_the_beginning=True, + backoff_sec=1) + + time.sleep(client_work_time) + stop_service_nodes(temp_clients, kill_temp_nodes) + + current_top_v += temp_client + + static_clients.await_event(f'ver={current_top_v}, locNode=', timeout_sec=80, + from_the_beginning=True, backoff_sec=0.1) + static_clients.stop() + + check_topology(control_utility, fin_top_ver) + + +def stop_service_nodes(service: IgniteApplicationService, kill_nodes): + """ + Base service stop command. + If kill_nodes=True kill node. + If kill_nodes=False then the node is shutting down correctly + """ + if kill_nodes: + for node in service.nodes: + service.stop_node(node=node, clean_shutdown=False) + else: + service.stop(clean_shutdown=True) Review comment: the base timeout of 10 seconds was not enough to register completion in the base method. However, when they are completed sequentially, I fit into the timeout ---------------------------------------------------------------- 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]
