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
=== modified file 'hooks/gpfshooklib.py'
--- hooks/gpfshooklib.py 2015-03-11 19:35:43 +0000
+++ hooks/gpfshooklib.py 2015-03-20 14:11:44 +0000
@@ -178,7 +178,7 @@
178def node_exists(nodename):178def node_exists(nodename):
179 # Check if node has already been added to cluster179 # Check if node has already been added to cluster
180 lscluster = check_output('mmlscluster')180 lscluster = check_output('mmlscluster')
181 node = re.search('^.*\d+.*%s.*\n' % nodename, lscluster, re.M)181 node = re.search('^ *\d+.*%s.*$' % nodename, lscluster, re.M)
182 return False if node is None else True182 return False if node is None else True
183183
184184
185185
=== modified file 'tests/00-setup'
--- tests/00-setup 2015-03-09 15:28:29 +0000
+++ tests/00-setup 2015-03-20 14:11:44 +0000
@@ -1,21 +1,23 @@
1#!/bin/bash1#!/bin/bash
22
3# ATTENTION: gpfs_url must contain the repository with
4# your GPFS packages
5GPFS_URL=${GPFS_URL?Error: GPFS repository must be defined in tests/00-setup}
6
3sudo add-apt-repository ppa:juju/stable -y7sudo add-apt-repository ppa:juju/stable -y
4sudo apt-get update8sudo apt-get update
5sudo apt-get install amulet python-requests -y9sudo apt-get install amulet python-requests -y
610
7# Add a local configuration file11# Add a local configuration file
8# ATTENTION: gpfs_url must contain the repository with12cat << EOF > local.yaml
9# your GPFS packages
10if [ ! -f '../local.yaml' ]; then
11 cat << EOF > ../local.yaml
12gpfs:13gpfs:
13 gpfs_url: "http://9.114.111.40/debs/gpfs4.1"14 gpfs_url: "$GPFS_URL"
14 update: true15 update: true
15 version: "4.1"16 version: "4.1"
17 quorum: "quorum"
16gpfs-client:18gpfs-client:
17 gpfs_url: "http://9.114.111.40/debs/gpfs4.1"19 gpfs_url: "$GPFS_URL"
18 update: true20 update: true
19 version: "4.1"21 version: "4.1"
22 quorum: "non-quorum"
20EOF23EOF
21fi
2224
=== modified file 'tests/10-deploy'
--- tests/10-deploy 2015-03-09 15:28:29 +0000
+++ tests/10-deploy 2015-03-20 14:11:44 +0000
@@ -3,17 +3,48 @@
3import amulet3import amulet
4import requests4import requests
5import os5import os
66import re
7#os.environ['JUJU_REPOSITORY'] = os.path.dirname(os.getcwd())7import yaml
8import urllib
9import sys
10from urllib.request import urlopen
11from amulet.helpers import (
12 timeout,
13 TimeoutError
14)
15
16
17def test_url(url):
18# Test if a gpfs url for the repository is defined
19 if not url:
20 print("You need to define a url for the GPFS packages repository.\n"
21 "Edit local.yaml or tests/00-setup and run it again.")
22 sys.exit(1)
23 #check if url is accessible
24 try:
25 resp = urlopen(url)
26 except urllib.error.HTTPError as HTTPerr:
27 print(HTTPerr.geturl(), HTTPerr.getcode(), HTTPerr.reason)
28 sys.exit(1)
29
30
31def get_config():
32 # get config from local.yaml
33 with open("local.yaml", "r") as fd:
34 return yaml.load(fd)
35
36
37config = get_config()
38test_url(config.get('gpfs').get('gpfs_url'))
8d = amulet.Deployment(juju_env='local', series='trusty')39d = amulet.Deployment(juju_env='local', series='trusty')
940
10d.add('gpfs')41d.add('gpfs')
11d.add('gpfs-client', charm='gpfs')42d.add('gpfs-client', charm='gpfs')
12config = {'gpfs_url': "http://9.114.111.40/debs/gpfs4.1", 'update':True, 'version':"4.1", 'quorum': 'non-quorum'}43d.configure('gpfs-client', config.get('gpfs-client'))
13d.configure('gpfs-client', config)44d.configure('gpfs', config.get('gpfs'))
14d.configure('gpfs', config)
15d.relate('gpfs:manager', 'gpfs-client:client')45d.relate('gpfs:manager', 'gpfs-client:client')
16#d.expose('gpfs')46d.expose('gpfs')
47d.expose('gpfs-client')
1748
18try:49try:
19 d.setup(timeout=900)50 d.setup(timeout=900)
@@ -25,24 +56,49 @@
2556
26unit_manager_0 = d.sentry.unit['gpfs/0']57unit_manager_0 = d.sentry.unit['gpfs/0']
27unit_client_0 = d.sentry.unit['gpfs-client/0']58unit_client_0 = d.sentry.unit['gpfs-client/0']
28print(unit_manager_0.info)59
2960
61## Tests ###
62def test_manager_is_set():
30# verify unit_manager is manager63# verify unit_manager is manager
31print(unit_manager_0.file('/var/mmfs/.manager'))64 mgr_file = '/var/mmfs/.manager'
3265 try:
33# test cluster is configured66 is_manager = unit_manager_0.file(mgr_file)
34print(unit_manager_0.run('/usr/lpp/mmfs/bin/mmlscluster'))67 except IOError:
3568 amulet.raise_status(amulet.SKIP, msg="Node is not manager")
36# test break relation69 try:
37d.unrelate('gpfs:manager','gpfs-client:client')70 is_client = unit_client_0.file(mgr_file)
38d.sentry.wait()71 amulet.raise_status(amulet.SKIP, msg="Node is not client")
39print(unit_manager_0.run('/usr/lpp/mmfs/bin/mmlscluster')) 72 except IOError:
4073 pass
41# test add and remove unit74
42#d.add_unit('gpfs-client')75
43#d.sentry.wait()76def test_unit_deployed():
44#unit_client_1 = d.sentry.unit['gpfs-client/1']77 # verify unit
45#print(unit_manager_0.run('/usr/lpp/mmfs/bin/mmlscluster'))78 state_mgr = unit_manager_0.info['agent-state']
79 state_clt = unit_client_0.info['agent-state']
80 assert state_mgr == 'started', "Manager not started"
81 assert state_clt == 'started', "Client not started"
82
83
84def _node_exists(nodename):
85 # Check if node has already been added to cluster
86 lscluster = unit_manager_0.run('/usr/lpp/mmfs/bin/mmlscluster')
87 assert lscluster[1] == 0, "Cluster not initialized"
88 node = re.search('^ *\d+.*%s.*$' % nodename, lscluster[0], re.M)
89 return False if node is None else True
90
91
92def test_cluster_configured():
93 mgr_ip = unit_manager_0.info['public-address']
94 clt_ip = unit_client_0.info['public-address']
95 assert _node_exists(mgr_ip), "Manager not found in cluster"
96 assert _node_exists(clt_ip), "Client not found in cluster"
97
98
99test_manager_is_set()
100test_unit_deployed()
101test_cluster_configured()
46102
47103
48# Now you can use d.sentry.unit[UNIT] to address each of the units and perform104# 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: