fix(e2e): working test scenario

pull/606/head
Adam Reese 10 years ago
parent 00cf94bd6a
commit 46e5075dbe

@ -8,6 +8,7 @@ import (
"os/exec"
"path"
"path/filepath"
"strings"
"testing"
)
@ -86,6 +87,18 @@ func (h *HelmCmd) Stderr() string {
return h.stderr.String()
}
func (h *HelmCmd) StdoutContains(substring string) bool {
return strings.Contains(h.Stdout(), substring)
}
func (h *HelmCmd) StderrContains(substring string) bool {
return strings.Contains(h.Stderr(), substring)
}
func (h *HelmCmd) Contains(substring string) bool {
return h.StdoutContains(substring) || h.StderrContains(substring)
}
func RepoRoot() string {
return filepath.Clean(filepath.Join(path.Base(os.Args[0]), "../../.."))
}

@ -6,6 +6,7 @@ import (
"flag"
"fmt"
"math/rand"
"os"
"strings"
"testing"
"time"
@ -19,6 +20,7 @@ var (
repoURL = flag.String("repo-url", "gs://areese-charts", "Repository URL")
repoName = flag.String("repo-name", "areese-charts", "Repository name")
chart = flag.String("chart", "gs://areese-charts/replicatedservice-3.tgz", "Chart to deploy")
host = flag.String("host", "", "The URL to the helm server")
)
func TestHelm(t *testing.T) {
@ -40,29 +42,48 @@ func TestHelm(t *testing.T) {
t.Fatal("Helm is not installed")
}
helm.Host = fmt.Sprintf("%s%s", kube.Server(), apiProxy)
t.Logf("Using host: %v", helm.Host)
helm.Host = helmHost()
t.Log("Executing deployment list")
helm.Run("deployment", "list")
if helm.Host == "" {
helm.Host = fmt.Sprintf("%s%s", kube.Server(), apiProxy)
}
t.Logf("Using host: %v", helm.Host)
t.Logf("Adding repo %s %s", *repoName, *repoURL)
helm.Run("repo", "add", *repoName, *repoURL)
if !helm.Run("repo", "list").Contains(*repoURL) {
t.Logf("Adding repo %s %s", *repoName, *repoURL)
helm.Run("repo", "add", *repoName, *repoURL)
}
deploymentName := genName()
t.Log("Executing deploy")
helm.Run("deploy", "--name", deploymentName, *chart)
helm.Run("deploy", "--properties", "container_port=6379,image=kubernetes/redis:v1,replicas=2", "--name", deploymentName, *chart)
t.Log("Executing deployment list")
helm.Run("deployment", "list")
if !helm.Run("deployment", "list").Contains(deploymentName) {
t.Fatal("Could not list deployment")
}
t.Log("Executing deployment info")
if !helm.Run("deployment", "info", deploymentName).Contains("Deployed") {
t.Fatal("Could not deploy")
}
t.Log("Executing deployment delete")
helm.Run("deployment", "delete", deploymentName)
if !helm.Run("deployment", "rm", deploymentName).Contains("Deleted") {
t.Fatal("Could not delete deployment")
}
}
func genName() string {
return fmt.Sprintf("%d", rand.Uint32())
return fmt.Sprintf("e2e-%d", rand.Uint32())
}
func helmHost() string {
if *host != "" {
return *host
}
return os.Getenv("HELM_HOST")
}
func helmRunning(h *HelmContext) bool {

Loading…
Cancel
Save