Merge lp:~gholt/swift/unittesttmp into lp:~hudson-openstack/swift/trunk

Proposed by gholt
Status: Merged
Approved by: Chuck Thier
Approved revision: 195
Merged at revision: 196
Proposed branch: lp:~gholt/swift/unittesttmp
Merge into: lp:~hudson-openstack/swift/trunk
Diff against target: 112 lines (+21/-23)
5 files modified
test/unit/container/test_server.py (+1/-1)
test/unit/container/test_updater.py (+1/-1)
test/unit/obj/test_auditor.py (+13/-17)
test/unit/obj/test_server.py (+1/-1)
test/unit/proxy/test_server.py (+5/-3)
To merge this branch: bzr merge lp:~gholt/swift/unittesttmp
Reviewer Review Type Date Requested Status
Chuck Thier (community) Approve
Review via email: mp+47344@code.launchpad.net

Description of the change

Fix tests to cleanup their /tmp dirs

To post a comment you must log in.
Revision history for this message
Chuck Thier (cthier) wrote :

squeaky clean

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'test/unit/container/test_server.py'
2--- test/unit/container/test_server.py 2011-01-19 22:19:43 +0000
3+++ test/unit/container/test_server.py 2011-01-25 01:14:58 +0000
4@@ -45,7 +45,7 @@
5
6 def tearDown(self):
7 """ Tear down for testing swift.object_server.ObjectController """
8- rmtree(self.testdir, ignore_errors=1)
9+ rmtree(os.path.dirname(self.testdir), ignore_errors=1)
10
11 def test_acl_container(self):
12 # Ensure no acl by default
13
14=== modified file 'test/unit/container/test_updater.py'
15--- test/unit/container/test_updater.py 2011-01-20 00:31:55 +0000
16+++ test/unit/container/test_updater.py 2011-01-25 01:14:58 +0000
17@@ -51,7 +51,7 @@
18 os.mkdir(self.sda1)
19
20 def tearDown(self):
21- rmtree(self.testdir, ignore_errors=1)
22+ rmtree(os.path.dirname(self.testdir), ignore_errors=1)
23
24 def test_creation(self):
25 cu = container_updater.ContainerUpdater({
26
27=== modified file 'test/unit/obj/test_auditor.py'
28--- test/unit/obj/test_auditor.py 2011-01-19 22:05:22 +0000
29+++ test/unit/obj/test_auditor.py 2011-01-25 01:14:58 +0000
30@@ -56,7 +56,7 @@
31 mount_check='false')
32
33 def tearDown(self):
34- rmtree(self.testdir, ignore_errors=1)
35+ rmtree(os.path.dirname(self.testdir), ignore_errors=1)
36
37 def test_object_audit_extra_data(self):
38 self.auditor = auditor.ObjectAuditor(self.conf)
39@@ -123,25 +123,21 @@
40 self.assertEquals(self.auditor.quarantines, pre_quarantines + 1)
41
42 def test_object_audit_no_meta(self):
43- self.auditor = auditor.ObjectAuditor(self.conf)
44 cur_part = '0'
45 disk_file = DiskFile(self.devices, 'sda', cur_part, 'a', 'c', 'o')
46- data = '0' * 1024
47- etag = md5()
48+ timestamp = str(normalize_timestamp(time.time()))
49+ path = os.path.join(disk_file.datadir, timestamp + '.data')
50+ mkdirs(disk_file.datadir)
51+ fp = open(path, 'w')
52+ fp.write('0' * 1024)
53+ fp.close()
54+ invalidate_hash(os.path.dirname(disk_file.datadir))
55+ self.auditor = auditor.ObjectAuditor(self.conf)
56 pre_quarantines = self.auditor.quarantines
57- with disk_file.mkstemp() as (fd, tmppath):
58- os.write(fd, data)
59- etag.update(data)
60- etag = etag.hexdigest()
61- timestamp = str(normalize_timestamp(time.time()))
62- os.fsync(fd)
63- invalidate_hash(os.path.dirname(disk_file.datadir))
64- renamer(tmppath, os.path.join(disk_file.datadir,
65- timestamp + '.data'))
66- self.auditor.object_audit(
67- os.path.join(disk_file.datadir, timestamp + '.data'),
68- 'sda', cur_part)
69- self.assertEquals(self.auditor.quarantines, pre_quarantines + 1)
70+ self.auditor.object_audit(
71+ os.path.join(disk_file.datadir, timestamp + '.data'),
72+ 'sda', cur_part)
73+ self.assertEquals(self.auditor.quarantines, pre_quarantines + 1)
74
75 def test_object_audit_bad_args(self):
76 self.auditor = auditor.ObjectAuditor(self.conf)
77
78=== modified file 'test/unit/obj/test_server.py'
79--- test/unit/obj/test_server.py 2011-01-19 22:05:22 +0000
80+++ test/unit/obj/test_server.py 2011-01-25 01:14:58 +0000
81@@ -53,7 +53,7 @@
82
83 def tearDown(self):
84 """ Tear down for testing swift.object_server.ObjectController """
85- rmtree(self.testdir)
86+ rmtree(os.path.dirname(self.testdir))
87
88 def test_POST_update_meta(self):
89 """ Test swift.object_server.ObjectController.POST """
90
91=== modified file 'test/unit/proxy/test_server.py'
92--- test/unit/proxy/test_server.py 2011-01-20 00:31:55 +0000
93+++ test/unit/proxy/test_server.py 2011-01-25 01:14:58 +0000
94@@ -142,7 +142,7 @@
95 for server in _test_coros:
96 server.kill()
97 proxy_server.CONTAINER_LISTING_LIMIT = _orig_container_listing_limit
98- rmtree(_testdir)
99+ rmtree(os.path.dirname(_testdir))
100
101
102 def fake_http_connect(*code_iter, **kwargs):
103@@ -3425,5 +3425,7 @@
104
105 if __name__ == '__main__':
106 setup()
107- unittest.main()
108- teardown()
109+ try:
110+ unittest.main()
111+ finally:
112+ teardown()