kafka_neu-1778570057504.zip-extract/kafka-4.2.0-src/tests/kafkatest/services/log_compaction_tester.py

Path
kafka_neu-1778570057504.zip-extract/kafka-4.2.0-src/tests/kafkatest/services/log_compaction_tester.py
Status
scanned
Type
file
Name
log_compaction_tester.py
Extension
.py
Programming language
Python
Mime type
text/x-script.python
File type
Python script, ASCII text executable
Tag

      
    
Rootfs path

      
    
Size
4484 (4.4 KB)
MD5
a83d345cb87e8cd949945b1c45b806fc
SHA1
763cd1b683edf7b16b3e47b253f2cf12c361d484
SHA256
856046e72bb26a35a17115a394df013b6d7f4258aa238770d46352c314337558
SHA512

      
    
SHA1_git
e932212864ff85c1deab8e0237d2ac645422f964
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
log_compaction_tester.py | 4.4 KB |

# 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. import os from ducktape.services.background_thread import BackgroundThreadService from kafkatest.directory_layout.kafka_path import KafkaPathResolverMixin, CORE_LIBS_JAR_NAME, CORE_DEPENDANT_TEST_LIBS_JAR_NAME from kafkatest.services.security.security_config import SecurityConfig from kafkatest.version import DEV_BRANCH class LogCompactionTester(KafkaPathResolverMixin, BackgroundThreadService): OUTPUT_DIR = "/mnt/logcompaction_tester" LOG_PATH = os.path.join(OUTPUT_DIR, "logcompaction_tester_stdout.log") VERIFICATION_STRING = "Data verification is completed" logs = { "tool_logs": { "path": LOG_PATH, "collect_default": True} } def __init__(self, context, kafka, security_protocol="PLAINTEXT", stop_timeout_sec=30, tls_version=None, compression_config={}): super(LogCompactionTester, self).__init__(context, 1) self.kafka = kafka self.security_protocol = security_protocol self.tls_version = tls_version self.security_config = SecurityConfig(self.context, security_protocol, tls_version=tls_version) self.stop_timeout_sec = stop_timeout_sec self.compression_config = compression_config self.log_compaction_completed = False def _worker(self, idx, node): node.account.ssh("mkdir -p %s" % LogCompactionTester.OUTPUT_DIR) cmd = self.start_cmd(node) self.logger.info("LogCompactionTester %d command: %s" % (idx, cmd)) self.security_config.setup_node(node) for line in node.account.ssh_capture(cmd): self.logger.debug("Checking line:{}".format(line)) if line.startswith(LogCompactionTester.VERIFICATION_STRING): self.log_compaction_completed = True def start_cmd(self, node): core_libs_jar = self.path.jar(CORE_LIBS_JAR_NAME, DEV_BRANCH) core_dependant_test_libs_jar = self.path.jar(CORE_DEPENDANT_TEST_LIBS_JAR_NAME, DEV_BRANCH) cmd = "for file in %s; do CLASSPATH=$CLASSPATH:$file; done;" % core_libs_jar cmd += " for file in %s; do CLASSPATH=$CLASSPATH:$file; done;" % core_dependant_test_libs_jar cmd += " export CLASSPATH;" cmd += self.path.script("kafka-run-class.sh", node) cmd += " %s" % self.java_class_name() cmd += " --bootstrap-server %s --messages 1000000 --sleep 20 --duplicates 10 --percent-deletes 10" % self.kafka.bootstrap_servers(self.security_protocol) if 'type' in self.compression_config: cmd += " --compression-type %s" % self.compression_config['type'] if 'level' in self.compression_config: cmd += " --compression-level %s" % self.compression_config['level'] cmd += " 2>> %s | tee -a %s &" % (self.logs["tool_logs"]["path"], self.logs["tool_logs"]["path"]) return cmd def stop_node(self, node): node.account.kill_java_processes(self.java_class_name(), clean_shutdown=True, allow_fail=True) stopped = self.wait_node(node, timeout_sec=self.stop_timeout_sec) assert stopped, "Node %s: did not stop within the specified timeout of %s seconds" % \ (str(node.account), str(self.stop_timeout_sec)) def clean_node(self, node): node.account.kill_java_processes(self.java_class_name(), clean_shutdown=False, allow_fail=True) node.account.ssh("rm -rf %s" % LogCompactionTester.OUTPUT_DIR, allow_fail=False) def java_class_name(self): return "org.apache.kafka.tools.LogCompactionTester" @property def is_done(self): return self.log_compaction_completed
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
21.17
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 8 8
Package URL License Primary language
pkg:pypi/kafkatest@4.2.0 apache-2.0 Python