9093 Commits

Author SHA1 Message Date
Johan Wikman
604502e1cb MXS-1461 Template Module -> class Module + template SpecificModule 2017-11-20 13:14:02 +02:00
Johan Wikman
25e288b571 MXS-1461 Add firewall test cases 2017-11-20 13:14:02 +02:00
Johan Wikman
8abe5a659e MXS-1461 Allow user and host to be exluded in test cases 2017-11-20 13:14:02 +02:00
Johan Wikman
a596e1a77c MXS-1461 Move client data to Client
The user and host are now in Client.
2017-11-20 13:14:02 +02:00
Johan Wikman
083c3bcad7 MXS-1461 Rename Upstream to Client 2017-11-20 13:14:02 +02:00
Johan Wikman
a35a4c7e9f MXS-1461 Modify mock classes 2017-11-20 13:14:02 +02:00
Johan Wikman
8fba2a8049 MXS-1461 Add local firewall filter tests
Only two now, more to be added.
2017-11-20 13:14:02 +02:00
Johan Wikman
da989d636e MXS-1461 Add TempFile
Class for creating a temporary file.
2017-11-20 13:14:02 +02:00
Johan Wikman
edb271fa8e MXS-1461 Modify some mock-classes 2017-11-20 13:14:02 +02:00
Johan Wikman
843c9b0ce1 MXS-1461 Add mock Upstream class
Upstream can be used as the upstream filter of a filter to
be tested.
2017-11-20 13:14:02 +02:00
Johan Wikman
8aeb49cffa MXS-1461 Add FilterModule class 2017-11-20 13:14:02 +02:00
Johan Wikman
815da1b7ad MXS-1461 Add mock RouterSession 2017-11-20 13:14:02 +02:00
Johan Wikman
1edccba885 MXS-1461 Add mock Backend class 2017-11-20 13:14:02 +02:00
Johan Wikman
d2c80d2e91 MXS-1461 Add QueryClassifierModule 2017-11-20 13:14:02 +02:00
Johan Wikman
531a8bafbd MXS-1461 Add mock classes Session and Dcb 2017-11-20 13:14:02 +02:00
Johan Wikman
65cf491350 MXS-1461 Add general purpose mocking functions 2017-11-20 13:14:02 +02:00
Johan Wikman
e434c7ec66 MXS-1461 Add template Module
This is the first in a series of commits that introduce components
that allow filters to be tested without MaxScale or backends.
Obviously the environment is not suited for all cases, but allow e.g.
the behaviour of the firewall filter to be tested in isolation.

The environment consists of helper classes loading and manipulating
modules and filters and mock-classes that provide the needed
scaffolding around a filter.

Currently all components exist under the test directory of the firewall
filter, but once proven they can be moved to a more general purpose
location.
2017-11-20 13:14:02 +02:00
Esa Korhonen
8077d97e25 MXS-1513: Work around the backend_read_timeout-setting
The setting limits the maximum time a MASTER_GTID_WAIT-function
can wait. To work around this limitation, the function is now called
in a loop such that the total timeout is approximately equal to
the requested timeout.
2017-11-20 12:31:11 +02:00
Esa Korhonen
59616b5f3e MXS-1490: Cleanup error printing, add json error
Slave redirection is a special case, as there the total failure
is only known after all redirects have been attempted. In the
failure case, all errors from connections are gathered to one
message.
2017-11-20 11:33:47 +02:00
Johan Wikman
204fa17322 MXS-1519 Prevent "inheritance" of fw rules
By using an the value of a global incremented integer as the
initial version number of a Dbfw instance it is ensured that every
such instance does not "inherit" any rules from a previous instance
that happened to exist in the same place as the new instance to be
created.
2017-11-20 10:11:23 +02:00
Markus Mäkelä
07e58444f6 Improve error message for zero monitor timeout values
The error message was not 100% accurate about the value. In addition to
that, neither the value itself nor the monitor or parameter names were
printed in the error message.
2017-11-17 18:05:03 +02:00
Esa Korhonen
84d1ea0bff MXS-1490: Perform failover only after failcount monitor loops
The same failcount variable is used for the detect_standalone_master-
feature.
2017-11-17 10:12:33 +02:00
Markus Mäkelä
703230a930 Only write monitor journal when it changes
The state of the monitored servers is only persisted if the states of the
servers have changed. This removes the unnecessary disk IO caused by the
writing on the monitor journal.
2017-11-16 15:38:13 +02:00
Markus Mäkelä
db61ec0d7e Add missing initialization in readwritesplit
A value was not always initialized for all queries when info level logging
was enabled.
2017-11-16 15:38:13 +02:00
Markus Mäkelä
e0b8ab0b9c Fix memory leak when users are dumped
When users are dumped to file, the JSON object wasn't freed.
2017-11-16 15:38:12 +02:00
Johan Wikman
decd5578bc MXS-1525 Check exact match first when checking host
Given a rule like

  ...
  users %@127.0.0.1 match any rules ...

