summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_datasource/test_smartos.py51
1 files changed, 11 insertions, 40 deletions
diff --git a/tests/unittests/test_datasource/test_smartos.py b/tests/unittests/test_datasource/test_smartos.py
index 062b44ee..19282bac 100644
--- a/tests/unittests/test_datasource/test_smartos.py
+++ b/tests/unittests/test_datasource/test_smartos.py
@@ -44,6 +44,7 @@ MOCK_RETURNS = {
'cloud-init:user-data': '\n'.join(['#!/bin/sh', '/bin/true', '']),
'sdc:datacenter_name': 'somewhere2',
'sdc:operator-script': '\n'.join(['bin/true', '']),
+ 'sdc:vendor-data': '\n'.join(['VENDOR_DATA', '']),
'user-data': '\n'.join(['something', '']),
'user-script': '\n'.join(['/bin/true', '']),
}
@@ -107,7 +108,6 @@ class MockSerial(object):
yield '\n'
-#class TestSmartOSDataSource(MockerTestCase):
class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
def setUp(self):
helpers.FilesystemMockingTestCase.setUp(self)
@@ -345,10 +345,10 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
there is no script remaining.
"""
- script_d = os.path.join(self.tmp, "scripts", "per-boot")
+ script_d = os.path.join(self.tmp, "instance", "data")
os.makedirs(script_d)
- test_script_f = "%s/99_user_script" % script_d
+ test_script_f = os.path.join(script_d, 'user-script')
with open(test_script_f, 'w') as f:
f.write("TEST DATA")
@@ -397,49 +397,20 @@ class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
dsrc = self._get_ds(mockdata=MOCK_RETURNS)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertEquals(MOCK_RETURNS['sdc:operator-script'],
- dsrc.metadata['vendordata'])
+ self.assertEquals(MOCK_RETURNS['sdc:vendor-data'],
+ dsrc.metadata['vendor-data'])
def test_default_vendor_data(self):
my_returns = MOCK_RETURNS.copy()
- def_op_script = my_returns['sdc:operator-script']
- del my_returns['sdc:operator-script']
+ def_op_script = my_returns['sdc:vendor-data']
+ del my_returns['sdc:vendor-data']
dsrc = self._get_ds(mockdata=my_returns)
ret = dsrc.get_data()
self.assertTrue(ret)
- self.assertNotEquals(def_op_script, dsrc.metadata['vendordata'])
-
- self.replicateTestRoot('simple_ubuntu', self.tmp)
- cfg = {
- 'cloud_init_modules': ['write-files'],
- }
- cloud_cfg = util.yaml_dumps(cfg)
- util.ensure_dir(os.path.join(self.tmp, 'etc', 'cloud'))
- util.write_file(os.path.join(self.tmp, 'etc',
- 'cloud', 'cloud.cfg'), cloud_cfg)
-
- self._patchIn(self.tmp)
-
- initer = stages.Init()
- initer.read_cfg()
- initer.datasource = dsrc
- initer.initialize()
- initer.fetch()
- _iid = initer.instancify()
- initer.update()
- initer.cloudify().run('consume_data',
- initer.consume_data,
- args=[PER_INSTANCE],
- freq=PER_INSTANCE)
- mods = stages.Modules(initer)
- (_which_ran, _failures) = mods.run_section('cloud_init_modules')
- pb_script_fns = os.path.join(dsrc.paths.get_cpath('scripts'),
- 'per-boot', '01_sdc-operator-script.sh')
- self.assertTrue(os.path.isfile(pb_script_fns))
- self.assertTrue(os.access(pb_script_fns, os.X_OK))
-
- with open(pb_script_fns, 'r') as fd:
- self.assertIn("#!/bin/sh", fd.readlines()[0])
+ self.assertNotEquals(def_op_script, dsrc.metadata['vendor-data'])
+
+ # we expect default vendor-data is a boothook
+ self.assertTrue(dsrc.vendordata_raw.startswith("#cloud-boothook"))
def test_disable_iptables_flag(self):
dsrc = self._get_ds(mockdata=MOCK_RETURNS)