apache-ignite

Форк
0
97 строк · 4.0 Кб
1
# Licensed to the Apache Software Foundation (ASF) under one or more
2
# contributor license agreements.  See the NOTICE file distributed with
3
# this work for additional information regarding copyright ownership.
4
# The ASF licenses this file to You under the Apache License, Version 2.0
5
# (the "License"); you may not use this file except in compliance with
6
# the License.  You may obtain a copy of the License at
7
#
8
#    http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15

16
"""
17
Checks Spec class that describes config and command line to start Ignite-aware service.
18
"""
19
from unittest.mock import Mock
20

21
import pytest
22

23
from ignitetest.services.utils.ignite_spec import IgniteApplicationSpec
24
from ignitetest.utils.ignite_test import JFR_ENABLED
25

26

27
@pytest.fixture
28
def service():
29
    """
30
    Create mock of service.
31
    """
32
    service = Mock()
33
    service.log_dir = ''
34
    service.persistent_root = ''
35
    service.context.globals = {"cluster_size": 1}
36
    service.log_config_file = ''
37

38
    return service
39

40

41
"""
42
Checks that the JVM options passed via constructor are not overriden by the default ones.
43
"""
44

45

46
def check_default_options__are_used__if_jvm_opts_is_not_passed(service):
47
    spec = IgniteApplicationSpec(service)
48
    assert "-DIGNITE_NO_SHUTDOWN_HOOK=true" in spec.jvm_opts
49
    assert "-Dlog4j.configDebug=true" in spec.jvm_opts
50

51

52
def check_default_options__are_overriden__if_passed_as_jvm_opts_string(service):
53
    spec_with_default = IgniteApplicationSpec(service)
54
    spec_with_default_overriden = IgniteApplicationSpec(service, jvm_opts="-Dlog4j.configDebug=false")
55
    assert "-Dlog4j.configDebug=true" in spec_with_default.jvm_opts
56
    assert "-Dlog4j.configDebug=true" not in spec_with_default_overriden.jvm_opts
57

58
    assert "-Dlog4j.configDebug=false" not in spec_with_default.jvm_opts
59
    assert "-Dlog4j.configDebug=false" in spec_with_default_overriden.jvm_opts
60

61

62
def check_default_options__are_overriden__if_passed_as_jvm_opts_list(service):
63
    spec_with_default = IgniteApplicationSpec(service)
64
    spec_with_default_overriden = IgniteApplicationSpec(service, jvm_opts=["-Dlog4j.configDebug=false"])
65
    assert "-Dlog4j.configDebug=true" in spec_with_default.jvm_opts
66
    assert "-Dlog4j.configDebug=true" not in spec_with_default_overriden.jvm_opts
67

68
    assert "-Dlog4j.configDebug=false" not in spec_with_default.jvm_opts
69
    assert "-Dlog4j.configDebug=false" in spec_with_default_overriden.jvm_opts
70

71

72
def check_default_jvm_options__are_not_used__if_merge_with_default_is_false(service):
73
    spec = IgniteApplicationSpec(service, jvm_opts="-Xmx256m -ea", merge_with_default=False)
74
    assert "-Xmx256m" in spec.jvm_opts
75
    assert "-ea" in spec.jvm_opts
76
    assert len(spec.jvm_opts) == 2
77

78
    spec = IgniteApplicationSpec(service, merge_with_default=False)
79
    assert len(spec.jvm_opts) == 0
80

81

82
def check_boolean_options__go_after_default_ones_and_overwrite_them__if_passed_via_jvm_opt(service):
83
    service.context.globals[JFR_ENABLED] = True
84
    spec = IgniteApplicationSpec(service, jvm_opts="-XX:-UnlockCommercialFeatures")
85
    assert "-XX:-UnlockCommercialFeatures" in spec.jvm_opts
86
    assert "-XX:-UnlockCommercialFeatures" in spec.jvm_opts
87
    assert spec.jvm_opts.index("-XX:-UnlockCommercialFeatures") >\
88
           spec.jvm_opts.index("-XX:+UnlockCommercialFeatures")
89

90

91
def check_colon_options__go_after_default_ones_and_overwrite_them__if_passed_via_jvm_opt(service):
92
    service.log_dir = "/default-path"
93
    spec = IgniteApplicationSpec(service, jvm_opts=["-Xloggc:/some-non-default-path/gc.log"])
94
    assert "-Xloggc:/some-non-default-path/gc.log" in spec.jvm_opts
95
    assert "-Xloggc:/default-path/gc.log" in spec.jvm_opts
96
    assert spec.jvm_opts.index("-Xloggc:/some-non-default-path/gc.log") > \
97
           spec.jvm_opts.index("-Xloggc:/default-path/gc.log")
98

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.