Merge lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-master/smoke-test into lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-master/trunk

Proposed by Cory Johns
Status: Merged
Merged at revision: 98
Proposed branch: lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-master/smoke-test
Merge into: lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-master/trunk
Diff against target: 107 lines (+84/-0)
3 files modified
README.md (+29/-0)
actions.yaml (+2/-0)
actions/smoke-test (+53/-0)
To merge this branch: bzr merge lp:~bigdata-dev/charms/trusty/apache-hadoop-hdfs-master/smoke-test
Reviewer Review Type Date Requested Status
Kevin W Monroe Approve
Review via email: mp+268263@code.launchpad.net

Description of the change

Added smoke-test action and relevant README section

To post a comment you must log in.
Revision history for this message
Kevin W Monroe (kwmonroe) wrote :

I really like this, but want confirmation that the action should bail out if a datanode isn't connected, which is to say that it won't be possible for charm.active to be True without a DN. Is that right?

Revision history for this message
Kevin W Monroe (kwmonroe) wrote :

LGTM after confirming previous comment; only beef here was a need to +x actions/smoke-test, but this has now been merged to ./trunk.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.md'
2--- README.md 2015-08-07 21:30:37 +0000
3+++ README.md 2015-08-17 18:17:22 +0000
4@@ -27,6 +27,35 @@
5 hadoop jar my-job.jar
6
7
8+## Status and Smoke Test
9+
10+The services provide extended status reporting to indicate when they are ready:
11+
12+ juju status --format=tabular
13+
14+This is particularly useful when combined with `watch` to track the on-going
15+progress of the deployment:
16+
17+ watch -n 0.5 juju status --format=tabular
18+
19+The message for each unit will provide information about that unit's state.
20+Once they all indicate that they are ready, you can perform a "smoke test"
21+to verify that HDFS is working as expected using the built-in `smoke-test`
22+action:
23+
24+ juju action do smoke-test
25+
26+After a few seconds or so, you can check the results of the smoke test:
27+
28+ juju action status
29+
30+You will see `status: completed` if the smoke test was successful, or
31+`status: failed` if it was not. You can get more information on why it failed
32+via:
33+
34+ juju action fetch <action-id>
35+
36+
37 ## Deploying in Network-Restricted Environments
38
39 The Apache Hadoop charms can be deployed in environments with limited network
40
41=== modified file 'actions.yaml'
42--- actions.yaml 2015-06-23 17:15:23 +0000
43+++ actions.yaml 2015-08-17 18:17:22 +0000
44@@ -4,3 +4,5 @@
45 description: All of the HDFS processes can be stopped with this Juju action.
46 restart-hdfs:
47 description: All of the HDFS processes can be restarted with this Juju action.
48+smoke-test:
49+ description: Verify that HDFS is working by creating and removing a small file.
50
51=== added file 'actions/smoke-test'
52--- actions/smoke-test 1970-01-01 00:00:00 +0000
53+++ actions/smoke-test 2015-08-17 18:17:22 +0000
54@@ -0,0 +1,53 @@
55+#!/usr/bin/env python
56+
57+import sys
58+
59+try:
60+ from charmhelpers.core import hookenv
61+ from charmhelpers.core import unitdata
62+ from jujubigdata.utils import run_as
63+ charm_ready = unitdata.kv().get('charm.active', False)
64+except ImportError:
65+ charm_ready = False
66+
67+if not charm_ready:
68+ # might not have hookenv.action_fail available yet
69+ from subprocess import call
70+ call(['action-fail', 'HDFS service not yet ready'])
71+
72+
73+# verify the hdfs-test directory does not already exist
74+output = run_as('ubuntu', 'hdfs', 'dfs', '-ls', '/tmp', capture_output=True)
75+if '/tmp/hdfs-test' in output:
76+ run_as('ubuntu', 'hdfs', 'dfs', '-rm', '-R', '/tmp/hdfs-test')
77+ output = run_as('ubuntu', 'hdfs', 'dfs', '-ls', '/tmp', capture_output=True)
78+ if 'hdfs-test' in output:
79+ hookenv.action_fail('Unable to remove existing hdfs-test directory')
80+ sys.exit()
81+
82+# create the directory
83+run_as('ubuntu', 'hdfs', 'dfs', '-mkdir', '-p', '/tmp/hdfs-test')
84+run_as('ubuntu', 'hdfs', 'dfs', '-chmod', '-R', '777', '/tmp/hdfs-test')
85+
86+# verify the newly created hdfs-test subdirectory exists
87+output = run_as('ubuntu', 'hdfs', 'dfs', '-ls', '/tmp', capture_output=True)
88+for line in output.split('\n'):
89+ if '/tmp/hdfs-test' in line:
90+ if 'ubuntu' not in line or 'drwxrwxrwx' not in line:
91+ hookenv.action_fail('Permissions incorrect for hdfs-test directory')
92+ sys.exit()
93+ break
94+else:
95+ hookenv.action_fail('Unable to create hdfs-test directory')
96+ sys.exit()
97+
98+# remove the directory
99+run_as('ubuntu', 'hdfs', 'dfs', '-rm', '-R', '/tmp/hdfs-test')
100+
101+# verify the hdfs-test subdirectory has been removed
102+output = run_as('ubuntu', 'hdfs', 'dfs', '-ls', '/tmp', capture_output=True)
103+if '/tmp/hdfs-test' in output:
104+ hookenv.action_fail('Unable to remove hdfs-test directory')
105+ sys.exit()
106+
107+hookenv.action_set({'outcome': 'success'})

Subscribers

People subscribed via source and target branches

to all changes: