summaryrefslogtreecommitdiff
path: root/tko
diff options
context:
space:
mode:
authormbligh <mbligh@592f7852-d20e-0410-864c-8624ca9c26a4>2009-05-26 19:36:50 +0000
committermbligh <mbligh@592f7852-d20e-0410-864c-8624ca9c26a4>2009-05-26 19:36:50 +0000
commitaae5c8bb38d0c96a712cc801db5f49014e884001 (patch)
tree719c6a569e90d30079f851aa49422004232ad61b /tko
parentf9fdb3f55ec7cd27ba2507c12e66c9ef4ebf4828 (diff)
Always use the host_group_name even if a sysinfo/hostname file exists
when the keyvals hostname is a list of machines. Fixes the version_0 host_group_name unittests to stub out find_hostname so that local files are not read. This also verifies that find_hostname is not called when a host_group_name is present. Signed-off-by: Gregory Smith <gps@google.com> git-svn-id: svn://test.kernel.org/autotest/trunk@3178 592f7852-d20e-0410-864c-8624ca9c26a4
Diffstat (limited to 'tko')
-rw-r--r--tko/parsers/version_0.py2
-rw-r--r--tko/parsers/version_0_unittest.py24
2 files changed, 25 insertions, 1 deletions
diff --git a/tko/parsers/version_0.py b/tko/parsers/version_0.py
index f83c479c..1018b080 100644
--- a/tko/parsers/version_0.py
+++ b/tko/parsers/version_0.py
@@ -24,7 +24,7 @@ class job(models.job):
label = keyval.get("label", None)
host_group_name = keyval.get("host_group_name", None)
machine = keyval.get("hostname", None)
- if machine and "," in machine:
+ if not host_group_name and machine and "," in machine:
try:
machine = job.find_hostname(dir) # find a unique hostname
except NoHostnameError:
diff --git a/tko/parsers/version_0_unittest.py b/tko/parsers/version_0_unittest.py
index 884989a6..8c076ff7 100644
--- a/tko/parsers/version_0_unittest.py
+++ b/tko/parsers/version_0_unittest.py
@@ -12,10 +12,13 @@ class test_job_load_from_dir(unittest.TestCase):
def setUp(self):
self.god = mock.mock_god()
self.god.stub_function(models.job, 'read_keyval')
+ self.god.stub_function(version_0.job, 'find_hostname')
+
def tearDown(self):
self.god.unstub_all()
+
keyval_return = {'job_queued': 1234567890,
'job_started': 1234567891,
'job_finished': 1234567892,
@@ -23,6 +26,7 @@ class test_job_load_from_dir(unittest.TestCase):
'label': 'steeltown',
'hostname': 'abc123'}
+
def test_load_from_dir_simple(self):
models.job.read_keyval.expect_call('.').and_return(
dict(self.keyval_return))
@@ -32,6 +36,24 @@ class test_job_load_from_dir(unittest.TestCase):
self.assertEqual('abc123', job['machine'])
self.god.check_playback()
+
+ def test_load_from_dir_two_machine(self):
+ raw_keyval = dict(self.keyval_return)
+ raw_keyval['hostname'] = 'easyas,abc123'
+ models.job.read_keyval.expect_call('.').and_return(raw_keyval)
+ version_0.job.find_hostname.expect_call('.').and_raises(
+ version_0.NoHostnameError('find_hostname stubbed out'))
+ job = version_0.job.load_from_dir('.')
+ self.assertEqual('easyas,abc123', job['machine'])
+
+ models.job.read_keyval.expect_call('.').and_return(raw_keyval)
+ version_0.job.find_hostname.expect_call('.').and_return('foo')
+ job = version_0.job.load_from_dir('.')
+ self.assertEqual('foo', job['machine'])
+
+ self.god.check_playback()
+
+
def test_load_from_dir_one_machine_group_name(self):
raw_keyval = dict(self.keyval_return)
raw_keyval['host_group_name'] = 'jackson five'
@@ -41,6 +63,7 @@ class test_job_load_from_dir(unittest.TestCase):
self.assertEqual('abc123', job['machine'])
self.god.check_playback()
+
def test_load_from_dir_multi_machine_group_name(self):
raw_keyval = dict(self.keyval_return)
raw_keyval['user'] = 'michael'
@@ -54,6 +77,7 @@ class test_job_load_from_dir(unittest.TestCase):
self.assertEqual('jackson five', job['machine'])
self.god.check_playback()
+
def test_load_from_dir_no_machine_group_name(self):
raw_keyval = dict(self.keyval_return)
del raw_keyval['hostname']