384 Commits

Author SHA1 Message Date
Johan Wikman
68e514f08b Fix test_event
If the logged line is found, it is not an error, if it is not,
it is.
2018-06-20 13:01:20 +03:00
Markus Mäkelä
df24f09ce5
Merge branch '2.2' into develop 2018-06-18 11:39:10 +03:00
Johan Wikman
6e3d3c0dcf MXS-421 Test that used facility has an effect
If the facility of an event is LOG_AUTH, it should by default
end up in /var/log/auth.log.
2018-06-18 11:32:50 +03:00
Johan Wikman
4c1b7f761c MXS-421 Add maxscale::event concept
MaxScale now defines events for which the syslog
facility and level can explicitly be defined by the
administrator. Currently there is only one such
event, namelt AUTHENTICATION_FAILURE.

In a subsequent commit, config.cc will be modified so
that event-related configuration parameters are passed
to event::configure() and in another subsequent commit
the authenticators will be modifed to use this mechanism.

In practice a line like:

   MXS_WARNING("%s: login attempt for user '%s'@[%s]:%s, "
               "authentication failed.",
               dcb->service->name, client_data->user,
               dcb->remote, dcb->path);

will be changed to

    MXS_LOG_EVENT(event::AUTHENTICATION_FAILURE,
                  "%s: login attempt for user '%s'@[%s]:%s, "
                  "authentication failed.",
                  dcb->service->name, client_data->user,
                  dcb->remote, dcb->path);
2018-06-18 11:32:50 +03:00
Markus Mäkelä
ca155fbfe9
Merge branch '2.1' into 2.2 2018-06-18 11:32:13 +03:00
Markus Mäkelä
a983df5a7e
Fix testlogthrottling compilation failure
The ifstream constructor for some reason doesn't understand strings.
2018-06-15 11:45:40 +03:00
Markus Mäkelä
4cc4deeaf1
MXS-1843: Test log throtting in a unique directory
This rules out external influence as a reason for the test failure.
2018-06-15 10:07:49 +03:00
Markus Mäkelä
bbeaaa97b5
Merge branch '2.2' into develop 2018-06-13 23:18:52 +03:00
Markus Mäkelä
1475b22eac
Upgrade REST-API npm packages
Upgraded packages to more recent versions.
2018-06-13 10:07:37 +03:00
Marko
880db1353a Merge branch '2.2' into develop 2018-06-07 14:39:16 +03:00
Marko
82a95bfe2d MXS-1709 Fix memory leaks causing test_server to fail 2018-06-06 22:36:10 +03:00
Marko
19a0c94661 Typo fix in logthrottling_test 2018-06-05 15:49:22 +03:00
Marko
48509d30f1 Silence the -Wunused-result warning
-Wunused-result warning in test_logthrottling.cc was causing error when
trying to build MaxScale from source. This warning can be silenced with by
putting the function triggering the warning in if-clause.
2018-06-05 11:30:55 +03:00
Johan Wikman
cb8cd4be3d MXS-1775 Add helper function for parsing disk_space_threshold
The function will be used by the functions

    server_set_disk_space_threshold() and
    monitor_set_disk_space_threshold()

