From b8019cf7dc7b48cf114b06008cf1d2289588849c Mon Sep 17 00:00:00 2001 From: Chris Hofstaedtler Date: Mon, 5 Mar 2018 12:21:57 +0100 Subject: [PATCH] TeeAction: make getStats() order deterministic --- pdns/dnsdist-lua-actions.cc | 4 ++-- pdns/dnsdist.hh | 2 +- regression-tests.dnsdist/test_TeeAction.py | 24 +++++++++++----------- 3 files changed, 15 insertions(+), 15 deletions(-) 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)) -- 2.47.2