MXS-1836 Add test that catches regression
This commit is contained in:
@ -911,6 +911,9 @@ add_test_executable(local_address.cpp local_address local_address LABELS REPL_BA
|
||||
# https://jira.mariadb.org/browse/MXS-1628
|
||||
add_test_executable(mxs1628_bad_handshake.cpp mxs1628_bad_handshake replication LABELS REPL_BACKEND)
|
||||
|
||||
# MXS-1836: MaxInfo "show eventTimes" returns garbage.
|
||||
add_test_executable(mxs1836_show_eventTimes.cpp mxs1836_show_eventTimes mxs1836_show_eventTimes LABELS REPL_BACKEND)
|
||||
|
||||
configure_file(templates.h.in templates.h @ONLY)
|
||||
|
||||
include(CTest)
|
||||
|
@ -0,0 +1,24 @@
|
||||
[maxscale]
|
||||
threads=1
|
||||
|
||||
[MaxAdmin]
|
||||
type=service
|
||||
router=cli
|
||||
|
||||
[MaxAdmin-Listener]
|
||||
type=listener
|
||||
service=MaxAdmin
|
||||
protocol=maxscaled
|
||||
socket=default
|
||||
|
||||
[MaxInfo]
|
||||
type=service
|
||||
router=maxinfo
|
||||
user=maxinfo_user
|
||||
passwd=maxinfo_passwd
|
||||
|
||||
[MaxInfo-Listener]
|
||||
type=listener
|
||||
service=MaxInfo
|
||||
protocol=MySQLClient
|
||||
port=9003
|
84
maxscale-system-test/mxs1836_show_eventTimes.cpp
Normal file
84
maxscale-system-test/mxs1836_show_eventTimes.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2016 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.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "testconnections.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// Specified in the configuration file.
|
||||
char USER[] = "maxinfo_user";
|
||||
char PASSWD[] = "maxinfo_passwd";
|
||||
int PORT = 9003;
|
||||
|
||||
void run(TestConnections& test, MYSQL* pMysql)
|
||||
{
|
||||
if (mysql_query(pMysql, "show eventTimes") == 0)
|
||||
{
|
||||
MYSQL_RES* pResult = mysql_store_result(pMysql);
|
||||
test.assert(pResult, "Executing 'show eventTimes' returned no result.");
|
||||
|
||||
if (pResult)
|
||||
{
|
||||
int nFields = mysql_field_count(pMysql);
|
||||
test.assert(nFields == 3, "Expected 3 fields, got %d.", nFields);
|
||||
|
||||
MYSQL_ROW row;
|
||||
while ((row = mysql_fetch_row(pResult)) != NULL)
|
||||
{
|
||||
cout << row[0] << ", " << row[1] << ", " << row[2] << endl;
|
||||
|
||||
// Right after startup, so all numbers should be small.
|
||||
// The regression caused garbage to be returned, so they
|
||||
// were all over the place.
|
||||
int64_t nEvents_queued = strtoll(row[1], NULL, 0);
|
||||
int64_t nEvents_executed = strtoll(row[2], NULL, 0);
|
||||
|
||||
test.assert(nEvents_queued >= 0 && nEvents_queued < 100,
|
||||
"Suspiciously large number of 'No. Events Queued'.");
|
||||
test.assert(nEvents_executed >= 0 && nEvents_executed < 100,
|
||||
"Suspiciously large number of 'No. Events Executed'.");
|
||||
}
|
||||
|
||||
mysql_free_result(pResult);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
test.assert(false, "Executing 'show eventTimes' failed.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
TestConnections test(argc, argv);
|
||||
|
||||
const char* zMaxScale_host = test.maxscales->ip(0);
|
||||
|
||||
MYSQL* pMysql = open_conn_no_db(PORT, zMaxScale_host, USER, PASSWD);
|
||||
test.assert(pMysql, "Could not connect to maxinfo on MaxScale.");
|
||||
|
||||
if (pMysql)
|
||||
{
|
||||
run(test, pMysql);
|
||||
|
||||
mysql_close(pMysql);
|
||||
}
|
||||
|
||||
return test.global_result;
|
||||
}
|
Reference in New Issue
Block a user