Merge lp:~ack/landscape-client/fix-mountinfo-tests-in-container into lp:~landscape/landscape-client/trunk

Proposed by Alberto Donato
Status: Merged
Approved by: Alberto Donato
Approved revision: 936
Merged at revision: 934
Proposed branch: lp:~ack/landscape-client/fix-mountinfo-tests-in-container
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 117 lines (+18/-40)
1 file modified
landscape/monitor/tests/test_mountinfo.py (+18/-40)
To merge this branch: bzr merge lp:~ack/landscape-client/fix-mountinfo-tests-in-container
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Adam Collard (community) Approve
🤖 Landscape Builder test results Approve
Review via email: mp+317958@code.launchpad.net

Commit message

Fix the following MountInfo unittests that fail in containers (LXC and LXD) because of lack of isolation from the system:

landscape.monitor.tests.test_mountinfo.MountInfoTest.test_read_proc_mounts
landscape.monitor.tests.test_mountinfo.MountInfoTest.test_call_on_accepted

Description of the change

Fix the following MountInfo unittests that fail in containers (LXC and LXD) because of lack of isolation from the system:

landscape.monitor.tests.test_mountinfo.MountInfoTest.test_read_proc_mounts
landscape.monitor.tests.test_mountinfo.MountInfoTest.test_call_on_accepted

Testing instructions:

In a container, run trial landscape.monitor.tests.test_mountinfo

To post a comment you must log in.
935. By Alberto Donato

Reapply change.

936. By Alberto Donato

Refactor some other tests.

Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: TRIAL_ARGS=-j4 make check
Result: Success
Revno: 936
Branch: lp:~ack/landscape-client/fix-mountinfo-tests-in-container
Jenkins: https://ci.lscape.net/job/latch-test-precise/866/

review: Approve (test results)
Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: TRIAL_ARGS=-j4 make check
Result: Success
Revno: 936
Branch: lp:~ack/landscape-client/fix-mountinfo-tests-in-container
Jenkins: https://ci.lscape.net/job/latch-test-precise/865/

review: Approve (test results)
Revision history for this message
Adam Collard (adam-collard) wrote :

+1

review: Approve
Revision history for this message
Данило Шеган (danilo) wrote :

Nice clean-up: it's funny how all these tests had slightly different set-up, yet didn't really depend on it. Approved as such, but...

...I am not getting any test failures even without this change in a xenial container. My system only has /dev/sd* disks, so maybe that's why it works (i.e. /dev/hd* does not conflict)? Is there a bug that has more info?

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

> Nice clean-up: it's funny how all these tests had slightly different set-up,
> yet didn't really depend on it. Approved as such, but...
>
> ...I am not getting any test failures even without this change in a xenial
> container. My system only has /dev/sd* disks, so maybe that's why it works
> (i.e. /dev/hd* does not conflict)? Is there a bug that has more info?

No, I have been seeing those two tests failing for a long time in my LXC/LXDs, maybe it's peculiar to my setup.
Anyway, isolating tests from the system sounds like a good idea in general :)

Revision history for this message
Alberto Donato (ack) wrote :

> Nice clean-up: it's funny how all these tests had slightly different set-up,
> yet didn't really depend on it. Approved as such, but...
>
> ...I am not getting any test failures even without this change in a xenial
> container. My system only has /dev/sd* disks, so maybe that's why it works
> (i.e. /dev/hd* does not conflict)? Is there a bug that has more info?

No, I have been seeing those two tests failing for a long time in my LXC/LXDs, maybe it's peculiar to my setup.
Anyway, isolating tests from the system sounds like a good idea in general :)

Revision history for this message
Alberto Donato (ack) wrote :

> Nice clean-up: it's funny how all these tests had slightly different set-up,
> yet didn't really depend on it. Approved as such, but...
>
> ...I am not getting any test failures even without this change in a xenial
> container. My system only has /dev/sd* disks, so maybe that's why it works
> (i.e. /dev/hd* does not conflict)? Is there a bug that has more info?

