summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Strikov <oleg.strikov@canonical.com>2014-02-27 22:34:55 +0400
committerOleg Strikov <oleg.strikov@canonical.com>2014-02-27 22:34:55 +0400
commitaa48873f26e6bb8161ea56c6d001a262a8b72e9d (patch)
treea905dde6dabc4ec5fb8ab9e9b5924a13d7c74780
parent53794c0cf2cf66868f5bf528883edaa375793dcf (diff)
downloadvyos-cloud-init-aa48873f26e6bb8161ea56c6d001a262a8b72e9d.tar.gz
vyos-cloud-init-aa48873f26e6bb8161ea56c6d001a262a8b72e9d.zip
AltCloud: fix test failures related to new arm-specific behavior
-rw-r--r--tests/unittests/test_datasource/test_altcloud.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/unittests/test_datasource/test_altcloud.py b/tests/unittests/test_datasource/test_altcloud.py
index bda61c7e..4ea820b3 100644
--- a/tests/unittests/test_datasource/test_altcloud.py
+++ b/tests/unittests/test_datasource/test_altcloud.py
@@ -104,11 +104,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 +243,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 +253,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 +452,19 @@ 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:
+ orig = getattr(os, 'uname')
+ if not force_arch._orig:
+ force_arch._orig = orig
+ setattr(os, 'uname', _os_uname)
+ elif force_arch._orig:
+ setattr(os, 'uname', force_arch._orig)
+
+force_arch._orig = None
+
# vi: ts=4 expandtab