584 Commits

Author SHA1 Message Date
Markus Mäkelä
c7b9b7ac4a MXS-1220: Unify resource member naming
All resoures now use the `state` member to describe their internal
state. This includes servers, services and monitors. This means that the
`status` keyword can be reserved for something else and it can be removed
until it is needed again.

Changed the module maturity field to `maturity` to better describe its
purpose.
2017-07-10 22:23:45 +03:00
Markus Mäkelä
a8bfdac49c MXS-1220: Use PUT to set/clear server
The correct method for set/clear endpoints is PUT, not POST, as the
resource always ends up in the desired state, regardless of its current
state.
2017-07-10 22:23:45 +03:00
Markus Mäkelä
63d2eee0e3 MXS-1220: Add endpoint for set/clear of server status
The server status can now be manipulated via the REST API. Added tests for
the state manipulation. Fixed minor issues in related code.
2017-07-10 22:23:44 +03:00
Markus Mäkelä
61241f9e07 Remove old feedback system
The feedback system wasn't used and was starting to cause problems on
Debian 9 where the libcurl required different version of OpenSSL than what
MaxScale was linked against.
2017-07-10 16:03:50 +03:00
MassimilianoPinto
cb57e10761 Develop merge
Develop merge
2017-06-29 15:34:22 +02:00
Markus Mäkelä
27d8212c51 Fix typo in server resource
The 'statistics' was mistakenly written as 'statictics'.
2017-06-27 21:45:00 +03:00
Markus Mäkelä
be28bf1e23 Fix internal DCB test
The test created a DCB of an unexpected type in an unexpected state with
an invalid file descriptor. This caused the test to fail due to a debug
assertion where the the validity of the file descriptor was asserted in
relation to the internal state of the DCB.
2017-06-26 21:06:05 +03:00
Johan Wikman
b83538d011 Merge branch '2.1' into develop 2017-06-26 12:29:46 +02:00
Johan Wikman
500f79a150 MXS-1296: Test that lc statements are parsed correctly
The transaction boundary parser - TrxBoundaryParser - must handle
upper and lowercase statements correctly.
2017-06-26 10:57:27 +03:00
Markus Mäkelä
45afbda100 Add descriptions to module commands
Each module command has to describe what it does. This should make module
commands self-documenting to some degree.
2017-06-12 10:08:25 +03:00
Markus Mäkelä
b3c1e15f22 MXS-1220: Add output for module commands
The module commands can now produce JSON formatted output which is passed
to the caller. The output should conform to the JSON API as closely as
possible.

Currently, the REST API wraps all JSON produced by module commands inside
a meta-object of the following type:

  {
    "meta": <output of module command>
  }

This allows the output to be JSON API conformant without modifying the
modules and allows incremental updates to code.
2017-06-12 10:08:25 +03:00
Markus Mäkelä
e4a004097e MXS-1220: Add support for PATCH
The PATCH method should now be used instead the PUT method to update
resources.  As PUT request bodies should represent complete resources, the
use of PUT to update resources is no longer supported.

Altered tests to use PATCH instead of PUT for updating resources.
2017-06-05 13:37:08 +03:00
Markus Mäkelä
ba546fcd21 MXS-1220: Add execution of module commands to REST API
The module command self links now point to an endpoint that executes the
module command. Depending on the type of the module command, either a GET
or a POST request must be made.
2017-06-02 12:52:33 +03:00
Johan Wikman
f546a17e77 Update change date of 2.2 2017-06-01 10:24:20 +03:00
Markus Mäkelä
6b8b19b439 MXS-1220: Add PUT support for /maxscale/ resource
The /maxscale/ resource now supports PUT requests which modify core
parameters. As not all parameters can be changed at runtime, only
modifications to parameters that support runtime configuration are
allowed.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
1067fd352c MXS-1220: Add creation and deletion of admin users
Admin users can now be created via the REST API. This allows remote
management of the administrative interface itself.
2017-05-24 15:05:11 +03:00
Markus Mäkelä
ead9059eeb MXS-1220: Add /users/ resource
The /users/ resource shows all user accounts that can be used with
MaxScale. This resource is further split into two resource collections,
/users/inet and /users/unix, which contain the network users and Linux
accounts respectively.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
e3c4bd7f72 MXS-1220: Add more validation checks to request JSON
The requests that send a body should define at least a `data` member.

