Merge lp:~terceiro/lava-dispatcher/fix-1032467 into lp:lava-dispatcher

Proposed by Antonio Terceiro
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: 379
Merged at revision: 379
Proposed branch: lp:~terceiro/lava-dispatcher/fix-1032467
Merge into: lp:lava-dispatcher
Diff against target: 42 lines (+11/-1)
3 files modified
lava_dispatcher/config.py (+4/-1)
lava_dispatcher/tests/test-config/devices/qemu01.conf (+2/-0)
lava_dispatcher/tests/test_config.py (+5/-0)
To merge this branch: bzr merge lp:~terceiro/lava-dispatcher/fix-1032467
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle (community) Approve
Review via email: mp+123833@code.launchpad.net

Description of the change

when tester_hostname has an empty value, use the default value of `linaro`.

To post a comment you must log in.
Revision history for this message
Andy Doan (doanac) wrote :

in the past we've avoided creating actual device configs. I see why you are doing it here, but I'm not sure the pros/cons. I'll defer to mwhudson.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Andy, the device config is in lava_dispatcher/tests/test-config/devices/ -- so an installation of the dispatcher still won't have a device configured. This seems fine.

I think this test is OK -- it's not perfect, because the test is not self-contained: you need to go and look at the qemu01.conf file to assess whether the test is correct. A better test would create a config file with contents specified by the test code itself, verify the code and then delete the config file again (possibly all using a helper to make it nice). But this is being picky, I'd be fine to land the code as is.

But, can you remove the hostname from the config file? I think I'd like to start squashing the meme that you need to repeat the hostname like that.

review: Approve
Revision history for this message
Antonio Terceiro (terceiro) wrote :

Michael Hudson-Doyle escreveu:
> Review: Approve
>
> Andy, the device config is in
> lava_dispatcher/tests/test-config/devices/ -- so an installation of
> the dispatcher still won't have a device configured. This seems fine.
>
> I think this test is OK -- it's not perfect, because the test is not
> self-contained: you need to go and look at the qemu01.conf file to
> assess whether the test is correct. A better test would create a
> config file with contents specified by the test code itself, verify
> the code and then delete the config file again (possibly all using a
> helper to make it nice). But this is being picky, I'd be fine to land
> the code as is.
>
> But, can you remove the hostname from the config file? I think I'd
> like to start squashing the meme that you need to repeat the hostname
> like that.

I like self-contained tests, so I will work a solution to create the
config file on the fly - let's see.

--
Antonio Terceiro
Software Engineer - Linaro
http://www.linaro.org

380. By Antonio Terceiro

make test self-contained

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Antonio Terceiro <email address hidden> writes:

> I like self-contained tests, so I will work a solution to create the
> config file on the fly - let's see.

I like what you did there :-)

Cheers,
mwh

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_dispatcher/config.py'
2--- lava_dispatcher/config.py 2012-08-08 22:30:52 +0000
3+++ lava_dispatcher/config.py 2012-09-11 21:04:19 +0000
4@@ -80,7 +80,10 @@
5 self.config_dir = config_dir
6 def get(self, key, default=_sentinel):
7 try:
8- return self.cp.get("DEFAULT", key)
9+ val = self.cp.get("DEFAULT", key)
10+ if default is not _sentinel and val == '':
11+ val = default
12+ return val
13 except NoOptionError:
14 if default is not _sentinel:
15 return default
16
17=== added file 'lava_dispatcher/tests/test-config/devices/qemu01.conf'
18--- lava_dispatcher/tests/test-config/devices/qemu01.conf 1970-01-01 00:00:00 +0000
19+++ lava_dispatcher/tests/test-config/devices/qemu01.conf 2012-09-11 21:04:19 +0000
20@@ -0,0 +1,2 @@
21+device_type = qemu
22+hostname = qemu01
23
24=== modified file 'lava_dispatcher/tests/test_config.py'
25--- lava_dispatcher/tests/test_config.py 2011-11-28 20:27:03 +0000
26+++ lava_dispatcher/tests/test_config.py 2012-09-11 21:04:19 +0000
27@@ -22,6 +22,7 @@
28
29 from lava_dispatcher.config import get_config, get_device_config
30 from lava_dispatcher.utils import string_to_list
31+from lava_dispatcher.client.base import LavaClient
32
33 test_config_dir = os.path.join(os.path.dirname(__file__), 'test-config')
34 print test_config_dir
35@@ -48,3 +49,7 @@
36 lava_server_ip = server_config.get("LAVA_SERVER_IP")
37 self.assertEqual(expected, lava_server_ip)
38
39+ def test_default_value_for_tester_hostname(self):
40+ config = get_device_config("qemu01", test_config_dir)
41+ client = LavaClient(None, config)
42+ self.assertEqual('linaro', client.tester_hostname)

Subscribers

People subscribed via source and target branches