Merge lp:~fginther/core-image-tester/queue-constants into lp:core-image-tester

Proposed by Francis Ginther
Status: Merged
Approved by: Thomi Richards
Approved revision: 35
Merged at revision: 35
Proposed branch: lp:~fginther/core-image-tester/queue-constants
Merge into: lp:core-image-tester
Diff against target: 103 lines (+23/-32)
2 files modified
core_image_tester/constants.py (+19/-24)
core_image_tester/queue.py (+4/-8)
To merge this branch: bzr merge lp:~fginther/core-image-tester/queue-constants
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
Review via email: mp+259860@code.launchpad.net

Commit message

Move the queue names into constants.py and update the solution name and hostname.

Description of the change

Move the queue names into constants.py and update the solution name and hostname.

To post a comment you must log in.

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'core_image_tester/constants.py'
2--- core_image_tester/constants.py 2015-04-07 18:10:22 +0000
3+++ core_image_tester/constants.py 2015-05-21 21:58:00 +0000
4@@ -15,37 +15,32 @@
5 # along with this program. If not, see <http://www.gnu.org/licenses/>.
6 #
7
8+import socket
9+
10+
11 """Constants for this service."""
12-
13-API_VERSION = "v1"
14+# Queue names are constant, rather than being defined in the config.
15+
16+# The queue we listen to for new payloads to check:
17+INPUT_QUEUE = "core.tests.v1"
18+
19+# The queue we put fatally error'd payloads into:
20+DEAD_LETTER_QUEUE = "core.deadletters.v1"
21+
22+# The queue we put payloads on to re-run the test:
23+TEST_RETRY_QUEUE = "core.tests.v1"
24+
25+# The queue we put results on:
26+DONE_QUEUE = "core.result.v1"
27+
28
29 RETRY_COUNT = 3
30
31-SOLUTION_NAME = "core-image-testing"
32+SOLUTION_NAME = "snappy-image-tests"
33
34 SERVICE_NAME = "core-image-tester"
35
36-
37-def _get_hostname():
38- """Return sanitized contents of /etc/hostname.
39-
40- It is necessary because current juju hostnames (juju-<env-name>-machine-#)
41- are too big due to our long environment names ('<spec_name>-<MD5>').
42- Linux (DNS for RFC1035, really) only supports labels up to 64 chars and
43- the fallback varies from tool to tool, `cloud-init` chokes on longer
44- names and sets 'ubuntu' (which is the value considered by socket.get*),
45- `hostnamectl` (systemd) would truncate the given data.
46-
47- None of this is ideal to our applications, that's why we will operate
48- on the pristine /etc/hostname and remove the 'juju-' and '-machine' terms
49- added by juju.
50- """
51- with open('/etc/hostname') as fd:
52- hostname = fd.read()
53- return hostname.replace('juju-', '').replace('-machine', '').strip()
54-
55-
56-HOSTNAME = _get_hostname()
57+HOSTNAME = socket.gethostname()
58
59 LOGGING_EXTRA = {
60 'solution': SOLUTION_NAME,
61
62=== modified file 'core_image_tester/queue.py'
63--- core_image_tester/queue.py 2015-03-31 19:01:25 +0000
64+++ core_image_tester/queue.py 2015-05-21 21:58:00 +0000
65@@ -79,7 +79,7 @@
66 def get_consumers(self, Consumer, channel):
67 """Return consumers instances for all configured queues."""
68 queues = [
69- kombu.Queue('core.tests.{}'.format(constants.API_VERSION))
70+ kombu.Queue(constants.INPUT_QUEUE)
71 ]
72 return [Consumer(queues=queues, callbacks=[self.process])]
73
74@@ -130,8 +130,7 @@
75 retry_count = int(message.payload.get(retry_key, '0'))
76 if retry_count < constants.RETRY_COUNT:
77 message.payload[retry_key] = retry_count + 1
78- queue = self.connection.SimpleQueue(
79- 'core.tests.{}'.format(constants.API_VERSION))
80+ queue = self.connection.SimpleQueue(constants.TEST_RETRY_QUEUE)
81 queue.put(message.payload)
82 queue.close()
83 message.ack()
84@@ -141,8 +140,7 @@
85 "Message will reside on the dead letter queue",
86 extra=extra
87 )
88- queue = self.connection.SimpleQueue(
89- 'core.deadletters.{}'.format(constants.API_VERSION))
90+ queue = self.connection.SimpleQueue(constants.DEAD_LETTER_QUEUE)
91 queue.put(message.payload)
92 queue.close()
93 message.ack()
94@@ -172,8 +170,6 @@
95
96 def __call__(self, payload):
97 """Take 'payload' and enqueue it on the rabbit queue."""
98- queue = self.connection.SimpleQueue(
99- "core.result.{}".format(constants.API_VERSION)
100- )
101+ queue = self.connection.SimpleQueue(constants.DONE_QUEUE)
102 queue.put(payload)
103 queue.close()

Subscribers

People subscribed via source and target branches