Merge lp:~fgimenez/snappy/config-for-remote-testbeds into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Federico Gimenez on 2015-07-29
Status: Merged
Approved by: Federico Gimenez on 2015-07-31
Approved revision: 626
Merged at revision: 623
Proposed branch: lp:~fgimenez/snappy/config-for-remote-testbeds
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Prerequisite: lp:~fgimenez/snappy/generalize-build-tests-across-versions
Diff against target: 120 lines (+44/-5)
4 files modified
_integration-tests/main.go (+4/-2)
_integration-tests/tests/info_test.go (+8/-0)
_integration-tests/testutils/config/config.go (+3/-2)
_integration-tests/testutils/config/config_test.go (+29/-1)
To merge this branch: bzr merge lp:~fgimenez/snappy/config-for-remote-testbeds
Reviewer Review Type Date Requested Status
Leo Arias 2015-07-29 Approve on 2015-07-31
Review via email: mp+266214@code.launchpad.net

Commit Message

Do not run tests that make assertions about release and channel in config when connecting to remote testbed

Description of the Change

Do not run tests that make assertions about release and channel in config when connecting to remote testbed

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

One comment for discussion.

review: Needs Information
621. By Federico Gimenez on 2015-07-30

Skipping info test when executing in remote testbed

Federico Gimenez (fgimenez) wrote :

I agree, the problem here are the default values of release and channel, if not specified they are not empty strings.

I've opted for your second suggestion, skipping the test when executing in remote testbeds, but using the given testbedIP to check if the testbed is remote, let me know what do you think.

Thanks!

622. By Federico Gimenez on 2015-07-30

merged prerequisite

623. By Federico Gimenez on 2015-07-30

merge prerequisite

Leo Arias (elopio) wrote :

> I agree, the problem here are the default values of release and channel, if
> not specified they are not empty strings.

Right, I understand now.
This is ok, so +1. A couple of alternatives that might be clearer or not would be:
- Instead of passing the test bed ip in the config, pass a boolean value that's "remote", set to true when the --ip flag is used.
- When the --ip flag is used, save "" as the release and channel in the config, instead of the default values.

I really don't know which is better between your current approach and those other two options, so I leave the top-approval to you. If you prefer it as it is, please go ahead and merge.

review: Approve
624. By Federico Gimenez on 2015-07-31

merged trunk

625. By Federico Gimenez on 2015-07-31

RemoteTestbed field for config

626. By Federico Gimenez on 2015-07-31

merged trunk

Federico Gimenez (fgimenez) wrote :