the code started with %@127.0.0.%, which meant that the exact
match rule would be missed.
2017-11-16 14:09:28 +02:00
Johan Wikman
11a240cb15 MXS-1519 Use fw instance specific rules and users
The rules and users need to be distinct not only for each thread
but for each instance and thread.
2017-11-16 14:06:50 +02:00
Esa Korhonen
b63c6504a3 MXS-1513: Switchover script
First version of switchover script. Unsafe to run as it has no
timeouts for most queries. Also, removed code launching the
previous switchover_script.
2017-11-16 10:51:12 +02:00
Esa Korhonen
032b2f3846 MXS-1333: QLAFilter, add option to log execution time
Adds an option 'reply_time' to log_data. When enabled, query execution time
in milliseconds is logged. Execution time is measured as the time between
routeQuery and the first clientReply.
2017-11-15 16:56:39 +02:00
Markus Mäkelä
fca11f992a 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.
2017-11-14 16:53:09 +02:00
Markus Mäkelä
f41111b4bd MXS-1517: Retain stale master bit even on master failure
If a server goes down and it has the stale master bit enabled, all other
bits for the server are cleared. This allows failed masters that have been
replaced to be first detected and then reintroduced into the replication
topology.
2017-11-14 16:53:09 +02:00
Markus Mäkelä
b80f394cd0 Use explicit types
Use uint64_t instead of unsigned. This guarantees that the size of the
type is the same across all platforms.
2017-11-14 16:53:09 +02:00
Johan Wikman
9d686c4c41 MXS-1461 Create error message only when blocking
Only if the filter is in blocking mode, will a match cause an error
to be returned. Thus, no point in creating the error message unless
the filter is in blocking mode.
2017-11-14 13:03:07 +02:00
Johan Wikman
ea0f8978b2 MXS-1461 Update log messages of firewall rules
Whether or not a match causes the query to be blocked or to be allowed
depends on whether the filter is in white-listing or black-listing mode,
so better if the text is neutral.
2017-11-14 13:03:07 +02:00
Johan Wikman
3eba77f43e MXS-1461 Implement not_function
If the instance represents `not_function` then it is a match if the
used function is not found amongst the listed functions.
2017-11-14 13:03:07 +02:00
Johan Wikman
3993ece209 MXS-1461 Remove special handling for function + allow
No need for this when 'not_function' is available.
2017-11-14 13:03:07 +02:00
Johan Wikman
3215458b30 MXS-1461 Introduce 'not_function' rule
Using 'not_function' it is possible to match functions other than
a specific set of ones. That will make it significantly easier to
allow certain functions to be used with certain columns.

The special handling of no arguments to `function` in conjunction
with an allowing filter has been removed. The same effect can now
be achieved, without special handling, using `not_function`, no
arguments and a blocking filter.

Implementation will follow in a subsequent commit.
2017-11-14 13:03:07 +02:00
Esa Korhonen
ced93acc20 MXS-1514: Add failover test
The test is composed of a few parts.
1: Test that failover happens on master failure.
2: Test that a server with slave sql thread stopped is not promoted.
3: Test that a server with log_slave_updates=1 is promoted before others.
2017-11-14 10:01:37 +02:00
Johan Wikman
b2b72474d9 Initialize thread as well in test_trxtracking 2017-11-10 14:45:54 +02:00
Johan Wikman
6cc8bc36c1 Initialize in test_dcb
Make necessary initializations in test_dcb.
2017-11-10 14:45:54 +02:00
Johan Wikman
f2b9525032 Initialize thread as well in test_trxcompare 2017-11-10 14:45:54 +02:00
Johan Wikman
f152c118cb Name core tests consistently
Now, given a concept xyz,
* the main test file is called test_xyz.cc
* the executable is called test_xyz, and
* the ctest test is called text_xyz.
2017-11-10 14:45:54 +02:00
Markus Mäkelä
2792f54089 Use explicit script path in test_maxctrl
The path to the script is now explicitly defined. This makes the call
unambiguous as the home directory depends on the current user.
2017-11-10 09:37:51 +02:00
Markus Mäkelä
5acdfab5e6 Start MaxScale as maxscale user in run_ctrl_c.sh
MaxScale should not be started as root.
2017-11-09 14:15:47 +02:00
Markus Mäkelä
dd58a8b3c8 Add missing close definition for examplefilter
The filter session method was not defined.
2017-11-09 14:15:47 +02:00
Johan Wikman
e68f16b099 Merge branch '2.2' into 2.2-mrm 2017-11-09 09:41:58 +02:00
Johan Wikman
3dbd201a86 MXS-1478 Provide daemon flag
With "--daemon" or "-n" MaxScale can now be told to run in daemon
mode, that is, it forks and the parent exits. This is the default
behaviour, but a flag to this effect is needed if the default
behaviour is changed.
2017-11-09 09:34:23 +02:00
Markus Mäkelä
cbb6739e00 Always open the SQLite database in binlogrouter
The SQLite database was mistakenly opened only when master GTID
registration was used.
2017-11-08 18:41:14 +02:00
Johan Wikman
0558a2195d MXS-1479 By default, refuse to run as root
MaxScale now refuses to run as root. However, it is possible to
start MaxScale as root, as long as a user to run MaxScale as is
provided as a command line argument.

It is possible to run as root by invoking MaxScale as root and
by specifying the MaxScale user to be root.
2017-11-08 16:03:05 +02:00
Esa Korhonen
3a13469691 MXS-1490 Fix bug with gtid_io_pos change check
The conditional was opposite to intention.
2017-11-08 10:46:51 +02:00