|
|
@ -21,25 +21,31 @@ var (
|
|
|
|
repoName = flag.String("repo-name", "areese-charts", "Repository name")
|
|
|
|
repoName = flag.String("repo-name", "areese-charts", "Repository name")
|
|
|
|
chart = flag.String("chart", "gs://areese-charts/replicatedservice-3.tgz", "Chart to deploy")
|
|
|
|
chart = flag.String("chart", "gs://areese-charts/replicatedservice-3.tgz", "Chart to deploy")
|
|
|
|
host = flag.String("host", "", "The URL to the helm server")
|
|
|
|
host = flag.String("host", "", "The URL to the helm server")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resourcifierImage = "quay.io/adamreese/resourcifier:latest"
|
|
|
|
|
|
|
|
expandybirdImage = "quay.io/adamreese/expandybird:latest"
|
|
|
|
|
|
|
|
managerImage = "quay.io/adamreese/manager:latest"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func TestHelm(t *testing.T) {
|
|
|
|
func TestHelm(t *testing.T) {
|
|
|
|
kube := NewKubeContext()
|
|
|
|
kube := NewKubeContext()
|
|
|
|
helm := NewHelmContext(t)
|
|
|
|
helm := NewHelmContext(t)
|
|
|
|
|
|
|
|
|
|
|
|
t.Log(kube.CurrentContext())
|
|
|
|
t.Logf("Kubenetes context: %s", kube.CurrentContext())
|
|
|
|
t.Log(kube.Cluster())
|
|
|
|
t.Logf("Cluster: %s", kube.Cluster())
|
|
|
|
t.Log(kube.Server())
|
|
|
|
t.Logf("Server: %s", kube.Server())
|
|
|
|
|
|
|
|
|
|
|
|
if !kube.Running() {
|
|
|
|
if !kube.Running() {
|
|
|
|
t.Fatal("Not connected to kubernetes")
|
|
|
|
t.Fatal("Not connected to kubernetes")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
t.Log("Kuberneter Version")
|
|
|
|
|
|
|
|
t.Log(kube.Version())
|
|
|
|
t.Log(kube.Version())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: skip check if running local binaries
|
|
|
|
if !helmRunning(helm) {
|
|
|
|
if !helmRunning(helm) {
|
|
|
|
t.Fatal("Helm is not installed")
|
|
|
|
t.Error("Helm is not installed")
|
|
|
|
|
|
|
|
helm.MustRun("server", "install", "--resourcifier-image", resourcifierImage, "--expandybird-image", expandybirdImage, "--manager-image", managerImage)
|
|
|
|
|
|
|
|
//TODO: wait for pods to be ready
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
helm.Host = helmHost()
|
|
|
|
helm.Host = helmHost()
|
|
|
@ -49,28 +55,30 @@ func TestHelm(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
t.Logf("Using host: %v", helm.Host)
|
|
|
|
t.Logf("Using host: %v", helm.Host)
|
|
|
|
|
|
|
|
|
|
|
|
if !helm.Run("repo", "list").Contains(*repoURL) {
|
|
|
|
// Add repo if it does not exsit
|
|
|
|
|
|
|
|
if !helm.MustRun("repo", "list").Contains(*repoURL) {
|
|
|
|
t.Logf("Adding repo %s %s", *repoName, *repoURL)
|
|
|
|
t.Logf("Adding repo %s %s", *repoName, *repoURL)
|
|
|
|
helm.Run("repo", "add", *repoName, *repoURL)
|
|
|
|
helm.MustRun("repo", "add", *repoName, *repoURL)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Generate a name
|
|
|
|
deploymentName := genName()
|
|
|
|
deploymentName := genName()
|
|
|
|
|
|
|
|
|
|
|
|
t.Log("Executing deploy")
|
|
|
|
t.Log("Executing deploy")
|
|
|
|
helm.Run("deploy", "--properties", "container_port=6379,image=kubernetes/redis:v1,replicas=2", "--name", deploymentName, *chart)
|
|
|
|
helm.MustRun("deploy", "--properties", "container_port=6379,image=kubernetes/redis:v1,replicas=2", "--name", deploymentName, *chart)
|
|
|
|
|
|
|
|
|
|
|
|
t.Log("Executing deployment list")
|
|
|
|
t.Log("Executing deployment list")
|
|
|
|
if !helm.Run("deployment", "list").Contains(deploymentName) {
|
|
|
|
if !helm.MustRun("deployment", "list").Contains(deploymentName) {
|
|
|
|
t.Fatal("Could not list deployment")
|
|
|
|
t.Fatal("Could not list deployment")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
t.Log("Executing deployment info")
|
|
|
|
t.Log("Executing deployment info")
|
|
|
|
if !helm.Run("deployment", "info", deploymentName).Contains("Deployed") {
|
|
|
|
if !helm.MustRun("deployment", "info", deploymentName).Contains("Deployed") {
|
|
|
|
t.Fatal("Could not deploy")
|
|
|
|
t.Fatal("Could not deploy")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
t.Log("Executing deployment delete")
|
|
|
|
t.Log("Executing deployment delete")
|
|
|
|
if !helm.Run("deployment", "rm", deploymentName).Contains("Deleted") {
|
|
|
|
if !helm.MustRun("deployment", "rm", deploymentName).Contains("Deleted") {
|
|
|
|
t.Fatal("Could not delete deployment")
|
|
|
|
t.Fatal("Could not delete deployment")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -87,6 +95,6 @@ func helmHost() string {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func helmRunning(h *HelmContext) bool {
|
|
|
|
func helmRunning(h *HelmContext) bool {
|
|
|
|
out := h.Run("server", "status").Stdout()
|
|
|
|
out := h.MustRun("server", "status").Stdout()
|
|
|
|
return strings.Count(out, "Running") == 5
|
|
|
|
return strings.Count(out, "Running") == 5
|
|
|
|
}
|
|
|
|
}
|
|
|
|