Commit 49a1619b authored by Daniele Venzano's avatar Daniele Venzano 🏇
Browse files

Merge branch 'devel/platform_status' into 'master'

Fix ZApp validation with new resource limits management

See merge request !47
parents 0886e348 019051b4
......@@ -24,6 +24,7 @@ import jsonschema
from zoe_lib.exceptions import InvalidApplicationDescription, ZoeLibException
import zoe_lib.version
import zoe_lib.config
log = logging.getLogger(__name__)
......@@ -56,11 +57,12 @@ def app_validate(data):
if service['monitor']:
found_monitor = True
service['resources']['memory']['max'] = zoe_lib.config.get_conf().max_memory_limit * (1024 ** 3)
if service['resources']['memory']['min'] is not None and service['resources']['memory']['min'] > service['resources']['memory']['max']:
raise InvalidApplicationDescription(msg='service {} has mismatching min and max memory limits'.format(service['name']))
raise InvalidApplicationDescription(msg='service {} tries to reserve more memory than the administrative limit'.format(service['name']))
if service['resources']['cores']['min'] is not None and service['resources']['cores']['min'] > service['resources']['cores']['max']:
raise InvalidApplicationDescription(msg='service {} has mismatching min and max memory limits'.format(service['name']))
if service['resources']['cores']['min'] is None:
service['resources']['cores']['min'] = 0.1
if not found_monitor:
raise InvalidApplicationDescription(msg="at least one process should have the monitor property set to true")
......@@ -16,14 +16,28 @@
"""Unit tests for zoe_lib/applications.py"""
import json
from collections import namedtuple
import pytest
from zoe_lib import applications
ConfigMockup = namedtuple('ConfigMockup', ['max_core_limit', 'max_memory_limit'])
def fake_get_conf():
"""Mock-up for the config.get_conf() method."""
return ConfigMockup(16, 64)
class TestApplicationsMethods:
"""Application validation tests."""
@pytest.fixture(autouse=True)
def mock_config(self, monkeypatch):
"""Fixture for mock config method."""
monkeypatch.setattr('zoe_lib.config.get_conf', fake_get_conf)
def test_pass_for_zapp(self):
"""Test zapp validation code."""
zapp_fp = json.load(open('tests/zapp.json', 'r'))
......
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