No, I have been seeing those two tests failing for a long time in my LXC/LXDs, maybe it's peculiar to my setup.
Anyway, isolating tests from the system sounds like a good idea in general :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/monitor/tests/test_mountinfo.py'
2--- landscape/monitor/tests/test_mountinfo.py 2016-06-15 21:29:53 +0000
3+++ landscape/monitor/tests/test_mountinfo.py 2017-02-22 10:56:00 +0000
4@@ -19,6 +19,10 @@
5 self.log_helper.ignore_errors("Typelib file for namespace")
6
7 def get_mount_info(self, *args, **kwargs):
8+ if "mounts_file" not in kwargs:
9+ kwargs["mounts_file"] = self.makeFile("/dev/hda1 / ext3 rw 0 0\n")
10+ if "mtab_file" not in kwargs:
11+ kwargs["mtab_file"] = self.makeFile("/dev/hda1 / ext3 rw 0 0\n")
12 if "statvfs" not in kwargs:
13 kwargs["statvfs"] = lambda path: (0,) * 1000
14 plugin = MountInfo(*args, **kwargs)
15@@ -136,13 +140,9 @@
16 def statvfs(path, multiplier=mock_counter(1).next):
17 return (4096, 0, mb(multiplier() * 1000), mb(100), 0, 0, 0, 0, 0)
18
19- filename = self.makeFile("""\
20-/dev/hda1 / ext3 rw 0 0
21-""")
22- plugin = self.get_mount_info(mounts_file=filename, statvfs=statvfs,
23- create_time=self.reactor.time,
24- interval=self.monitor.step_size,
25- mtab_file=filename)
26+ plugin = self.get_mount_info(
27+ statvfs=statvfs, create_time=self.reactor.time,
28+ interval=self.monitor.step_size)
29 self.monitor.add(plugin)
30
31 self.reactor.advance(self.monitor.step_size * 2)
32@@ -216,12 +216,8 @@
33 def statvfs(path):
34 return (4096, 0, mb(1000), mb(100), 0, 0, 0, 0, 0)
35
36- filename = self.makeFile("""\
37-/dev/hda1 / ext3 rw 0 0
38-""")
39- plugin = self.get_mount_info(mounts_file=filename, statvfs=statvfs,
40- create_time=self.reactor.time,
41- mtab_file=filename)
42+ plugin = self.get_mount_info(
43+ statvfs=statvfs, create_time=self.reactor.time)
44 step_size = self.monitor.step_size
45 self.monitor.add(plugin)
46
47@@ -251,12 +247,8 @@
48 def statvfs(path):
49 return (4096, 0, mb(1000), mb(100), 0, 0, 0, 0, 0)
50
51- filename = self.makeFile("""\
52-/dev/hda1 / ext3 rw 0 0
53-""")
54- plugin = self.get_mount_info(mounts_file=filename, statvfs=statvfs,
55- create_time=self.reactor.time,
56- mtab_file=filename)
57+ plugin = self.get_mount_info(
58+ statvfs=statvfs, create_time=self.reactor.time)
59 self.monitor.add(plugin)
60
61 self.reactor.advance(self.monitor.step_size)
62@@ -323,9 +315,7 @@
63 """
64 "Removable" partitions are not reported to the server.
65 """
66- filename = self.makeFile("""\
67-/dev/hdc4 /mm xfs rw 0 0""")
68- plugin = self.get_mount_info(mounts_file=filename, mtab_file=filename)
69+ plugin = self.get_mount_info()
70
71 plugin.is_device_removable = lambda x: True # They are all removable
72
73@@ -339,12 +329,8 @@
74 def statvfs(path, multiplier=mock_counter(1).next):
75 return (4096, 0, mb(1000), mb(multiplier() * 100), 0, 0, 0, 0, 0)
76
77- filename = self.makeFile("""\
78-/dev/hda2 / xfs rw 0 0
79-""")
80- plugin = self.get_mount_info(mounts_file=filename, statvfs=statvfs,
81- create_time=self.reactor.time,
82- mtab_file=filename)
83+ plugin = self.get_mount_info(
84+ statvfs=statvfs, create_time=self.reactor.time)
85 step_size = self.monitor.step_size
86 self.monitor.add(plugin)
87
88@@ -409,12 +395,8 @@
89 """
90 def statvfs(path):
91 return (4096, 0, mb(1000), mb(100), 0, 0, 0, 0, 0)
92- filename = self.makeFile("""\
93-/dev/hda1 / ext3 rw 0 0
94-""")
95- plugin = self.get_mount_info(mounts_file=filename,
96- create_time=self.reactor.time,
97- statvfs=statvfs, mtab_file=filename)
98+ plugin = self.get_mount_info(
99+ create_time=self.reactor.time, statvfs=statvfs)
100 self.monitor.add(plugin)
101
102 plugin.run()
103@@ -605,12 +587,8 @@
104 def statvfs(path):
105 return (4096, 0, mb(1000), mb(100), 0, 0, 0, 0, 0)
106
107- filename = self.makeFile("""\
108-/dev/hda1 / ext3 rw 0 0
109-""")
110- plugin = self.get_mount_info(mounts_file=filename, statvfs=statvfs,
111- create_time=self.reactor.time,
112- mtab_file=filename)
113+ plugin = self.get_mount_info(
114+ statvfs=statvfs, create_time=self.reactor.time)
115 # Limit the test exchange to 5 items.
116 plugin.max_free_space_items_to_exchange = 5
117 step_size = self.monitor.step_size

Subscribers

People subscribed via source and target branches

to all changes: