diff options
author | Scott Moser <smoser@ubuntu.com> | 2014-02-27 14:12:01 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2014-02-27 14:12:01 -0500 |
commit | 20098e0167e8d8024317a6ed61b0cac363bdae2a (patch) | |
tree | 334bce6f0fc7b2a804c1da4e2db52edb25a389d5 /tests/unittests/test_datasource | |
parent | 53794c0cf2cf66868f5bf528883edaa375793dcf (diff) | |
parent | aa48873f26e6bb8161ea56c6d001a262a8b72e9d (diff) | |
download | vyos-cloud-init-20098e0167e8d8024317a6ed61b0cac363bdae2a.tar.gz vyos-cloud-init-20098e0167e8d8024317a6ed61b0cac363bdae2a.zip |
test_altcloud: fix altcloud tests when running on arm
Similar test-hack as the SmartOS one.
Here we just pretend that we're running on x86_64 so as to avoid
re-writing the tests to expect otherwise on arm.
Diffstat (limited to 'tests/unittests/test_datasource')
-rw-r--r-- | tests/unittests/test_datasource/test_altcloud.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unittests/test_datasource/test_altcloud.py b/tests/unittests/test_datasource/test_altcloud.py index bda61c7e..eaaa90e6 100644 --- a/tests/unittests/test_datasource/test_altcloud.py +++ b/tests/unittests/test_datasource/test_altcloud.py @@ -33,6 +33,8 @@ import cloudinit.sources.DataSourceAltCloud from cloudinit.sources.DataSourceAltCloud import DataSourceAltCloud from cloudinit.sources.DataSourceAltCloud import read_user_data_callback +OS_UNAME_ORIG = getattr(os, 'uname') + def _write_cloud_info_file(value): ''' @@ -104,11 +106,16 @@ class TestGetCloudType(TestCase): def setUp(self): '''Set up.''' self.paths = helpers.Paths({'cloud_dir': '/tmp'}) + # We have a different code path for arm to deal with LP1243287 + # We have to switch arch to x86_64 to avoid test failure + force_arch('x86_64') def tearDown(self): # Reset cloudinit.sources.DataSourceAltCloud.CMD_DMI_SYSTEM = \ ['dmidecode', '--string', 'system-product-name'] + # Return back to original arch + force_arch() def test_rhev(self): ''' @@ -238,6 +245,9 @@ class TestGetDataNoCloudInfoFile(TestCase): self.paths = helpers.Paths({'cloud_dir': '/tmp'}) cloudinit.sources.DataSourceAltCloud.CLOUD_INFO_FILE = \ 'no such file' + # We have a different code path for arm to deal with LP1243287 + # We have to switch arch to x86_64 to avoid test failure + force_arch('x86_64') def tearDown(self): # Reset @@ -245,6 +255,8 @@ class TestGetDataNoCloudInfoFile(TestCase): '/etc/sysconfig/cloud-info' cloudinit.sources.DataSourceAltCloud.CMD_DMI_SYSTEM = \ ['dmidecode', '--string', 'system-product-name'] + # Return back to original arch + force_arch() def test_rhev_no_cloud_file(self): '''Test No cloud info file module get_data() forcing RHEV.''' @@ -442,4 +454,16 @@ class TestReadUserDataCallback(TestCase): _remove_user_data_files(self.mount_dir) self.assertEquals(None, read_user_data_callback(self.mount_dir)) + +def force_arch(arch=None): + + def _os_uname(): + return ('LINUX', 'NODENAME', 'RELEASE', 'VERSION', arch) + + if arch: + setattr(os, 'uname', _os_uname) + elif arch is None: + setattr(os, 'uname', OS_UNAME_ORIG) + + # vi: ts=4 expandtab |