Fix ALTER TABLE regression in avrorouter

The avrorouter failed to detect ALTER TABLE statements which caused a
regression. Extended the alter table tests to parse the JSON for more
strict validation of test results.
This commit is contained in:
Markus Mäkelä 2017-07-04 09:31:11 +03:00
parent c952b6805e
commit 5c50045227
3 changed files with 20 additions and 9 deletions

View File

@ -7,7 +7,6 @@
*/
#include <iostream>
#include "testconnections.h"
#include "maxadmin_operations.h"
#include "sql_t1.h"
@ -49,8 +48,6 @@ int main(int argc, char *argv[])
sleep(10);
test.set_timeout(120);
char * avro_check = test.ssh_maxscale_output(true,
"maxavrocheck -vv /var/lib/maxscale/avro/test.t1.000001.avro | grep \"{\"");
char * output = test.ssh_maxscale_output(true, "maxavrocheck -d /var/lib/maxscale/avro/test.t1.000001.avro");
std::istringstream iss;

View File

@ -3,7 +3,9 @@
*/
#include "testconnections.h"
#include <jansson.h>
#include <sstream>
#include <iostream>
int main(int argc, char *argv[])
{
@ -43,11 +45,23 @@ int main(int argc, char *argv[])
for (int i = 1; i <=5; i++)
{
std::stringstream cmd;
cmd << "maxavrocheck -d /var/lib/maxscale/avro/test.t1.00000" << i << ".avro|wc -l";
cmd << "maxavrocheck -d /var/lib/maxscale/avro/test.t1.00000" << i << ".avro";
char* rows = test.ssh_maxscale_output(true, cmd.str().c_str());
int nrows = atoi(rows);
int nrows = 0;
std::istringstream iss;
iss.str(rows);
for (std::string line; std::getline(iss, line);)
{
json_error_t err;
json_t* json = json_loads(line.c_str(), 0, &err);
test.add_result(json == NULL, "Failed to parse JSON: %s", line.c_str());
json_decref(json);
nrows++;
}
test.add_result(nrows != 1, "Expected 1 line in file number %d, got %d: %s", i, nrows, rows);
free(rows);
test.add_result(nrows != 1, "Expected 1 line in file number %d, got %d", i, nrows);
}
execute_query(test.repl->nodes[0], "DROP TABLE test.t1;RESET MASTER");

View File

@ -1055,14 +1055,14 @@ void handle_query_event(AVRO_INSTANCE *router, REP_HEADER *hdr, int *pending_tra
bool combine = (strnlen(db, 1) && strchr(ident, '.') == NULL);
size_t len = strlen(ident) + 1; // + 1 for the NULL
size_t ident_len = strlen(ident) + 1; // + 1 for the NULL
if (combine)
{
len += (strlen(db) + 1); // + 1 for the "."
ident_len += (strlen(db) + 1); // + 1 for the "."
}
char full_ident[len];
char full_ident[ident_len];
full_ident[0] = 0; // Set full_ident to "".
if (combine)