/proc/self/cwd/test/integration/server_stats.h
Line | Count | Source |
1 | | #pragma once |
2 | | |
3 | | #include "envoy/event/dispatcher.h" |
4 | | #include "envoy/stats/stats.h" |
5 | | |
6 | | namespace Envoy { |
7 | | |
8 | | // Abstract interface for IntegrationTestServer stats methods. |
9 | | class IntegrationTestServerStats { |
10 | | public: |
11 | 1.97k | virtual ~IntegrationTestServerStats() = default; |
12 | | |
13 | | /** |
14 | | * Wait for a counter to == a given value. |
15 | | * @param name counter name. |
16 | | * @param value target value. |
17 | | * @param timeout amount of time to wait before asserting false, or 0 for no timeout. |
18 | | * @param dispatcher the dispatcher to run non-blocking periodically during the wait. |
19 | | */ |
20 | | virtual void |
21 | | waitForCounterEq(const std::string& name, uint64_t value, |
22 | | std::chrono::milliseconds timeout = std::chrono::milliseconds::zero(), |
23 | | Event::Dispatcher* dispatcher = nullptr) PURE; |
24 | | |
25 | | /** |
26 | | * Wait for a counter to >= a given value. |
27 | | * @param name counter name. |
28 | | * @param value target value. |
29 | | * @param timeout amount of time to wait before asserting false, or 0 for no timeout. |
30 | | */ |
31 | | virtual void |
32 | | waitForCounterGe(const std::string& name, uint64_t value, |
33 | | std::chrono::milliseconds timeout = std::chrono::milliseconds::zero()) PURE; |
34 | | |
35 | | /** |
36 | | * Wait for a counter to exist. |
37 | | * @param name counter name. |
38 | | */ |
39 | | virtual void waitForCounterExists(const std::string& name) PURE; |
40 | | |
41 | | /** |
42 | | * Wait for a counter to not exist. |
43 | | * @param name counter name. |
44 | | * @param timeout amount of time to wait for the counter to not exist. |
45 | | */ |
46 | | virtual void waitForCounterNonexistent(const std::string& name, |
47 | | std::chrono::milliseconds timeout) PURE; |
48 | | |
49 | | /** |
50 | | * Wait until a histogram has samples. |
51 | | * @param name histogram name. |
52 | | */ |
53 | | virtual void waitUntilHistogramHasSamples( |
54 | | const std::string& name, |
55 | | std::chrono::milliseconds timeout = std::chrono::milliseconds::zero()) PURE; |
56 | | |
57 | | /** |
58 | | * Wait until a histogram has at least sample_count samples. |
59 | | * @param name histogram name. |
60 | | * @param sample_count the number of samples the histogram should at least |
61 | | * have. |
62 | | */ |
63 | | virtual void waitForNumHistogramSamplesGe( |
64 | | const std::string& name, uint64_t sample_count, |
65 | | std::chrono::milliseconds timeout = std::chrono::milliseconds::zero()) PURE; |
66 | | |
67 | | /** |
68 | | * Wait for a gauge to >= a given value. |
69 | | * @param name gauge name. |
70 | | * @param value target value. |
71 | | * @param timeout amount of time to wait before asserting false, or 0 for no timeout. |
72 | | */ |
73 | | virtual void |
74 | | waitForGaugeGe(const std::string& name, uint64_t value, |
75 | | std::chrono::milliseconds timeout = std::chrono::milliseconds::zero()) PURE; |
76 | | |
77 | | /** |
78 | | * Wait for a gauge to == a given value. |
79 | | * @param name gauge name. |
80 | | * @param value target value. |
81 | | * @param timeout amount of time to wait before asserting false, or 0 for no timeout. |
82 | | */ |
83 | | virtual void |
84 | | waitForGaugeEq(const std::string& name, uint64_t value, |
85 | | std::chrono::milliseconds timeout = std::chrono::milliseconds::zero()) PURE; |
86 | | |
87 | | /** |
88 | | * Wait for a gauge to be destroyed. Note that MockStatStore does not destroy stat. |
89 | | * @param name gauge name. |
90 | | */ |
91 | | virtual void waitForGaugeDestroyed(const std::string& name) PURE; |
92 | | |
93 | | /** |
94 | | * Counter lookup. This is not thread safe, since we don't get a consistent |
95 | | * snapshot, uses counters() instead for this behavior. |
96 | | * @param name counter name. |
97 | | * @return Stats::CounterSharedPtr counter if it exists, otherwise nullptr. |
98 | | */ |
99 | | virtual Stats::CounterSharedPtr counter(const std::string& name) PURE; |
100 | | |
101 | | /** |
102 | | * Gauge lookup. This is not thread safe, since we don't get a consistent |
103 | | * snapshot, uses gauges() instead for this behavior. |
104 | | * @param name gauge name. |
105 | | * @return Stats::GaugeSharedPtr gauge if it exists, otherwise nullptr. |
106 | | */ |
107 | | virtual Stats::GaugeSharedPtr gauge(const std::string& name) PURE; |
108 | | |
109 | | /** |
110 | | * @return std::vector<Stats::CounterSharedPtr> snapshot of server counters. |
111 | | */ |
112 | | virtual std::vector<Stats::CounterSharedPtr> counters() PURE; |
113 | | |
114 | | /** |
115 | | * @return std::vector<Stats::GaugeSharedPtr> snapshot of server counters. |
116 | | */ |
117 | | virtual std::vector<Stats::GaugeSharedPtr> gauges() PURE; |
118 | | |
119 | | /** |
120 | | * @return std::vector<Stats::ParentHistogramSharedPtr> snapshot of server histograms. |
121 | | */ |
122 | | virtual std::vector<Stats::ParentHistogramSharedPtr> histograms() PURE; |
123 | | }; |
124 | | |
125 | | } // namespace Envoy |