diff options
author | Scott Moser <smoser@ubuntu.com> | 2014-01-16 20:11:27 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2014-01-16 20:11:27 -0500 |
commit | 92aa725a284c08be9234bd792227e5896c4b1d1c (patch) | |
tree | 0d6b842e68d7504236263e8a07dd63f1802c56eb /tests | |
parent | 08b50a6ea239f480493f202c563d788cabb92380 (diff) | |
download | vyos-cloud-init-92aa725a284c08be9234bd792227e5896c4b1d1c.tar.gz vyos-cloud-init-92aa725a284c08be9234bd792227e5896c4b1d1c.zip |
DataSourceOpenNebula:parse_shell_config skip 'SECONDS' var if seen
SECONDS is a special variable in bash, it gets set to the time the
shell has been alive. This would cause us to fail randomly (if the
process happened to take more than 1 second, then SECONDS would
be defined).
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unittests/test_datasource/test_opennebula.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/unittests/test_datasource/test_opennebula.py b/tests/unittests/test_datasource/test_opennebula.py index e1812a88..ce9ee9f4 100644 --- a/tests/unittests/test_datasource/test_opennebula.py +++ b/tests/unittests/test_datasource/test_opennebula.py @@ -258,6 +258,14 @@ iface eth0 inet static ''') +class TestParseShellConfig(MockerTestCase): + def test_no_seconds(self): + cfg = '\n'.join(["foo=bar", "SECONDS=2", "xx=foo"]) + # we could test 'sleep 2', but that would make the test run slower. + ret = ds.parse_shell_config(cfg); + self.assertEqual(ret, {"foo": "bar", "xx": "foo"}) + + def populate_context_dir(path, variables): data = "# Context variables generated by OpenNebula\n" for (k, v) in variables.iteritems(): |