8175 Commits

Author SHA1 Message Date
Markus Mäkelä
84dc0b2d37 MXS-1300: Add enabled log priorities to /maxscale/logs resurce
The logging priorities should be displayed as a part of the resource as
they can be enabled or disabled at runtime.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
f28a919982 MXS-1300: Remove redundant commands
The disabling of maxlog and syslog should be done by altering the logging
parameters.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
53789f3b4b MXS-1300: Fix logging and maxscale alteration
The alterations to logging and maxscale were sending malformed JSON to
MaxScale. Boolean values weren't converted to JSON booleans but were sent
as strings.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
310ef3b31e MXS-1300: Add show logging command
The show logging command shows the current log file and the logging
parameters.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
cf8028a5ce MXS-1300: Un-modularize the core
Making the core a module proved to bring more problems than it solved. For
the sake of simplicity in installation and code coverage reporting, the
core is now completely contained in the `lib/` directory.

Also added preliminary coverage reporting with nyc.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
0f1a427458 MXS-1300: Add monitor test to MaxCtrl
The test runts tests on the commands that interact with monitors.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
0f8cd4e90c MXS-1300: Add monitor credentials as create options
The monitor user and password can now be defined as options to the create
command. This should help with the creation of a monitor in one request.

Fixed the command description of `create listener`.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
fa6bea33fe MXS-1300: Fix monitor and listener creation
The creation commands for monitors and listeners referred to undefined
variables. Also fixed the test case names being duplicated.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
2411288388 MXS-1300: Add service test for MaxCtrl
The test goes through the commands that affect services.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
d515094646 Return error on bad service parameter alteration
When a service parameter is being altered and it is not in the list of
dynamic parameters, the alteration function returns an error.
2017-07-23 08:21:00 +03:00
MassimilianoPinto
2e274d0d8b Added virtual destructor in Rule base class
Added virtual destructor in Rule base class
2017-07-20 15:45:14 +02:00
MassimilianoPinto
741c6d9aaf Documentation update for obfuscation method
Example changed to reflect new algorithm output
2017-07-18 11:18:32 +02:00
MassimilianoPinto
e9ad2e5627 Masking filter: added new obfuscation routine
Masking filter: added new obfuscation routine
2017-07-18 11:18:32 +02:00
Markus Mäkelä
d1bee274fa MXS-1300: Add MaxCtrl server tests
The test creates, destroys and alters servers with both valid and invalid
parameters.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
de546a0356 MXS-1220: Validate integer values for alter operations
All of the alter operations weren't properly validating the integer
parameters. This appeared to the client as successful modifications of
parameters with bad value.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
11e270e60a MXS-1220: Add missing server resource fields
The server resource now correctly fills the `authenticator` and
`authenticator_options` fields` if they are defined.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
f9e161eaf6 MXS-1300: Add finer granularity to error message content
If an unexpected network error occurs, only the error part of the response
should be printed. The complete object should be dumped only as a last
resort.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
64c5d6d610 Control npm testing with environment variables
The NPM based tests can now skip the stopping of the docker-compose
cluster by defining the SKIP_SHUTDOWN environment variable.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
9e688772cc MXS-1300: Make the MaxCtrl core a Node.js module
The core is now a module that is loaded by the command line client. This
allows the core library to be reused for testing.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
9a6e281456 MXS-1300: Add list listeners command
The listeners of a service can now be listed.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
985fea43a0 MXS-1220: Fix /sessions/ response documentation
The response body listed listener sessions when only client sessions are
listed.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
3255d58e70 MXS-1300: Take the refactored core into use
The refactored maxctrl function is now in use.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
b98b326bba MXS-1300: Refactor multi-hosts command execution
The main `maxctrl` function now does the cluster health checks and handles
the iteration over the host list. This solves the problem of how to
execute commands on multiple hosts while still allowing recursive calls
into the common functions.

This does not, however, solve the problem of how interconnected commands
across a set of servers are handled. One way to solve this would be to
offer a second main function, `maxctrl_cluster` which would call the
callback with a set of servers instead of a single server.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
aabbf64991 MXS-1300: Add server state manipulation test
The test sets and clears server states and verifies it via the REST
API. It also checks that only correct arguments are accepted.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
18f05578c3 MXS-1300: Disable all output with --quiet
As the option is currently only used for testing, it's better to have it
produce no output at all.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
738dc48df7 MXS-1300: Add basic maxctrl tests
Added basic tests for maxctrl. They simply test that the diagnostic
commands work.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
d938dcc701 MXS-1300: Make output optional
Minor refactoring to the core library to allow multiple calls from within
the same program.

Added --quiet option to silence output so that tests aren't so
verbose. Currently this only works on UNIX based systems.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
ec5b0fea39 MXS-1300: Use native promises for requests
The request-promise-native package adds support for request with native
promises. This is a convenient way to synchronize multiple HTTP requests.

The functions are changed to use promises to make testing easier. With
promises, the testing code can use the chai-as-promised library.

There are a few cases where doRequest is called with a callback that again
calls doAsyncRequest. With multiple hosts, this causes each command to be
propagated to all servers. This is a design flaw of the current multi-host
mode and needs to be changed.

Changed maxctrl.js to wait on the promises to silence some warnings if the
promise rejections are ignored.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
b54e94ce95 MXS-1300: Add TSV output to MaxCtrl
TSV output is a lot easier to parse compared to the pretty-printed
Unicode.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
816e317485 MXS-1300: Make MaxCtrl more like a library
All invocations into the common helper functions are now done through the
`maxctrl` function. This allows the program arguments to be passed to the
core as a parameter instead of reading them from global variables.

This helps with the implicit initialization that was done when the yargs
library was required which caused duplicated output.

Refactored the core functions so that they only process the argument
vector. The parsing of the argument vector is done in maxctrl.js where it
is more appropriate.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
67b2654f50 Move REST API test scripts into a common directory
Moved and renamed the starting and stopping scripts from the REST API
tests to a common directory. This way the MaxCtrl tests can use the same
scripts to start and stop MaxScale.

Also moved the test configuration file into the `test/` directory and
changed some of the default directory locations.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
173a97ae70 Refactor REST API test script into a npm test framework
The script can now be used to run an arbitrary set of Node.js tests as
long as they define the `test` npm target. Refactored REST API tests to
fit into this framework.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
01fa1a827a MXS-1300: Move the REST API tests back into the core
As the REST API is a part of the core, it is more appropriate for the
tests to reside there as well. Further refactoring of the testing needs to
be done to allow multiple components to use the same framework but with
different tests.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
a082871726 MXS-1300: Refactor the way maxctrl is invoked
Making the invocation explicit should allow testing without actually
starting the process fromt the command line. Also returning a promise
allows chaining of commands for testing and verification.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
6c601955d6 MXS-1300: Build MaxCtrl if npm was found
If npm is installed on the local system, try to build MaxCtrl as a part of
the core.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
d3f45f0e0e MXS-1300: Speed up REST API testing
The MariaDB servers are now started first. This will give them time to
prepare while other parts of the tests are being prepared.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
4dcefed974 MXS-1300: Fix test server creation
Before creating the users, the master will do a RESET MASTER to remove the
automatically generated binlogs. The servers should now start a lot faster
since they no longer need to replicate the large amounts of data that were
in these generated binlogs.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
16ed95d865 MXS-1220: Fix REST API tests
The service and server tests were deleting the relationships object and
posting a body without it instead of posting an empty relationships object
to delete relationships.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
6479788283 MXS-1300: Add docker based cluster for REST API testing
The REST API test suite now starts a four node MariaDB cluster with
docker-compose. This allows quick and easy local testing.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
d59d3ab638 MXS-1300: Combine REST API and MaxCtrl tests
The REST API tests are now located under the maxctrl directory. This
allows both tests to use the same framework for testing.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
f83d793704 MXS-1300: Split the code into core and cli parts
The cli part of the code just passes the process argument vector the the
core part. The core part contains the actual functional parts of the
code. This split is done to make testing easier.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
2670ca36a0 MXS-1300: Send requests to multiple hosts
The host and port options were replace with one hosts option which
combines the two. This allows a single command to be executed on multiple
maxscale instances. Added accompanying code for checking responsiveness of
all maxscale instances and handling synchronization of the check
results. The code uses ECMAScript 2016 native promises to do this.

Added a configurable timeout to all requests. This should allow users to
interact with MaxScale over slow and laggy networks.

Before each executed command, all hosts given as parameters are pinged to
make sure they are alive. This should reduce the possibility of partial
execution of commands due to failed MaxScales.

The results of requests are grouped by the values of the hosts
option. This allows users to compare results of multiple servers with
relative ease.

Fixed reversion of the default credentials from mariadb:admin to
admin:mariadb.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
11c8493167 MXS-1300: Only use single quotes
Fixed mixed use of single and double quotes.
2017-07-18 11:37:18 +03:00
Markus Mäkelä
c7a45466fb Use Backend::write for all writes in schemarouter
The schemarouter should always use Backend::write for communication with
the backend servers. This keeps the backends in the correct state.

This fix solves some of the random test failures in the `sharding` test.
2017-07-18 11:36:54 +03:00
MassimilianoPinto
62fdda8534 Masking filter: unused code is now removed
Masking filter: unused code is now removed
2017-07-17 14:12:55 +02:00
MassimilianoPinto
ac142a1b71 Documentation update with 'obfuscate' rule and 'match' option in 'replace' rule
Documentation update with 'obfuscate' rule and 'match' option in
'replace' rule
2017-07-17 12:16:43 +02:00
MassimilianoPinto
1c9f4784dc MXS-1302: pass the rule_type to rule_check_database_options() in order to log the proper rule
rule_check_database_options() can now log the right rule type being
checked
2017-07-17 09:01:53 +02:00
MassimilianoPinto
f1b2257383 MXS-1302: the keyword in the Json is now "match" and MatchRule class substitutes CaptureRule
The keyword in the Json is now "match" and MatchRule class substitutes
CaptureRule

"replace": {
"column": "d_code",
"match": "(?<=aaa).*(?=-12)|(?<=-12).*"
},…
2017-07-14 14:21:40 +02:00
MassimilianoPinto
85d7d67ab8 MXS-1302: capture option in use and pcre2_match matches all the patterns
pcre2_match matches all the patterns
2017-07-14 14:21:40 +02:00
Markus Mäkelä
2410c23e66 Assume that the test database exists
The tests should not drop the test database and then recreate it. This
adds an unnecessary burden on replication which will cause false positives
when replication is not fast enough.
2017-07-11 22:34:01 +03:00