MXS-2481 Rename MaxCtrl to MaxRest
So as not to believe that the program depends upon or uses maxctrl.
This commit is contained in:
@ -28,7 +28,7 @@ add_library(testcore SHARED testconnections.cpp nodes.cpp mariadb_nodes.cpp maxs
|
||||
sql_t1.cpp test_binlog_fnc.cpp get_my_ip.cpp big_load.cpp get_com_select_insert.cpp
|
||||
different_size.cpp fw_copy_rules maxinfo_func.cpp config_operations.cpp rds_vpc.cpp execute_cmd.cpp
|
||||
blob_test.cpp keepalived_func.cpp tcp_connection.cpp base/stopwatch.cpp fw_copy_rules.cpp
|
||||
labels_table.cpp envv.cpp clustrix_nodes.cpp maxctrl.cc
|
||||
labels_table.cpp envv.cpp clustrix_nodes.cpp maxrest.cc
|
||||
# Include the CDC connector in the core library
|
||||
${CMAKE_SOURCE_DIR}/connectors/cdc-connector/cdc_connector.cpp)
|
||||
target_link_libraries(testcore ${MARIADB_CONNECTOR_LIBRARIES} ${JANSSON_LIBRARIES} z m pthread ssl dl rt crypto crypt maxbase)
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
#include <maxbase/string.hh>
|
||||
#include <maxscale/jansson.hh>
|
||||
#include "testconnections.h"
|
||||
#include "maxctrl.hh"
|
||||
#include "maxrest.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -28,11 +28,11 @@ const set<string> bootstrap_servers =
|
||||
const std::string monitor_name = "Clustrix-Monitor";
|
||||
|
||||
|
||||
void check_for_servers(const MaxCtrl& maxctrl)
|
||||
void check_for_servers(const MaxRest& maxrest)
|
||||
{
|
||||
TestConnections& test = maxctrl.test();
|
||||
TestConnections& test = maxrest.test();
|
||||
|
||||
auto servers = maxctrl.list_servers();
|
||||
auto servers = maxrest.list_servers();
|
||||
|
||||
test.expect(servers.size() >= bootstrap_servers.size(),
|
||||
"Expected at least %d servers.", (int)bootstrap_servers.size());
|
||||
@ -78,9 +78,9 @@ void check_for_servers(const MaxCtrl& maxctrl)
|
||||
|
||||
void run_test(TestConnections& test)
|
||||
{
|
||||
MaxCtrl maxctrl(&test);
|
||||
MaxRest maxrest(&test);
|
||||
|
||||
check_for_servers(maxctrl);
|
||||
check_for_servers(maxrest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -11,35 +11,35 @@
|
||||
* Public License.
|
||||
*/
|
||||
|
||||
#include "maxctrl.hh"
|
||||
#include "maxrest.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
MaxCtrl::Server::Server(const MaxCtrl& maxctrl, json_t* pObject)
|
||||
: name (maxctrl.get<string> (pObject, "id", Presence::MANDATORY))
|
||||
, address (maxctrl.get<string> (pObject, "attributes/parameters/address"))
|
||||
, port (maxctrl.get<int64_t>(pObject, "attributes/parameters/port"))
|
||||
, connections(maxctrl.get<int64_t>(pObject, "attributes/statistics/connections"))
|
||||
, state (maxctrl.get<string> (pObject, "attributes/state"))
|
||||
MaxRest::Server::Server(const MaxRest& maxrest, json_t* pObject)
|
||||
: name (maxrest.get<string> (pObject, "id", Presence::MANDATORY))
|
||||
, address (maxrest.get<string> (pObject, "attributes/parameters/address"))
|
||||
, port (maxrest.get<int64_t>(pObject, "attributes/parameters/port"))
|
||||
, connections(maxrest.get<int64_t>(pObject, "attributes/statistics/connections"))
|
||||
, state (maxrest.get<string> (pObject, "attributes/state"))
|
||||
{
|
||||
}
|
||||
|
||||
MaxCtrl::MaxCtrl(TestConnections* pTest)
|
||||
MaxRest::MaxRest(TestConnections* pTest)
|
||||
: m_test(*pTest)
|
||||
{
|
||||
}
|
||||
|
||||
unique_ptr<json_t> MaxCtrl::servers() const
|
||||
unique_ptr<json_t> MaxRest::servers() const
|
||||
{
|
||||
return curl("servers");
|
||||
}
|
||||
|
||||
vector<MaxCtrl::Server> MaxCtrl::list_servers() const
|
||||
vector<MaxRest::Server> MaxRest::list_servers() const
|
||||
{
|
||||
return get_array<Server>(servers().get(), "data", Presence::MANDATORY);
|
||||
}
|
||||
|
||||
json_t* MaxCtrl::get_object(json_t* pObject, const string& key, Presence presence) const
|
||||
json_t* MaxRest::get_object(json_t* pObject, const string& key, Presence presence) const
|
||||
{
|
||||
json_t* pValue = json_object_get(pObject, key.c_str());
|
||||
|
||||
@ -51,7 +51,7 @@ json_t* MaxCtrl::get_object(json_t* pObject, const string& key, Presence presenc
|
||||
return pValue;
|
||||
}
|
||||
|
||||
json_t* MaxCtrl::get_leaf_object(json_t* pObject, const string& key, Presence presence) const
|
||||
json_t* MaxRest::get_leaf_object(json_t* pObject, const string& key, Presence presence) const
|
||||
{
|
||||
auto i = key.find("/");
|
||||
|
||||
@ -71,7 +71,7 @@ json_t* MaxCtrl::get_leaf_object(json_t* pObject, const string& key, Presence pr
|
||||
return pObject;
|
||||
}
|
||||
|
||||
unique_ptr<json_t> MaxCtrl::parse(const string& json) const
|
||||
unique_ptr<json_t> MaxRest::parse(const string& json) const
|
||||
{
|
||||
json_error_t error;
|
||||
unique_ptr<json_t> sRoot(json_loads(json.c_str(), 0, &error));
|
||||
@ -84,7 +84,7 @@ unique_ptr<json_t> MaxCtrl::parse(const string& json) const
|
||||
return sRoot;
|
||||
}
|
||||
|
||||
unique_ptr<json_t> MaxCtrl::curl(const string& path) const
|
||||
unique_ptr<json_t> MaxRest::curl(const string& path) const
|
||||
{
|
||||
string url = "http://127.0.0.1:8989/v1/" + path;
|
||||
string command = "curl -u admin:mariadb " + url;
|
||||
@ -99,14 +99,14 @@ unique_ptr<json_t> MaxCtrl::curl(const string& path) const
|
||||
return parse(result.second);
|
||||
}
|
||||
|
||||
void MaxCtrl::raise(const std::string& message) const
|
||||
void MaxRest::raise(const std::string& message) const
|
||||
{
|
||||
++m_test.global_result;
|
||||
throw runtime_error(message);
|
||||
}
|
||||
|
||||
template<>
|
||||
string MaxCtrl::get<string>(json_t* pObject, const string& key, Presence presence) const
|
||||
string MaxRest::get<string>(json_t* pObject, const string& key, Presence presence) const
|
||||
{
|
||||
json_t* pValue = get_leaf_object(pObject, key, presence);
|
||||
|
||||
@ -119,7 +119,7 @@ string MaxCtrl::get<string>(json_t* pObject, const string& key, Presence presenc
|
||||
}
|
||||
|
||||
template<>
|
||||
int64_t MaxCtrl::get<int64_t>(json_t* pObject, const string& key, Presence presence) const
|
||||
int64_t MaxRest::get<int64_t>(json_t* pObject, const string& key, Presence presence) const
|
||||
{
|
||||
json_t* pValue = get_leaf_object(pObject, key, presence);
|
||||
|
||||
@ -15,18 +15,24 @@
|
||||
#include "testconnections.h"
|
||||
#include <maxscale/jansson.hh>
|
||||
|
||||
class MaxCtrl
|
||||
/**
|
||||
* @class MaxRest
|
||||
*
|
||||
* MaxRest is a class that (eventually) provides the same functionality as
|
||||
* the command line program maxctrl, but for use in programs.
|
||||
*/
|
||||
class MaxRest
|
||||
{
|
||||
public:
|
||||
MaxCtrl(const MaxCtrl&) = delete;
|
||||
MaxCtrl& operator=(const MaxCtrl&) = delete;
|
||||
MaxRest(const MaxRest&) = delete;
|
||||
MaxRest& operator=(const MaxRest&) = delete;
|
||||
|
||||
/**
|
||||
* A class corresponding to a row in the output of 'maxctrl list servers'
|
||||
*/
|
||||
struct Server
|
||||
{
|
||||
Server(const MaxCtrl& maxctrl, json_t* pObject);
|
||||
Server(const MaxRest& maxrest, json_t* pObject);
|
||||
|
||||
std::string name;
|
||||
std::string address;
|
||||
@ -39,9 +45,9 @@ public:
|
||||
* Constructor
|
||||
*
|
||||
* @param pTest The TestConnections instance. Must exist for the lifetime
|
||||
* of the MaxCtrl instance.
|
||||
* of the MaxRest instance.
|
||||
*/
|
||||
MaxCtrl(TestConnections* pTest);
|
||||
MaxRest(TestConnections* pTest);
|
||||
|
||||
/**
|
||||
* @return The TestConnections instance used by this instance.
|
||||
@ -170,7 +176,7 @@ private:
|
||||
};
|
||||
|
||||
template<>
|
||||
std::string MaxCtrl::get<std::string>(json_t* pObject, const std::string& path, Presence presence) const;
|
||||
std::string MaxRest::get<std::string>(json_t* pObject, const std::string& path, Presence presence) const;
|
||||
|
||||
template<>
|
||||
int64_t MaxCtrl::get<int64_t>(json_t* pObject, const std::string& path, Presence presence) const;
|
||||
int64_t MaxRest::get<int64_t>(json_t* pObject, const std::string& path, Presence presence) const;
|
||||
Reference in New Issue
Block a user