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

Proposed by Leo Arias
Status: Merged
Approved by: Federico Gimenez
Approved revision: 716
Merged at revision: 719
Proposed branch: lp:~elopio/snappy/skip_fan
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 141 lines (+109/-1)
4 files modified
_integration-tests/tests/ubuntuFan_test.go (+4/-0)
_integration-tests/testutils/common/common.go (+1/-1)
_integration-tests/testutils/common/info.go (+46/-0)
_integration-tests/testutils/common/info_test.go (+58/-0)
To merge this branch: bzr merge lp:~elopio/snappy/skip_fan
Reviewer Review Type Date Requested Status
Federico Gimenez (community) Approve
Review via email: mp+272312@code.launchpad.net

Commit message

Skip the ubuntu fan tests in 15.04.

Description of the change

I didn't use the release value from Cfg because when we pass an ip to the test, that value is not accurate.

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

Fmt.

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

Nicely done, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '_integration-tests/tests/ubuntuFan_test.go'
2--- _integration-tests/tests/ubuntuFan_test.go 2015-09-10 10:15:43 +0000
3+++ _integration-tests/tests/ubuntuFan_test.go 2015-09-24 21:06:13 +0000
4@@ -45,6 +45,10 @@
5 }
6
7 func (s *fanTestSuite) SetUpTest(c *check.C) {
8+ if common.Release(c) == "15.04" {
9+ c.Skip("Ubuntu Fan not available in 15.04")
10+ }
11+
12 s.SnappySuite.SetUpTest(c)
13 var err error
14 s.subjectIP, err = getIPAddr(c)
15
16=== modified file '_integration-tests/testutils/common/common.go'
17--- _integration-tests/testutils/common/common.go 2015-09-03 10:46:21 +0000
18+++ _integration-tests/testutils/common/common.go 2015-09-24 21:06:13 +0000
19@@ -29,7 +29,7 @@
20 "strconv"
21 "strings"
22
23- check "gopkg.in/check.v1"
24+ "gopkg.in/check.v1"
25
26 "launchpad.net/snappy/_integration-tests/testutils/config"
27 )
28
29=== added file '_integration-tests/testutils/common/info.go'
30--- _integration-tests/testutils/common/info.go 1970-01-01 00:00:00 +0000
31+++ _integration-tests/testutils/common/info.go 2015-09-24 21:06:13 +0000
32@@ -0,0 +1,46 @@
33+// -*- Mode: Go; indent-tabs-mode: t -*-
34+
35+/*
36+ * Copyright (C) 2015 Canonical Ltd
37+ *
38+ * This program is free software: you can redistribute it and/or modify
39+ * it under the terms of the GNU General Public License version 3 as
40+ * published by the Free Software Foundation.
41+ *
42+ * This program is distributed in the hope that it will be useful,
43+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
44+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45+ * GNU General Public License for more details.
46+ *
47+ * You should have received a copy of the GNU General Public License
48+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
49+ *
50+ */
51+
52+package common
53+
54+import (
55+ "bufio"
56+ "strings"
57+
58+ "gopkg.in/check.v1"
59+)
60+
61+// dependency aliasing
62+var execCommand = ExecCommand
63+
64+// Release returns the release of the current snappy image
65+func Release(c *check.C) string {
66+ info := execCommand(c, "snappy", "info")
67+ reader := strings.NewReader(info)
68+ scanner := bufio.NewScanner(reader)
69+ for scanner.Scan() {
70+ if strings.HasPrefix(scanner.Text(), "release: ") {
71+ releaseInfo := strings.TrimPrefix(scanner.Text(), "release: ")
72+ return strings.Split(releaseInfo, "/")[1]
73+ }
74+ }
75+ c.Error("Release information not found")
76+ c.FailNow()
77+ return ""
78+}
79
80=== added file '_integration-tests/testutils/common/info_test.go'
81--- _integration-tests/testutils/common/info_test.go 1970-01-01 00:00:00 +0000
82+++ _integration-tests/testutils/common/info_test.go 2015-09-24 21:06:13 +0000
83@@ -0,0 +1,58 @@
84+// -*- Mode: Go; indent-tabs-mode: t -*-
85+
86+/*
87+ * Copyright (C) 2014-2015 Canonical Ltd
88+ *
89+ * This program is free software: you can redistribute it and/or modify
90+ * it under the terms of the GNU General Public License version 3 as
91+ * published by the Free Software Foundation.
92+ *
93+ * This program is distributed in the hope that it will be useful,
94+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
95+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96+ * GNU General Public License for more details.
97+ *
98+ * You should have received a copy of the GNU General Public License
99+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
100+ *
101+ */
102+
103+package common
104+
105+import "gopkg.in/check.v1"
106+
107+type infoTestSuite struct {
108+ execReturnValue string
109+ backExecCommand func(*check.C, ...string) string
110+}
111+
112+var _ = check.Suite(&infoTestSuite{})
113+
114+func (s *infoTestSuite) SetUpSuite(c *check.C) {
115+ s.backExecCommand = execCommand
116+ execCommand = s.fakeExecCommand
117+}
118+
119+func (s *infoTestSuite) TearDownSuite(c *check.C) {
120+ execCommand = s.backExecCommand
121+}
122+
123+func (s *infoTestSuite) fakeExecCommand(c *check.C, args ...string) (output string) {
124+ return s.execReturnValue
125+}
126+
127+var releaseTests = []struct {
128+ infoOutput string
129+ expectedRelease string
130+}{
131+ {"someInfo1: someValue1\nrelease: ubuntu-core/15.04/edge\nsomeInfo2: someValue2", "15.04"},
132+ {"someInfo1: someValue1\nrelease: ubuntu-core/rolling/alpha\nsomeInfo2: someValue2", "rolling"},
133+}
134+
135+func (s *infoTestSuite) TestRelease(c *check.C) {
136+ for _, t := range releaseTests {
137+ s.execReturnValue = t.infoOutput
138+ release := Release(c)
139+ c.Assert(release, check.Equals, t.expectedRelease, check.Commentf("Wrong release"))
140+ }
141+}

Subscribers

People subscribed via source and target branches