246 Commits

Author SHA1 Message Date
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
Markus Mäkelä
4b4a87fb41 MXS-1220: Clean up requested resource paths
Remove trailing slashes in requested resource paths.
2017-05-04 09:10:33 +03:00
Markus Mäkelä
34ee4a1997 MXS-1220: Add option parsing
The options of a request are now parsed and exposed by the HttpRequest
class.

Added tests for the request options.

Also added missing error handling of invalid requests.
2017-05-04 09:10:33 +03:00
Markus Mäkelä
9d0d394361 MXS-1220: Expand HttpResponse class
The class now generates default headers. The ETag and Last-Modified tags
do not represent any actual modification time or resource hash.

The basic functionality of the HTTP responses is tested by the core test
suite. More advanced testing of the whole REST API is still required.

Removed the static `create` functions as only the JSON parsing version
could generated errors and even then the errors were unlikely. By
replacing the static creator function with a normal constructor, the
HttpResponse class can now also be created on the stack making its use
easier.
2017-05-04 09:10:33 +03:00
Markus Mäkelä
55b52b8ab1 MXS-1220: Add HEAD method support
The HEAD method was not in the list of supported methods.
2017-05-04 09:10:32 +03:00
Markus Mäkelä
c937457738 MXS-1220: Add request body parsing
The HTTP request body is expected to be a valid JSON object. All other
requests are considered malformed requests and result in a HTTP 400 error.

Added the Jansson license to the LICENSE-THIRDPARTY.TXT file. Imported
some of the tests from the Jansson test suite to the HttpParser test.
2017-05-04 09:10:32 +03:00
Markus Mäkelä
4eb121ce35 MXS-1220: Rename and reorganize HttpParser
The HttpParser class was renamed to HttpRequest as it parses and processes
only HTTP requests. A second class that creates a HTTP response needs to
be created to handle the response generation.

Moved some of the HTTP constants and helper functions to a separate
http.hh header.
2017-05-04 09:10:32 +03:00
Markus Mäkelä
439d67d129 MXS-1220: Add test for HttpParser
The test simulates various HTTP requests and checks that they are parsed
properly.
2017-05-04 09:10:32 +03:00
Markus Mäkelä
6f24c04a4f Compile core unit tests as C++
Since the core source is C++, the tests should also be C++.
2017-05-03 14:02:25 +03:00
Johan Wikman
1eb409a666 Add possibility to wait several times on a semaphore 2017-04-25 13:10:01 +03:00
Markus Mäkelä
19cf8c489e Rename atomic store and load functions
The atomic store and load functions are now called atomic_store_X and
atomic_load_X where X is one of int32, int64 or uint64.
2017-04-24 16:11:34 +03:00
Markus Mäkelä
f91d415be1 Add simple test for atomic operations
The test runs some simple tests with the atomic operations in MaxScale.
2017-04-24 15:58:28 +03:00
Johan Wikman
b0922576be Add Semaphore class
A simple Semaphore class that makes it simpler and less
erroprone to use a semaphore.
2017-04-23 18:54:18 +03:00
Johan Wikman
5138032fe5 Add shutdown support
The shutdown is now performed so that a shutdown message is
sent to all workers. When the workers receive that message, they
turn on a shutdown flag, which subsequently is checked in the poll
loop.
2017-04-20 13:51:16 +03:00
Johan Wikman
c3cfc86a7b Merge branch '2.1' into develop 2017-04-19 18:19:13 +03:00
Esa Korhonen
9e8ddc842c Fix leaks in testconfig 2017-04-06 12:51:09 +03:00
Esa Korhonen
15951423d8 Fix memory errors in test_poll and test_queuemanager
test_poll was calling poll_init() two times since it's already included in
init_test_env().

