584 Commits

Author SHA1 Message Date
Johan Wikman
cefed56c48 Update unit tests due to mysqlauth -> mariadbauth change 2019-05-14 14:37:11 +03:00
Johan Wikman
32c2724454 Merge branch '2.3' into develop 2019-05-14 13:36:54 +03:00
Johan Wikman
600e23ae2d MXS-2470 Add unit test that reveals problem 2019-05-14 13:36:33 +03:00
Markus Mäkelä
b4e8f79c5f
Format core sources again
Formatted with nl_func_type_name and related options set to ignore. This
keeps the formatting intact for long return types in declarations and
definitions.
2019-05-10 09:21:52 +03:00
Markus Mäkelä
50b5fe76ef
Pass parameters as const ref to server_alloc 2019-05-10 09:21:52 +03:00
Markus Mäkelä
3813c728b1
Move listener parameter handling into Listener::create
The Listener::create method now takes a set of configuration parameters
from which it constructs a listener. This removes the duplicated code and
makes the behavior of listener creation similar to other objects in
MaxScale. It also allows the configuration parameters to be stored in the
listener object itself.
2019-05-10 09:21:52 +03:00
Esa Korhonen
4e6ffc0381 Clean up server config parameter handling
Removes helper classes which are no longer required.
2019-05-07 15:39:34 +03:00
Markus Mäkelä
20a7170024
Fix unit tests that use durations
The tests that used objects that expected a default value for a duration
failed due to missing parameters.
2019-05-06 15:38:43 +03:00
Markus Mäkelä
20afbfca76
Merge branch '2.3' into develop 2019-05-02 20:24:04 +03:00
Markus Mäkelä
0d61522586
Fix test_adminusers
The test did not remove old inet user password files.
2019-05-02 12:53:42 +03:00
Esa Korhonen
82b4338eca Remove MonitorManager calls from Monitor functions
Also adds admin thread checks to MonitorManager functions and combines
anonymous namespaces.
2019-04-30 13:45:48 +03:00
Johan Wikman
638debcdc0 MXS-2329 Allow the restriction of duration units
It's now possible to specify in the config parameter declaration
that the smallest allowed unit is seconds. For parameters whose
granularity is seconds, allowing to specify a duration in
milliseconds would open up a possibility for hard to detect errors.
2019-04-30 13:02:53 +03:00
Markus Mäkelä
820ff756a7
Fix test_config2
The static structures referred to non-static data.
2019-04-24 18:01:28 +03:00
Markus Mäkelä
2bc0b9c875
Don't ignore getcwd return value
The return value should be used.
2019-04-24 11:08:34 +03:00
Markus Mäkelä
d60ec9e281
Fix test_config2
If the /etc/maxscale.modules.d/ didn't exist or wasn't accessable by the
current user, the test would fail.
2019-04-23 11:57:10 +03:00
Markus Mäkelä
ddf004b733
MXS-2349: Extend REST API tests
Added tests to the REST API that make sure the `socket` parameter works.
2019-04-16 11:52:37 +03:00
Johan Wikman
0c7a3240bd MXS-2346 Exclude core parameters
Core parameters are not handled by the module but by the core and
must hence be ignored when validating and configuring.
2019-04-12 15:03:02 +03:00
Johan Wikman
c381aefefc MXS-2346 Add config::ParamInteger and config::Integer 2019-04-12 15:03:02 +03:00
Johan Wikman
09702ab0a0 MXS-2346 Provide new configuration mechanism
The configuration mechanism consists of the following concepts:

Specification
  Specifies the available configuration parameters of a module,
  their names and their types.
Param
  Specifies a parameter, its name and its type.
Type
  Specifies the type of a configuration parameters; Bool, Size,
  Count, etc.
Configuration
  Specifies the configuration values of a particular instance of
  the module. Configuration walks hand in hand with Specification,
  the latter specifies what the former should contain.

A Specification is capable of configuring a Configuration from a
MXS_CONFIG_PARAMETER, checking in the process that all parameters
are of the correct type and that the required parameters are present.

A Specification is capable of persisting itself so that it later
can be read back.

