Commit bd0228a3 authored by Kirill Smelkov's avatar Kirill Smelkov

Merge branch 'master' into x/lte-multiru

* master:
  recipe/check_parameter: support multi lines values
  software/erp5/test: use short partition references
  stack/erp5: rename an internal parameter still mentioning apache
parents b127c288 54dcf459
...@@ -45,10 +45,8 @@ class Recipe(GenericBaseRecipe): ...@@ -45,10 +45,8 @@ class Recipe(GenericBaseRecipe):
elif self.options.get('expected-type') == "ipv4": elif self.options.get('expected-type') == "ipv4":
template = self.getTemplateFilename('check_ipv4.py.in') template = self.getTemplateFilename('check_ipv4.py.in')
else: else:
config["expected-value"] = self.options.get('expected-value') config["expected-value"] = str(self.options.get('expected-value', ''))
config["expected-not-value"] = str(self.options.get('expected-not-value', ''))
config["expected-not-value"] = self.options.get('expected-not-value')
template = self.getTemplateFilename('check_parameter.py.in') template = self.getTemplateFilename('check_parameter.py.in')
promise = self.createExecutable( promise = self.createExecutable(
......
...@@ -5,14 +5,14 @@ from __future__ import print_function ...@@ -5,14 +5,14 @@ from __future__ import print_function
import socket import socket
import sys import sys
value = "%(value)s" value = %(value)r
expected = "%(expected-value)s" expected = %(expected-value)r
not_expected = "%(expected-not-value)s" not_expected = %(expected-not-value)r
if expected != "" and value != expected: if expected != "" and value != expected:
print("FAIL: %%s != %%s" %% (value, expected)) print("FAIL: %%s != %%s" %% (value, expected))
sys.exit(127) sys.exit(127)
if not_expected != "" and value == not_expected: if not_expected != "" and value == not_expected:
print("FAIL: %%s == %%s" %% (value, not_expected)) print("FAIL: %%s == %%s" %% (value, not_expected))
sys.exit(127) sys.exit(127)
import os
import subprocess
import tempfile
import unittest
import zc.buildout.testing
from slapos.recipe import check_parameter
class TestCheckParameter(unittest.TestCase):
def setUp(self):
self.buildout = zc.buildout.testing.Buildout()
def _makeRecipe(self, options):
path = tempfile.NamedTemporaryFile(delete=False).name
self.addCleanup(os.unlink, path)
options.setdefault("path", path)
self.buildout["check-parameter"] = options
recipe = check_parameter.Recipe(
self.buildout, "check-parameter", self.buildout["check-parameter"]
)
return recipe
def test_expected_value_ok(self):
script = self._makeRecipe({"expected-value": "foo", "value": "foo"}).install()
subprocess.check_call(script)
def test_expected_value_not_ok(self):
script = self._makeRecipe({"expected-value": "foo", "value": "bar"}).install()
with self.assertRaises(subprocess.CalledProcessError) as e:
subprocess.check_output(script, universal_newlines=True)
self.assertEqual(e.exception.output, "FAIL: bar != foo\n")
def test_expected_value_multi_lines_ok(self):
script = self._makeRecipe(
{"expected-value": "foo\nbar", "value": "foo\nbar"}
).install()
subprocess.check_output(script)
def test_expected_value_multi_lines_not_ok(self):
script = self._makeRecipe({"expected-value": "foo\nbar", "value": "foo"}).install()
with self.assertRaises(subprocess.CalledProcessError) as e:
subprocess.check_output(script, universal_newlines=True)
self.assertEqual(e.exception.output, "FAIL: foo != foo\nbar\n")
def test_expected_not_value_ok(self):
script = self._makeRecipe({"expected-not-value": "foo", "value": "bar"}).install()
subprocess.check_call(script)
def test_expected_not_value_not_ok(self):
script = self._makeRecipe({"expected-not-value": "foo", "value": "foo"}).install()
with self.assertRaises(subprocess.CalledProcessError) as e:
subprocess.check_output(script, universal_newlines=True)
self.assertEqual(e.exception.output, "FAIL: foo == foo\n")
...@@ -1104,7 +1104,7 @@ class TestNEO(ZopeSkinsMixin, CrontabMixin, ERP5InstanceTestCase): ...@@ -1104,7 +1104,7 @@ class TestNEO(ZopeSkinsMixin, CrontabMixin, ERP5InstanceTestCase):
class TestWithMaxRlimitNofileParameter(ERP5InstanceTestCase, TestPublishedURLIsReachableMixin): class TestWithMaxRlimitNofileParameter(ERP5InstanceTestCase, TestPublishedURLIsReachableMixin):
"""Test setting the with-max-rlimit-nofile parameter sets the open fd soft limit to the hard limit. """Test setting the with-max-rlimit-nofile parameter sets the open fd soft limit to the hard limit.
""" """
__partition_reference__ = 'with-max-rlimit-nofile' __partition_reference__ = 'nf'
@classmethod @classmethod
def getInstanceParameterDict(cls): def getInstanceParameterDict(cls):
...@@ -1123,7 +1123,7 @@ class TestWithMaxRlimitNofileParameter(ERP5InstanceTestCase, TestPublishedURLIsR ...@@ -1123,7 +1123,7 @@ class TestWithMaxRlimitNofileParameter(ERP5InstanceTestCase, TestPublishedURLIsR
class TestUnsetWithMaxRlimitNofileParameter(ERP5InstanceTestCase, TestPublishedURLIsReachableMixin): class TestUnsetWithMaxRlimitNofileParameter(ERP5InstanceTestCase, TestPublishedURLIsReachableMixin):
"""Test not setting the with-max-rlimit-nofile parameter doesn't change the soft limit of erp5 """Test not setting the with-max-rlimit-nofile parameter doesn't change the soft limit of erp5
""" """
__partition_reference__ = 'unset-with-max-rlimit-nofile' __partition_reference__ = 'nnf'
def test_unset_with_max_rlimit_nofile(self) -> None: def test_unset_with_max_rlimit_nofile(self) -> None:
with self.slap.instance_supervisor_rpc as supervisor: with self.slap.instance_supervisor_rpc as supervisor:
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
# not need these here). # not need these here).
[template-erp5] [template-erp5]
filename = instance-erp5.cfg.in filename = instance-erp5.cfg.in
md5sum = c605292e57a12e42d9c2676e38c072c6 md5sum = 1fbfca2d64a9824054f7a3281e71efdc
[template-balancer] [template-balancer]
filename = instance-balancer.cfg.in filename = instance-balancer.cfg.in
......
...@@ -309,7 +309,7 @@ config-webdav = {{ dumps(current_zope_family_override_dict.get('webdav', zope_pa ...@@ -309,7 +309,7 @@ config-webdav = {{ dumps(current_zope_family_override_dict.get('webdav', zope_pa
config-publisher-timeout = {{ dumps(current_zope_family_override_dict.get('publisher-timeout', global_publisher_timeout)) }} config-publisher-timeout = {{ dumps(current_zope_family_override_dict.get('publisher-timeout', global_publisher_timeout)) }}
config-activity-timeout = {{ dumps(current_zope_family_override_dict.get('activity-timeout', global_activity_timeout)) }} config-activity-timeout = {{ dumps(current_zope_family_override_dict.get('activity-timeout', global_activity_timeout)) }}
{% if test_runner_enabled -%} {% if test_runner_enabled -%}
config-test-runner-apache-url-list = ${publish-early:{{ zope_family }}-test-runner-url-list} config-test-runner-balancer-url-list = ${publish-early:{{ zope_family }}-test-runner-url-list}
[{{ promise_software_url_section_name }}] [{{ promise_software_url_section_name }}]
# Promise to wait for zope partition to use the expected software URL, # Promise to wait for zope partition to use the expected software URL,
......
...@@ -74,7 +74,7 @@ md5sum = 55232eae0bcdb68a7cb2598d2ba9d60c ...@@ -74,7 +74,7 @@ md5sum = 55232eae0bcdb68a7cb2598d2ba9d60c
[template-erp5] [template-erp5]
filename = instance-erp5.cfg.in filename = instance-erp5.cfg.in
md5sum = 2bb2addc8deddff00053a065f5e2793e md5sum = 359bab24aec7772adb5d822c1389b1bd
[template-zeo] [template-zeo]
filename = instance-zeo.cfg.in filename = instance-zeo.cfg.in
...@@ -86,7 +86,7 @@ md5sum = 0ac4b74436f554cd677f19275d18d880 ...@@ -86,7 +86,7 @@ md5sum = 0ac4b74436f554cd677f19275d18d880
[template-zope] [template-zope]
filename = instance-zope.cfg.in filename = instance-zope.cfg.in
md5sum = 8a2c78000e1e791dc48305a2e7330b16 md5sum = 2439b90d6f707f47050fc9074fa4d810
[template-balancer] [template-balancer]
filename = instance-balancer.cfg.in filename = instance-balancer.cfg.in
......
...@@ -321,12 +321,12 @@ config-webdav = {{ dumps(current_zope_family_override_dict.get('webdav', zope_pa ...@@ -321,12 +321,12 @@ config-webdav = {{ dumps(current_zope_family_override_dict.get('webdav', zope_pa
config-publisher-timeout = {{ dumps(current_zope_family_override_dict.get('publisher-timeout', global_publisher_timeout)) }} config-publisher-timeout = {{ dumps(current_zope_family_override_dict.get('publisher-timeout', global_publisher_timeout)) }}
config-activity-timeout = {{ dumps(current_zope_family_override_dict.get('activity-timeout', global_activity_timeout)) }} config-activity-timeout = {{ dumps(current_zope_family_override_dict.get('activity-timeout', global_activity_timeout)) }}
{% if test_runner_enabled -%} {% if test_runner_enabled -%}
config-test-runner-apache-url-list = ${publish-early:{{ zope_family }}-test-runner-url-list} config-test-runner-balancer-url-list = ${publish-early:{{ zope_family }}-test-runner-url-list}
[{{ check_test_runner_url_section_name }}] [{{ check_test_runner_url_section_name }}]
# Promise to wait for zope partition to receive the expected test-runner URL # Promise to wait for zope partition to receive the expected test-runner URL
recipe = slapos.cookbook:check_parameter recipe = slapos.cookbook:check_parameter
value = {{ '${' ~ section_name ~ ':config-test-runner-apache-url-list}' }} value = {{ '${' ~ section_name ~ ':config-test-runner-balancer-url-list}' }}
expected-not-value = not-ready expected-not-value = not-ready
expected-value = expected-value =
path = ${directory:bin}/${:_buildout_section_name_} path = ${directory:bin}/${:_buildout_section_name_}
......
...@@ -523,7 +523,7 @@ command-line-extra = ...@@ -523,7 +523,7 @@ command-line-extra =
--erp5_sql_connection_string '{{ connection_string_list[0] }}' --erp5_sql_connection_string '{{ connection_string_list[0] }}'
--extra_sql_connection_string_list '{{ ','.join(connection_string_list[1:]) }}' --extra_sql_connection_string_list '{{ ','.join(connection_string_list[1:]) }}'
--zserver {{ test_runner_address_list[0][0] ~ ':' ~ test_runner_address_list[0][1] }} --zserver {{ test_runner_address_list[0][0] ~ ':' ~ test_runner_address_list[0][1] }}
--zserver_frontend_url {{ slapparameter_dict['test-runner-apache-url-list'][0] }} --zserver_frontend_url {{ slapparameter_dict['test-runner-balancer-url-list'][0] }}
{% if test_runner_random_activity_priority is not none %} {% if test_runner_random_activity_priority is not none %}
--random_activity_priority={{ test_runner_random_activity_priority }} --random_activity_priority={{ test_runner_random_activity_priority }}
{%- endif %} {%- endif %}
...@@ -540,21 +540,21 @@ environment-extra += ...@@ -540,21 +540,21 @@ environment-extra +=
{% do zserver_address_list.append(ip ~ ':' ~ port) %} {% do zserver_address_list.append(ip ~ ':' ~ port) %}
{% endfor -%} {% endfor -%}
zserver_address_list={{ ','.join(zserver_address_list) }} zserver_address_list={{ ','.join(zserver_address_list) }}
zserver_frontend_url_list={{ ','.join(slapparameter_dict['test-runner-apache-url-list']) }} zserver_frontend_url_list={{ ','.join(slapparameter_dict['test-runner-balancer-url-list']) }}
[promise-test-runner-apache-url-executable] [promise-test-runner-balancer-url-executable]
# promise to wait for apache partition to have returned the parameter # promise to wait for balancer partition to have returned the parameter
recipe = slapos.cookbook:check_parameter recipe = slapos.cookbook:check_parameter
value = {{ slapparameter_dict['test-runner-apache-url-list'] }} value = {{ slapparameter_dict['test-runner-balancer-url-list'] }}
expected-not-value = not-ready expected-not-value = not-ready
path = ${directory:bin}/${:_buildout_section_name_} path = ${directory:bin}/${:_buildout_section_name_}
expected-value = expected-value =
[{{ section("promise-test-runner-apache-url") }}] [{{ section("promise-test-runner-balancer-url") }}]
<= monitor-promise-base <= monitor-promise-base
promise = check_command_execute promise = check_command_execute
name = ${:_buildout_section_name_}.py name = ${:_buildout_section_name_}.py
config-command = ${promise-test-runner-apache-url-executable:path} config-command = ${promise-test-runner-balancer-url-executable:path}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment