Merge lp:~brad-marshall/charms/precise/bip/add-amulet-tests into lp:charms/bip

Proposed by Brad Marshall
Status: Merged
Merged at revision: 21
Proposed branch: lp:~brad-marshall/charms/precise/bip/add-amulet-tests
Merge into: lp:charms/bip
Diff against target: 132 lines (+52/-54)
3 files modified
tests/00-setup (+0/-5)
tests/10-deploy (+52/-0)
tests/99-autogen (+0/-49)
To merge this branch: bzr merge lp:~brad-marshall/charms/precise/bip/add-amulet-tests
Reviewer Review Type Date Requested Status
José Antonio Rey (community) Approve
Cory Johns Needs Fixing
Review Queue (community) automated testing Needs Fixing
Review via email: mp+241480@code.launchpad.net

Description of the change

Add some basic amulet tests to confirm bip is running, and the port is open. Any extra testing ideas would be great.

I've done some basic testing with trusty and would like to see the charm promulgated to trusty if possible.

Fixed the error reporting on the socket connection testing.

To post a comment you must log in.
18. By Tim Van Steenburgh

[brad-marshall] Added config options for backlog

19. By Tim Van Steenburgh

[mbruzek] Added tests

Revision history for this message
Review Queue (review-queue) wrote :

This items has failed automated testing! Results available here http://reports.vapour.ws/charm-tests/charm-bundle-test-10340-results

review: Needs Fixing (automated testing)
Revision history for this message
Cory Johns (johnsca) wrote :

Brad,

Thanks for adding these tests! It looks like the "failure" reported above is due to a merge conflict between this test and the boilerplate test added in revision #19 [1]. However, these tests are clearly superior, and it should be an easy merge to discard the tests from upstream in favor of these.

However, when running these tests, I found that the backlog changes merged in with revision #18 [2] did not include the variables in the template context, resulting in a broken bip.conf file.

Before approving this, could you please resolve the merge conflict and add the two variables (backlog_lines and backlog_msg_only) to the template context so that the tests can pass?

[1]: http://bazaar.launchpad.net/~charmers/charms/precise/bip/trunk/revision/19
[2]: http://bazaar.launchpad.net/~charmers/charms/precise/bip/trunk/revision/18

review: Needs Fixing
20. By Brad Marshall

[bradm] Fixed merge conflict from existing tests dir

Revision history for this message
Brad Marshall (brad-marshall) wrote :

I've fixed the merge request to not conflict, please let me know if there's any other issues.

Revision history for this message
José Antonio Rey (jose) wrote :

Hey Brad,

I have just reviewied the addition of these tests. They all pass. Tested with bundletester under EC2. No merge conflicts, everything seems to be in order now.

+1!

Thanks for working on these, greatly appreciated!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'tests'
=== removed directory 'tests'
=== added file 'tests/00-setup'
--- tests/00-setup 1970-01-01 00:00:00 +0000
+++ tests/00-setup 2014-12-12 03:10:58 +0000
@@ -0,0 +1,5 @@
1#!/bin/bash
2
3sudo add-apt-repository ppa:juju/stable -y
4sudo apt-get update
5sudo apt-get install amulet -y
06
=== removed file 'tests/00-setup'
--- tests/00-setup 2014-11-06 16:22:56 +0000
+++ tests/00-setup 1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
1#!/bin/bash
2
3sudo add-apt-repository ppa:juju/stable -y
4sudo apt-get update
5sudo apt-get install amulet python3-requests -y
60
=== added file 'tests/10-deploy'
--- tests/10-deploy 1970-01-01 00:00:00 +0000
+++ tests/10-deploy 2014-12-12 03:10:58 +0000
@@ -0,0 +1,52 @@
1#!/usr/bin/env python3
2
3import amulet
4import socket
5import unittest
6
7class TestDeployment(unittest.TestCase):
8 @classmethod
9 def setUpClass(cls):
10 cls.deployment = amulet.Deployment()
11
12 cls.deployment.add('bip')
13 cls.deployment.expose('bip')
14
15 try:
16 cls.deployment.setup(timeout=900, cleanup=False)
17 cls.deployment.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
23 cls.unit = cls.deployment.sentry.unit['bip/0']
24 cls.ipaddr = cls.unit.info['public-address']
25 cls.ports = cls.unit.info['open-ports']
26
27 def test_1_check_running(self):
28 output = self.unit.run('service bip status')
29 service_active = 'bip is running' in str(output)
30 if service_active:
31 print("Found running bip on %s" % self.ipaddr)
32 #amulet.raise_status(amulet.PASS, msg=message)
33 else:
34 message = "Failed to find running bip"
35 amulet.raise_status(amulet.FAIL, msg=message)
36
37 def test_2_check_port_open(self):
38 s = socket.socket()
39 for p in self.ports:
40 (port, proto) = p.split("/")
41 try:
42 s.connect((self.ipaddr, int(port)))
43 message = "Connect to %s on port %s succeeded" % (self.ipaddr, port)
44 #amulet.raise_status(amulet.PASS, msg=message)
45 print(message)
46 except socket.error as e:
47 message = "Connection to %s on port %s failed: %s" % (self.ipaddr, port, e)
48 amulet.raise_status(amulet.FAIL, msg=message)
49
50
51if __name__ == '__main__':
52 unittest.main()
053
=== removed file 'tests/99-autogen'
--- tests/99-autogen 2014-11-06 16:22:56 +0000
+++ tests/99-autogen 1970-01-01 00:00:00 +0000
@@ -1,49 +0,0 @@
1#!/usr/bin/env python3
2
3import amulet
4import requests
5import unittest
6
7
8class TestDeployment(unittest.TestCase):
9 @classmethod
10 def setUpClass(cls):
11 cls.deployment = amulet.Deployment(series='precise')
12
13 cls.deployment.add('bip')
14
15 try:
16 cls.deployment.setup(timeout=900)
17 cls.deployment.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
23 def test_case(self):
24 # Now you can use self.deployment.sentry.unit[UNIT] to address each of
25 # the units and perform more in-depth steps. You can also reference
26 # the first unit as self.unit.
27 # There are three test statuses that can be triggered with
28 # amulet.raise_status():
29 # - amulet.PASS
30 # - amulet.FAIL
31 # - amulet.SKIP
32 # Each unit has the following methods:
33 # - .info - An array of the information of that unit from Juju
34 # - .file(PATH) - Get the details of a file on that unit
35 # - .file_contents(PATH) - Get plain text output of PATH file from that unit
36 # - .directory(PATH) - Get details of directory
37 # - .directory_contents(PATH) - List files and folders in PATH on that unit
38 # - .relation(relation, service:rel) - Get relation data from return service
39 # add tests here to confirm service is up and working properly
40 # For example, to confirm that it has a functioning HTTP server:
41 # page = requests.get('http://{}'.format(self.unit.info['public-address']))
42 # page.raise_for_status()
43 # More information on writing Amulet tests can be found at:
44 # https://juju.ubuntu.com/docs/tools-amulet.html
45 pass
46
47
48if __name__ == '__main__':
49 unittest.main()

Subscribers

People subscribed via source and target branches

to all changes: