GitLab maintenance scheduled for Tomorrow, 2019-04-24, from 12:00 to 13:00 CDT - Services will be unavailable during this time.

Commit 951e07c8 authored by Swann Perarnau's avatar Swann Perarnau

[fix] feature not in manifest counted as enabled

Missing checks in aci resulted in features absent from the manifest to
be counted as enabled.
parent 1fa07af3
......@@ -258,7 +258,9 @@ class IsolatorList(SpecField):
setattr(self, name.lstrip("argo/"), v)
for k in self.types:
if self.types[k].required:
assert name.lstrip("argo/") in self.__dict__
if not hasattr(self, k.lstrip("argo/")):
logger.error("Missing mandatory isolator: %s", k)
return False
return True
......@@ -318,4 +320,6 @@ class ImageManifest(SpecField):
if hasattr(isolator, 'enabled'):
if isolator.enabled not in true_values:
return False
return True
return True
else:
return False
......@@ -11,9 +11,16 @@ def manifest_base_data():
"acKind": "ImageManifest",
"acVersion": "0.6.0",
"name": "test",
"app":
{
"isolators": []
"app": {
"isolators": [
{
"name": "argo/container",
"value": {
"cpus": "1",
"mems": "1"
}
}
]
}
}'''
return json.loads(data)
......@@ -30,7 +37,7 @@ def test_manifest_disabled_perfwrapper(manifest_base_data):
}'''
isolator = json.loads(isolator_text)
data = manifest_base_data
data["app"]["isolators"] = [isolator]
data["app"]["isolators"].append(isolator)
assert manifest.load_dict(data)
assert not manifest.is_feature_enabled("perfwrapper")
......@@ -44,6 +51,13 @@ def test_enabled_feature(manifest_base_data):
}'''
isolator = json.loads(isolator_text)
data = manifest_base_data
data["app"]["isolators"] = [isolator]
data["app"]["isolators"].append(isolator)
assert manifest.load_dict(data)
assert manifest.is_feature_enabled("perfwrapper")
def test_missing_disabled(manifest_base_data):
"""Ensure that a missing feature doesn't appear enabled."""
manifest = nrm.aci.ImageManifest()
assert manifest.load_dict(manifest_base_data)
assert not manifest.is_feature_enabled("perfwrapper")
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