Added a simple test that checks that bad requests are rejected. This test
should be expanded to check that the returned error body contains the
correct members.
2017-05-24 15:05:10 +03:00
Markus Mäkelä
322983a5f4 Merge branch '2.1' into develop 2017-05-17 13:48:52 +03:00
Markus Mäkelä
551f635f50 MXS-1220: Make the http.hh header public
As it contains utility functions for formatting time_t values to HTTP-date
values, there's no real need to make it an internal header.
2017-05-17 10:14:56 +03:00
Markus Mäkelä
56cf06ee08 Don't use explicit struct initialization
Older GCC versions don't seem to support explicit struct member
initialization.
2017-05-16 11:39:57 +03:00
Markus Mäkelä
8e2c7fd952 Merge branch '2.0' into 2.1 2017-05-10 09:12:42 +03:00
Markus Mäkelä
157b7f853b MXS-1220: Fix resource self links
The top level resource self links pointed to the collection instead of the
resource itself. The individual resoures now also have a links field that
contains the self link to the resource. This should make navigation of the
API easier as all objects have valid links in them.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
778631a860 MXS-1220: Add support for conditional HTTP requests
The REST API now supports the If-Modified-Since, If-Unmodified-Since,
If-Match and If-None-Match headers and returns the correct response if the
conditional fails.

Added tests for the date parsing and expanded the HTTP header tests in the
REST API test suite.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
3deb497394 MXS-1220: Add Last-Modified and ETag headers
The resource system now tracks both the time when a resource was last
modified and the revision number of the resource. This allows working
Last-Modified and ETag headers to be generated by the REST API.

The If-Modified-Since and If-None-Match request headers are not yet
processed and using them will always return the resource instead of a 304
Not Modified response.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
461cd6afd9 MXS-1220: Add creation of listeners via REST API
Listeners can now be created via the REST API by doing a POST request to
the service listener resource.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
e3ff3b56bc MXS-1220: Add test for /maxscale/logs/ endpoint
The test alters logging options and flushes the logs.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
efc5461daa MXS-1220: Return 204 No Content for PUT and POST request
Returning 204 No Content removes the cost of always sending back the
modified resource. If the modified resource is required, a GET request
should be made to retrieve it.

Updated tests to account for this change.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
d4212b9c78 MXS-1220: Add request option test
Currently only the `pretty=true` option is supported but it is also
tested.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
16e597d43e MXS-1220: Expand REST API test suite
Added tests for services and extended the monitor test suite to test
actions on monitors.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
08dca8c273 MXS-1220: Treat service listeners as service sub-resources
The listeners under the /services/:service/listeners collection are now
fully JSON API compliant resources.

The listeners could also be exposed as a /listeners collection to easily
group all listener type resources in one place. This approach does has
some semantical and practical problems, namely the fact that each listener
has a many-to-one relationship with its service and listeners by
themselves can't exist alone.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
1d98b4b67b MXS-1220: Return 403 Forbidden for invalid requests
The JSON API specification suggests that the API returns the 403 Forbidden
error when the user does an invalid request. The 400 Bad Request isn't the
ideal error for cases where the syntax is correct but the action being
performed is wrong.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
798ee840a8 MXS-1220: Make /maxscale/ resource conform to JSON API
The /maxscale/ resource now conforms to the JSON API and a test checks
that it the returned JSON is valid.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
7ce20b75d7 MXS-1220: Extend and fix REST API tests
Fixed a few broken tests and extended the monitor tests.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
c1968aac2f MXS-1220: Migrate create/update monitor to JSON API format
The creation and modification of moitor now supports the JSON API
conforming format generated by the GET endpoints.

