Merge lp:~elopio/snappy/examples4 into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Leo Arias
Status: Merged
Approved by: Leo Arias
Approved revision: 765
Merged at revision: 772
Proposed branch: lp:~elopio/snappy/examples4
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Prerequisite: lp:~elopio/snappy/examples3
Diff against target: 129 lines (+34/-11)
5 files modified
_integration-tests/data/snaps/basic-service/bin/start (+3/-0)
_integration-tests/data/snaps/basic-service/meta/package.yaml (+8/-0)
_integration-tests/data/snaps/basic-service/meta/readme.md (+3/-0)
_integration-tests/tests/service_test.go (+18/-11)
_integration-tests/testutils/data/data.go (+2/-0)
To merge this branch: bzr merge lp:~elopio/snappy/examples4
Reviewer Review Type Date Requested Status
Federico Gimenez (community) Approve
Review via email: mp+274345@code.launchpad.net

Commit message

Updated the service tests to use a local snap.

To post a comment you must log in.
lp:~elopio/snappy/examples4 updated
764. By Leo Arias

Merged with parent.

Revision history for this message
Federico Gimenez (fgimenez) wrote :

LGTM, thanks!

A minor comment inline, feel free to ignore it :)

review: Approve
lp:~elopio/snappy/examples4 updated
765. By Leo Arias

