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
=== added directory '_integration-tests/data/snaps/basic-service'
=== added directory '_integration-tests/data/snaps/basic-service/bin'
=== added file '_integration-tests/data/snaps/basic-service/bin/start'
--- _integration-tests/data/snaps/basic-service/bin/start 1970-01-01 00:00:00 +0000
+++ _integration-tests/data/snaps/basic-service/bin/start 2015-10-14 23:04:41 +0000
@@ -0,0 +1,3 @@
1#!/bin/sh
2
3while :; do echo 'Service running'; sleep 10; done
04
=== added directory '_integration-tests/data/snaps/basic-service/meta'
=== added file '_integration-tests/data/snaps/basic-service/meta/package.yaml'
--- _integration-tests/data/snaps/basic-service/meta/package.yaml 1970-01-01 00:00:00 +0000
+++ _integration-tests/data/snaps/basic-service/meta/package.yaml 2015-10-14 23:04:41 +0000
@@ -0,0 +1,8 @@
1name: basic-service
2version: 1.0
3vendor: Snappy Developers <snappy-devel@lists.ubuntu.com>
4icon: meta/snappy64.png
5services:
6 - name: service
7 start: ./bin/start
8 description: Test service
09
=== added file '_integration-tests/data/snaps/basic-service/meta/readme.md'
--- _integration-tests/data/snaps/basic-service/meta/readme.md 1970-01-01 00:00:00 +0000
+++ _integration-tests/data/snaps/basic-service/meta/readme.md 2015-10-14 23:04:41 +0000
@@ -0,0 +1,3 @@
1Basic-service snap
2
3A basic buildable snap with a service.
04
=== added file '_integration-tests/data/snaps/basic-service/meta/snappy64.png'
1Binary 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 differ5Binary 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
=== modified file '_integration-tests/tests/service_test.go'
--- _integration-tests/tests/service_test.go 2015-10-08 05:57:00 +0000
+++ _integration-tests/tests/service_test.go 2015-10-14 23:04:41 +0000
@@ -21,10 +21,13 @@
2121
22import (22import (
23 "fmt"23 "fmt"
24 "os"
24 "regexp"25 "regexp"
2526
27 "launchpad.net/snappy/_integration-tests/testutils/build"
26 "launchpad.net/snappy/_integration-tests/testutils/cli"28 "launchpad.net/snappy/_integration-tests/testutils/cli"
27 "launchpad.net/snappy/_integration-tests/testutils/common"29 "launchpad.net/snappy/_integration-tests/testutils/common"
30 "launchpad.net/snappy/_integration-tests/testutils/data"
28 "launchpad.net/snappy/_integration-tests/testutils/wait"31 "launchpad.net/snappy/_integration-tests/testutils/wait"
2932
30 "gopkg.in/check.v1"33 "gopkg.in/check.v1"
@@ -38,25 +41,23 @@
3841
39func (s *serviceSuite) TearDownTest(c *check.C) {42func (s *serviceSuite) TearDownTest(c *check.C) {
40 if !common.NeedsReboot() && common.CheckRebootMark("") {43 if !common.NeedsReboot() && common.CheckRebootMark("") {
41 common.RemoveSnap(c, "hello-dbus-fwk.canonical")44 common.RemoveSnap(c, data.BasicServiceSnapName)
42 }45 }
43 // run cleanup last46 // run cleanup last
44 s.SnappySuite.TearDownTest(c)47 s.SnappySuite.TearDownTest(c)
45}48}
4649
47func isServiceRunning(c *check.C) bool {50func isServiceRunning(c *check.C) bool {
48 packageVersion := common.GetCurrentVersion(c, "hello-dbus-fwk")51 packageVersion := common.GetCurrentVersion(c, data.BasicServiceSnapName)
49 service := fmt.Sprintf("hello-dbus-fwk_srv_%s.service", packageVersion)52 service := fmt.Sprintf("%s_service_%s.service", data.BasicServiceSnapName, packageVersion)
5053
51 err := wait.ForActiveService(c, service)54 err := wait.ForActiveService(c, service)
52 c.Assert(err, check.IsNil)55 c.Assert(err, check.IsNil)
5356
54 statusOutput := cli.ExecCommand(57 statusOutput := cli.ExecCommand(c, "systemctl", "status", service)
55 c, "systemctl", "status",
56 service)
5758
58 expected := "(?ms)" +59 expected := "(?ms)" +
59 ".* hello-dbus-fwk_srv_.*\\.service .*\n" +60 fmt.Sprintf(".* %s_service_.*\\.service .*\n", data.BasicServiceSnapName) +
60 ".*Loaded: loaded .*\n" +61 ".*Loaded: loaded .*\n" +
61 ".*Active: active \\(running\\) .*\n" +62 ".*Active: active \\(running\\) .*\n" +
62 ".*"63 ".*"
@@ -66,15 +67,21 @@
66 return matched67 return matched
67}68}
6869
70func installSnapWithService(c *check.C) {
71 snapPath, err := build.LocalSnap(c, data.BasicServiceSnapName)
72 defer os.Remove(snapPath)
73 c.Assert(err, check.IsNil)
74 common.InstallSnap(c, snapPath)
75}
76
69func (s *serviceSuite) TestInstalledServiceMustBeStarted(c *check.C) {77func (s *serviceSuite) TestInstalledServiceMustBeStarted(c *check.C) {
70 common.InstallSnap(c, "hello-dbus-fwk.canonical")78 installSnapWithService(c)
71
72 c.Assert(isServiceRunning(c), check.Equals, true)79 c.Assert(isServiceRunning(c), check.Equals, true)
73}80}
7481
75func (s *serviceSuite) TestServiceMustBeStartedAfterReboot(c *check.C) {82func (s *serviceSuite) TestServiceMustBeStartedAfterReboot(c *check.C) {
76 if common.BeforeReboot() {83 if common.BeforeReboot() {
77 common.InstallSnap(c, "hello-dbus-fwk.canonical")84 installSnapWithService(c)
78 common.Reboot(c)85 common.Reboot(c)
79 } else if common.AfterReboot(c) {86 } else if common.AfterReboot(c) {
80 common.RemoveRebootMark(c)87 common.RemoveRebootMark(c)
@@ -84,7 +91,7 @@
8491
85func (s *serviceSuite) TestServiceMustBeStartedAfterUpdate(c *check.C) {92func (s *serviceSuite) TestServiceMustBeStartedAfterUpdate(c *check.C) {
86 if common.BeforeReboot() {93 if common.BeforeReboot() {
87 common.InstallSnap(c, "hello-dbus-fwk.canonical")94 installSnapWithService(c)
88 common.CallFakeUpdate(c)95 common.CallFakeUpdate(c)
89 common.Reboot(c)96 common.Reboot(c)
90 } else if common.AfterReboot(c) {97 } else if common.AfterReboot(c) {
9198
=== modified file '_integration-tests/testutils/data/data.go'
--- _integration-tests/testutils/data/data.go 2015-10-13 17:34:10 +0000
+++ _integration-tests/testutils/data/data.go 2015-10-14 23:04:41 +0000
@@ -28,6 +28,8 @@
28 BasicBinariesSnapName = "basic-binaries"28 BasicBinariesSnapName = "basic-binaries"
29 // BasicFrameworkSnapName is the name of the basic framework snap29 // BasicFrameworkSnapName is the name of the basic framework snap
30 BasicFrameworkSnapName = "basic-framework"30 BasicFrameworkSnapName = "basic-framework"
31 // BasicServiceSnapName is the name of the basic snap with a service
32 BasicServiceSnapName = "basic-service"
31 // WrongYamlSnapName is the name of a snap with an invalid meta yaml33 // WrongYamlSnapName is the name of a snap with an invalid meta yaml
32 WrongYamlSnapName = "wrong-yaml"34 WrongYamlSnapName = "wrong-yaml"
33 // MissingReadmeSnapName is the name of a snap without readme35 // MissingReadmeSnapName is the name of a snap without readme

Subscribers

People subscribed via source and target branches