Merge lp:~ibmcharmers/charms/trusty/gpfs/devel into lp:~ibmcharmers/charms/trusty/gpfs/trunk

Proposed by Adalberto Medeiros
Status: Merged
Merged at revision: 34
Proposed branch: lp:~ibmcharmers/charms/trusty/gpfs/devel
Merge into: lp:~ibmcharmers/charms/trusty/gpfs/trunk
Diff against target: 173 lines (+89/-31)
3 files modified
hooks/gpfshooklib.py (+1/-1)
tests/00-setup (+9/-7)
tests/10-deploy (+79/-23)
To merge this branch: bzr merge lp:~ibmcharmers/charms/trusty/gpfs/devel
Reviewer Review Type Date Requested Status
Michael Chase-Salerno Approve
Review via email: mp+253679@code.launchpad.net

Description of the change

Tests changes

------------------------------------------------------------
revno: 36
committer: Adalberto Medeiros <email address hidden>
branch nick: devel
timestamp: Fri 2015-03-20 13:51:29 +0000
message:
  Defined tests (remove print only)
------------------------------------------------------------
revno: 35
committer: Adalberto Medeiros <email address hidden>
branch nick: devel
timestamp: Fri 2015-03-20 13:51:02 +0000
message:
  Fix regex to check if node exists
------------------------------------------------------------
revno: 34
committer: Adalberto Medeiros <email address hidden>
branch nick: devel
timestamp: Sat 2015-03-14 23:38:23 +0000
message:
  Check if the GFPS packages repository url is set for tests.

  Verify if the url is set and if you can access it.
  Removed the hardcode url.
------------------------------------------------------------
revno: 33
committer: Adalberto Medeiros <email address hidden>
branch nick: devel
timestamp: Wed 2015-03-11 19:35:43 +0000
message:
  small pep8 fixes

To post a comment you must log in.
Revision history for this message
Michael Chase-Salerno (mcs-chasal) :
review: Approve
34. By Adalberto Medeiros

