~kos.tsakalozos/charms/trusty/hdp-storm/trunk

« back to all changes in this revision

Viewing changes to tests/01-zookeeper-deploy

  • Committer: amir sanjar
  • Date: 2014-09-17 00:31:34 UTC
  • Revision ID: amir.sanjar@canonical.com-20140917003134-qzvpp37bw9rghw0h
Review update

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python3
2
 
 
3
 
import amulet
4
 
import yaml
5
 
import os
6
 
import sys
7
 
 
8
 
class TestDeployment(object):
9
 
    def __init__(self):
10
 
        self.d =  amulet.Deployment(series='trusty')
11
 
        f = open('zookeeper.yaml')
12
 
        bun = f.read()
13
 
        self.d.load(yaml.safe_load(bun))
14
 
        #self.d.add('hdp-zookeeper', charm='~/development/charms/trusty/hdp-zookeeper', units=3)
15
 
        try:
16
 
            self.d.setup(timeout=900000)
17
 
            self.d.sentry.wait()
18
 
        except amulet.helpers.TimeoutError:
19
 
            amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
20
 
        except:
21
 
            raise
22
 
        self.zk_unit = self.d.sentry.unit['hdp-zookeeper/0']
23
 
        
24
 
   
25
 
    def run(self):
26
 
        for test in dir(self):
27
 
            if test.startswith('test_'):
28
 
                getattr(self, test)()
29
 
 
30
 
 
31
 
 
32
 
    def test_zookeeper_service_status(self):
33
 
        o,c= self.zk_unit.run("jps | awk '{print $2}'")
34
 
        if o.find('QuorumPeerMain') == -1:
35
 
            amulet.raise_status(amulet.FAIL, msg="Zookeeper QuorumPeerMain not started")
36
 
    
37
 
    def test_validate_zoo_cfg(self):
38
 
        #verify formation of three zookeeper servers in the quorum
39
 
        zoocfgpath = os.path.join(os.path.sep,'etc', 'zookeeper', 'conf','zoo.cfg')
40
 
        out = self.zk_unit.file_contents(zoocfgpath)
41
 
        lines = out.split("\n")
42
 
        foundServer = 0
43
 
        for i in range(0,len(lines)):
44
 
            if str(lines[i]).startswith("server."):
45
 
               foundServer +=1
46
 
        if foundServer != 3:
47
 
            amulet.raise_status(amulet.FAIL, msg="Zookeeper- Quorum count is not three") 
48
 
                    
49
 
                    
50
 
                    
51
 
if __name__ == '__main__':
52
 
    runner = TestDeployment()
53
 
    runner.run()