diff options
| -rw-r--r-- | integration-tests/tests/base_test.go | 35 | ||||
| -rw-r--r-- | integration-tests/tests/snapd_test.go | 22 |
2 files changed, 34 insertions, 23 deletions
diff --git a/integration-tests/tests/base_test.go b/integration-tests/tests/base_test.go index b69e5acd22..310082df24 100644 --- a/integration-tests/tests/base_test.go +++ b/integration-tests/tests/base_test.go @@ -2,7 +2,7 @@ // +build !excludeintegration /* - * Copyright (C) 2015 Canonical Ltd + * Copyright (C) 2015, 2016 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -23,17 +23,22 @@ package tests import ( "io" "os" + "os/exec" + "path/filepath" "testing" "gopkg.in/check.v1" "github.com/ubuntu-core/snappy/integration-tests/testutils/cli" + "github.com/ubuntu-core/snappy/integration-tests/testutils/config" "github.com/ubuntu-core/snappy/integration-tests/testutils/partition" "github.com/ubuntu-core/snappy/integration-tests/testutils/report" "github.com/ubuntu-core/snappy/integration-tests/testutils/runner" "github.com/ubuntu-core/snappy/integration-tests/testutils/wait" ) +var daemonCmd *exec.Cmd + func init() { c := &check.C{} // Workaround for bug https://bugs.launchpad.net/snappy/+bug/1498293 @@ -44,6 +49,13 @@ func init() { cli.ExecCommand(c, "sudo", "systemctl", "stop", "snappy-autopilot.timer") cli.ExecCommand(c, "sudo", "systemctl", "disable", "snappy-autopilot.timer") + + cfg, err := config.ReadConfig(config.DefaultFileName) + c.Assert(err, check.IsNil, check.Commentf("Error reading config: %v", err)) + + if cfg.FromBranch { + setUpSnapdFromBranch(c) + } } // Hook up gocheck into the "go test" runner. @@ -53,3 +65,24 @@ func Test(t *testing.T) { report.NewSubunitV2ParserReporter(&report.FileReporter{})) runner.TestingT(t, output) } + +func setUpSnapdFromBranch(c *check.C) { + if daemonCmd == nil { + trustedKey, err := filepath.Abs("integration-tests/data/trusted.acckey") + c.Assert(err, check.IsNil) + + cli.ExecCommand(c, "sudo", "systemctl", "stop", + "ubuntu-snappy.snapd.service", "ubuntu-snappy.snapd.socket") + + // FIXME: for now pass a test-only trusted key through an env var + daemonCmd = exec.Command("sudo", "env", "PATH="+os.Getenv("PATH"), + "SNAPPY_TRUSTED_ACCOUNT_KEY="+trustedKey, + "/lib/systemd/systemd-activate", "--setenv=SNAPPY_TRUSTED_ACCOUNT_KEY", + "-l", "/run/snapd.socket", "snapd") + + err = daemonCmd.Start() + c.Assert(err, check.IsNil) + + wait.ForCommand(c, `^$`, "sudo", "chmod", "0666", "/run/snapd.socket") + } +} diff --git a/integration-tests/tests/snapd_test.go b/integration-tests/tests/snapd_test.go index b2e7416ed6..123f7c1fbc 100644 --- a/integration-tests/tests/snapd_test.go +++ b/integration-tests/tests/snapd_test.go @@ -50,34 +50,12 @@ type snapdTestSuite struct { func (s *snapdTestSuite) SetUpTest(c *check.C) { s.SnappySuite.SetUpTest(c) - trustedKey, err := filepath.Abs("integration-tests/data/trusted.acckey") - c.Assert(err, check.IsNil) - - cli.ExecCommand(c, "sudo", "systemctl", "stop", - "ubuntu-snappy.snapd.service", "ubuntu-snappy.snapd.socket") - - // FIXME: for now pass a test-only trusted key through an env var - s.cmd = exec.Command("sudo", "env", "PATH="+os.Getenv("PATH"), - "SNAPPY_TRUSTED_ACCOUNT_KEY="+trustedKey, - "/lib/systemd/systemd-activate", "--setenv=SNAPPY_TRUSTED_ACCOUNT_KEY", - "-l", "/run/snapd.socket", "snapd") - - err = s.cmd.Start() - c.Assert(err, check.IsNil) - - wait.ForCommand(c, `^$`, "sudo", "chmod", "0666", "/run/snapd.socket") common.InstallSnap(c, httpClientSnap+"/edge") } func (s *snapdTestSuite) TearDownTest(c *check.C) { s.SnappySuite.TearDownTest(c) - proc := s.cmd.Process - if proc != nil { - proc.Kill() - } - cli.ExecCommand(c, "sudo", "systemctl", "start", "ubuntu-snappy.snapd.socket") - common.RemoveSnap(c, httpClientSnap) } |
