From eda761080690debd64d25eab0bc027c185ef743a Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Fri, 3 May 2019 11:16:38 -0700 Subject: [PATCH] Fix sporadic openflow/broker test failure Looked like a possible race condition in how the test was structured: an endpoint sees its peer got lost and likewise exits immediately before having a chance to process events the peer had sent just before exiting. Fix is to reverse which endpoint initiates the termination sequence so we can be sure we see the required events. --- CHANGES | 4 +++ VERSION | 2 +- .../frameworks/openflow/broker-basic.zeek | 31 +++++++------------ 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/CHANGES b/CHANGES index 11e3ec5d8f..7ac58d9f4a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,8 @@ +2.6-264 | 2019-05-03 11:16:38 -0700 + + * Fix sporadic openflow/broker test failure (Jon Siwek, Corelight) + 2.6-263 | 2019-05-02 22:49:40 -0700 * Install local.zeek as symlink to pre-existing local.bro (Jon Siwek, Corelight) diff --git a/VERSION b/VERSION index 733b341e51..70f4699737 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.6-263 +2.6-264 diff --git a/testing/btest/scripts/base/frameworks/openflow/broker-basic.zeek b/testing/btest/scripts/base/frameworks/openflow/broker-basic.zeek index 3cce7bda1e..70c7203170 100644 --- a/testing/btest/scripts/base/frameworks/openflow/broker-basic.zeek +++ b/testing/btest/scripts/base/frameworks/openflow/broker-basic.zeek @@ -55,14 +55,26 @@ event connection_established(c: connection) OpenFlow::flow_mod(of_controller, match_rev, flow_mod); } +global msg_count: count = 0; + +function got_message() + { + ++msg_count; + + if ( msg_count == 6 ) + terminate(); + } + event OpenFlow::flow_mod_success(name: string, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string) { print "Flow_mod_success"; + got_message(); } event OpenFlow::flow_mod_failure(name: string, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod, msg: string) { print "Flow_mod_failure"; + got_message(); } @TEST-END-FILE @@ -73,13 +85,6 @@ event OpenFlow::flow_mod_failure(name: string, match: OpenFlow::ofp_match, flow_ redef exit_only_after_terminate = T; -global msg_count: count = 0; - -event die() - { - terminate(); - } - event zeek_init() { Broker::subscribe("bro/openflow"); @@ -96,28 +101,16 @@ event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string) terminate(); } -function got_message() - { - ++msg_count; - - if ( msg_count >= 4 ) - { - schedule 2sec { die() }; - } - } - event OpenFlow::broker_flow_mod(name: string, dpid: count, match: OpenFlow::ofp_match, flow_mod: OpenFlow::ofp_flow_mod) { print "got flow_mod", dpid, match, flow_mod; Broker::publish("bro/openflow", OpenFlow::flow_mod_success, name, match, flow_mod, ""); Broker::publish("bro/openflow", OpenFlow::flow_mod_failure, name, match, flow_mod, ""); - got_message(); } event OpenFlow::broker_flow_clear(name: string, dpid: count) { print "flow_clear", dpid; - got_message(); } @TEST-END-FILE