test_queuemanager was missing a bunch of frees. This doesn't fix it completely,
but removes most of the leaks and valgrind errors.
2017-04-05 17:37:21 +03:00
Esa Korhonen
b1f66d21c8 Fix valgrind-errors in test_filter and test_modutil
Reduces valgrind clutter quite a bit.
2017-04-05 15:04:36 +03:00
Markus Mäkelä
ad1c05b015 Merge branch '2.1' into develop 2017-04-05 11:35:13 +03:00
Esa Korhonen
2d987b25b2 Fix test_dcb
Set threadcount to one, don't check validity after freeing.
2017-04-05 10:49:43 +03:00
Esa Korhonen
dca086571b TestMaxScalePCRE2: Fix memory leaks
Not really leaks, but this reduces needless clutter in the valgrind
output.
2017-04-04 16:18:47 +03:00
Johan Wikman
8d2d6d8721 Join threads to prevent leaks 2017-04-03 14:20:54 +03:00
Johan Wikman
8284716e6a Add test for gwbuf_clone to testbuffer.c
- Under valgrind, this test reveals the leak of gebuf_clone.
2017-03-30 22:14:58 +03:00
Johan Wikman
29fa4a6088 Fix testbuffer.c
Free memory allocated by tests, so that it is meaningful to run under
valgrind in order to check for GWBUF leaks.
2017-03-30 22:02:34 +03:00
Johan Wikman
bb1b7f9755 Compile server, service and session as C++ 2017-03-24 10:52:09 +02:00
Johan Wikman
96df523ce4 Compile load_utils.c as C++ 2017-03-24 09:21:20 +02:00
Johan Wikman
74085978b4 Compile config.c as C++ 2017-03-24 09:21:20 +02:00
Johan Wikman
7469c5be52 Add functionality for bypassing MySQL whitespace/comments
This functionality is needed both in the query classifier, where
it was first created, and in the cache.
2017-03-17 10:27:16 +02:00
Johan Wikman
5e39268e37 Remove support for TrxBoundaryMatcher
For the general case, regex matching simply will not do. The
regex becomes so hairy so it turns write-only, i.e. unmaintainable.
Regex matching is also slower than a handwritten custom parser.
2017-03-15 10:39:26 +02:00
Johan Wikman
1c8205e005 Add missing flag handling 2017-03-15 10:25:02 +02:00
Johan Wikman
96f0321b7e Add program for profiling TrxBoundaryParser 2017-03-15 09:35:15 +02:00
Johan Wikman
9a33cf4d3e Add smoke-test for qc_get_trx_type_mask_using
Use the query classifier test files and compare that the
result returned by qc_sqlite and the custom parser agree
for every statement.
2017-03-15 09:35:15 +02:00
Johan Wikman
c2add97e30 Recognise various autocommit syntaxes
set autocommit=1
set global autocommit=1
set session autocommit=1
set @@global.autocommit=1
set @@session.autocommit=1
2017-03-15 09:35:15 +02:00
Johan Wikman
470de51e22 Handle whitespace in TrxBoundaryParser
TheBoundaryMatcher is not updated as it is likely it will be removed
altogether. A regex that accepts comments in all relevant places becomes
so hairy it is unmaintainable. It seems that the only working solution
would be to first remove all comments and then perform the regex.
2017-03-15 09:35:15 +02:00
Johan Wikman
931f765df5 Enhance transaction tracking test 2017-03-15 09:35:15 +02:00
Johan Wikman
d5fc54a9de Handle WITH CONSISTENT SNAPSHOT as well
TrsBoundaryParser now capable of parsing WITH CONSISTENT
SNAPSHOT transaction statements as well.
2017-03-15 09:35:15 +02:00
Johan Wikman
a85ce2e915 Take TrxBoundaryParser into use 2017-03-15 09:35:15 +02:00
Johan Wikman
8e81941058 Enable trx boundary detection using regexes
Transaction boundaries can now be detected using regexes.
All else being equal, it gives a 10% performance improvement
compared to qc-based detection.

In a subsequent change, mysql_client.c will be modified to use
qc_get_trx_type_mask() instead of qc_get_type_mask().

Currently the use of regex matching is turned on using an
environment variable. That will change.
2017-03-15 09:35:15 +02:00