Merge devel

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/gpfshooklib.py'
2--- hooks/gpfshooklib.py 2015-03-11 19:35:43 +0000
3+++ hooks/gpfshooklib.py 2015-03-20 14:11:44 +0000
4@@ -178,7 +178,7 @@
5 def node_exists(nodename):
6 # Check if node has already been added to cluster
7 lscluster = check_output('mmlscluster')
8- node = re.search('^.*\d+.*%s.*\n' % nodename, lscluster, re.M)
9+ node = re.search('^ *\d+.*%s.*$' % nodename, lscluster, re.M)
10 return False if node is None else True
11
12
13
14=== modified file 'tests/00-setup'
15--- tests/00-setup 2015-03-09 15:28:29 +0000
16+++ tests/00-setup 2015-03-20 14:11:44 +0000
17@@ -1,21 +1,23 @@
18 #!/bin/bash
19
20+# ATTENTION: gpfs_url must contain the repository with
21+# your GPFS packages
22+GPFS_URL=${GPFS_URL?Error: GPFS repository must be defined in tests/00-setup}
23+
24 sudo add-apt-repository ppa:juju/stable -y
25 sudo apt-get update
26 sudo apt-get install amulet python-requests -y
27
28 # Add a local configuration file
29-# ATTENTION: gpfs_url must contain the repository with
30-# your GPFS packages
31-if [ ! -f '../local.yaml' ]; then
32- cat << EOF > ../local.yaml
33+cat << EOF > local.yaml
34 gpfs:
35- gpfs_url: "http://9.114.111.40/debs/gpfs4.1"
36+ gpfs_url: "$GPFS_URL"
37 update: true
38 version: "4.1"
39+ quorum: "quorum"
40 gpfs-client:
41- gpfs_url: "http://9.114.111.40/debs/gpfs4.1"
42+ gpfs_url: "$GPFS_URL"
43 update: true
44 version: "4.1"
45+ quorum: "non-quorum"
46 EOF
47-fi
48
49=== modified file 'tests/10-deploy'
50--- tests/10-deploy 2015-03-09 15:28:29 +0000
51+++ tests/10-deploy 2015-03-20 14:11:44 +0000
52@@ -3,17 +3,48 @@
53 import amulet
54 import requests
55 import os
56-
57-#os.environ['JUJU_REPOSITORY'] = os.path.dirname(os.getcwd())
58+import re
59+import yaml
60+import urllib
61+import sys
62+from urllib.request import urlopen
63+from amulet.helpers import (
64+ timeout,
65+ TimeoutError
66+)
67+
68+
69+def test_url(url):
70+# Test if a gpfs url for the repository is defined
71+ if not url:
72+ print("You need to define a url for the GPFS packages repository.\n"
73+ "Edit local.yaml or tests/00-setup and run it again.")
74+ sys.exit(1)
75+ #check if url is accessible
76+ try:
77+ resp = urlopen(url)
78+ except urllib.error.HTTPError as HTTPerr:
79+ print(HTTPerr.geturl(), HTTPerr.getcode(), HTTPerr.reason)
80+ sys.exit(1)
81+
82+
83+def get_config():
84+ # get config from local.yaml
85+ with open("local.yaml", "r") as fd:
86+ return yaml.load(fd)
87+
88+
89+config = get_config()
90+test_url(config.get('gpfs').get('gpfs_url'))
91 d = amulet.Deployment(juju_env='local', series='trusty')
92
93 d.add('gpfs')
94 d.add('gpfs-client', charm='gpfs')
95-config = {'gpfs_url': "http://9.114.111.40/debs/gpfs4.1", 'update':True, 'version':"4.1", 'quorum': 'non-quorum'}
96-d.configure('gpfs-client', config)
97-d.configure('gpfs', config)
98+d.configure('gpfs-client', config.get('gpfs-client'))
99+d.configure('gpfs', config.get('gpfs'))
100 d.relate('gpfs:manager', 'gpfs-client:client')
101-#d.expose('gpfs')
102+d.expose('gpfs')
103+d.expose('gpfs-client')
104
105 try:
106 d.setup(timeout=900)
107@@ -25,24 +56,49 @@
108
109 unit_manager_0 = d.sentry.unit['gpfs/0']
110 unit_client_0 = d.sentry.unit['gpfs-client/0']
111-print(unit_manager_0.info)
112-
113+
114+
115+## Tests ###
116+def test_manager_is_set():
117 # verify unit_manager is manager
118-print(unit_manager_0.file('/var/mmfs/.manager'))
119-
120-# test cluster is configured
121-print(unit_manager_0.run('/usr/lpp/mmfs/bin/mmlscluster'))
122-
123-# test break relation
124-d.unrelate('gpfs:manager','gpfs-client:client')
125-d.sentry.wait()
126-print(unit_manager_0.run('/usr/lpp/mmfs/bin/mmlscluster'))
127-
128-# test add and remove unit
129-#d.add_unit('gpfs-client')
130-#d.sentry.wait()
131-#unit_client_1 = d.sentry.unit['gpfs-client/1']
132-#print(unit_manager_0.run('/usr/lpp/mmfs/bin/mmlscluster'))
133+ mgr_file = '/var/mmfs/.manager'
134+ try:
135+ is_manager = unit_manager_0.file(mgr_file)
136+ except IOError:
137+ amulet.raise_status(amulet.SKIP, msg="Node is not manager")
138+ try:
139+ is_client = unit_client_0.file(mgr_file)
140+ amulet.raise_status(amulet.SKIP, msg="Node is not client")
141+ except IOError:
142+ pass
143+
144+
145+def test_unit_deployed():
146+ # verify unit
147+ state_mgr = unit_manager_0.info['agent-state']
148+ state_clt = unit_client_0.info['agent-state']
149+ assert state_mgr == 'started', "Manager not started"
150+ assert state_clt == 'started', "Client not started"
151+
152+
153+def _node_exists(nodename):
154+ # Check if node has already been added to cluster
155+ lscluster = unit_manager_0.run('/usr/lpp/mmfs/bin/mmlscluster')
156+ assert lscluster[1] == 0, "Cluster not initialized"
157+ node = re.search('^ *\d+.*%s.*$' % nodename, lscluster[0], re.M)
158+ return False if node is None else True
159+
160+
161+def test_cluster_configured():
162+ mgr_ip = unit_manager_0.info['public-address']
163+ clt_ip = unit_client_0.info['public-address']
164+ assert _node_exists(mgr_ip), "Manager not found in cluster"
165+ assert _node_exists(clt_ip), "Client not found in cluster"
166+
167+
168+test_manager_is_set()
169+test_unit_deployed()
170+test_cluster_configured()
171
172
173 # Now you can use d.sentry.unit[UNIT] to address each of the units and perform

Subscribers

People subscribed via source and target branches

to all changes: