Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGNITE-14520 Plugins support in Ignite configuration #9008

Merged
merged 27 commits into from
Apr 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9d57c3c
add params in templete
map7000 Apr 12, 2021
6c6667e
fix tox
map7000 Apr 12, 2021
c022421
set ssl params to defaults
map7000 Apr 15, 2021
2c668fe
put client configuration in ignite xml
map7000 Apr 16, 2021
0409790
working version
map7000 Apr 19, 2021
baad576
Merge remote-tracking branch 'upstream/ignite-ducktape' into IGNITE-1…
map7000 Apr 19, 2021
cd6e251
go home
map7000 Apr 19, 2021
b81f669
fix indentation
map7000 Apr 20, 2021
4d6e6b5
Add posibility to extend config in spec
map7000 Apr 21, 2021
f85bd89
Merge remote-tracking branch 'upstream/ignite-ducktape' into IGNITE-1…
map7000 Apr 21, 2021
b3de34b
succesfull run
map7000 Apr 21, 2021
f3bb1c7
fix indent
map7000 Apr 21, 2021
08f8ede
config extension moved to spec
map7000 Apr 21, 2021
0d6ccfc
Merge branch 'ignite-ducktape' into IGNITE-14520
nizhikov Apr 22, 2021
363b63d
PR update
nizhikov Apr 22, 2021
ec3817b
PR update
nizhikov Apr 22, 2021
eb10257
PR update
nizhikov Apr 22, 2021
a20e97e
PR update
nizhikov Apr 22, 2021
de563f8
PR update
nizhikov Apr 22, 2021
953ba29
Merge branch 'ignite-ducktape' into IGNITE-14520
nizhikov Apr 23, 2021
cfbea97
IGNITE-14631 SSL certificates generation via python code
nizhikov Apr 25, 2021
ac2d6cd
IGNITE-14631 SSL certificates generation via python code
nizhikov Apr 26, 2021
ba2d5f9
IGNITE-14631 SSL certificates generation via python code
nizhikov Apr 26, 2021
0186c1d
IGNITE-14631 SSL certificates generation via python code
nizhikov Apr 26, 2021
4420bbf
IGNITE-14631 SSL certificates generation via python code
nizhikov Apr 26, 2021
c03ea0a
IGNITE-14520 Code style fix
nizhikov Apr 29, 2021
e51bfd9
IGNITE-14520 Code review fixes.
nizhikov Apr 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,21 @@ class TestParams:
expected_ssl_params_jks = {'key_store_path': os.path.join(CERT_DIR1, TEST_KEYSTORE_JKS),
'key_store_password': TEST_PASSWORD,
'trust_store_path': os.path.join(CERT_DIR1, TEST_TRUSTSTORE_JKS),
'trust_store_password': TEST_PASSWORD}
'trust_store_password': TEST_PASSWORD,
'cipher_suites': None,
'trust_managers': None}
expected_ssl_params_path = {'key_store_path': os.path.join(CERT_DIR2, TEST_KEYSTORE_JKS),
'key_store_password': TEST_PASSWORD,
'trust_store_path': os.path.join(CERT_DIR2, TEST_TRUSTSTORE_JKS),
'trust_store_password': TEST_PASSWORD}
'trust_store_password': TEST_PASSWORD,
'cipher_suites': None,
'trust_managers': None}
expected_ssl_params_default = {'key_store_path': os.path.join(CERT_DIR1, DEFAULT_CLIENT_KEYSTORE),
'key_store_password': DEFAULT_PASSWORD,
'trust_store_path': os.path.join(CERT_DIR1, DEFAULT_TRUSTSTORE),
'trust_store_password': DEFAULT_PASSWORD}
'trust_store_password': DEFAULT_PASSWORD,
'cipher_suites': None,
'trust_managers': None}