The mechanism is closed for modification but open for extension in
the sense that if a module requires a custom parameter, all it needs
to do is to derive one class from Param and another from Type.

The canonical way for using this mechanism is as follows. Consider
a module xyx that has three parameters; a parameter called
"enabled" that is of boolean type, a parameter called "period"
that is of duration type, and a parameter "cache" that is of
size type. That would be declared as follows:

    // xyz.hh
    class XYZSession;

    class XYZ : public maxscale::Filter<XYZ, XYZSession>
    {
    public:
        static XYZ* create(const char* zName, MXS_CONFIG_PARAMETER* pParams);

    private:
        XYZ();

        static config::Specification                       s_specification;
        static config::ParamBool                           s_enabled;
        static config::ParamDuration<std::chrono::seconds> s_period;
        static config::ParamSize                           s_cache;

        config::Configuration                              m_configuration;
        config::Bool                                       m_enabled;
        config::Duration<std::chrono::seconds>             m_period;
        config::Size                                       m_cache;
    };

    // xyz.cc

    config::Specification XYZ::s_specification(MXS_MODULE_NAME);

    config::ParamBool XYZ::s_enabled(
        &s_specification,
        "enabled",
        "Specifies whether ... should be enabled or not."
        );
    config::ParamDuration<std::chrono::seconds> XYZ::s_period(
        &s_specification,
        "period",
        "Specifies the period. Rounded to the nearest second."
        );
    config::ParamSize XYZ::s_cache(
        &s_specification,
        "cache",
        "Specifies the size of the internal cache."
        );

    XYZ::XYZ()
        : m_configuration(&s_specification)
        , m_enabled(&m_configuration, &s_enabled)
        , m_period(&m_configuration, &s_period)
        , m_cache(&m_configuration, &s_cache)
    {
    }

    XYZ* XYZ::create(const char* zName, MXS_CONFIG_PARAMETER* pParams)
    {
        XYZ* pXyz = new XYZ;

        if (!s_specification.configure(pXyz->m_configuration, pParams))
        {
            delete pXyz;
            pXyz = nullptr;
        }

        return pXyz;
    }
2019-04-12 15:03:02 +03:00
Markus Mäkelä
c643f9bc8d
Merge branch '2.3' into develop 2019-04-12 13:23:49 +03:00
Markus Mäkelä
9a5b60a071
Add forced maintenance mode tests
Tested that the force option works and is accepted.
2019-04-09 10:00:50 +03:00
Markus Mäkelä
adba581a4d
Fix addition of admin users
The user passwords were stored in plaintext format.
2019-04-05 01:00:44 +03:00
Johan Wikman
ea6ffe2371 MXS-2363 Add REST-API test 2019-03-29 11:31:35 +02:00
Markus Mäkelä
203bba0e1d
Add support for multiple runtime error messages
Storing all the runtime errors makes it possible to return all of them
them via the REST API. MaxAdmin will still only show the latest error but
MaxCtrl will now show all errors if more than one error occurs.
2019-03-21 18:19:10 +02:00
Esa Korhonen
cc3891a43c Fix test_modulecmd
The test created a mariadbmonitor without a valid configuration. The
test worked before because only the base monitor configuration was checked.
2019-03-19 15:04:42 +02:00
Esa Korhonen
e7abc53b70 MXS-2304 Clean up configuration serialization
The parameters are now written in the order they appear in the module
parameter definitions. Also enabled a previously disabled part in
server unit test.
2019-03-12 12:51:23 +02:00
Esa Korhonen
c2459c420d MXS-2304 Rename fields of CONFIG_CONTEXT
Added m_-prefix.
2019-03-04 12:27:36 +02:00
Esa Korhonen
41a72bcc30 Fix config parameter related tests
The tests gave null arguments when a valid object was expected.
2019-02-25 17:10:00 +02:00
Esa Korhonen
3fa4a85a1e MXS-2304 Use values instead of pointers in CONFIG_CONTEXT
Simplifies ctor/dtor.
2019-02-22 16:39:45 +02:00
Esa Korhonen
5828c93112 MXS-2304 Convert static config parameter methods to non-static
Parameter handling changed in several places.
2019-02-22 15:17:55 +02:00
Esa Korhonen
afe41c38ed Merge branch '2.3' into develop 2019-02-20 10:33:14 +02:00
Esa Korhonen
9fbaafea91 MXS-2304 Remove additional module parameter classes
Equivalent functionality is now in the basic config parameter class.
2019-02-19 13:52:44 +02:00
Esa Korhonen
25a53a649a MXS-2304 Remove config_get_param()
Replaced with other functions. Also removed password deprecation check.
2019-02-15 10:48:19 +02:00
Esa Korhonen
35e17d9878 Disable server config serialization test
The config parameter ordering depends on which end of the linked list the
parameters are added. The test should be re-enabled once parameter handling
has been refactored.
2019-02-14 15:39:37 +02:00
Johan Wikman
1fed465fdb MXS-2246 Remove duplicate info in SERVICE and Service
Both of them contained fields for the service and router names.
Now the names are in SERVICE and they must be accessed via member
function.
2019-02-14 15:24:10 +02:00
Johan Wikman
c116452c25 MXS-2253 Add MXS_MODULE_PARAM_DURATION
Added a new module parameter type to be used for parameters
that specify a duration. With the suffixes 'h', 'm', 's' and
'ms' the duration can be specified in hours, minutes, seconds
or milliseconds, respectively.

Irrespective of how the duration is specified, it is always
returned as milliseconds.

For backward compatibility, when a duration value is read it must
be specifed how a value *not* defined using a suffix should be
interpreted; as seconds or milliseconds.

  value = param->get_duration(name, mxs::config::INTERPRET_AS_SECONDS);
2019-02-14 10:57:55 +02:00
Markus Mäkelä
49c6244245
Update MaxCtrl and REST API dependencies 2019-02-13 13:54:56 +02:00
Esa Korhonen
35ab911d5c MXS-2304 Use configuration class methods instead of separate implementations
Replaces parameter add/set/remove/free.
2019-02-07 13:51:16 +02:00
Esa Korhonen
5ab7734e9d MXS-2304 Add contains() to test if a parameter exists
Replaces uses of config_get_param() in modules either with contains()
or get_string(). The config_get_param() is moved to internal headers,
as it allows seeing inside a config setting.
2019-02-06 12:36:23 +02:00
Esa Korhonen
4132c9bbbc MXS-2304 Use get_c_str_copy instead of config_copy_string()
Also uses get_string() in core-code when appropriate.
2019-02-05 10:28:37 +02:00
Esa Korhonen
b357717149 MXS-2304 Use get_bool() instead of config_get_bool() 2019-02-01 17:18:49 +02:00
Esa Korhonen
f2d2202ea3 MXS-2304 Use get_enum() instead of config_get_enum() 2019-02-01 10:29:24 +02:00
Esa Korhonen
c8a84cebd0 MXS-2304 Use get_integer() instead of config_get_integer() 2019-01-31 18:12:25 +02:00
Esa Korhonen
f559bf3d95 MXS-2271 Move disk space settings to a settings-container 2019-01-24 09:49:53 +02:00
Esa Korhonen
3321a591ef MXS-2271 Move some monitor management functions to an internal class
The class MonitorManager contains monitor-related functions that should not
be called from modules. MonitorManager can access private fields and methods
of the monitor.
2019-01-22 10:31:06 +02:00
Johan Wikman
0d1743c76b Merge branch '2.3' into develop 2019-01-21 14:07:47 +02:00
Markus Mäkelä
9542641dae Fix buffer overrun on non-terminated comment
Also made the behavior consistent when an incomplete comment is found.
2019-01-21 13:43:53 +02:00
Esa Korhonen
3b55893a20 Combine maxscale/buffer.h with maxscale/buffer.hh 2019-01-17 12:37:40 +02:00
Esa Korhonen
d4674faa7d Convert maxscale/query_classifier.h to .hh
The header was not merged with queryclassifier.hh since the latter
does not include the former.
2019-01-15 18:18:39 +02:00
Johan Wikman
6ba2cb61df MXS-2218 Implement housekeeper in terms of MainWorker 2019-01-08 16:01:36 +02:00