Skip to content

Commit a8040f9

Browse files
committed
Print cluster hash for GKE k8s integration tests
Change-Id: Id9befb7508b785ed1fe96efff48c5fa84a6f1d1a
1 parent c0695cb commit a8040f9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/k8s-integration/cluster.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"bufio"
45
"encoding/json"
56
"errors"
67
"fmt"
@@ -268,6 +269,26 @@ func clusterUpGKE(gceZone, gceRegion string, numNodes int, numWindowsNodes int,
268269
}
269270
}
270271

272+
cmd = exec.Command("gcloud", "container", "clusters", "describe", *gkeTestClusterName, locationArg, locationVal)
273+
out, err = cmd.CombinedOutput()
274+
if err != nil {
275+
return fmt.Errorf("failed to list cluster: %v %s", err, out)
276+
}
277+
scanner := bufio.NewScanner(strings.NewReader(string(out)))
278+
printedHash := false
279+
for scanner.Scan() {
280+
line := scanner.Text()
281+
if strings.HasPrefix(line, "id: ") {
282+
klog.Infof("GKE cluster: %s %s", *gkeTestClusterName, locationVal)
283+
klog.Infof("GKE cluster hash %s", line)
284+
printedHash = true
285+
break
286+
}
287+
}
288+
if !printedHash {
289+
return fmt.Errorf("failed to find cluster hash in cluster describe: %s", out)
290+
}
291+
271292
return nil
272293
}
273294

0 commit comments

Comments
 (0)