def test(self, ignite_version, load_type): """ Tests PME-free switch scenario (node stop). """ data = {} caches = [CacheConfiguration(name='test-cache', backups=2, atomicity_mode='TRANSACTIONAL')] l_type = LoadType.construct_from(load_type) # Checking PME (before 2.8) vs PME-free (2.8+) switch duration, but # focusing on switch duration (which depends on caches amount) when long_txs is false and # on waiting for previously started txs before the switch (which depends on txs duration) when long_txs of true. if l_type is LoadType.EXTRA_CACHES: for idx in range(1, self.EXTRA_CACHES_AMOUNT): caches.append(CacheConfiguration(name="cache-%d" % idx, backups=2, atomicity_mode='TRANSACTIONAL')) config = IgniteConfiguration(version=IgniteVersion(ignite_version), caches=caches, cluster_state="INACTIVE") num_nodes = len(self.test_context.cluster) - 2 self.test_context.logger.info("Nodes amount calculated as %d." % num_nodes) ignites = IgniteService(self.test_context, config, num_nodes=num_nodes) ignites.start() if IgniteVersion(ignite_version) >= V_2_8_0: ControlUtility(ignites).disable_baseline_auto_adjust() ControlUtility(ignites).activate() client_config = config._replace(client_mode=True, discovery_spi=from_ignite_cluster(ignites, slice(0, num_nodes - 1))) long_tx_streamer = IgniteApplicationService( self.test_context, client_config, java_class_name="org.apache.ignite.internal.ducktest.tests.pme_free_switch_test.LongTxStreamerApplication", params={"cacheName": "test-cache"}, startup_timeout_sec=180) if l_type is LoadType.LONG_TXS: long_tx_streamer.start() single_key_tx_streamer = IgniteApplicationService( self.test_context, client_config, java_class_name="org.apache.ignite.internal.ducktest.tests.pme_free_switch_test." "SingleKeyTxStreamerApplication", params={"cacheName": "test-cache", "warmup": 1000}, startup_timeout_sec=180) single_key_tx_streamer.start() ignites.stop_node(ignites.nodes[num_nodes - 1]) single_key_tx_streamer.await_event("Node left topology", 60, from_the_beginning=True) if l_type is LoadType.LONG_TXS: time.sleep(30) # keeping txs alive for 30 seconds. long_tx_streamer.stop_async() single_key_tx_streamer.await_event("Node left topology", 60, from_the_beginning=True) single_key_tx_streamer.await_event("APPLICATION_STREAMED", 60) # waiting for streaming continuation. single_key_tx_streamer.stop() data["Worst latency (ms)"] = single_key_tx_streamer.extract_result("WORST_LATENCY") data["Streamed txs"] = single_key_tx_streamer.extract_result("STREAMED") data["Measure duration (ms)"] = single_key_tx_streamer.extract_result("MEASURE_DURATION") data["Server nodes"] = num_nodes return data
def await_event(service: IgniteApplicationService, message): """ :param service: target service for wait :param message: message """ service.await_event(message, timeout_sec=80, from_the_beginning=True)
def test_logging(self, ignite_version): """ Tests logging goes to the correct file (consistency.log) when default AI config used. """ cfg_filename = "ignite-default-log4j.xml" ignites = IgniteApplicationService( self.test_context, IgniteConfiguration( version=IgniteVersion(ignite_version), cluster_state="INACTIVE", properties=self.PROPERTIES, log4j_config=cfg_filename # default AI config (will be generated below) ), java_class_name="org.apache.ignite.internal.ducktest.tests.control_utility.InconsistentNodeApplication", params={ "cacheName": self.CACHE_NAME, "amount": 1024, "parts": 1, "tx": False }, startup_timeout_sec=180, num_nodes=len(self.test_context.cluster)) for node in ignites.nodes: # copying default AI config with log path replacement ignites.init_persistent(node) cfg_file = f"{ignites.config_dir}/{cfg_filename}" ignites.exec_command(node, f"cp {ignites.home_dir}/config/ignite-log4j.xml {cfg_file}") orig = "${IGNITE_HOME}/work/log".replace('/', '\\/') fixed = ignites.log_dir.replace('/', '\\/') ignites.exec_command(node, f"sed -i 's/{orig}/{fixed}/g' {cfg_file}") ignites.start() control_utility = ControlUtility(ignites) control_utility.activate() ignites.await_event("APPLICATION_STREAMING_FINISHED", 60, from_the_beginning=True) try: control_utility.idle_verify() # making sure we have broken data raise IgniteExecutionException("Fail.") except AssertionError: pass control_utility.check_consistency(f"repair {self.CACHE_NAME} 0") # checking/repairing message = "Cache consistency violations recorded." ignites.await_event(message, 60, from_the_beginning=True, log_file="consistency.log") try: ignites.await_event(message, 10, from_the_beginning=True) raise IgniteExecutionException("Fail.") except TimeoutError: pass