Make rejectable_message_size configurable for log-api tests

When setting [service]max_log_size in the monasca-log-api
configuration to a value larger than the default (which is 1 MB
currently), the following tempest tests fail:

- monasca_tempest_tests.tests.log_api.test_constraints.\
  TestLogApiConstraints.test_should_reject_too_big_message
- monasca_tempest_tests.tests.log_api.test_constraints.\
  TestLogApiConstraints.test_should_reject_too_big_message_multiline

This happens because the tempest tests assume that the maximum log
size is 1 MB but that is not always the case because
[service]max_log_size can be increased to a larger value.

So add a new configuration option in tempest.conf under the
[monitoring] section to be able to set the maximum log size. This
option (called "log_api_max_log_size") should be set to the same value
than [service]max_log_size in the monasca-log-api configuration file.

Depends-On: https://review.openstack.org/#/c/634308/
Change-Id: I893c66fd640017e6cc94298207d771a3ac3b8053
Story: 2004944
Task: 29346
This commit is contained in:
Thomas Bechtold 2019-02-06 07:01:08 +01:00
parent 0ad394d8da
commit 2bbd16e46d
2 changed files with 10 additions and 2 deletions

View File

@ -54,5 +54,10 @@ MonitoringGroup = [
help='monasca-log-api API version'), help='monasca-log-api API version'),
cfg.StrOpt('kibana_version', cfg.StrOpt('kibana_version',
default='4.6.3', default='4.6.3',
help='Kibana version') help='Kibana version'),
cfg.IntOpt('log_api_max_log_size',
default=1024 * 1024,
help=('Refers to payload/envelope size. This should be set '
'to the same value as "[service]max_log_size" in the '
'monasca-log-api configuration'))
] ]

View File

@ -40,7 +40,10 @@ def _get_message_size(size_base):
_SMALL_MESSAGE_SIZE = _get_message_size(0.001) _SMALL_MESSAGE_SIZE = _get_message_size(0.001)
_MEDIUM_MESSAGE_SIZE = _get_message_size(0.01) _MEDIUM_MESSAGE_SIZE = _get_message_size(0.01)
_LARGE_MESSAGE_SIZE = _get_message_size(0.1) _LARGE_MESSAGE_SIZE = _get_message_size(0.1)
_REJECTABLE_MESSAGE_SIZE = _get_message_size(1.1) # rejectable message must be larger than [service]max_log_size
# from monasca-log-api.conf
_reject_size = CONF.monitoring.log_api_max_log_size/_ONE_MB + 0.1
_REJECTABLE_MESSAGE_SIZE = _get_message_size(_reject_size)
def generate_unique_message(message=None, size=50): def generate_unique_message(message=None, size=50):