From: Chris Hofstaedtler Date: Mon, 5 Mar 2018 11:21:57 +0000 (+0100) Subject: TeeAction: make getStats() order deterministic X-Git-Tag: dnsdist-1.3.0~64^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b8019cf7dc7b48cf114b06008cf1d2289588849c;p=thirdparty%2Fpdns.git TeeAction: make getStats() order deterministic --- diff --git a/pdns/dnsdist-lua-actions.cc b/pdns/dnsdist-lua-actions.cc index 4be1d0302e..9a9339f495 100644 --- a/pdns/dnsdist-lua-actions.cc +++ b/pdns/dnsdist-lua-actions.cc @@ -103,7 +103,7 @@ public: ~TeeAction() override; DNSAction::Action operator()(DNSQuestion* dq, string* ruleresult) const override; string toString() const override; - std::unordered_map getStats() const override; + std::map getStats() const override; private: ComboAddress d_remote; @@ -181,7 +181,7 @@ string TeeAction::toString() const return "tee to "+d_remote.toStringWithPort(); } -std::unordered_map TeeAction::getStats() const +std::map TeeAction::getStats() const { return {{"queries", d_queries}, {"responses", d_responses}, diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index d9fa51d96b..d4e91232d8 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -108,7 +108,7 @@ public: { } virtual string toString() const = 0; - virtual std::unordered_map getStats() const + virtual std::map getStats() const { return {{}}; } diff --git a/regression-tests.dnsdist/test_TeeAction.py b/regression-tests.dnsdist/test_TeeAction.py index 905f348455..3d74410281 100644 --- a/regression-tests.dnsdist/test_TeeAction.py +++ b/regression-tests.dnsdist/test_TeeAction.py @@ -73,16 +73,16 @@ class TestTeeAction(DNSDistTest): # check the TeeAction stats stats = self.sendConsoleCommand("getAction(0):printStats()") - self.assertEquals(stats, """refuseds\t0 + self.assertEquals(stats, """noerrors\t%d nxdomains\t0 -noerrors\t%d -servfails\t0 +other-rcode\t0 +queries\t%d recv-errors\t0 -tcp-drops\t0 +refuseds\t0 responses\t%d -other-rcode\t0 send-errors\t0 -queries\t%d +servfails\t0 +tcp-drops\t0 """ % (numberOfQueries, numberOfQueries, numberOfQueries)) def testTeeWithoutECS(self): @@ -121,14 +121,14 @@ queries\t%d # check the TeeAction stats stats = self.sendConsoleCommand("getAction(0):printStats()") - self.assertEquals(stats, """refuseds\t0 + self.assertEquals(stats, """noerrors\t%d nxdomains\t0 -noerrors\t%d -servfails\t0 +other-rcode\t0 +queries\t%d recv-errors\t0 -tcp-drops\t0 +refuseds\t0 responses\t%d -other-rcode\t0 send-errors\t0 -queries\t%d +servfails\t0 +tcp-drops\t0 """ % (numberOfQueries, numberOfQueries, numberOfQueries))