that will be introduced.
2018-06-01 13:48:15 +03:00
Niclas Antti
5d02d8c0ba Merge branch '2.2' into develop 2018-06-01 09:33:04 +03:00
Niclas Antti
89296ed4e4 MXS-1740 Hintfilter leaks memory
Single spot where an existing hint ptr was overwritten. Removed gwbuf_add_hint()
because it was  adding hints at the opposite end compared to functions in hint.h.
Added hint_splice() to replace.
2018-05-31 14:04:22 +03:00
Johan Wikman
7e9062f20f Merge branch '2.2' into develop 2018-05-16 09:31:13 +03:00
Markus Mäkelä
f29da6545b
MXS-1843: Test log throtting in a unique directory
This rules out external influence as a reason for the test failure.
2018-05-15 10:15:32 +03:00
Johan Wikman
42c10cfa1c MXS-1848 Move Worker from internal to public include dir
maxscale::Worker needs to be public if monitors should be
implementable using it.
2018-05-14 10:10:18 +03:00
Johan Wikman
13eecfbaa3 MXS-1809 Cancel all delayed calls when worker is going down
Unless the calls are canceled and deleted, there will be a leak.
2018-05-08 16:01:27 +03:00
Esa Korhonen
12035289f4 Remove server authenticator options
Was unused. A warning is printed if the parameter is defined. Any value is ignored.
2018-05-08 14:18:00 +03:00
Johan Wikman
851cefefc6 MXS-1848 monitor_[alloc|free]() -> monitor_[create|destroy]
As these will call the createInstance and destroyInstance functions
of the monitor, they are more appropriately named like this.
2018-05-07 14:08:36 +03:00
Markus Mäkelä
658329b648
Merge branch '2.2' into develop 2018-05-03 10:00:44 +03:00
Markus Mäkelä
612b4e1a32
MXS-1847: Fix server_get_parameter
The function now takes an output buffer as a parameter. This prevents race
conditions by copying the parameter value into a local buffer.
2018-05-03 09:50:52 +03:00
Esa Korhonen
5d010ff712 Cleanup SERVER struct
Removed one unused field. Rearranged others, clarified comments.
2018-04-27 10:48:56 +03:00
Markus Mäkelä
5572f0efcd
Fix test_utils failure
The Checksum class interface was changed in a way that caused the tests to
fail.
2018-04-26 13:44:27 +03:00
Markus Mäkelä
bb96c368c2
MXS-1810: Create generic Checksum class
The Checksum class defines an interface which the SHA1Checksum and
CRC32Checksum implement.

Added test unit test cases to verify that the checksums work and perform
as expected.
2018-04-26 13:44:23 +03:00
Johan Wikman
ac7d1198fb MXS-1754 Alter order of parameters
When providing pointer to instance and pointer to member function
of the class of the instance, the pointer to the member function
should be first and the pointer to the instance second.
2018-04-23 13:58:00 +03:00
Johan Wikman
cbd7e51dd8 MXS-1754 Identify delayed calls using id and not tag
When a delayed call is scheduled for execution, the caller is
now returned a unique id using which the delayed call can be
cancelled.
2018-04-23 13:58:00 +03:00
Johan Wikman
be9504ac94 MXS-1754 Add possibility to cancel delayed calls
The interface for canceling calls is now geared towards the needs
of sessions. Basically the idea is as follows:

class MyFilterSession : public maxscale::FilterSession
{
    ...
    int MyFilterSession::routeQuery(GWBUF* pPacket)
    {
       ...
       if (needs_to_be_delayed())
       {
           Worker* pWorker = Worker::current();
           void* pTag = this;
           pWorker->delayed_call(5000, pTag, this,
                                 &MyFilterSession::delayed_routeQuery,
                                 pPacket);
           return 1;
       }
       ...
    }

    bool MyFilterSession::delayed_routeQuery(Worker::Call:action_t action,
                                             GWBUF* pPacket)
    {
        if (action == Worker::Call::EXECUTE)
        {
            routeQuery(pPacket);
        }
        else
        {
            ss_dassert(action == Worker::Call::CANCEL);
            gwbuf_free(pPacket);
        }
        return false;
    }

    ~MyFilterSession()
    {
        void* pTag = this;
        Worker::current()->cancel_delayed_calls(pTag);
    }
}

The alternative, returning some key that the caller must keep
around seems more cumbersome for the general case.
2018-04-23 13:58:00 +03:00
Johan Wikman
84b2156508 MXS-1754 Add delayed calling to Worker
It's now possible to provide Worker with a function to call
at a later time. It's possible to provide a function or a
member function (with the object), taking zero or one argument
of any kind. The argument must be copyable.

There's currently no way to cancel a call, which must be added
as typically the delayed calling is associated with a session
and if the session is closed before the delayed call is made,
bad things are likely to happen.
2018-04-23 13:58:00 +03:00
Johan Wikman
4d4ab83e99 MXS-754 Fix unit test failures caused by RoutingWorker 2018-04-19 10:51:28 +03:00
Markus Mäkelä
99a9dd1006
Merge branch '2.2' into develop 2018-04-18 09:36:17 +03:00
Markus Mäkelä
474736584b
Fix test_poll failure
With the changes to the DCB handling, the service pointer of a client DCB
must always be assigned.

