Merge lp:~axwalk/juju-core/environs-manual-detection-stderr into lp:~go-bot/juju-core/trunk
Proposed by
Andrew Wilkins
Status: | Merged |
---|---|
Approved by: | Andrew Wilkins |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2167 |
Proposed branch: | lp:~axwalk/juju-core/environs-manual-detection-stderr |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
55 lines (+22/-7) 2 files modified
environs/manual/detection.go (+7/-5) environs/manual/detection_test.go (+15/-2) |
To merge this branch: | bzr merge lp:~axwalk/juju-core/environs-manual-detection-stderr |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+199617@code.launchpad.net |
Commit message
environs/manual: ignore stderr in detection
SSH warnings were mucking up series/hw detection.
Description of the change
environs/manual: ignore stderr in detection
SSH warnings were mucking up series/hw detection.
To post a comment you must log in.
Reviewers: mp+199617_ code.launchpad. net,
Message:
Please take a look.
Description:
environs/manual: ignore stderr in detection
SSH warnings were mucking up series/hw detection.
https:/ /code.launchpad .net/~axwalk/ juju-core/ environs- manual- detection- stderr/ +merge/ 199617
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/44200043/
Affected files (+24, -7 lines): manual/ detection. go manual/ detection_ test.go
A [revision details]
M environs/
M environs/
Index: [revision details] 20131219033619- 8j3q9tyevvm9j34 c
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: environs/ manual/ detection. go manual/ detection. go' manual/ detection. go 2013-12-03 05:20:25 +0000 manual/ detection. go 2013-12-19 06:39:26 +0000 HardwareCharact eristics( sshHost string) (hc HardwareCharact eristics, series string, err error) { Infof(" Detecting series and characteristics on %s", sshHost) sshHost, []string{"bash"}) String( detectionScript ) put() TrimSpace( string( out))) TrimSpace( stderr. String( ))) Split(string( out), "\n") Split(stdout. String( ), "\n") TrimSpace( lines[0] )
=== modified file 'environs/
--- environs/
+++ environs/
@@ -54,15 +54,17 @@
func DetectSeriesAnd
instance.
logger.
cmd := ssh.Command(
+ var stdout, stderr bytes.Buffer
+ cmd.Stdout = &stdout
+ cmd.Stderr = &stderr
cmd.Stdin = bytes.NewBuffer
- out, err := cmd.CombinedOut
- if err != nil {
- if len(out) != 0 {
- err = fmt.Errorf("%v (%v)", err, strings.
+ if err := cmd.Run(); err != nil {
+ if stderr.Len() != 0 {
+ err = fmt.Errorf("%v (%v)", err, strings.
}
return hc, "", err
}
- lines := strings.
+ lines := strings.
series = strings.
// Normalise arch.
Index: environs/ manual/ detection_ test.go manual/ detection_ test.go' manual/ detection_ test.go 2013-11-18 04:53:44 +0000 manual/ detection_ test.go 2013-12-19 06:39:26 +0000
=== modified file 'environs/
--- environs/
+++ environs/
@@ -32,9 +32,22 @@
}
func (s *detectionSuite) TestDetectionEr ror(c *gc.C) { HardwareCharact eristics( "whatever" ) Join([] string{ scriptResponse, "oh HardwareCharact eristics( "hostname" ) scriptResponse, "non-empty- stderr" }, 0)() HardwareCharact eristics( "hostname" ) hc.String( ), gc.Equals, "arch=arm cpu-cores=1 mem=4M")
- defer installFakeSSH(c, detectionScript, "oh noes", 33)()
- _, _, err := DetectSeriesAnd
+ scriptResponse := strings.
+ "edgy",
+ "armv4",
+ "MemTotal: 4096 kB",
+ "processor: 0",
+ }, "\n")
+ // if the script fails for whatever reason, then checkProvisioned
+ // will return an error. stderr will be included in the error message.
+ defer installFakeSSH(c, detectionScript, []string{
noes"}, 33)()
+ hc, _, err := DetectSeriesAnd
c.Assert(err, gc.ErrorMatches, "exit status 33 \\(oh noes\\)")
+ // if the script doesn't fail, stderr is simply ignored.
+ defer installFakeSSH(c, detectionScript,
[]string{
+ hc, _, err = DetectSeriesAnd
+ c.Assert(err, gc.IsNil)
+ c.Assert(
}
func (s *detectionSuite) TestDetectHardw areCharacterist ics(c *gc....