MXS-173 Test for throttling filter
The test may fail if the client/maxscale/mariadb combo is too slow. TODO, maybe: today I saw mysql_query() hang (in a poll) when maxscale disconnected. Is there something that can be done about that? I added a source directory, base, for stuff that should become part of a common utility library in the future.
This commit is contained in:
56
maxscale-system-test/base/stopwatch.h
Normal file
56
maxscale-system-test/base/stopwatch.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2018 MariaDB Corporation Ab
|
||||
*
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
|
||||
*
|
||||
* Change Date: 2020-01-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
// Same StopWatch as in maxscale, but dropping support for gcc 4.4
|
||||
namespace base
|
||||
{
|
||||
using Clock = std::chrono::steady_clock;
|
||||
|
||||
struct Duration : public Clock::duration // for ADL
|
||||
{
|
||||
using Clock::duration::duration;
|
||||
Duration() = default;
|
||||
Duration(Clock::duration d) : Clock::duration(d) {}
|
||||
};
|
||||
|
||||
using TimePoint = std::chrono::time_point<Clock, Duration>;
|
||||
|
||||
class StopWatch
|
||||
{
|
||||
public:
|
||||
// Starts the stopwatch, which is always running.
|
||||
StopWatch();
|
||||
// Get elapsed time.
|
||||
Duration lap() const;
|
||||
// Get elapsed time, restart StopWatch.
|
||||
Duration restart();
|
||||
private:
|
||||
TimePoint m_start;
|
||||
};
|
||||
|
||||
// Returns the value as a double and string adjusted to a suffix like ms for milliseconds.
|
||||
std::pair<double, std::string> dur_to_human_readable(Duration dur);
|
||||
|
||||
// Human readable output. No standard library for it yet.
|
||||
std::ostream& operator<<(std::ostream&, Duration dur);
|
||||
|
||||
// TimePoint
|
||||
std::string time_point_to_string(TimePoint tp, const std::string& fmt = "%F %T");
|
||||
std::ostream& operator<<(std::ostream&, TimePoint tp);
|
||||
|
||||
} // base
|
||||
Reference in New Issue
Block a user