def cleanup_cluster(cluster, test_path, log_watch_thread=None): with log_filter('cassandra'): # quiet noise from driver when nodes start going down if KEEP_TEST_DIR: cluster.stop(gently=RECORD_COVERAGE) else: # when recording coverage the jvm has to exit normally # or the coverage information is not written by the jacoco agent # otherwise we can just kill the process if RECORD_COVERAGE: cluster.stop(gently=True) # Cleanup everything: try: if log_watch_thread: stop_active_log_watch(log_watch_thread) finally: debug("removing ccm cluster {name} at: {path}".format(name=cluster.name, path=test_path)) cluster.remove() debug("clearing ssl stores from [{0}] directory".format(test_path)) for filename in ('keystore.jks', 'truststore.jks', 'ccm_node.cer'): try: os.remove(os.path.join(test_path, filename)) except OSError as e: # once we port to py3, which has better reporting for exceptions raised while # handling other excpetions, we should just assert e.errno == errno.ENOENT if e.errno != errno.ENOENT: # ENOENT = no such file or directory raise os.rmdir(test_path) cleanup_last_test_dir()
def patient_cql_connection(self, node, keyspace=None, user=None, password=None, timeout=30, compression=True, protocol_version=None, port=None, ssl_opts=None): """ Returns a connection after it stops throwing NoHostAvailables due to not being ready. If the timeout is exceeded, the exception is raised. """ if is_win(): timeout *= 2 expected_log_lines = ('Control connection failed to connect, shutting down Cluster:', '[control connection] Error connecting to ') with log_filter('cassandra.cluster', expected_log_lines): session = retry_till_success( self.cql_connection, node, keyspace=keyspace, user=user, password=password, timeout=timeout, compression=compression, protocol_version=protocol_version, port=port, ssl_opts=ssl_opts, bypassed_exception=NoHostAvailable ) return session
def cleanup_cluster(self): with log_filter('cassandra'): # quiet noise from driver when nodes start going down if self.dtest_config.keep_test_dir: self.cluster.stop(gently=self.dtest_config.enable_jacoco_code_coverage) else: # when recording coverage the jvm has to exit normally # or the coverage information is not written by the jacoco agent # otherwise we can just kill the process if self.dtest_config.enable_jacoco_code_coverage: self.cluster.stop(gently=True) # Cleanup everything: try: if self.log_watch_thread: self.stop_active_log_watch() finally: logger.debug("removing ccm cluster {name} at: {path}".format(name=self.cluster.name, path=self.test_path)) self.cluster.remove() logger.debug("clearing ssl stores from [{0}] directory".format(self.test_path)) for filename in ('keystore.jks', 'truststore.jks', 'ccm_node.cer'): try: os.remove(os.path.join(self.test_path, filename)) except OSError as e: # ENOENT = no such file or directory assert e.errno == errno.ENOENT os.rmdir(self.test_path) self.cleanup_last_test_dir()
def cleanup_cluster(self, request=None): with log_filter('cassandra'): # quiet noise from driver when nodes start going down if self.dtest_config.keep_test_dir or (self.dtest_config.keep_failed_test_dir and request and request.node.rep_call.failed): self.cluster.stop(gently=self.dtest_config.enable_jacoco_code_coverage) else: # when recording coverage the jvm has to exit normally # or the coverage information is not written by the jacoco agent # otherwise we can just kill the process if self.dtest_config.enable_jacoco_code_coverage: self.cluster.stop(gently=True) # Cleanup everything: try: if self.log_watch_thread: self.stop_active_log_watch() finally: logger.debug("removing ccm cluster {name} at: {path}".format(name=self.cluster.name, path=self.test_path)) self.cluster.remove() logger.debug("clearing ssl stores from [{0}] directory".format(self.test_path)) for filename in ('keystore.jks', 'truststore.jks', 'ccm_node.cer'): try: os.remove(os.path.join(self.test_path, filename)) except OSError as e: # ENOENT = no such file or directory assert e.errno == errno.ENOENT os.rmdir(self.test_path) self.cleanup_last_test_dir()
def patient_cql_connection(self, node, keyspace=None, user=None, password=None, timeout=30, compression=True, protocol_version=None, port=None, ssl_opts=None, **kwargs): """ Returns a connection after it stops throwing NoHostAvailables due to not being ready. If the timeout is exceeded, the exception is raised. """ if is_win(): timeout *= 2 expected_log_lines = ('Control connection failed to connect, shutting down Cluster:', '[control connection] Error connecting to ') with log_filter('cassandra.cluster', expected_log_lines): session = retry_till_success( self.cql_connection, node, keyspace=keyspace, user=user, password=password, timeout=timeout, compression=compression, protocol_version=protocol_version, port=port, ssl_opts=ssl_opts, bypassed_exception=NoHostAvailable, **kwargs ) return session