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): ...@@ -258,7 +258,9 @@ class IsolatorList(SpecField):
setattr(self, name.lstrip("argo/"), v) setattr(self, name.lstrip("argo/"), v)
for k in self.types: for k in self.types:
if self.types[k].required: 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 return True
...@@ -318,4 +320,6 @@ class ImageManifest(SpecField): ...@@ -318,4 +320,6 @@ class ImageManifest(SpecField):
if hasattr(isolator, 'enabled'): if hasattr(isolator, 'enabled'):
if isolator.enabled not in true_values: if isolator.enabled not in true_values:
return False return False
return True return True
else:
return False
...@@ -11,9 +11,16 @@ def manifest_base_data(): ...@@ -11,9 +11,16 @@ def manifest_base_data():
"acKind": "ImageManifest", "acKind": "ImageManifest",
"acVersion": "0.6.0", "acVersion": "0.6.0",
"name": "test", "name": "test",
"app": "app": {
{ "isolators": [
"isolators": [] {
"name": "argo/container",
"value": {
"cpus": "1",
"mems": "1"
}
}
]
} }
}''' }'''
return json.loads(data) return json.loads(data)
...@@ -30,7 +37,7 @@ def test_manifest_disabled_perfwrapper(manifest_base_data): ...@@ -30,7 +37,7 @@ def test_manifest_disabled_perfwrapper(manifest_base_data):
}''' }'''
isolator = json.loads(isolator_text) isolator = json.loads(isolator_text)
data = manifest_base_data data = manifest_base_data
data["app"]["isolators"] = [isolator] data["app"]["isolators"].append(isolator)
assert manifest.load_dict(data) assert manifest.load_dict(data)
assert not manifest.is_feature_enabled("perfwrapper") assert not manifest.is_feature_enabled("perfwrapper")
...@@ -44,6 +51,13 @@ def test_enabled_feature(manifest_base_data): ...@@ -44,6 +51,13 @@ def test_enabled_feature(manifest_base_data):
}''' }'''
isolator = json.loads(isolator_text) isolator = json.loads(isolator_text)
data = manifest_base_data data = manifest_base_data
data["app"]["isolators"] = [isolator] data["app"]["isolators"].append(isolator)
assert manifest.load_dict(data) assert manifest.load_dict(data)
assert manifest.is_feature_enabled("perfwrapper") 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