forked from bsteciuk/kismatic
/
upgrade.go
48 lines (41 loc) · 1.07 KB
/
upgrade.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package integration_tests
import (
"encoding/json"
"os/exec"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
type infoOutput struct {
EarliestVersion string
LatestVersion string
Nodes []struct {
Version string
}
}
type versionOutput struct {
Version string
}
func assertClusterVersionIsCurrent() {
By("Calling ./kismatic version to get Kismatic version")
cmd := exec.Command("./kismatic", "version", "-o", "json")
out, err := cmd.Output()
FailIfError(err)
ver := versionOutput{}
err = json.Unmarshal(out, &ver)
FailIfError(err)
assertClusterVersion(ver.Version)
}
func assertClusterVersion(version string) {
By("Calling ./kismatic info to get the cluster's version")
cmd := exec.Command("./kismatic", "info", "-f", "kismatic-testing.yaml", "-o", "json")
out, err := cmd.Output()
FailIfError(err)
info := infoOutput{}
err = json.Unmarshal(out, &info)
FailIfError(err)
Expect(info.EarliestVersion).To(Equal(version))
Expect(info.LatestVersion).To(Equal(version))
for _, n := range info.Nodes {
Expect(n.Version).To(Equal(version))
}
}