Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

CI fixes #844

Merged
merged 5 commits into from Jan 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 20 additions & 5 deletions test/cluster/cluster.go
Expand Up @@ -75,7 +75,7 @@ func New(bc BootConfig, out io.Writer) *Cluster {
func BuildFlynn(bc BootConfig, rootFS, commit string, merge bool, out io.Writer) (string, error) {
c := New(bc, out)
defer c.Shutdown()
return c.BuildFlynn(rootFS, commit, merge)
return c.BuildFlynn(rootFS, commit, merge, false)
}

func (c *Cluster) log(a ...interface{}) (int, error) {
Expand All @@ -86,7 +86,7 @@ func (c *Cluster) logf(f string, a ...interface{}) (int, error) {
return fmt.Fprintf(c.out, f, a...)
}

func (c *Cluster) BuildFlynn(rootFS, commit string, merge bool) (string, error) {
func (c *Cluster) BuildFlynn(rootFS, commit string, merge bool, runTests bool) (string, error) {
c.log("Building Flynn...")

if err := c.setup(); err != nil {
Expand Down Expand Up @@ -122,9 +122,11 @@ func (c *Cluster) BuildFlynn(rootFS, commit string, merge bool) (string, error)
return build.Drive("hda").FS, fmt.Errorf("error running build script: %s", err)
}

if err := runUnitTests(build, c.out); err != nil {
build.Kill()
return build.Drive("hda").FS, fmt.Errorf("unit tests failed: %s", err)
if runTests {
if err := runUnitTests(build, c.out); err != nil {
build.Kill()
return build.Drive("hda").FS, fmt.Errorf("unit tests failed: %s", err)
}
}

if err := build.Shutdown(); err != nil {
Expand Down Expand Up @@ -500,6 +502,19 @@ func lookupUser(name string) (int, int, error) {
}

func (c *Cluster) DumpLogs(w io.Writer) {
done := make(chan struct{})
go func() {
c.dumpLogs(w)
close(done)
}()
select {
case <-done:
case <-time.After(60 * time.Second):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This timeout covers all the log gather attempts at once... do we need the big one, if the timeout per ssh connection is now low?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ssh timeout only covers the connect time, this covers execution time too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OH.... so if the dialSSH call times out or errors once, it doesn't stop future runs from trying and timing out again. Maybe that's not the greatest behavior, maybe we should just set an "error and stop trying" flag for that? WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine for now.

fmt.Fprintln(w, "failed to dump logs within 60 seconds, skipping")
}
}

func (c *Cluster) dumpLogs(w io.Writer) {
streams := &Streams{Stdout: w, Stderr: w}
run := func(inst *Instance, cmd string) error {
fmt.Fprint(w, "\n\n***** ***** ***** ***** ***** ***** ***** ***** ***** *****\n\n")
Expand Down
4 changes: 2 additions & 2 deletions test/cluster/instance.go
Expand Up @@ -62,7 +62,7 @@ func (v *VMManager) NewInstance(c *VMConfig) (*Instance, error) {
if err != nil {
return nil, err
}
inst.IP = inst.tap.RemoteIP.String()
inst.IP = inst.tap.IP.String()
return inst, nil
}

Expand Down Expand Up @@ -258,7 +258,7 @@ func (i *Instance) dialSSH(stderr io.Writer) error {

var sshAttempts = attempt.Strategy{
Min: 5,
Total: 5 * time.Minute,
Total: 30 * time.Second,
Delay: time.Second,
}

Expand Down
27 changes: 7 additions & 20 deletions test/cluster/net.go
Expand Up @@ -176,20 +176,17 @@ func deleteTap(name string) error {
}

type Tap struct {
Name string
LocalIP, RemoteIP net.IP
bridge *Bridge
Name string
IP net.IP
bridge *Bridge
}

func (t *Tap) Close() error {
if err := deleteTap(t.Name); err != nil {
return err
}
if t.LocalIP != nil {
ipallocator.ReleaseIP(t.bridge.ipNet, t.LocalIP)
}
if t.RemoteIP != nil {
ipallocator.ReleaseIP(t.bridge.ipNet, t.RemoteIP)
if t.IP != nil {
ipallocator.ReleaseIP(t.bridge.ipNet, t.IP)
}
return nil
}
Expand All @@ -205,7 +202,7 @@ iface eth0 inet static

func (t *Tap) WriteInterfaceConfig(f io.Writer) error {
return ifaceConfig.Execute(f, map[string]string{
"Address": t.RemoteIP.String(),
"Address": t.IP.String(),
"Gateway": t.bridge.IP(),
})
}
Expand All @@ -222,13 +219,7 @@ func (t *TapManager) NewTap(uid, gid int) (*Tap, error) {
}

var err error
tap.LocalIP, err = ipallocator.RequestIP(t.bridge.ipNet, nil)
if err != nil {
tap.Close()
return nil, err
}

tap.RemoteIP, err = ipallocator.RequestIP(t.bridge.ipNet, nil)
tap.IP, err = ipallocator.RequestIP(t.bridge.ipNet, nil)
if err != nil {
tap.Close()
return nil, err
Expand All @@ -239,10 +230,6 @@ func (t *TapManager) NewTap(uid, gid int) (*Tap, error) {
tap.Close()
return nil, err
}
if err := netlink.NetworkLinkAddIp(iface, tap.LocalIP, t.bridge.ipNet); err != nil {
tap.Close()
return nil, err
}
if err := netlink.NetworkLinkUp(iface); err != nil {
tap.Close()
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion test/main.go
Expand Up @@ -77,7 +77,7 @@ func main() {
if flynnrc == "" {
var rootFS string
testCluster = cluster.New(args.BootConfig, os.Stdout)
rootFS, err = testCluster.BuildFlynn(args.RootFS, "origin/master", false)
rootFS, err = testCluster.BuildFlynn(args.RootFS, "origin/master", false, false)
if err != nil {
testCluster.Shutdown()
log.Println("could not build flynn: ", err)
Expand Down
2 changes: 1 addition & 1 deletion test/runner/runner.go
Expand Up @@ -259,7 +259,7 @@ func (r *Runner) build(b *Build) (err error) {
c.Shutdown()
}()

rootFS, err := c.BuildFlynn(r.rootFS, b.Commit, b.Merge)
rootFS, err := c.BuildFlynn(r.rootFS, b.Commit, b.Merge, true)
defer removeRootFS(rootFS)
if err != nil {
return fmt.Errorf("could not build flynn: %s", err)
Expand Down
22 changes: 21 additions & 1 deletion test/scripts/debug-info.sh
@@ -1,7 +1,7 @@
#!/bin/bash
#
# This script is run by the CI runner to collect debugging information
# which will be printed if any tests fail. It currently runs no code.
# which will be printed if any tests fail.

memwatch() {
interests=("$@")
Expand All @@ -24,3 +24,23 @@ memwatch() {
sleep 1
done
}

netdebug() {
while true; do
echo "===> $(date +%H:%M:%S.%3N)"
trace ifconfig eth0
trace route -n
trace arp -a
echo "==================="
echo
sleep 5
done
}

trace() {
local cmd=$@
echo "+ ${cmd}"
$cmd
}

netdebug