# Test that certificate log deduplication works in clustered mode. # # @TEST-PORT: BROKER_MANAGER_PORT # @TEST-PORT: BROKER_WORKER1_PORT # @TEST-PORT: BROKER_WORKER2_PORT # # @TEST-EXEC: cp $FILES/broker/cluster-layout.zeek . # # @TEST-EXEC: btest-bg-run manager "cp ../cluster-layout.zeek . && CLUSTER_NODE=manager zeek -b %INPUT" # @TEST-EXEC: btest-bg-run worker-1 "cp ../cluster-layout.zeek . && CLUSTER_NODE=worker-1 zeek -b --pseudo-realtime -C -r $TRACES/tls/ecdhe.pcap %INPUT" # @TEST-EXEC: $SCRIPTS/wait-for-file manager/lost 15 || (btest-bg-wait -k 1 && false) # @TEST-EXEC: btest-bg-run worker-2 "cp ../cluster-layout.zeek . && CLUSTER_NODE=worker-2 zeek -b --pseudo-realtime -C -r $TRACES/tls/ecdhe.pcap %INPUT" # @TEST-EXEC: btest-bg-wait 30 # @TEST-EXEC: btest-diff manager/x509.log @load base/protocols/ssl @load base/frameworks/cluster @load base/frameworks/logging redef Log::default_rotation_interval = 0secs; redef Log::default_rotation_postprocessor_cmd = "echo"; redef exit_only_after_terminate = T; event terminate_me() { terminate(); } @if ( Cluster::local_node_type() == Cluster::WORKER ) event zeek_init() { suspend_processing(); } event Broker::peer_added(endpoint: Broker::EndpointInfo, msg: string) { if ( /worker-2/ in Cluster::node ) { when ( |X509::known_log_certs| >= 3 ) { continue_processing(); } timeout 3sec { Reporter::error("Timeout waiting for X509::known_log_certs to be populated!"); terminate(); } } else continue_processing(); } @endif event SSL::log_ssl(i: SSL::Info) { print "log_line"; schedule 2secs { terminate_me() }; } global peers_lost = 0; event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string) { ++peers_lost; system("touch lost"); if ( peers_lost == 2 ) schedule 2sec { terminate_me() }; }