Merge lp:~fgimenez/snappy/build-test into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Federico Gimenez on 2015-06-30
Status: Merged
Approved by: Leo Arias on 2015-07-06
Approved revision: 564
Merged at revision: 560
Proposed branch: lp:~fgimenez/snappy/build-test
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Prerequisite: lp:~elopio/snappy/upgrade-test
Diff against target: 269 lines (+153/-13)
9 files modified
_integration-tests/data/snaps/basic/meta/package.yaml (+4/-0)
_integration-tests/data/snaps/basic/meta/readme.md (+3/-0)
_integration-tests/data/snaps/missing-readme/meta/package.yaml (+4/-0)
_integration-tests/data/snaps/wrong-yaml/meta/package.yaml (+5/-0)
_integration-tests/data/snaps/wrong-yaml/meta/readme.md (+3/-0)
_integration-tests/tests/common/common.go (+10/-0)
_integration-tests/tests/latest/base_test.go (+29/-0)
_integration-tests/tests/latest/build_test.go (+90/-0)
_integration-tests/tests/latest/install_test.go (+5/-13)
To merge this branch: bzr merge lp:~fgimenez/snappy/build-test
Reviewer Review Type Date Requested Status
Leo Arias 2015-06-30 Approve on 2015-07-06
Review via email: mp+263327@code.launchpad.net

Commit Message

Snap build test

Description of the Change

Includes a basic buildable snap test and two erroneous snaps to check the build errors

To post a comment you must log in.
Leo Arias (elopio) :
Federico Gimenez (fgimenez) wrote :

@Leo comments addressed, thx! Good idea the data directory, we can put the control template in a subdir there too

Cheers!

lp:~fgimenez/snappy/build-test updated on 2015-07-02
558. By Federico Gimenez on 2015-07-02

updated readme for wrong-yaml

Leo Arias (elopio) wrote :

I like this very much Federico! thanks!
I left some small comments.

lp:~fgimenez/snappy/build-test updated on 2015-07-03
559. By Federico Gimenez on 2015-07-03

renamed wrong-readme to missing-readme; added comment in yaml file for wrong-yaml; using defer to remove installed snap

Federico Gimenez (fgimenez) wrote :

Thanks a lot Leo, the issues should be fixed now

Cheers!

lp:~fgimenez/snappy/build-test updated on 2015-07-03
560. By Federico Gimenez on 2015-07-03

basic snap name parameterized

561. By Federico Gimenez on 2015-07-03

rename wrong readme test

562. By Federico Gimenez on 2015-07-03

merged trunk

Leo Arias (elopio) wrote :

+11!

changing to needs info, because I think you added this file by mistake:
=== added file '_integration-tests/data/snaps/basic/basic_1.0_all.snap'

Or maybe you have a reason I failed to notice.

review: Needs Information
lp:~fgimenez/snappy/build-test updated on 2015-07-04
563. By Federico Gimenez on 2015-07-04

removedd snap file

Federico Gimenez (fgimenez) wrote :

No, totally by mistake, sorry :)

I'll try to setup a specific rule for the files that should be ignored in my bazaar home configuration, thanks!

lp:~fgimenez/snappy/build-test updated on 2015-07-04
564. By Federico Gimenez on 2015-07-04

removing generated snap file after the test

Federico Gimenez (fgimenez) wrote :

A little better now, the generated snap file is removed after the test.

Cheers!

Leo Arias (elopio) wrote :

I'm testing this with image #92 because I still can't udf the latest one. I'm getting this error:

basic_1.0_all.snap failed to install: Signature verification failed: No signatures, or no origin signature. (exit code 10)

With --allow-unauthenticated, it passes:

http://paste.ubuntu.com/11824532/

review: Needs Fixing
Federico Gimenez (fgimenez) wrote :

mmm I have it passing with the current code [1], what command did you use to generate the #92 image? Did you include --developer-mode?

Which brings another question, why aren't you able to use udf? These are my installed versions [2]

Thanks!

[1] http://paste.ubuntu.com/11824606/
[2] http://paste.ubuntu.com/11824619/

Leo Arias (elopio) wrote :

mmm, weird.

I installed udf from the proposed ppa, and I could flash the latest and it worked there indeed. So, approving.

I don't understand why it failed on 92, but lets keep running it and if we see a signature failure we dig deeper on it.

To answer your questinos, I generated #92 just by hardcoding "92" on the calls to createImage. So it has --developer-mode, because I didn't change that part of the ExecuteCommand.

I'm not able to use udf from the tools ppa because it has the guid bug. Fixed on the proposed ppa, so that's good now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory '_integration-tests/data'
2=== added directory '_integration-tests/data/snaps'
3=== added directory '_integration-tests/data/snaps/basic'
4=== added directory '_integration-tests/data/snaps/basic/meta'
5=== added file '_integration-tests/data/snaps/basic/meta/package.yaml'
6--- _integration-tests/data/snaps/basic/meta/package.yaml 1970-01-01 00:00:00 +0000
7+++ _integration-tests/data/snaps/basic/meta/package.yaml 2015-07-04 05:49:23 +0000
8@@ -0,0 +1,4 @@
9+name: basic
10+version: 1.0
11+vendor: Snappy Developers <snappy-devel@lists.ubuntu.com>
12+icon: meta/snappy64.png
13
14=== added file '_integration-tests/data/snaps/basic/meta/readme.md'
15--- _integration-tests/data/snaps/basic/meta/readme.md 1970-01-01 00:00:00 +0000
16+++ _integration-tests/data/snaps/basic/meta/readme.md 2015-07-04 05:49:23 +0000
17@@ -0,0 +1,3 @@
18+Basic snap
19+
20+A basic buildable snap
21
22=== added file '_integration-tests/data/snaps/basic/meta/snappy64.png'
23Binary files _integration-tests/data/snaps/basic/meta/snappy64.png 1970-01-01 00:00:00 +0000 and _integration-tests/data/snaps/basic/meta/snappy64.png 2015-07-04 05:49:23 +0000 differ
24=== added directory '_integration-tests/data/snaps/missing-readme'
25=== added directory '_integration-tests/data/snaps/missing-readme/meta'
26=== added file '_integration-tests/data/snaps/missing-readme/meta/package.yaml'
27--- _integration-tests/data/snaps/missing-readme/meta/package.yaml 1970-01-01 00:00:00 +0000
28+++ _integration-tests/data/snaps/missing-readme/meta/package.yaml 2015-07-04 05:49:23 +0000
29@@ -0,0 +1,4 @@
30+name: missing-readme
31+version: 1.0
32+vendor: Snappy Developers <snappy-devel@lists.ubuntu.com>
33+icon: meta/snappy64.png
34
35=== added file '_integration-tests/data/snaps/missing-readme/meta/snappy64.png'
36Binary files _integration-tests/data/snaps/missing-readme/meta/snappy64.png 1970-01-01 00:00:00 +0000 and _integration-tests/data/snaps/missing-readme/meta/snappy64.png 2015-07-04 05:49:23 +0000 differ
37=== added directory '_integration-tests/data/snaps/wrong-yaml'
38=== added directory '_integration-tests/data/snaps/wrong-yaml/meta'
39=== added file '_integration-tests/data/snaps/wrong-yaml/meta/package.yaml'
40--- _integration-tests/data/snaps/wrong-yaml/meta/package.yaml 1970-01-01 00:00:00 +0000
41+++ _integration-tests/data/snaps/wrong-yaml/meta/package.yaml 2015-07-04 05:49:23 +0000
42@@ -0,0 +1,5 @@
43+# This is an invalid yaml, there's a missing colon after the 'name' field
44+name wrong-yaml
45+version: 1.0
46+vendor: Snappy Developers <snappy-devel@lists.ubuntu.com>
47+icon: meta/snappy64.png
48
49=== added file '_integration-tests/data/snaps/wrong-yaml/meta/readme.md'
50--- _integration-tests/data/snaps/wrong-yaml/meta/readme.md 1970-01-01 00:00:00 +0000
51+++ _integration-tests/data/snaps/wrong-yaml/meta/readme.md 2015-07-04 05:49:23 +0000
52@@ -0,0 +1,3 @@
53+Wrong metadata snap
54+
55+A snap with an invalid meta/package.yaml
56
57=== added file '_integration-tests/data/snaps/wrong-yaml/meta/snappy64.png'
58Binary files _integration-tests/data/snaps/wrong-yaml/meta/snappy64.png 1970-01-01 00:00:00 +0000 and _integration-tests/data/snaps/wrong-yaml/meta/snappy64.png 2015-07-04 05:49:23 +0000 differ
59=== modified file '_integration-tests/tests/common/common.go'
60--- _integration-tests/tests/common/common.go 2015-07-01 15:02:58 +0000
61+++ _integration-tests/tests/common/common.go 2015-07-04 05:49:23 +0000
62@@ -186,3 +186,13 @@
63 func getVersionFile() string {
64 return filepath.Join(os.Getenv("ADT_ARTIFACTS"), "version")
65 }
66+
67+// InstallSnap executes the required command to install the specified snap
68+func InstallSnap(c *check.C, packageName string) string {
69+ return ExecCommand(c, "sudo", "snappy", "install", packageName)
70+}
71+
72+// RemoveSnap executes the required command to remove the specified snap
73+func RemoveSnap(c *check.C, packageName string) string {
74+ return ExecCommand(c, "sudo", "snappy", "remove", packageName)
75+}
76
77=== added file '_integration-tests/tests/latest/base_test.go'
78--- _integration-tests/tests/latest/base_test.go 1970-01-01 00:00:00 +0000
79+++ _integration-tests/tests/latest/base_test.go 2015-07-04 05:49:23 +0000
80@@ -0,0 +1,29 @@
81+// -*- Mode: Go; indent-tabs-mode: t -*-
82+
83+/*
84+ * Copyright (C) 2015 Canonical Ltd
85+ *
86+ * This program is free software: you can redistribute it and/or modify
87+ * it under the terms of the GNU General Public License version 3 as
88+ * published by the Free Software Foundation.
89+ *
90+ * This program is distributed in the hope that it will be useful,
91+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
92+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
93+ * GNU General Public License for more details.
94+ *
95+ * You should have received a copy of the GNU General Public License
96+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
97+ *
98+ */
99+
100+package latest
101+
102+import (
103+ "testing"
104+
105+ . "gopkg.in/check.v1"
106+)
107+
108+// Hook up gocheck into the "go test" runner.
109+func Test(t *testing.T) { TestingT(t) }
110
111=== added file '_integration-tests/tests/latest/build_test.go'
112--- _integration-tests/tests/latest/build_test.go 1970-01-01 00:00:00 +0000
113+++ _integration-tests/tests/latest/build_test.go 2015-07-04 05:49:23 +0000
114@@ -0,0 +1,90 @@
115+// -*- Mode: Go; indent-tabs-mode: t -*-
116+
117+/*
118+ * Copyright (C) 2015 Canonical Ltd
119+ *
120+ * This program is free software: you can redistribute it and/or modify
121+ * it under the terms of the GNU General Public License version 3 as
122+ * published by the Free Software Foundation.
123+ *
124+ * This program is distributed in the hope that it will be useful,
125+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
126+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
127+ * GNU General Public License for more details.
128+ *
129+ * You should have received a copy of the GNU General Public License
130+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
131+ *
132+ */
133+
134+package latest
135+
136+import (
137+ "fmt"
138+ "os"
139+ "os/exec"
140+
141+ . "../common"
142+
143+ . "gopkg.in/check.v1"
144+)
145+
146+const (
147+ baseSnapPath = "_integration-tests/data/snaps"
148+ basicSnapName = "basic"
149+ wrongYamlSnapName = "wrong-yaml"
150+ missingReadmeSnapName = "missing-readme"
151+)
152+
153+var _ = Suite(&buildSuite{})
154+
155+type buildSuite struct {
156+ SnappySuite
157+}
158+
159+func buildSnap(c *C, snapPath string) string {
160+ return ExecCommand(c, "snappy", "build", snapPath)
161+}
162+
163+func (s *buildSuite) TestBuildBasicSnapOnSnappy(c *C) {
164+ // build basic snap and check output
165+ snapPath := baseSnapPath + "/" + basicSnapName
166+ buildOutput := buildSnap(c, snapPath)
167+ snapName := basicSnapName + "_1.0_all.snap"
168+ expected := fmt.Sprintf("Generated '%s' snap\n", snapName)
169+ c.Check(buildOutput, Equals, expected)
170+ defer os.Remove(snapPath + "/" + snapName)
171+
172+ // install built snap and check output
173+ installOutput := InstallSnap(c, snapName)
174+ defer RemoveSnap(c, basicSnapName)
175+ expected = "" +
176+ "Installing " + snapName + "\n" +
177+ ".*Signature check failed, but installing anyway as requested\n" +
178+ "Name Date Version Developer \n" +
179+ ".*\n" +
180+ basicSnapName + " .* .* sideload \n" +
181+ ".*\n"
182+
183+ c.Check(installOutput, Matches, expected)
184+
185+ // teardown, remove snap file
186+ c.Assert(os.Remove(snapName), IsNil, Commentf("Error removing %s", snapName))
187+}
188+
189+func (s *buildSuite) TestBuildWrongYamlSnapOnSnappy(c *C) {
190+ commonWrongTest(c, wrongYamlSnapName, "can not parse package.yaml:.*\n")
191+}
192+
193+func (s *buildSuite) TestBuildMissingReadmeSnapOnSnappy(c *C) {
194+ commonWrongTest(c, missingReadmeSnapName, ".*readme.md: no such file or directory\n")
195+}
196+
197+func commonWrongTest(c *C, testName, expected string) {
198+ // build wrong snap and check output
199+ cmd := exec.Command("snappy", "build", fmt.Sprintf("%s/%s", baseSnapPath, testName))
200+ echoOutput, err := cmd.CombinedOutput()
201+ c.Assert(err, NotNil, Commentf("%s should not be built", testName))
202+
203+ c.Assert(string(echoOutput), Matches, expected)
204+}
205
206=== modified file '_integration-tests/tests/latest/install_test.go'
207--- _integration-tests/tests/latest/install_test.go 2015-07-01 15:02:58 +0000
208+++ _integration-tests/tests/latest/install_test.go 2015-07-04 05:49:23 +0000
209@@ -21,32 +21,24 @@
210
211 import (
212 "os/exec"
213- "testing"
214
215 . "../common"
216
217 . "gopkg.in/check.v1"
218 )
219
220-// Hook up gocheck into the "go test" runner.
221-func Test(t *testing.T) { TestingT(t) }
222-
223 var _ = Suite(&installSuite{})
224
225 type installSuite struct {
226 SnappySuite
227 }
228
229-func installSnap(c *C, packageName string) string {
230- return ExecCommand(c, "sudo", "snappy", "install", packageName)
231-}
232-
233 func (s *installSuite) TearDownTest(c *C) {
234- ExecCommand(c, "sudo", "snappy", "remove", "hello-world")
235+ RemoveSnap(c, "hello-world")
236 }
237
238 func (s *installSuite) TestInstallSnapMustPrintPackageInformation(c *C) {
239- installOutput := installSnap(c, "hello-world")
240+ installOutput := InstallSnap(c, "hello-world")
241
242 expected := "" +
243 "Installing hello-world\n" +
244@@ -59,7 +51,7 @@
245 }
246
247 func (s *installSuite) TestCallBinaryFromInstalledSnap(c *C) {
248- installSnap(c, "hello-world")
249+ InstallSnap(c, "hello-world")
250
251 echoOutput := ExecCommand(c, "hello-world.echo")
252
253@@ -67,7 +59,7 @@
254 }
255
256 func (s *installSuite) TestCallBinaryWithPermissionDeniedMustPrintError(c *C) {
257- installSnap(c, "hello-world")
258+ InstallSnap(c, "hello-world")
259
260 cmd := exec.Command("hello-world.evil")
261 echoOutput, err := cmd.CombinedOutput()
262@@ -85,7 +77,7 @@
263 }
264
265 func (s *installSuite) TestInfoMustPrintInstalledPackageInformation(c *C) {
266- installSnap(c, "hello-world")
267+ InstallSnap(c, "hello-world")
268
269 infoOutput := ExecCommand(c, "snappy", "info")
270

Subscribers

People subscribed via source and target branches