Also added tests for creating and altering monitors via the REST API.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
9495438f2b MXS-1220: Add server test
The test creates, alters and destroys servers.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
a3c683ab87 MXS-1220: Simplify test creation
The tests now automatically start MaxScale before each test block and stop
it and perform cleanup after the test. This is done by simply calling the
`before.sh` and `after.sh` scripts before each test block.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
6b0fabf834 MXS-1220: Make REST API locally testable
The `test_rest_api` make target creates a discardable installation of
MaxScale which is used to launch a local instance of MaxScale. This local
instance is then used to test the REST API.

This is definitely not an efficient way to test the MaxScale but it allows
local testing without virtual machines or containers.
2017-05-09 15:32:42 +03:00
Markus Mäkelä
2f8db4ec1a MXS-1220: Add JSON Pointer support for json_t objects
Using the JSON Pointer syntax specified in RFC 6901
(https://tools.ietf.org/html/rfc6901) allows for a convenient way to
access values deep in a JSON object.
2017-05-09 15:32:41 +03:00
Markus Mäkelä
432a6d6f28 MXS-1220: Reorganize filter resource
The filter resource now conforms to the JSON API schema. Added a test case
for the individual filter resource.
2017-05-09 15:32:41 +03:00
Markus Mäkelä
b9a5d91fe6 MXS-1220: Reorganize monitor resource
The monitor resource now conforms to the JSON API schema. Added a test
case for the individual monitor resource.
2017-05-09 15:32:41 +03:00
Markus Mäkelä
fb7f283316 MXS-1220: Reorganize service resource
The service resource now conforms to the JSON API schema. Added a test
case for individual resources and resource collections.
2017-05-09 15:32:41 +03:00
Markus Mäkelä
5ae9ff9663 MXS-1220: Add simple REST API validator
The validator uses Node.js to check that the REST API endpoints conform to
the specified schema.
2017-05-09 15:32:41 +03:00
Markus Mäkelä
c7cffa0722 Add atomic compare-and-swap
The atomic compare-and-swap can be used to implement lock-free
structures. The planned use for this is to remove some of the locking done
in the services when listeners are being manipulated.
2017-05-09 15:28:04 +03:00
Markus Mäkelä
c27b2a1805 Fix internal test header
The polling and message queue systems weren't initalized.
2017-05-09 09:53:02 +03:00
Markus Mäkelä
9e68726219 Fix internal test suite
Fixed minor problems in DCB and configuration tests.
2017-05-09 09:53:02 +03:00
Markus Mäkelä
5dc49a59be Fix build failures on CentOS 6
The older C++ compiler doesn't support struct initialization with explicit
values. In addition to this, fixed a few other warnings that caused
errors.
2017-05-05 19:59:36 +03:00
Markus Mäkelä
d242203279 MXS-1220: Use libmicrohttpd for the HTTP handling
The HTTP side of the REST API is better handled with an actual
library. The libmicrohttpd library provides a convenient way of handling
the HTTP traffic between the clients and MaxScale.
2017-05-04 09:12:15 +03:00
Markus Mäkelä
900bf2db5a MXS-1220: Take the resource handler into use
The resource handler system is now usable but it doesn't perform anything
useful. Although, this will allows it to be tested for correctness.

Minor fixes to HttpResponse output and renaming of functions.
2017-05-04 09:10:33 +03:00
Markus Mäkelä
e248178349 MXS-1220: Split requested resource into parts
When a client requests a resource, the HttpRequest class now splits the
requested resource into parts. This should help with the resource
validation and navigation.

Added test that checks that the resources are correctly split into the
correct number of arguments and that the argument contents are correct.
2017-05-04 09:10:33 +03:00