Merge lp:~jtv/maas-test/var-log-maas-test into lp:maas-test

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: 111
Merged at revision: 107
Proposed branch: lp:~jtv/maas-test/var-log-maas-test
Merge into: lp:maas-test
Diff against target: 246 lines (+52/-20)
6 files modified
docs/man/maas-test.8.rst (+6/-4)
maastest/proxyfixture.py (+20/-6)
maastest/report.py (+3/-3)
maastest/tests/test_proxyfixture.py (+14/-3)
maastest/utils.py (+3/-0)
man/maas-test.8 (+6/-4)
To merge this branch: bzr merge lp:~jtv/maas-test/var-log-maas-test
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Review via email: mp+200958@code.launchpad.net

Commit message

Move logs into /var/log/maas-test.

Description of the change

This is still follow-up from a change pre-imped with Julian earlier today. The logs (including the actual test result files) now go into /var/log/maas-test, no longer /var/cache/maas-test.

The test changes were limited thanks to a factory I had created earlier. I just needed to add one more configurable directory to the factory, and add tests for the timely creation of the log directory. I also noticed that in moving the pidfiles to /run I had missed a place that needed updating, where the proxy was configured. So this branch fixes both items in the proxy configuration.

Now that things are neatly laid out in /var, having proxy configuration in /var/cache does stick out a bit. But not enough to do anything about, I think.

Jeroen

To post a comment you must log in.
lp:~jtv/maas-test/var-log-maas-test updated
111. By Jeroen T. Vermeulen

Copyright.

Revision history for this message
Julian Edwards (julian-edwards) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/man/maas-test.8.rst'
2--- docs/man/maas-test.8.rst 2014-01-09 03:51:20 +0000
3+++ docs/man/maas-test.8.rst 2014-01-09 07:48:39 +0000
4@@ -109,7 +109,7 @@
5 attachment.
6
7 By default, the results are also written to timestamped log files under
8-`/var/cache/maas-test/logs`.
9+`/var/log/maas-test`.
10
11
12 Options
13@@ -199,7 +199,7 @@
14 --log-results-only
15 Write test results to a file, but don't upload them to Launchpad.
16 Results will be written to a timestamped log file under
17- `/var/cache/maas-test/logs`.
18+ `/var/log/maas-test`.
19
20
21 Reporting bugs
22@@ -228,6 +228,8 @@
23
24 State and configuration for `maas-test` is stored in `/var/cache/maas-test`.
25 This includes an ssh key pair for communicating with the virtual machine.
26+Pidfiles are stored in `/run/maas-test`, and logs and test results are written
27+to `/var/log/maas-test`.
28
29-If you choose to run a local proxy, downloaded data will also be cached there.
30-It can quickly grow to gigabyte sizes.
31+If you choose to run a local proxy, downloaded data will also be cached in the
32+`/var/cache/maas-test`. It can quickly grow to gigabyte sizes.
33
34=== modified file 'maastest/proxyfixture.py'
35--- maastest/proxyfixture.py 2014-01-09 05:56:08 +0000
36+++ maastest/proxyfixture.py 2014-01-09 07:48:39 +0000
37@@ -1,4 +1,4 @@
38-# Copyright 2013 Canonical Ltd. This software is licensed under the
39+# Copyright 2013-2014 Canonical Ltd. This software is licensed under the
40 # GNU Affero General Public License version 3 (see the file LICENSE).
41
42 """Test whether or not a node is compatible with MAAS."""
43@@ -29,8 +29,8 @@
44
45 PROXY_CONFIG_ITEMS = {
46 'daemonise': 'true',
47- 'logFile': '%(config_dir)s/proxy.log',
48- 'pidFile': '%(config_dir)s/proxy.pid',
49+ 'logFile': '%(log_file)s',
50+ 'pidFile': '%(pid_file)s',
51 'proxyAddress': "::0",
52 'proxyPort': '%(port)d',
53 'allowedClients': '127.0.0.1,%(ip_address)s/%(netmask)s',
54@@ -58,7 +58,8 @@
55
56 #TODO: port should be determined at runtime from the set of
57 # available ports rather than being an arbitrary one as it is here.
58- def __init__(self, config_dir=None, port=42676, pidfile_dir=None):
59+ def __init__(self, config_dir=None, port=42676, pidfile_dir=None,
60+ log_dir=None):
61 """Create a `LocalProxyFixture` object.
62
63 :param url: The URL of the proxy to use. If None, LocalProxyFixture
64@@ -70,9 +71,14 @@
65 :param config_dir: The directory in which to put the proxy's
66 configuration and cache.
67 :type config_dir: string
68- :param pid_dir: Optional directory in which to write the proxy's
69+ :param pidfile_dir: Optional directory in which to write the proxy's
70 pidfile. Will be created if not present. Defaults to
71 `/run/maas-test`.
72+ :type pidfile_dir: string
73+ :param log_dir: Optional directory in which to write the proxy's log
74+ files. Will be created if not present. Defaults to
75+ `/var/log/maas-test`.
76+ :type log_dir: string
77 """
78 super(LocalProxyFixture, self).__init__()
79 self.port = port
80@@ -81,7 +87,10 @@
81 self.config_dir = config_dir
82 if pidfile_dir is None:
83 pidfile_dir = utils.DEFAULT_PIDFILE_DIR
84+ if log_dir is None:
85+ log_dir = utils.DEFAULT_LOG_DIR
86 self.pid_file = os.path.join(pidfile_dir, 'proxy.pid')
87+ self.log_file = os.path.join(log_dir, 'proxy.log')
88 self._network_address = None
89
90 def _get_config_arguments(self):
91@@ -92,6 +101,8 @@
92 'port': self.port,
93 'ip_address': ip_address.ip.format(),
94 'netmask': ip_address.prefixlen,
95+ 'pid_file': self.pid_file,
96+ 'log_file': self.log_file,
97 }
98 config_args = []
99 for key, value in PROXY_CONFIG_ITEMS.items():
100@@ -124,10 +135,13 @@
101 # From this point, if further setup fails, we'll need to clean up.
102 self.addCleanup(self.kill_running_proxy)
103
104- # Create pidfile directory if it did not already exist.
105+ # Create pidfile and log directories if they did not already exist.
106 pidfile_dir = os.path.dirname(self.pid_file)
107 if not os.path.isdir(pidfile_dir):
108 os.makedirs(pidfile_dir, 0o755)
109+ log_dir = os.path.dirname(self.log_file)
110+ if not os.path.isdir(log_dir):
111+ os.makedirs(log_dir)
112
113 self.start_proxy()
114
115
116=== modified file 'maastest/report.py'
117--- maastest/report.py 2014-01-09 03:51:20 +0000
118+++ maastest/report.py 2014-01-09 07:48:39 +0000
119@@ -1,4 +1,4 @@
120-# Copyright 2013 Canonical Ltd. This software is licensed under the
121+# Copyright 2013-2014 Canonical Ltd. This software is licensed under the
122 # GNU Affero General Public License version 3 (see the file LICENSE).
123
124 """Reporting functions for MAAS test."""
125@@ -28,7 +28,7 @@
126 )
127
128 from apiclient import multipart
129-from maastest.utils import DEFAULT_STATE_DIR
130+from maastest.utils import DEFAULT_LOG_DIR
131
132
133 # This is largely cargo-culted from apiclient.multipart because
134@@ -128,7 +128,7 @@
135 :param log_dir: The directory under which to create `log_file_name`.
136 """
137 if log_dir is None:
138- log_dir = DEFAULT_STATE_DIR
139+ log_dir = DEFAULT_LOG_DIR
140 if not os.path.exists(log_dir):
141 os.makedirs(log_dir)
142
143
144=== modified file 'maastest/tests/test_proxyfixture.py'
145--- maastest/tests/test_proxyfixture.py 2014-01-09 05:50:54 +0000
146+++ maastest/tests/test_proxyfixture.py 2014-01-09 07:48:39 +0000
147@@ -1,4 +1,4 @@
148-# Copyright 2013 Canonical Ltd. This software is licensed under the
149+# Copyright 2013-2014 Canonical Ltd. This software is licensed under the
150 # GNU Affero General Public License version 3 (see the file LICENSE).
151
152 """Tests for `maastest.utils`."""
153@@ -44,7 +44,8 @@
154 """Create a temporary directory for the duration of this test."""
155 return self.useFixture(TempDir()).path
156
157- def make_fixture(self, port=None, config_dir=None, pidfile_dir=None):
158+ def make_fixture(self, port=None, config_dir=None, pidfile_dir=None,
159+ log_dir=None):
160 """Create a `LocalProxyFixture`.
161
162 :param port: Optional port. Defaults to a random choice.
163@@ -52,6 +53,8 @@
164 temporary directory.
165 :param pidfile_dir: Optional pidfile directory. Defaults to a
166 temporary directory.
167+ :param log_dir: Optional log directory. Defaults to a temporary
168+ directory.
169 """
170 if port is None:
171 port = self.get_random_port_number()
172@@ -59,8 +62,11 @@
173 config_dir = self.make_dir()
174 if pidfile_dir is None:
175 pidfile_dir = self.make_dir()
176+ if log_dir is None:
177+ log_dir = self.make_dir()
178 return LocalProxyFixture(
179- port=port, config_dir=config_dir, pidfile_dir=pidfile_dir)
180+ port=port, config_dir=config_dir, pidfile_dir=pidfile_dir,
181+ log_dir=log_dir)
182
183 def get_random_port_number(self):
184 return random.randint(1, 65535)
185@@ -82,6 +88,11 @@
186 with self.make_fixture(pidfile_dir=pidfile_dir):
187 self.assertThat(pidfile_dir, DirExists())
188
189+ def test_creates_log_dir(self):
190+ log_dir = os.path.join(self.make_dir(), "maas-test-logs")
191+ with self.make_fixture(log_dir=log_dir):
192+ self.assertThat(log_dir, DirExists())
193+
194 def test_get_url_returns_proxy_url(self):
195 port = self.get_random_port_number()
196 proxy_fixture = self.make_fixture(port=port)
197
198=== modified file 'maastest/utils.py'
199--- maastest/utils.py 2014-01-09 05:49:14 +0000
200+++ maastest/utils.py 2014-01-09 07:48:39 +0000
201@@ -54,6 +54,9 @@
202 # Default location for pidfiles.
203 DEFAULT_PIDFILE_DIR = '/run/maas-test'
204
205+# Default location for log files.
206+DEFAULT_LOG_DIR = '/var/log/maas-test'
207+
208
209 def read_file(path):
210 """Return a given file's contents, as `bytes`."""
211
212=== modified file 'man/maas-test.8'
213--- man/maas-test.8 2014-01-09 03:51:20 +0000
214+++ man/maas-test.8 2014-01-09 07:48:39 +0000
215@@ -122,7 +122,7 @@
216 attachment.
217 .sp
218 By default, the results are also written to timestamped log files under
219-\fI/var/cache/maas\-test/logs\fP\&.
220+\fI/var/log/maas\-test\fP\&.
221 .SH OPTIONS
222 .INDENT 0.0
223 .TP
224@@ -210,7 +210,7 @@
225 .B \-\-log\-results\-only
226 Write test results to a file, but don\(aqt upload them to Launchpad.
227 Results will be written to a timestamped log file under
228-\fI/var/cache/maas\-test/logs\fP\&.
229+\fI/var/log/maas\-test\fP\&.
230 .UNINDENT
231 .SH REPORTING BUGS
232 .sp
233@@ -230,9 +230,11 @@
234 .sp
235 State and configuration for \fImaas\-test\fP is stored in \fI/var/cache/maas\-test\fP\&.
236 This includes an ssh key pair for communicating with the virtual machine.
237+Pidfiles are stored in \fI/run/maas\-test\fP, and logs and test results are written
238+to \fI/var/log/maas\-test\fP\&.
239 .sp
240-If you choose to run a local proxy, downloaded data will also be cached there.
241-It can quickly grow to gigabyte sizes.
242+If you choose to run a local proxy, downloaded data will also be cached in the
243+\fI/var/cache/maas\-test\fP\&. It can quickly grow to gigabyte sizes.
244 .SH AUTHOR
245 MAAS engineering team at Canonical, Ltd.
246 .SH COPYRIGHT

Subscribers

People subscribed via source and target branches