Fix verify_master_failure
The test expected the wrong error message to be in the log. To better cope with changes in the text, the test now uses a regular expression to do the matching.
This commit is contained in:
parent
f41111b4bd
commit
fca11f992a
@ -1183,6 +1183,21 @@ int TestConnections::start_mm()
|
||||
return global_result;
|
||||
}
|
||||
|
||||
bool TestConnections::log_matches(const char* pattern)
|
||||
{
|
||||
return ssh_maxscale(true, "grep '%s' /var/log/maxscale/maxscale*.log", pattern) == 0;
|
||||
}
|
||||
|
||||
void TestConnections::log_includes(const char* pattern)
|
||||
{
|
||||
add_result(!log_matches(pattern), "Log does not match pattern '%s'", pattern);
|
||||
}
|
||||
|
||||
void TestConnections::log_excludes(const char* pattern)
|
||||
{
|
||||
add_result(log_matches(pattern), "Log matches pattern '%s'", pattern);
|
||||
}
|
||||
|
||||
void TestConnections::check_log_err(const char * err_msg, bool expected)
|
||||
{
|
||||
|
||||
|
@ -43,6 +43,7 @@ class TestConnections
|
||||
private:
|
||||
/** Whether timeouts are enabled or not */
|
||||
bool enable_timeouts;
|
||||
bool log_matches(const char* pattern);
|
||||
public:
|
||||
/**
|
||||
* @brief TestConnections constructor: reads environmental variables, copies MaxScale.cnf for MaxScale machine
|
||||
@ -634,6 +635,22 @@ public:
|
||||
*/
|
||||
void check_log_err(const char * err_msg, bool expected);
|
||||
|
||||
/**
|
||||
* @brief Check whether logs match a pattern
|
||||
*
|
||||
* The patterns are interpreted as `grep` compatible patterns (BRE regular expressions). If the
|
||||
* log file does not match the pattern, it is considered an error.
|
||||
*/
|
||||
void log_includes(const char* pattern);
|
||||
|
||||
/**
|
||||
* @brief Check whether logs do not match a pattern
|
||||
*
|
||||
* The patterns are interpreted as `grep` compatible patterns (BRE regular expressions). If the
|
||||
* log file match the pattern, it is considered an error.
|
||||
*/
|
||||
void log_excludes(const char* pattern);
|
||||
|
||||
/**
|
||||
* @brief FindConnectedSlave Finds slave node which has connections from MaxScale
|
||||
* @param Test TestConnections object which contains info about test setup
|
||||
|
@ -13,11 +13,12 @@ int main(int argc, char *argv[])
|
||||
test.tprintf("Blocking master and checking that master failure is delayed at least once.");
|
||||
test.repl->block_node(0);
|
||||
sleep(5);
|
||||
test.check_log_err("delaying failover", true);
|
||||
test.log_includes("delaying.*failover");
|
||||
|
||||
test.tprintf("Waiting to see if failover is performed.");
|
||||
sleep(10);
|
||||
test.check_log_err("Performing failover", true);
|
||||
|
||||
test.log_includes("Performing.*failover");
|
||||
|
||||
// TODO: Extend the test
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user