Ok, I've gone for the first option, having a RemoteTestbed boolean field in the config. Tested in rolling and 15.04, top-approving

Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '_integration-tests/main.go'
2--- _integration-tests/main.go 2015-07-31 07:32:21 +0000
3+++ _integration-tests/main.go 2015-07-31 08:00:41 +0000
4@@ -79,17 +79,19 @@
5 testutils.PrepareTargetDir(dataOutputDir)
6 defer os.RemoveAll(dataOutputDir)
7
8+ remoteTestbed := *testbedIP != ""
9+
10 // TODO: pass the config as arguments to the test binaries.
11 // --elopio - 2015-07-15
12 cfg := config.NewConfig(
13 configFileName, *imgRelease, *imgChannel, *targetRelease, *targetChannel,
14- *update, *rollback)
15+ remoteTestbed, *update, *rollback)
16 cfg.Write()
17
18 rootPath := testutils.RootPath()
19
20 test := autopkgtest.NewAutopkgtest(rootPath, baseDir, *testFilter, build.IntegrationTestName)
21- if *testbedIP == "" {
22+ if !remoteTestbed {
23 img := image.NewImage(*imgRelease, *imgChannel, *imgRevision, baseDir)
24
25 if imagePath, err := img.UdfCreate(); err == nil {
26
27=== modified file '_integration-tests/tests/info_test.go'
28--- _integration-tests/tests/info_test.go 2015-07-28 04:03:52 +0000
29+++ _integration-tests/tests/info_test.go 2015-07-31 08:00:41 +0000
30@@ -34,6 +34,14 @@
31 }
32
33 func (s *infoSuite) TestInfoMustPrintReleaseAndChannel(c *check.C) {
34+ // skip test when having a remote testbed (we can't know which the
35+ // release and channels are)
36+ if Cfg.RemoteTestbed {
37+ c.Skip(fmt.Sprintf(
38+ "Skipping %s while testing in remote testbed",
39+ c.TestName()))
40+ }
41+
42 infoOutput := ExecCommand(c, "snappy", "info")
43
44 expected := "(?ms)" +
45
46=== modified file '_integration-tests/testutils/config/config.go'
47--- _integration-tests/testutils/config/config.go 2015-07-29 11:06:52 +0000
48+++ _integration-tests/testutils/config/config.go 2015-07-31 08:00:41 +0000
49@@ -33,16 +33,17 @@
50 Channel string
51 TargetRelease string
52 TargetChannel string
53+ RemoteTestbed bool
54 Update bool
55 Rollback bool
56 }
57
58 // NewConfig is the Config constructor
59-func NewConfig(fileName, release, channel, targetRelease, targetChannel string, update, rollback bool) *Config {
60+func NewConfig(fileName, release, channel, targetRelease, targetChannel string, remoteTestbed, update, rollback bool) *Config {
61 return &Config{
62 FileName: fileName, Release: release, Channel: channel,
63 TargetRelease: targetRelease, TargetChannel: targetChannel,
64- Update: update, Rollback: rollback,
65+ RemoteTestbed: remoteTestbed, Update: update, Rollback: rollback,
66 }
67 }
68
69
70=== modified file '_integration-tests/testutils/config/config_test.go'
71--- _integration-tests/testutils/config/config_test.go 2015-07-29 11:06:52 +0000
72+++ _integration-tests/testutils/config/config_test.go 2015-07-31 08:00:41 +0000
73@@ -47,7 +47,7 @@
74 return NewConfig(
75 fileName,
76 "testrelease", "testchannel", "testtargetrelease", "testtargetchannel",
77- true, true)
78+ true, true, true)
79 }
80 func testConfigContents(fileName string) string {
81 return `{` +
82@@ -56,6 +56,7 @@
83 `"Channel":"testchannel",` +
84 `"TargetRelease":"testtargetrelease",` +
85 `"TargetChannel":"testtargetchannel",` +
86+ `"RemoteTestbed":true,` +
87 `"Update":true,` +
88 `"Rollback":true` +
89 `}`
90@@ -91,3 +92,30 @@
91 c.Assert(err, check.IsNil, check.Commentf("Error reading config: %v", err))
92 c.Assert(cfg, check.DeepEquals, testConfigStruct(configFileName))
93 }
94+
95+func (s *ConfigSuite) TestReadConfigLocalTestBed(c *check.C) {
96+ configFileName := testConfigFileName(c)
97+
98+ configContents := `{` +
99+ fmt.Sprintf(`"FileName":"%s",`, configFileName) +
100+ `"Release":"testrelease",` +
101+ `"Channel":"testchannel",` +
102+ `"TargetRelease":"testtargetrelease",` +
103+ `"TargetChannel":"testtargetchannel",` +
104+ `"RemoteTestbed":false,` +
105+ `"Update":true,` +
106+ `"Rollback":true` +
107+ `}`
108+
109+ ioutil.WriteFile(configFileName, []byte(configContents), 0644)
110+
111+ cfg, err := ReadConfig(configFileName)
112+
113+ testConfigStruct := NewConfig(
114+ configFileName,
115+ "testrelease", "testchannel", "testtargetrelease", "testtargetchannel",
116+ false, true, true)
117+
118+ c.Assert(err, check.IsNil, check.Commentf("Error reading config: %v", err))
119+ c.Assert(cfg, check.DeepEquals, testConfigStruct)
120+}

Subscribers

People subscribed via source and target branches