coreos/fleet — pull request #947 by jonboulle (2014-10-07 00:25:54+00:00)
Title: Tests fail in docker

Found when attempting to add a test-docker script to mirror the build-docker script. The error also manifests if you run the tests as root.

In the ssh package tests TestWrongHostKeyFile will cause a panic when a nil key is eventually passed to gossh.MarshalAuthorizedKey in renderHostLine.

Normally in the test PutHostKey exits early with an access denied error at known_hosts.go:274 but when run under root the call succeeds.

```
Building fleetd...
Building fleetctl...
Running tests...
ok github.com/coreos/fleet/agent 0.004s coverage: 64.7% of statements
ok github.com/coreos/fleet/api 0.005s coverage: 80.4% of statements
ok github.com/coreos/fleet/config 0.003s coverage: 100.0% of statements
ok github.com/coreos/fleet/engine 0.005s coverage: 54.1% of statements
ok github.com/coreos/fleet/etcd 0.006s coverage: 81.3% of statements
ok github.com/coreos/fleet/fleetctl 0.005s coverage: 24.0% of statements
ok github.com/coreos/fleet/job 0.004s coverage: 89.2% of statements
ok github.com/coreos/fleet/machine 0.004s coverage: 33.0% of statements
ok github.com/coreos/fleet/pkg 0.004s coverage: 85.0% of statements
ok github.com/coreos/fleet/registry 0.004s coverage: 27.8% of statements
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
93:d8:4c:0d:b2:c3:2e:da:b9:c0:67:db:e4:8f:95:04.
Please contact your system administrator.
Add correct host key in ../fixtures/known_hosts to get rid of this message.
Host key verification failed.
Host key verification failed.
Warning: Permanently added '[192.0.2.10]:2222' (RSA) to the list of known hosts.
--- FAIL: TestWrongHostKeyFile (0.00 seconds)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x28 pc=0x5082a4]

goroutine 24 [running]:
runtime.panic(0x6dce40, 0x8bc1d3)
/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
testing.func·006()
/usr/local/go/src/pkg/testing/testing.go:416 +0x176
runtime.panic(0x6dce40, 0x8bc1d3)
/usr/local/go/src/pkg/runtime/panic.c:248 +0x18d
github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/go.crypto/ssh.MarshalAuthorizedKey(0x0, 0x0, 0x0, 0x0, 0x0)
/opt/fleet/gopath/src/github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/go.crypto/ssh/keys.go:182 +0x84
github.com/coreos/fleet/ssh.renderHostLine(0x7123d0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
github.com/coreos/fleet/ssh/_test/_obj_test/known_hosts.go:316 +0x73
github.com/coreos/fleet/ssh.(*HostKeyFile).PutHostKey(0xc208000a10, 0x7123d0, 0x0, 0x0, 0x0, 0x0, 0x0)
github.com/coreos/fleet/ssh/_test/_obj_test/known_hosts.go:305 +0x1ba
github.com/coreos/fleet/ssh.TestWrongHostKeyFile(0xc20804e510)
/opt/fleet/gopath/src/github.com/coreos/fleet/ssh/known_hosts_test.go:148 +0x29c
testing.tRunner(0xc20804e510, 0x8bb200)
/usr/local/go/src/pkg/testing/testing.go:422 +0x8b
created by testing.RunTests
/usr/local/go/src/pkg/testing/testing.go:504 +0x8db

goroutine 16 [chan receive]:
testing.RunTests(0x7ac7a8, 0x8bb1a0, 0xb, 0xb, 0x6b9e01)
/usr/local/go/src/pkg/testing/testing.go:505 +0x923
testing.Main(0x7ac7a8, 0x8bb1a0, 0xb, 0xb, 0x8c5c60, 0x0, 0x0, 0x8c5c60, 0x0, 0x0)
/usr/local/go/src/pkg/testing/testing.go:435 +0x84
main.main()
github.com/coreos/fleet/ssh/_test/_testmain.go:117 +0x10c

goroutine 19 [finalizer wait]:
runtime.park(0x413dc0, 0x8c0ca0, 0x8bef49)
/usr/local/go/src/pkg/runtime/proc.c:1369 +0x89
runtime.parkunlock(0x8c0ca0, 0x8bef49)
/usr/local/go/src/pkg/runtime/proc.c:1385 +0x3b
runfinq()
/usr/local/go/src/pkg/runtime/mgc0.c:2644 +0xcf
runtime.goexit()
/usr/local/go/src/pkg/runtime/proc.c:1445
FAIL github.com/coreos/fleet/ssh 0.007s
ok github.com/coreos/fleet/unit 0.003s coverage: 89.6% of statements
```