Also removed the unnecessary parentheses around the comparison.
2018-04-18 08:10:42 +03:00
Johan Wikman
230876cd69 MXS-1754 Rename mxs::Worker to mxs::RoutingWorker
A new class mxs::Worker will be introduced and mxs::RoutingWorker
will be inherited from that. mxs::Worker will basically only be a
thread with a message-loop.

Once available, all current non-worker threads (but the one
implicitly created by microhttpd) can be creating by inheriting
from that; in practice that means the housekeeping thread, all
monitor threads and possibly the logging thread.

The benefit of this arrangement is that there then will be a general
mechanism for cross thread communication without having to use any
shared data structures.
2018-04-16 14:53:08 +03:00
Markus Mäkelä
e4efc29297
MXS-1702: Process comments when canonicalizing
The canonicalization process now strips non-executable comments from the
SQL and replaces all constants in executable comments.

Enabled the comment test and updated expected output of the select and
alter tests.
2018-03-20 13:53:55 +02:00
Markus Mäkelä
9fe25c8003
MXS-1702: Update tests
Updated tests with new expected output. Also took new function into use
and removed the old one.

Since the comment removal isn't added yet, one of the tests is expected to
fail and it is temporarily disabled.
2018-03-20 13:53:55 +02:00
Markus Mäkelä
a03e8d46f0
MXS-1702: Rename tests
The test naming now follows the common convention.
2018-03-20 13:53:55 +02:00
Markus Mäkelä
e90c29cce2
MXS-1702: Clean up and convert test to C++
Cleaned up and updated the test; the code was written with a pre-C99
standard in mind.

Added a get() method into mxs::Buffer to make it easier to use with
non-C++ functions.
2018-03-20 13:53:54 +02:00
Markus Mäkelä
cb170eb88e
MXS-1702: Move canonicalization test into core
Moved the test into the core where it belongs.
2018-03-20 13:53:54 +02:00
Johan Wikman
69383c0943 Merge branch '2.2' into develop 2018-03-12 14:38:37 +02:00
Johan Wikman
aea9c36498 Merge branch '2.1' into 2.2 2018-03-12 14:38:13 +02:00
Johan Wikman
c5345d34ca MXS-1714 Use local_address also with MaxScale connections
If local address has been specified, then all connections created
using mxs_mysql_real_connect() will use that same local address as
well.

A system test has not been created as our VMs do not have more than
one usable IP-address. Locally it has been verified to work as
expected.
2018-03-12 11:35:46 +02:00
Markus Mäkelä
dfbecc41e2 Format protocol modules
Formatted the MariaDB protocol modules with Astyle.
2018-01-24 11:20:11 +02:00
Markus Mäkelä
fe73458d65 Merge remote-tracking branch 'ybbct/MXS-1603' into develop 2018-01-24 11:15:14 +02:00
Dapeng Huang
73e5fd52fa misc fix and remove all tail spaces 2018-01-22 22:02:22 +08:00
Markus Mäkelä
73f1005e7a Fix memory leak in test_users
Users were allocated but not freed. Same with the JSON objects.
2018-01-22 15:29:21 +02:00
Markus Mäkelä
ef53ded057 Fix test_atomic
As the function documentation states, the expected value must be read
again after a call to atomic_cas_ptr. This is due to the fact that if the
values are not the same, the __atomic builtin version will store the
current value into the expected value.

The new value given to the atomic_cas_ptr function was the address of the
new value, not the new value itself. The behavior of the atomic_cas_ptr is
what caused the test to pass on systeems that implement the __atomic
builtins. On older systems that do not implement it, the expected value
was never modified which caused the test to hang.
2018-01-22 15:29:21 +02:00
Markus Mäkelä
ccebf38bc0 Update test configuration files
Updated the REST API and MaxCtrl configuration files with new object
names. Updated tests with new object names.
2018-01-22 15:29:21 +02:00
Dapeng Huang
81f303512e check protocol state to determine real ok packet 2018-01-22 14:52:12 +08:00