diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-05-28 16:59:53 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-05-28 16:59:53 +0000 |
| commit | 713d612582a2c82ea1eae0d7286d2f83e95cb258 (patch) | |
| tree | 9719d538005c037d7f002b7f6de2087658e35870 /nova/tests | |
| parent | c80ab0094a22ff790c1e13064fd635862a213f82 (diff) | |
| parent | 0357b01c12eb6b84b5038bbf465fd3b9d4921a29 (diff) | |
Merge "xenapi: make the xenapi agent optional per image"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/virt/xenapi/imageupload/test_glance.py | 4 | ||||
| -rw-r--r-- | nova/tests/virt/xenapi/test_agent.py | 51 | ||||
| -rw-r--r-- | nova/tests/virt/xenapi/test_xenapi.py | 2 |
3 files changed, 56 insertions, 1 deletions
diff --git a/nova/tests/virt/xenapi/imageupload/test_glance.py b/nova/tests/virt/xenapi/imageupload/test_glance.py index 34e95ab80..7b6fbd43d 100644 --- a/nova/tests/virt/xenapi/imageupload/test_glance.py +++ b/nova/tests/virt/xenapi/imageupload/test_glance.py @@ -48,10 +48,12 @@ class TestGlanceStore(test.TestCase): properties = { 'auto_disk_config': True, 'os_type': 'default', + 'xenapi_use_agent': 'true', } image_id = 'fake_image_uuid' vdi_uuids = ['fake_vdi_uuid'] - instance = {'uuid': 'blah'} + instance = {'uuid': 'blah', + 'system_metadata': {'image_xenapi_use_agent': 'true'}} instance.update(properties) params = {'vdi_uuids': vdi_uuids, diff --git a/nova/tests/virt/xenapi/test_agent.py b/nova/tests/virt/xenapi/test_agent.py new file mode 100644 index 000000000..9a4d7c345 --- /dev/null +++ b/nova/tests/virt/xenapi/test_agent.py @@ -0,0 +1,51 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2013 OpenStack Foundation +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +from nova import test +from nova.virt.xenapi import agent + + +class AgentEnabledCase(test.TestCase): + def test_agent_is_present(self): + self.flags(xenapi_use_agent_default=False) + instance = {"system_metadata": + {"image_xenapi_use_agent": "true"}} + self.assertTrue(agent.should_use_agent(instance)) + + def test_agent_is_disabled(self): + self.flags(xenapi_use_agent_default=True) + instance = {"system_metadata": + {"image_xenapi_use_agent": "false"}} + self.assertFalse(agent.should_use_agent(instance)) + + def test_agent_uses_deafault_when_prop_invalid(self): + self.flags(xenapi_use_agent_default=True) + instance = {"system_metadata": + {"image_xenapi_use_agent": "bob"}, + "uuid": "uuid"} + self.assertTrue(agent.should_use_agent(instance)) + + def test_agent_default_not_present(self): + self.flags(xenapi_use_agent_default=False) + instance = {"system_metadata": {}} + self.assertFalse(agent.should_use_agent(instance)) + + def test_agent_default_present(self): + self.flags(xenapi_use_agent_default=True) + instance = {"system_metadata": {}} + self.assertTrue(agent.should_use_agent(instance)) diff --git a/nova/tests/virt/xenapi/test_xenapi.py b/nova/tests/virt/xenapi/test_xenapi.py index af2d97f67..538752cf2 100644 --- a/nova/tests/virt/xenapi/test_xenapi.py +++ b/nova/tests/virt/xenapi/test_xenapi.py @@ -972,6 +972,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): def test_spawn_ssh_key_injection(self): # Test spawning with key_data on an instance. Should use # agent file injection. + self.flags(xenapi_use_agent_default=True) actual_injected_files = [] def fake_inject_file(self, method, args): @@ -999,6 +1000,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase): def test_spawn_injected_files(self): # Test spawning with injected_files. + self.flags(xenapi_use_agent_default=True) actual_injected_files = [] def fake_inject_file(self, method, args): |
