summaryrefslogtreecommitdiff
diff options
authorMichael Vogt <michael.vogt@gmail.com>2016-02-25 10:41:58 +0100
committerMichael Vogt <michael.vogt@gmail.com>2016-02-25 10:41:58 +0100
commiteaf596317a29726f9d4d746c413172a65260420c (patch)
treeeaa7d342e21fc64310e50ad3c606599db78acc15
parent1f5745206d6e315a4710172e0575bcaa8fe8cfe3 (diff)
parent71bea7a2f32c73053e3dd461557fafbdaec91e18 (diff)
Merge pull request #512 from fgimenez/snapd-from-branch-for-all-suites
integration-tests: always use the built snapd when compiling binaries from branch
-rw-r--r--integration-tests/tests/base_test.go35
-rw-r--r--integration-tests/tests/snapd_test.go22
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)
}