github.com/jlmeeker/kismatic@v1.10.1-0.20180612190640-57f9005a1f1a/integration-tests/upgrade.go (about)

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