Removed the hardcoded snap name.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory '_integration-tests/data/snaps/basic-service'
2=== added directory '_integration-tests/data/snaps/basic-service/bin'
3=== added file '_integration-tests/data/snaps/basic-service/bin/start'
4--- _integration-tests/data/snaps/basic-service/bin/start 1970-01-01 00:00:00 +0000
5+++ _integration-tests/data/snaps/basic-service/bin/start 2015-10-14 23:04:41 +0000
6@@ -0,0 +1,3 @@
7+#!/bin/sh
8+
9+while :; do echo 'Service running'; sleep 10; done
10
11=== added directory '_integration-tests/data/snaps/basic-service/meta'
12=== added file '_integration-tests/data/snaps/basic-service/meta/package.yaml'
13--- _integration-tests/data/snaps/basic-service/meta/package.yaml 1970-01-01 00:00:00 +0000
14+++ _integration-tests/data/snaps/basic-service/meta/package.yaml 2015-10-14 23:04:41 +0000
15@@ -0,0 +1,8 @@
16+name: basic-service
17+version: 1.0
18+vendor: Snappy Developers <snappy-devel@lists.ubuntu.com>
19+icon: meta/snappy64.png
20+services:
21+ - name: service
22+ start: ./bin/start
23+ description: Test service
24
25=== added file '_integration-tests/data/snaps/basic-service/meta/readme.md'
26--- _integration-tests/data/snaps/basic-service/meta/readme.md 1970-01-01 00:00:00 +0000
27+++ _integration-tests/data/snaps/basic-service/meta/readme.md 2015-10-14 23:04:41 +0000
28@@ -0,0 +1,3 @@
29+Basic-service snap
30+
31+A basic buildable snap with a service.
32
33=== added file '_integration-tests/data/snaps/basic-service/meta/snappy64.png'
34Binary files _integration-tests/data/snaps/basic-service/meta/snappy64.png 1970-01-01 00:00:00 +0000 and _integration-tests/data/snaps/basic-service/meta/snappy64.png 2015-10-14 23:04:41 +0000 differ
35=== modified file '_integration-tests/tests/service_test.go'
36--- _integration-tests/tests/service_test.go 2015-10-08 05:57:00 +0000
37+++ _integration-tests/tests/service_test.go 2015-10-14 23:04:41 +0000
38@@ -21,10 +21,13 @@
39
40 import (
41 "fmt"
42+ "os"
43 "regexp"
44
45+ "launchpad.net/snappy/_integration-tests/testutils/build"
46 "launchpad.net/snappy/_integration-tests/testutils/cli"
47 "launchpad.net/snappy/_integration-tests/testutils/common"
48+ "launchpad.net/snappy/_integration-tests/testutils/data"
49 "launchpad.net/snappy/_integration-tests/testutils/wait"
50
51 "gopkg.in/check.v1"
52@@ -38,25 +41,23 @@
53
54 func (s *serviceSuite) TearDownTest(c *check.C) {
55 if !common.NeedsReboot() && common.CheckRebootMark("") {
56- common.RemoveSnap(c, "hello-dbus-fwk.canonical")
57+ common.RemoveSnap(c, data.BasicServiceSnapName)
58 }
59 // run cleanup last
60 s.SnappySuite.TearDownTest(c)
61 }
62
63 func isServiceRunning(c *check.C) bool {
64- packageVersion := common.GetCurrentVersion(c, "hello-dbus-fwk")
65- service := fmt.Sprintf("hello-dbus-fwk_srv_%s.service", packageVersion)
66+ packageVersion := common.GetCurrentVersion(c, data.BasicServiceSnapName)
67+ service := fmt.Sprintf("%s_service_%s.service", data.BasicServiceSnapName, packageVersion)
68
69 err := wait.ForActiveService(c, service)
70 c.Assert(err, check.IsNil)
71
72- statusOutput := cli.ExecCommand(
73- c, "systemctl", "status",
74- service)
75+ statusOutput := cli.ExecCommand(c, "systemctl", "status", service)
76
77 expected := "(?ms)" +
78- ".* hello-dbus-fwk_srv_.*\\.service .*\n" +
79+ fmt.Sprintf(".* %s_service_.*\\.service .*\n", data.BasicServiceSnapName) +
80 ".*Loaded: loaded .*\n" +
81 ".*Active: active \\(running\\) .*\n" +
82 ".*"
83@@ -66,15 +67,21 @@
84 return matched
85 }
86
87+func installSnapWithService(c *check.C) {
88+ snapPath, err := build.LocalSnap(c, data.BasicServiceSnapName)
89+ defer os.Remove(snapPath)
90+ c.Assert(err, check.IsNil)
91+ common.InstallSnap(c, snapPath)
92+}
93+
94 func (s *serviceSuite) TestInstalledServiceMustBeStarted(c *check.C) {
95- common.InstallSnap(c, "hello-dbus-fwk.canonical")
96-
97+ installSnapWithService(c)
98 c.Assert(isServiceRunning(c), check.Equals, true)
99 }
100
101 func (s *serviceSuite) TestServiceMustBeStartedAfterReboot(c *check.C) {
102 if common.BeforeReboot() {
103- common.InstallSnap(c, "hello-dbus-fwk.canonical")
104+ installSnapWithService(c)
105 common.Reboot(c)
106 } else if common.AfterReboot(c) {
107 common.RemoveRebootMark(c)
108@@ -84,7 +91,7 @@
109
110 func (s *serviceSuite) TestServiceMustBeStartedAfterUpdate(c *check.C) {
111 if common.BeforeReboot() {
112- common.InstallSnap(c, "hello-dbus-fwk.canonical")
113+ installSnapWithService(c)
114 common.CallFakeUpdate(c)
115 common.Reboot(c)
116 } else if common.AfterReboot(c) {
117
118=== modified file '_integration-tests/testutils/data/data.go'
119--- _integration-tests/testutils/data/data.go 2015-10-13 17:34:10 +0000
120+++ _integration-tests/testutils/data/data.go 2015-10-14 23:04:41 +0000
121@@ -28,6 +28,8 @@
122 BasicBinariesSnapName = "basic-binaries"
123 // BasicFrameworkSnapName is the name of the basic framework snap
124 BasicFrameworkSnapName = "basic-framework"
125+ // BasicServiceSnapName is the name of the basic snap with a service
126+ BasicServiceSnapName = "basic-service"
127 // WrongYamlSnapName is the name of a snap with an invalid meta yaml
128 WrongYamlSnapName = "wrong-yaml"
129 // MissingReadmeSnapName is the name of a snap without readme

Subscribers

People subscribed via source and target branches