#pragma once #include "envoy/event/dispatcher.h" #include "envoy/stats/stats.h" namespace Envoy { // Abstract interface for IntegrationTestServer stats methods. class IntegrationTestServerStats { public: virtual ~IntegrationTestServerStats() = default; /** * Wait for a counter to == a given value. * @param name counter name. * @param value target value. * @param timeout amount of time to wait before asserting false, or 0 for no timeout. * @param dispatcher the dispatcher to run non-blocking periodically during the wait. */ virtual void waitForCounterEq(const std::string& name, uint64_t value, std::chrono::milliseconds timeout = std::chrono::milliseconds::zero(), Event::Dispatcher* dispatcher = nullptr) PURE; /** * Wait for a counter to >= a given value. * @param name counter name. * @param value target value. * @param timeout amount of time to wait before asserting false, or 0 for no timeout. */ virtual void waitForCounterGe(const std::string& name, uint64_t value, std::chrono::milliseconds timeout = std::chrono::milliseconds::zero()) PURE; /** * Wait for a counter to exist. * @param name counter name. */ virtual void waitForCounterExists(const std::string& name) PURE; /** * Wait for a gauge to >= a given value. * @param name gauge name. * @param value target value. * @param timeout amount of time to wait before asserting false, or 0 for no timeout. */ virtual void waitForGaugeGe(const std::string& name, uint64_t value, std::chrono::milliseconds timeout = std::chrono::milliseconds::zero()) PURE; /** * Wait for a gauge to == a given value. * @param name gauge name. * @param value target value. * @param timeout amount of time to wait before asserting false, or 0 for no timeout. */ virtual void waitForGaugeEq(const std::string& name, uint64_t value, std::chrono::milliseconds timeout = std::chrono::milliseconds::zero()) PURE; /** * Counter lookup. This is not thread safe, since we don't get a consistent * snapshot, uses counters() instead for this behavior. * @param name counter name. * @return Stats::CounterSharedPtr counter if it exists, otherwise nullptr. */ virtual Stats::CounterSharedPtr counter(const std::string& name) PURE; /** * Gauge lookup. This is not thread safe, since we don't get a consistent * snapshot, uses gauges() instead for this behavior. * @param name gauge name. * @return Stats::GaugeSharedPtr gauge if it exists, otherwise nullptr. */ virtual Stats::GaugeSharedPtr gauge(const std::string& name) PURE; /** * @return std::vector snapshot of server counters. */ virtual std::vector counters() PURE; /** * @return std::vector snapshot of server counters. */ virtual std::vector gauges() PURE; }; } // namespace Envoy