func OmahaPing(c platform.TestCluster) error { qc, ok := c.Cluster.(*platform.QEMUCluster) if !ok { return errors.New("test only works in qemu") } omahaserver := qc.LocalCluster.OmahaServer svc := &pingServer{ ping: make(chan struct{}), } omahaserver.Updater = svc m := c.Machines()[0] out, err := m.SSH("update_engine_client -check_for_update") if err != nil { return fmt.Errorf("failed to execute update_engine_client -check_for_update: %v: %v", out, err) } tc := time.After(30 * time.Second) select { case <-tc: platform.Manhole(m) return errors.New("timed out waiting for omaha ping") case <-svc.ping: } return nil }
func runSpawn(cmd *cobra.Command, args []string) { var userdata []byte var err error var cluster platform.Cluster if spawnUserData != "" { userdata, err = ioutil.ReadFile(spawnUserData) if err != nil { die("Reading userdata failed: %v", err) } } switch kolaPlatform { case "qemu": cluster, err = platform.NewQemuCluster(kola.QEMUOptions) case "gce": cluster, err = platform.NewGCECluster(kola.GCEOptions) case "aws": cluster, err = platform.NewAWSCluster(kola.AWSOptions) default: err = fmt.Errorf("invalid platform %q", kolaPlatform) } if err != nil { die("Cluster failed: %v", err) } mach, err := cluster.NewMachine(string(userdata)) if err != nil { die("Spawning instance failed: %v", err) } if spawnRemove { defer mach.Destroy() } if spawnShell { if err := platform.Manhole(mach); err != nil { die("Manhole failed: %v", err) } } }