Merge lp:~jose/charms/precise/nyancat/port-changing+amulet-tests into lp:charms/nyancat

Proposed by José Antonio Rey
Status: Rejected
Rejected by: Matt Bruzek
Proposed branch: lp:~jose/charms/precise/nyancat/port-changing+amulet-tests
Merge into: lp:charms/nyancat
Diff against target: 97 lines (+50/-6)
3 files modified
hooks/nyancat-relations (+17/-6)
tests/00-setup (+5/-0)
tests/100-deploy (+28/-0)
To merge this branch: bzr merge lp:~jose/charms/precise/nyancat/port-changing+amulet-tests
Reviewer Review Type Date Requested Status
Matt Bruzek (community) Needs Fixing
Ryan Finnie (community) Needs Fixing
Tim Van Steenburgh (community) Needs Information
Review via email: mp+216352@code.launchpad.net

Description of the change

* Added support for port changing
* Added amulet test (test passes with charm test)
* Changed package source: it now clones from git instead of using a package in the charm

To post a comment you must log in.
Revision history for this message
Tim Van Steenburgh (tvansteenburgh) wrote :

Hey José,

Thanks for this! The git clone and config-changed updates look great, but I don't see any amulet tests...perhaps you forgot to `bzr add` them?

Tim

Revision history for this message
Tim Van Steenburgh (tvansteenburgh) :
review: Needs Information
Revision history for this message
José Antonio Rey (jose) wrote :

Sorry, forgot to add them. Did and everything's working fine now. Thanks for reminding me! :)

Revision history for this message
Ryan Finnie (fo0bar) wrote :

Please do not switch the default source to pulling from github HEAD, as it's 1) a remote dependency which can be a problem for private clouds, and 2) pulling from HEAD is unpredictable what you actually get.

I'd recommend leaving the default method as local tarball copy (maybe updating the tarball to current 1.4.4 at the same time), and adding a config option to instead pull from a git repo (default https://github.com/klange/nyancat.git), optionally with a specific tag.

review: Needs Fixing
Revision history for this message
Matt Bruzek (mbruzek) wrote :

José,

Thanks for your work here I am very happy to see amulet tests! It seems that the change to pull from head is controversial. I would suggest breaking out the amulet tests in a separate merge proposal.

# charm proof

I ran charm proof and there is some warnings that are unrelated to this merge proposal. If you could make an icon for nyancat that would be great.

$ charm proof
W: No icon.svg file.
I: all charms should provide at least one thing

# review

The issue with pulling from head has some merit and I would suggest keeping the old binary in there, and making the source a configuration option.

00-setup:
The file needs some non-interactive flags on the commands. The 00-setup command hangs waiting for input, but I see no ouput.
sudo add-apt-repository -y ppa:juju/stable
sudo apt-get update -qq
sudo apt-get install -y amulet

100-deploy:
This test did not pass.

review: Needs Fixing

Unmerged revisions

8. By José Antonio Rey

Added forgotten config-changed symlink

7. By José Antonio Rey

Forgot to bzr add tests, added now

6. By José Antonio Rey

Changed charm for it to grab source from git

5. By José Antonio Rey

Added support for port changing and amulet tests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed directory 'dist'
2=== removed file 'dist/nyancat-1.2.tar.gz'
3Binary files dist/nyancat-1.2.tar.gz 2013-05-27 14:07:12 +0000 and dist/nyancat-1.2.tar.gz 1970-01-01 00:00:00 +0000 differ
4=== added symlink 'hooks/config-changed'
5=== target is u'nyancat-relations'
6=== modified file 'hooks/nyancat-relations'
7--- hooks/nyancat-relations 2013-05-27 14:04:04 +0000
8+++ hooks/nyancat-relations 2014-05-01 19:00:07 +0000
9@@ -14,12 +14,11 @@
10
11 function install_hook() {
12 juju-log "nyancat: Installing packages"
13- apt-get -y --force-yes install build-essential openbsd-inetd update-inetd tcpd
14+ apt-get -y --force-yes install build-essential openbsd-inetd update-inetd tcpd git
15
16 BUILD_DIR="$(mktemp -d)"
17- TARBALL="dist/nyancat-1.2.tar.gz"
18- juju-log "nyancat: Extracting $TARBALL to $BUILD_DIR"
19- tar -zx --strip-components=1 -C "$BUILD_DIR" -f "$TARBALL"
20+ juju-log "nyancat: Cloning source from git"
21+ git clone https://github.com/klange/nyancat.git $BUILD_DIR
22
23 juju-log "nyancat: Building nyancat"
24 make -C "$BUILD_DIR"
25@@ -37,14 +36,26 @@
26 function start_hook() {
27 juju-log "nyancat: Restarting inetd"
28 service openbsd-inetd restart
29+}
30
31- juju-log "nyancat: Opening port $OPEN_PORT"
32- open-port "$OPEN_PORT"
33+function config_hook() {
34+ if [ ! -f .port ]; then
35+ juju-log "nyancat: Opening port $OPEN_PORT"
36+ open-port "$OPEN_PORT"
37+ echo "$OPEN_PORT" > .port
38+ elif [ -f .port ] && [ `cat .port` != "$OPEN_PORT" ]; then
39+ PORT=`cat .port`
40+ juju-log "Changing port to $OPEN_PORT"
41+ close-port "$PORT"
42+ open-port "$OPEN_PORT"
43+ echo "$OPEN_PORT" > .port
44+ fi
45 }
46
47 juju-log "nyancat: Firing hook $ARG0"
48 case $ARG0 in
49 "install") install_hook ;;
50 "start") start_hook ;;
51+ "config-changed") config_hook ;;
52 "stop") exit 0 ;;
53 esac
54
55=== added directory 'tests'
56=== added file 'tests/00-setup'
57--- tests/00-setup 1970-01-01 00:00:00 +0000
58+++ tests/00-setup 2014-05-01 19:00:07 +0000
59@@ -0,0 +1,5 @@
60+#!/bin/bash
61+
62+sudo add-apt-repository ppa:juju/stable
63+sudo apt-get update
64+sudo apt-get install amulet
65
66=== added file 'tests/100-deploy'
67--- tests/100-deploy 1970-01-01 00:00:00 +0000
68+++ tests/100-deploy 2014-05-01 19:00:07 +0000
69@@ -0,0 +1,28 @@
70+#!/usr/bin/python3
71+
72+import amulet
73+import telnetlib
74+
75+d = amulet.Deployment()
76+
77+d.add('nyancat')
78+d.configure('nyancat', {'inetd-service': 'http'})
79+d.configure('nyancat', {'inetd-service': 'telnet'})
80+d.expose ('nyancat')
81+
82+try:
83+ d.setup(timeout=900)
84+ d.sentry.wait()
85+except amulet.helpers.TimeoutError:
86+ amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
87+except:
88+ raise
89+
90+def ping_server():
91+ tn = telnetlib.Telnet("%s" %
92+ d.sentry.unit['nyancat/0'].info['public-address'])
93+ tel = tn.read_until("nyaned".encode(), 30)
94+ if "nyaned".encode() not in tel:
95+ amulet.raise_status(amulet.FAIL, message="Server is not up!")
96+
97+ping_server()

Subscribers

People subscribed via source and target branches

to all changes: