Merge lp:~marcoceppi/charms/precise/zookeeper/trunk into lp:charms/zookeeper

Proposed by Marco Ceppi
Status: Merged
Merged at revision: 12
Proposed branch: lp:~marcoceppi/charms/precise/zookeeper/trunk
Merge into: lp:charms/zookeeper
Diff against target: 73 lines (+56/-0)
3 files modified
tests/00-setup (+16/-0)
tests/10-bundles-test.py (+33/-0)
tests/bundles.yaml (+7/-0)
To merge this branch: bzr merge lp:~marcoceppi/charms/precise/zookeeper/trunk
Reviewer Review Type Date Requested Status
Matt Bruzek (community) Approve
Review via email: mp+240876@code.launchpad.net

Commit message

Tests for charm

To post a comment you must log in.
Revision history for this message
Matt Bruzek (mbruzek) wrote :

+1 LGTM tests pass when I ran them.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'tests'
2=== added file 'tests/00-setup'
3--- tests/00-setup 1970-01-01 00:00:00 +0000
4+++ tests/00-setup 2014-11-06 15:59:10 +0000
5@@ -0,0 +1,16 @@
6+#!/bin/bash
7+
8+# This script sets up the requirements for amulet tests.
9+
10+set -x
11+
12+# Check if amulet is installed before adding the stable repository and updating apt-get.
13+dpkg -s amulet
14+if [ $? -ne 0 ]; then
15+ sudo add-apt-repository -y ppa:juju/stable
16+ sudo apt-get update -qq
17+ sudo apt-get install -y amulet
18+fi
19+
20+# Install any additional python packages or other required software.
21+sudo apt-get install -y python3-requests
22\ No newline at end of file
23
24=== added file 'tests/10-bundles-test.py'
25--- tests/10-bundles-test.py 1970-01-01 00:00:00 +0000
26+++ tests/10-bundles-test.py 2014-11-06 15:59:10 +0000
27@@ -0,0 +1,33 @@
28+#!/usr/bin/env python3
29+
30+# This amulet test deploys the bundles.yaml file in this directory.
31+
32+import os
33+import unittest
34+import yaml
35+import amulet
36+
37+seconds_to_wait = 720
38+
39+
40+class BundleTest(unittest.TestCase):
41+ """ Create a class for testing the charm in the unit test framework. """
42+ @classmethod
43+ def setUpClass(cls):
44+ """ Set up an amulet deployment using the bundle. """
45+ d = amulet.Deployment()
46+ bundle_path = os.path.join(os.path.dirname(__file__), 'bundles.yaml')
47+ with open(bundle_path, 'r') as bundle_file:
48+ contents = yaml.safe_load(bundle_file)
49+ d.load(contents)
50+ d.setup(seconds_to_wait)
51+ d.sentry.wait(seconds_to_wait)
52+ cls.d = d
53+
54+ def test_deployed(self):
55+ """ Test to see if the bundle deployed successfully. """
56+ self.assertTrue(self.d.deployed)
57+
58+
59+if __name__ == '__main__':
60+ unittest.main()
61\ No newline at end of file
62
63=== added file 'tests/bundles.yaml'
64--- tests/bundles.yaml 1970-01-01 00:00:00 +0000
65+++ tests/bundles.yaml 2014-11-06 15:59:10 +0000
66@@ -0,0 +1,7 @@
67+zookeeper-automated-bundle:
68+ relations: []
69+ series: precise
70+ services:
71+ zookeeper:
72+ charm: zookeeper
73+ num_units: 1

Subscribers

People subscribed via source and target branches

to all changes: