61 Commits

Author SHA1 Message Date
Markus Mäkelä
c34bc24a8b MXS-1390: Fix create user documentation
The documentation stated that the users are created with administrative
privileges by default when in fact they were created with read-only
privileges.
2017-09-07 10:02:14 +03:00
Markus Mäkelä
d480fe97f6 MXS-1390: Update MaxCtrl documentation
Updated documentation generation script and regenerated documentation. Now
all command documentation is generated by using the output of the `help`
commands.
2017-09-07 10:02:14 +03:00
Markus Mäkelä
c8490df566 MXS-1390: Add detailed MaxCtrl documentation
Added a more detailed description for commands that needed it.
2017-09-07 10:02:14 +03:00
Markus Mäkelä
9b6f3366ac MXS-1390: Add MaxCtrl documentation script
The script generates the MaxCtrl documentation by exporting the help
output into a Markdown document.
2017-09-07 10:02:14 +03:00
Markus Mäkelä
0d8e51c8f1 Move create monitor options under the correct header
The options were under the generic options header instead of the monitor
creation one.
2017-09-07 10:02:14 +03:00
Markus Mäkelä
cbe58b5355 MXS-620: Add start/stop maxscale to MaxCtrl
The commands allow all services in MaxScale to be either stopped or
started.
2017-08-22 21:15:12 +03:00
Markus Mäkelä
6ee7ed6a38 MXS-1354: Add creation of basic/admin users to maxctrl
The type of the created user can now be specified with the --type option.

Expanded tests that cover the user creation. Also added a test case that
checks that basic users are only allowed to read through the REST API.
2017-08-18 10:28:21 +03:00
Markus Mäkelä
80569dd5a9 MXS-1300: Correct test case descriptions
The test descriptions now describe the expected logical outcome of the
test, not the operation being done.
2017-08-09 11:39:25 +03:00
Markus Mäkelä
d64cb9fa80 MXS-1300: Test calling of module commands via MaxCtrl
The calling of module commands is tested by using the qlafilter log
command.
2017-08-09 11:39:25 +03:00
Markus Mäkelä
c2a2688b93 Fix duplicate listener checks
Only the protocol, port and address of the listener were used to check if
a listener exists. The check should also use the name of the listener to
be sure that each name is unique.

Expanded tests to check that the creation of duplicate listeners is
detected. Did minor improvements to related test code.
2017-08-09 11:39:25 +03:00
Markus Mäkelä
c593a1bf32 MXS-1300: Test cluster diff functionality
The `cluster diff` command is now tested by doing add/alter/remove
operations on servers. As the same methods are used for all objects, they
should detect all sorts of modifications between two Maxscales.
2017-08-09 11:39:25 +03:00
Markus Mäkelä
70ae93a9ab MXS-1300: Move service checks in cluster to a function
The check that the two MaxScales have the same services is now in a common
function. Added more details into the error message as to why the command
failed. The hosts and their extra services are logged for both the source
and target of the command.

The `cluster diff` command could display the extra services in the diff
but this could be interpreted as a sign that MaxScale could act on that
part of the diff. Returning an error instead of silently ignoring the
extra services should allow for a more consistent user experience.
2017-08-09 11:39:25 +03:00
Markus Mäkelä
f422e92496 MXS-1300: Return output instead of printing it
The `execute` command now returns the output of the command instead of
printint it. This allows the tests to actually test the output of the
commands instead manually verifying that it is correct. It also allows the
library part to be used as an actual library that only returns data.
2017-08-09 11:39:25 +03:00
Markus Mäkelä
9a04dd0311 MXS-1300: Resolved the promise for help commands
The promise returned by the `execute` MaxCtrl library function is now
properly resolved also for `help` type commands.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
0ab7df88dc MXS-1300: Fix MaxCtrl cluster sync test for listeners
The test is not very useful for a locally hosted setup as both MaxScales
can't bind to the same port.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
db531fb2e2 MXS-1300: Improve MaxCtrl HTTP error messages
The messages now show where the request failed and what was
requested. This should help resolve both develper and end-user problems.

Also fixed the missing logging of the output string in the `parse`
callback of the main function and cleaned up the POSTed server body.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
8f7be8a4f3 MXS-1300: Fix MaxCtrl cluster tests
Fixed tests to use correct functions, extended tests of problematic
cases. Added a secondary directory for the second MaxScale instance.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
e133e758a6 MXS-1300: Fix deletion of monitors
The monitors should only be reused if they have the same name and they use
the same module. This way the only difference is in configuration.

Fixed MaxCtrl detection of bad options and altered monitor creation test
to expect correct results. Also improved some of the error messages.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
161776d576 MXS-1300: Add more MaxCtrl cluster tests
Added scripts that start two MaxScale on the same machine. This allows the
cluster synchronization commands to be tested locally.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
3bd13cded6 MXS-1300: Fix minor MaxCtrl bugs
Fixed unresolved promises, wrong resources being requested and enabled
strict mode so unknown arguments are not ignored.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
a3e9d5c327 MXS-1300: Add creation/deletion of listeners to cluster sync
New listeners are created and old ones removed. As listeners cannot yet be
altered via the REST API, differing listeners are not modified.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
0dc53df32e MXS-1300: Add listener diffs
The diff command now shows new, removed and changed listeners.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
10bfa072d9 MXS-1300: Add test for cluster command internals
The test tests the internals of the cluster diff generation
algorithms. This should guarantee that the diff calculation and the
resulting synchronization will work as expected without having to test it
on a live cluster.
2017-08-09 11:39:24 +03:00
Markus Mäkelä
8fb4532468 MXS-1300: Add cluster sync command
The `cluster sync` command synchronizes a MaxScale cluster with one
server. This allows new MaxScale instances to be synchronized with an old
instance by using the same configuration file and performing a cluster
sync.
2017-08-09 11:39:23 +03:00
Markus Mäkelä
fad1b4e3e0 MXS-1300: Add simple diff calculation
The `cluster diff` command prints out the difference between the source
and target MaxScale. This allows users to detect changes that have
happened on one MaxScale but not on the other.
2017-08-09 11:39:23 +03:00
Markus Mäkelä
2c92a86fd6 MXS-1300: Move MaxCtrl into a separate package
Moved MaxCtrl into a separate package to simplify packaging and
distribution process. Having the client as a separate component allows one
set of packages to be used on multiple platforms.
2017-08-09 11:39:23 +03:00
Markus Mäkelä
4bb4b921cb MXS-1300: Add check for Node.js version
The Node.js version is checked before MaxCtrl is built.
2017-07-24 12:33:19 +03:00
Markus Mäkelä
ba5a321ec3 MXS-1300: Improve overall error handling
All errors are now returned as rejected Promises. This will make the error
reporting more consistent with the tested output as well as the actual
output.

Added more tests for error cases and fixed minor argument processing bugs.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
c9f3d014d6 MXS-1300: Improve test coverage
The tests now cover 100% of all source files with the exception of the
call.js and common.js source files.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
e76dc80e47 MXS-1300: Reorganize and refactor tests
The tests are now sorted by command type. This allows for more consistent
test creation as tests can be done per source code file instead of per
object type.

Added helper functions for common testing operations. The two main ones
are doCommand, which executes a MaxCtrl command and returns a result, and
verifyCommand, that executes a command and verifies the result via the
REST API.
2017-07-23 08:21:00 +03:00
Markus Mäkelä
5edfe3040e MXS-1300: Return a rejected promise for unknown commands
When an unknow command is executed, the core should return a rejected
promise.
2017-07-23 08:21:00 +03:00
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ä
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ä
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ä
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ä
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