// SetUpSuite disables the snappy autopilot. It will run before all the // integration suites. func (s *SnappySuite) SetUpSuite(c *check.C) { var err error Cfg, err = config.ReadConfig(config.DefaultFileName) c.Assert(err, check.IsNil, check.Commentf("Error reading config: %v", err)) if !IsInRebootProcess() { if Cfg.Update || Cfg.Rollback { // TODO handle updates to a different release and channel. // Always use the installed snappy because we are updating from an old // image, so we should not use the snappy from the branch. output := cli.ExecCommand(c, "sudo", "/usr/bin/snappy", "update") expected := "(?ms)" + ".*" + fmt.Sprintf("^Reboot to use %s version .*\\.\n", partition.OSSnapName(c)) c.Assert(output, check.Matches, expected) RebootWithMark(c, "setupsuite-update") } } else if CheckRebootMark("setupsuite-update") { RemoveRebootMark(c) // Update was already executed. Update the config so it's not triggered again. Cfg.Update = false Cfg.Write() if Cfg.Rollback { cli.ExecCommand(c, "sudo", "snappy", "rollback", partition.OSSnapName(c)) RebootWithMark(c, "setupsuite-rollback") } } else if CheckRebootMark("setupsuite-rollback") { RemoveRebootMark(c) // Rollback was already executed. Update the config so it's not triggered again. Cfg.Rollback = false Cfg.Write() } }
// SetUpSuite disables the snappy autopilot. It will run before all the // integration suites. func (s *SnappySuite) SetUpSuite(c *check.C) { var err error Cfg, err = config.ReadConfig( "integration-tests/data/output/testconfig.json") c.Assert(err, check.IsNil, check.Commentf("Error reading config: %v", err)) if !IsInRebootProcess() { if Cfg.Update || Cfg.Rollback { switchSystemImageConf(c, Cfg.TargetRelease, Cfg.TargetChannel, "0") // Always use the installed snappy because we are updating from an old // image, so we should not use the snappy from the branch. output := cli.ExecCommand(c, "sudo", "/usr/bin/snappy", "update") if output != "" { RebootWithMark(c, "setupsuite-update") } } } else if CheckRebootMark("setupsuite-update") { RemoveRebootMark(c) // Update was already executed. Update the config so it's not triggered again. Cfg.Update = false Cfg.Write() if Cfg.Rollback { cli.ExecCommand(c, "sudo", "snappy", "rollback", "ubuntu-core") RebootWithMark(c, "setupsuite-rollback") } } else if CheckRebootMark("setupsuite-rollback") { RemoveRebootMark(c) // Rollback was already executed. Update the config so it's not triggered again. Cfg.Rollback = false Cfg.Write() } }
func (s *snapRefreshAppSuite) TestAppUpdate(c *check.C) { c.Skip("port to snapd") snap := "hello-world.canonical" storeSnap := fmt.Sprintf("%s", snap) // install edge version from the store (which is squshfs) cli.ExecCommand(c, "sudo", "snap", "install", storeSnap) defer cli.ExecCommand(c, "sudo", "snap", "remove", snap) // make a fakestore and make it available to snapd // use /var/tmp is not a tempfs for space reasons blobDir, err := ioutil.TempDir("/var/tmp", "snap-fake-store-blobs-") c.Assert(err, check.IsNil) defer cli.ExecCommand(c, "sudo", "rm", "-rf", blobDir) fakeStore := store.NewStore(blobDir) err = fakeStore.Start() c.Assert(err, check.IsNil) defer fakeStore.Stop() env := fmt.Sprintf(`SNAPPY_FORCE_CPI_URL=%s`, fakeStore.URL()) cfg, _ := config.ReadConfig(config.DefaultFileName) tearDownSnapd(cfg.FromBranch) setUpSnapd(c, cfg.FromBranch, env) // run the fake update output := updates.CallFakeSnapRefresh(c, snap, updates.NoOp, fakeStore) c.Assert(output, check.Matches, "(?ms).*^hello-world.*fake1.*") }
// SetUpSuite disables the snappy autopilot. It will run before all the // integration suites. func (s *SnappySuite) SetUpSuite(c *check.C) { var err error Cfg, err = config.ReadConfig( "integration-tests/data/output/testconfig.json") c.Assert(err, check.IsNil, check.Commentf("Error reading config: %v", err)) if !IsInRebootProcess() { if Cfg.Update || Cfg.Rollback { // TODO handle updates to a different release and channel. // Always use the installed snappy because we are updating from an old // image, so we should not use the snappy from the branch. output := cli.ExecCommand(c, "sudo", "/usr/bin/snappy", "update") // TODO raise an error if there is no available update. if output != "" { RebootWithMark(c, "setupsuite-update") } } } else if CheckRebootMark("setupsuite-update") { RemoveRebootMark(c) // Update was already executed. Update the config so it's not triggered again. Cfg.Update = false Cfg.Write() if Cfg.Rollback { cli.ExecCommand(c, "sudo", "snappy", "rollback", partition.OSSnapName(c)) RebootWithMark(c, "setupsuite-rollback") } } else if CheckRebootMark("setupsuite-rollback") { RemoveRebootMark(c) // Rollback was already executed. Update the config so it's not triggered again. Cfg.Rollback = false Cfg.Write() } }
// AddOptionsToCommand inserts the required coverage options in // the given snappy command slice func AddOptionsToCommand(cmds []string) ([]string, error) { index := findIndex(cmds, "snappy", "snap", "snapd") if index != -1 { cfg, err := config.ReadConfig(config.DefaultFileName) if err != nil { return []string{}, err } if cfg.FromBranch { return addCoverageOptions(cmds, index) } } return cmds, nil }
// Hook up gocheck into the "go test" runner. func Test(t *testing.T) { output := io.MultiWriter( os.Stdout, report.NewSubunitV2ParserReporter(&report.FileReporter{})) runner.TestingT(t, output) if _, err := os.Stat(config.DefaultFileName); err == nil { cfg, err := config.ReadConfig(config.DefaultFileName) if err != nil { t.Fatalf("Error reading config: %v", err) } if err := tearDownSnapd(cfg.FromBranch); err != nil { t.Fatalf("Error stopping daemon: %v", err) } } }
func init() { c := &check.C{} // Workaround for bug https://bugs.launchpad.net/snappy/+bug/1498293 // TODO remove once the bug is fixed // originally added by elopio - 2015-09-30 to the rollback test, moved // here by --fgimenez - 2015-10-15 wait.ForFunction(c, "regular", partition.Mode) if _, err := os.Stat(config.DefaultFileName); err == nil { 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)) setUpSnapd(c, cfg.FromBranch, "") } }