run_remote.go: factor out registerGceHostIP()

Prep for future patch.
This commit is contained in:
Jonathan Lebon 2021-11-05 11:58:12 -04:00
parent 806e38aeb7
commit 36233b985b

View File

@ -436,28 +436,30 @@ func getImageMetadata(input string) *compute.Metadata {
return &ret
}
// Run tests in archive against host
func testHost(host string, deleteFiles bool, imageDesc, junitFileName, ginkgoFlagsStr string) *TestResult {
func registerGceHostIP(host string) error {
instance, err := computeService.Instances.Get(*project, *zone, host).Do()
if err != nil {
return &TestResult{
err: err,
host: host,
exitOk: false,
}
return err
}
if strings.ToUpper(instance.Status) != "RUNNING" {
err = fmt.Errorf("instance %s not in state RUNNING, was %s", host, instance.Status)
return &TestResult{
err: err,
host: host,
exitOk: false,
}
return fmt.Errorf("instance %s not in state RUNNING, was %s", host, instance.Status)
}
externalIP := getExternalIP(instance)
if len(externalIP) > 0 {
remote.AddHostnameIP(host, externalIP)
}
return nil
}
// Run tests in archive against host
func testHost(host string, deleteFiles bool, imageDesc, junitFileName, ginkgoFlagsStr string) *TestResult {
if err := registerGceHostIP(host); err != nil {
return &TestResult{
err: err,
host: host,
exitOk: false,
}
}
path, err := arc.getArchive()
if err != nil {