Merge lp:~lazypower/charms/trusty/hive2/tests into lp:~asanjar/charms/trusty/hive2/trunk

Proposed by Charles Butler
Status: Merged
Merged at revision: 5
Proposed branch: lp:~lazypower/charms/trusty/hive2/tests
Merge into: lp:~asanjar/charms/trusty/hive2/trunk
Diff against target: 120 lines (+79/-6)
3 files modified
hooks/hive-common (+6/-6)
tests/00-setup (+5/-0)
tests/100-deploy-hive-mysql (+68/-0)
To merge this branch: bzr merge lp:~lazypower/charms/trusty/hive2/tests
Reviewer Review Type Date Requested Status
amir sanjar Approve
Review via email: mp+226331@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Charles Butler (lazypower) wrote :

Adds amulet tests to validate the MySQL / Hive2 metadata relationship sets up properly, the Hive daemons and JVM are present.

Revision history for this message
Charles Butler (lazypower) wrote :

Note that before this is promoted to a store charm branch - the locations of the HIVE charm should be changed to reflect a charm store path (possibly after, depending on how deep down the chicken/egg rabbit hole we want to go)

7. By Charles Butler

Changed GPG Key fetch to use secure channel, changed cp /dev/null to touch statements

Revision history for this message
amir sanjar (asanjar) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/hive-common'
2--- hooks/hive-common 2014-06-18 15:53:02 +0000
3+++ hooks/hive-common 2014-07-10 17:26:40 +0000
4@@ -30,7 +30,7 @@
5 ;;
6 "bigtop")
7 juju-log "Install and Configuring hive using bigtop repository..."
8- wget -O- http://archive.apache.org/dist/bigtop/bigtop-0.7.0/repos/GPG-KEY-bigtop | apt-key add -
9+ wget -O- https://archive.apache.org/dist/bigtop/bigtop-0.7.0/repos/GPG-KEY-bigtop | apt-key add -
10 wget -O /etc/apt/sources.list.d/bigtop-0.7.0.list http://archive.apache.org/dist/bigtop/bigtop-0.7.0/repos/precise/bigtop.list
11 ;;
12 esac
13@@ -100,7 +100,7 @@
14 cp -r /etc/hive/conf.dist /etc/hive/conf.juju
15 update-alternatives --install /etc/hive/conf hive-conf \
16 /etc/hive/conf.juju 50
17- cp /dev/null /etc/hive/conf.juju/hive-site.xml
18+ touch /etc/hive/conf.juju/hive-site.xml
19 mv /etc/hive/conf.juju/hive-env.sh.template \
20 /etc/hive/conf.juju/hive-env.sh
21 dotdee --setup /etc/hive/conf.juju/hive-site.xml
22@@ -111,10 +111,10 @@
23 cp -r /etc/hadoop/conf.empty /etc/hadoop/conf.juju
24 update-alternatives --install /etc/hadoop/conf hadoop-conf \
25 /etc/hadoop/conf.juju 50
26- cp /dev/null /etc/hadoop/conf.juju/hdfs-site.xml
27- cp /dev/null /etc/hadoop/conf.juju/core-site.xml
28- cp /dev/null /etc/hadoop/conf.juju/mapred-site.xml
29- cp /dev/null /etc/hadoop/conf.juju/yarn-site.xml
30+ touch /etc/hadoop/conf.juju/hdfs-site.xml
31+ touch /etc/hadoop/conf.juju/core-site.xml
32+ touch /etc/hadoop/conf.juju/mapred-site.xml
33+ touch /etc/hadoop/conf.juju/yarn-site.xml
34 dotdee --setup /etc/hadoop/conf.juju/hdfs-site.xml
35 dotdee --setup /etc/hadoop/conf.juju/core-site.xml
36 dotdee --setup /etc/hadoop/conf.juju/mapred-site.xml
37
38=== added directory 'tests'
39=== added file 'tests/00-setup'
40--- tests/00-setup 1970-01-01 00:00:00 +0000
41+++ tests/00-setup 2014-07-10 17:26:40 +0000
42@@ -0,0 +1,5 @@
43+#!/bin/bash
44+
45+sudo add-apt-repository ppa:juju/stable -y
46+sudo apt-get update
47+sudo apt-get install python3 amulet -y
48
49=== added file 'tests/100-deploy-hive-mysql'
50--- tests/100-deploy-hive-mysql 1970-01-01 00:00:00 +0000
51+++ tests/100-deploy-hive-mysql 2014-07-10 17:26:40 +0000
52@@ -0,0 +1,68 @@
53+#!/usr/bin/python3
54+
55+import amulet
56+
57+
58+class TestDeployment(object):
59+
60+ def __init__(self):
61+ self.deploy = amulet.Deployment(series='trusty')
62+
63+ self.deploy.add('hive-server', 'cs:~asanjar/trusty/hive2')
64+ self.deploy.add('hive-metastore', 'cs:~asanjar/trusty/hive2')
65+ self.deploy.add('mysql', 'cs:trusty/mysql')
66+
67+ self.deploy.configure('mysql', {'binlog-format': 'row'})
68+
69+ self.deploy.relate('hive-server:db', 'mysql:db')
70+ self.deploy.relate('hive-metastore:db', 'mysql:db')
71+
72+ self.deploy.expose('hive-server')
73+
74+ try:
75+ self.deploy.setup(900)
76+ self.deploy.sentry.wait(900)
77+ except amulet.helpers.TimeoutError:
78+ amulet.raise_status(amulet.FAIL,
79+ msg="Environment wasn't stood up in time")
80+
81+ self.hive_unit = self.deploy.sentry.unit['hive-server/0']
82+ self.meta_unit = self.deploy.sentry.unit['hive-metastore/0']
83+
84+ # Clever test runner. TY cory
85+ def run(self):
86+ for test in dir(self):
87+ if test.startswith('test_'):
88+ getattr(self, test)()
89+
90+
91+ # Validate the service is running
92+ def test_service_status(self):
93+ output, code = self.hive_unit.run('service hive-server2 status')
94+ if output != "* Hive Server2 is running":
95+ amulet.raise_status(amulet.FAIL, "Hive2 Server not running")
96+
97+ # Validate the JVM
98+ def test_jvm_status(self):
99+ output, code = self.hive_unit.run('jps')
100+ if not "Jps" in output or not "RunJar" in output:
101+ amulet.raise_status(amulet.FAIL, "JVM not present")
102+
103+ def test_mysql_meta_tables(self):
104+ unit = self.deploy.sentry.unit['mysql/0']
105+
106+ tables = ['DATABASE_PARAMS', 'DBS', 'SEQUENCE_TABLE']
107+
108+ # Determine SQL Password and define the login routine
109+ sql_pass, code = unit.run('cat /var/lib/mysql/mysql.passwd')
110+ sql_login = 'mysql -u root -p{}'.format(sql_pass)
111+ cmd = '{} relation-sentry -e "SHOW TABLES"'.format(sql_login)
112+ output, code = unit.run(cmd)
113+ for t in tables:
114+ if not t in output:
115+ msg = "Unable to locate table {}".format(t)
116+ amulet.raise_status(amulet.FAIL, msg=msg)
117+
118+if __name__ == '__main__':
119+ runner = TestDeployment()
120+ runner.run()

Subscribers

People subscribed via source and target branches