class CheckCaseJks:
Expand Down
5 changes: 5 additions & 0 deletions modules/ducktests/tests/docker/ducker-ignite
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ ducker_test() {
must_pushd "${ignite_dir}"
#(test mvn) && mvn package -DskipTests -Dmaven.javadoc.skip=true -Plgpl,-examples,-clean-libs,-release,-scala,-clientDocs
must_popd
if [[ -n "${DUCKTAPE_EXTRA_SETUP}" ]]; then
echo "executing extra ducktape setup with '${DUCKTAPE_EXTRA_SETUP}'"
docker exec --user=root ducker01 bash -c "${DUCKTAPE_EXTRA_SETUP}"
[[ $? -ne 0 ]] && die "failed to execute extra ducktape setup."
fi
cmd="cd /opt/ignite-dev && ducktape --cluster-file /opt/ignite-dev/modules/ducktests/tests/docker/build/cluster.json $args"
echo "docker exec ducker01 bash -c \"${cmd}\""
exec docker exec --user=ducker ducker01 bash -c "${cmd}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@

from jinja2 import FileSystemLoader, Environment

DEFAULT_CONFIG_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "templates")
DEFAULT_IGNITE_CONF = os.path.join(DEFAULT_CONFIG_PATH, "ignite.xml.j2")
DEFAULT_THIN_CLIENT_CONF = os.path.join(DEFAULT_CONFIG_PATH, "thin_client_config.xml.j2")
IGNITE_TEMPLATE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "templates")
ZK_TEMPLATE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "zk", "templates")
DEFAULT_IGNITE_CONF = "ignite.xml.j2"
DEFAULT_THIN_CLIENT_CONF = "thin_client_config.xml.j2"
DEFAULT_LOG4J_CONF = "log4j.xml.j2"

TEMPLATE_PATHES = [IGNITE_TEMPLATE_PATH, ZK_TEMPLATE_PATH]


class ConfigTemplate:
"""
Basic configuration.
"""
def __init__(self, path):
tmpl_dir = os.path.dirname(path)
tmpl_file = os.path.basename(path)

tmpl_loader = FileSystemLoader(searchpath=[DEFAULT_CONFIG_PATH, tmpl_dir])
env = Environment(loader=tmpl_loader)
env = Environment(loader=FileSystemLoader(searchpath=TEMPLATE_PATHES))

self.template = env.get_template(tmpl_file)
self.template = env.get_template(path)
self.default_params = {}

def render(self, **kwargs):
Expand Down Expand Up @@ -79,4 +79,4 @@ class IgniteLoggerConfigTemplate(ConfigTemplate):
Ignite logger configuration.
"""
def __init__(self):
super().__init__(os.path.join(DEFAULT_CONFIG_PATH, "log4j.xml.j2"))
super().__init__(DEFAULT_LOG4J_CONF)
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,11 @@ def init_shared(self, node):
node.account.copy_to(os.path.join(local_shared_dir, file), self.shared_root)

def _prepare_configs(self, node):
config = self.config.prepare_for_env(self.globals, self.shared_root, node, self)
config = self.spec \
.extend_config(self.config) \
.prepare_for_env(self, node)

for name, template in self.spec.config_templates:
for name, template in self.spec.config_templates():
config_txt = template.render(config_dir=self.config_dir, work_dir=self.work_dir, config=config)

node.account.create_file(os.path.join(self.config_dir, name), config_txt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from ignitetest.services.utils.ssl.connector_configuration import ConnectorConfiguration
from ignitetest.services.utils.ignite_configuration.data_storage import DataStorageConfiguration
from ignitetest.services.utils.ignite_configuration.discovery import DiscoverySpi, TcpDiscoverySpi
from ignitetest.services.utils.ignite_configuration.binary_configuration import BinaryConfiguration
from ignitetest.services.utils.ssl.ssl_params import SslParams, is_ssl_enabled, get_ssl_params, IGNITE_CLIENT_ALIAS, \
IGNITE_SERVER_ALIAS
from ignitetest.utils.version import IgniteVersion, DEV_BRANCH
Expand All @@ -45,18 +46,24 @@ class IgniteConfiguration(NamedTuple):
sys_worker_blocked_timeout: int = 10000
properties: str = None
data_storage: DataStorageConfiguration = None
binary_configuration: BinaryConfiguration = None
caches: list = []
local_host: str = None
ssl_params: SslParams = None
connector_configuration: ConnectorConfiguration = None
client_connector_configuration: ClientConnectorConfiguration = None
auth_enabled: bool = False
plugins: list = []
ext_beans: list = []
peer_class_loading_enabled: bool = True
metric_exporter: str = None
rebalance_thread_pool_size: int = None
rebalance_batch_size: int = None
rebalance_batches_prefetch_count: int = None
rebalance_throttle: int = None
local_event_listeners: str = None
include_event_types: str = None
event_storage_spi: str = None

def __prepare_ssl(self, test_globals, shared_root):
"""
Expand All @@ -75,7 +82,7 @@ def __prepare_ssl(self, test_globals, shared_root):
ssl_params=ssl_params))
return self

def __prepare_discovery(self, node, cluster):
def __prepare_discovery(self, cluster, node):
"""
Updates discovery configuration based on current environment.
"""
Expand All @@ -90,11 +97,11 @@ def __prepare_discovery(self, node, cluster):
return config

# pylint: disable=protected-access
def prepare_for_env(self, test_globals, shared_root, node, cluster):
def prepare_for_env(self, cluster, node):
"""
Updates configuration based on current environment.
"""
return self.__prepare_ssl(test_globals, shared_root).__prepare_discovery(node, cluster)
return self.__prepare_ssl(cluster.globals, cluster.shared_root).__prepare_discovery(cluster, node)

@property
def service_type(self):
Expand All @@ -119,7 +126,7 @@ class IgniteThinClientConfiguration(NamedTuple):
version: IgniteVersion = DEV_BRANCH

# pylint: disable=unused-argument
def prepare_for_env(self, test_globals, shared_root, node, cluster):
def prepare_for_env(self, cluster, node):
"""
Updates configuration based on current environment.
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License

"""
This module contains classes and utilities for Ignite Binary configuration.
"""

from typing import NamedTuple


class BinaryConfiguration(NamedTuple):
"""
Ignite Binary Configuration
"""
compact_footer: bool = True
13 changes: 9 additions & 4 deletions modules/ducktests/tests/ignitetest/services/utils/ignite_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def __init__(self, service, jvm_opts, full_jvm_opts):
"-Dlog4j.configuration=file:" + self.service.log_config_file,
"-Dlog4j.configDebug=true"])

@property
def config_templates(self):
"""
:return: config that service will use to start on a node
Expand All @@ -111,6 +110,13 @@ def config_templates(self):

return config_templates

# pylint: disable=unused-argument,no-self-use
def extend_config(self, config):
"""
Extend config with custom variables
"""
return config

def __home(self, product=None):
"""
Get home directory for current spec.
Expand Down Expand Up @@ -180,8 +186,7 @@ def init_local_shared(self):

script_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "certs")

self.__runcmd(f"cp {script_dir}/*.sh {local_dir}")
self.__runcmd(f"{local_dir}/mkcerts.sh")
self._runcmd(f"{script_dir}/mkcerts.sh {local_dir}")

return local_dir

Expand All @@ -196,7 +201,7 @@ def _add_jvm_opts(self, opts):
"""Properly adds JVM options to current"""
self.jvm_opts = merge_jvm_settings(self.jvm_opts, opts)

def __runcmd(self, cmd):
def _runcmd(self, cmd):
self.service.logger.debug(cmd)
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout, _ = proc.communicate()
Expand Down
4 changes: 4 additions & 0 deletions modules/ducktests/tests/ignitetest/services/utils/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def init_logs_attribute(self):
"config": {
"path": self.config_dir,
"collect_default": True
},
"shared": {
"path": self.shared_root,
"collect_default": True
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,20 @@

from typing import NamedTuple

from ignitetest.services.utils.ssl.ssl_params import SslParams


class ClientConnectorConfiguration(NamedTuple):
"""
Ignite ClientConnectorConfiguration.
Used to configure thin client properties.
"""
port: int = 10800
ssl_enabled: bool = False
use_ignite_ssl_context_factory: bool = True
ssl_client_auth: bool = False
ssl_params: SslParams = None
ssl_enabled: bool = False
use_ignite_ssl_context_factory: bool = True
ssl_client_auth: bool = False
ssl_params: SslParams = None
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ class ConnectorConfiguration(NamedTuple):
Used to connect from ControlUtility (control.sh).
"""
ssl_enabled: bool = False
ssl_client_auth: bool = False
ssl_params: SslParams = None
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,17 @@ class SslParams:
# pylint: disable=R0913
def __init__(self, root_dir: str, key_store_jks: str = None, key_store_password: str = DEFAULT_PASSWORD,
trust_store_jks: str = DEFAULT_TRUSTSTORE, trust_store_password: str = DEFAULT_PASSWORD,
key_store_path: str = None, trust_store_path: str = None):
key_store_path: str = None, trust_store_path: str = None, cipher_suites: str = None,
trust_managers: str = None):
if not key_store_jks and not key_store_path:
raise Exception("Keystore must be specified to init SslParams")

self.key_store_path = key_store_path if key_store_path else os.path.join(root_dir, key_store_jks)
self.key_store_password = key_store_password
self.trust_store_path = trust_store_path if trust_store_path else os.path.join(root_dir, trust_store_jks)
self.trust_store_password = trust_store_password
self.cipher_suites = cipher_suites
self.trust_managers = trust_managers


def get_ssl_params(_globals: dict, shared_root: str, alias: str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<property name="sslFactory">
{{ ssl_params_util.ssl_params(config.ssl_params) }}
</property>
<property name="sslClientAuth" value="{{ config.ssl_client_auth }}"/>
{% endif %}
</bean>
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="workDirectory" value="{{ work_dir }}" />
<property name="gridLogger">
Expand All @@ -41,6 +42,7 @@
<property name="consistentId" value="{{ config.consistent_id }}"/>
<property name="failureDetectionTimeout" value="{{ config.failure_detection_timeout }}"/>
<property name="systemWorkerBlockedTimeout" value="{{ config.sys_worker_blocked_timeout }}"/>
<property name="peerClassLoadingEnabled" value="{{ config.peer_class_loading_enabled }}"/>
<property name="authenticationEnabled" value="{{ config.auth_enabled | lower }}"/>
{% if config.rebalance_thread_pool_size %}
<property name="rebalanceThreadPoolSize" value="{{ config.rebalance_thread_pool_size }}"/>
Expand Down Expand Up @@ -93,9 +95,41 @@
{% if config.client_connector_configuration %}
<property name="clientConnectorConfiguration">
<bean class="org.apache.ignite.configuration.ClientConnectorConfiguration">
<property name="port" value="{{ config.client_connector_configuration.port }}"/>
<property name="port" value="{{ config.client_connector_configuration.port }}"/>
{% if config.client_connector_configuration.ssl_enabled %}
nizhikov marked this conversation as resolved.
Show resolved Hide resolved
<property name="sslEnabled" value="true"/>
<property name="sslContextFactory">
{{ ssl_params_util.ssl_params(config.client_connector_configuration.ssl_params) }}
</property>
<property name="useIgniteSslContextFactory" value="{{ config.client_connector_configuration.use_ignite_ssl_context_factory }}"/>
<property name="sslClientAuth" value="{{ config.client_connector_configuration.ssl_client_auth }}"/>
{% endif %}
</bean>
</property>
{% endif %}

{% if config.binary_configuration %}
<property name="binaryConfiguration">
<bean class="org.apache.ignite.configuration.BinaryConfiguration">
<property name="compactFooter" value="{{ config.binary_configuration.compact_footer }}"/>
</bean>
</property>
{% endif %}

{% if config.local_event_listeners %}
<property name="localEventListeners" ref="{{ config.local_event_listeners }}"/>
{% endif %}

{% if config.include_event_types %}
<property name="includeEventTypes" ref="{{ config.include_event_types }}"/>
{% endif %}

{% if config.event_storage_spi %}
<property name="eventStorageSpi" ref="{{ config.event_storage_spi }}"/>
{% endif %}

{{ misc_utils.plugins(config) }}
</bean>

{{ misc_utils.ext_beans(config) }}
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,25 @@
<property name="activeOnStart" value="{{ 'false' if state == 'INACTIVE' else 'true'}}"/>
{% endif %}
{% endmacro %}

{% macro plugins(config) %}
{% if config.plugins %}
<property name="pluginProviders">
<list>
{% for plugin in config.plugins %}
{% import plugin[0] as plugin_template -%}
{{ plugin_template.apply(config, plugin[1]) }}
{% endfor %}
</list>
</property>
{% endif %}
{% endmacro %}

{% macro ext_beans(config) %}
{% if config.ext_beans %}
{% for ext_bean in config.ext_beans %}
{% import ext_bean[0] as bean_template -%}
{{ bean_template.apply(config, ext_bean[1]) }}
{% endfor %}
{% endif %}
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,13 @@
<property name="keyStorePassword" value="{{ ctx.key_store_password }}"/>
<property name="trustStoreFilePath" value="{{ ctx.trust_store_path }}"/>
<property name="trustStorePassword" value="{{ ctx.trust_store_password }}"/>

{% if ctx.cipher_suites %}
<property name="cipherSuites" value="{{ ctx.cipher_suites }}"/>
{% endif %}

{% if ctx.trust_managers %}
<property name="trustManagers" ref="{{ ctx.trust_managers }}"/>
{% endif %}
</bean>
{% endmacro %}