diff --git a/e2e/e2e_suite_test.go b/e2e/e2e_suite_test.go new file mode 100644 index 000000000..7da6d1435 --- /dev/null +++ b/e2e/e2e_suite_test.go @@ -0,0 +1,28 @@ +/* +Copyright 2017 The Kubernetes Authors All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e_test + +import ( + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +func TestE2e(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "E2e Suite") +} diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go new file mode 100644 index 000000000..59bb4f2fb --- /dev/null +++ b/e2e/e2e_test.go @@ -0,0 +1,74 @@ +/* +Copyright 2017 The Kubernetes Authors All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package e2e + +import ( + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" +) + +var _ = Describe("Basic Suite", func() { + var helm HelmManager + var namespace *v1.Namespace + var clientset kubernetes.Interface + + BeforeEach(func() { + var err error + clientset, err = KubeClient() + Expect(err).NotTo(HaveOccurred()) + By("Creating namespace and initializing test framework") + namespaceObj := &v1.Namespace{ + ObjectMeta: metav1.ObjectMeta{ + GenerateName: "e2e-helm-", + }, + } + namespace, err = clientset.Core().Namespaces().Create(namespaceObj) + Expect(err).NotTo(HaveOccurred()) + helm = &BinaryHelmManager{ + Namespace: namespace.Name, + Clientset: clientset, + HelmBin: helmBinPath, + TillerHost: tillerHost, + } + if !localTiller { + Expect(helm.InstallTiller()).NotTo(HaveOccurred()) + } + }) + + AfterEach(func() { + By("Removing namespace") + DeleteNS(clientset, namespace) + }) + + It("Should be possible to create/delete/upgrade/rollback and check status of wordpress chart", func() { + chartName := "stable/wordpress" + By("Install chart stable/wordpress") + releaseName, err := helm.Install(chartName, nil) + Expect(err).NotTo(HaveOccurred()) + By("Check status of release " + releaseName) + Expect(helm.Status(releaseName)).NotTo(HaveOccurred()) + By("Upgrading release " + releaseName) + Expect(helm.Upgrade(chartName, releaseName, map[string]string{"image": "bitnami/wordpress:4.7.3-r1"})).NotTo(HaveOccurred()) + By("Rolling back release " + releaseName + "to a first revision") + Expect(helm.Rollback(releaseName, 1)).NotTo(HaveOccurred()) + By("Deleting release " + releaseName) + Expect(helm.Delete(releaseName)).NotTo(HaveOccurred()) + }) +}) diff --git a/e2e/helm_client.go b/e2e/helm_client.go index 183472415..fa0cf72b9 100644 --- a/e2e/helm_client.go +++ b/e2e/helm_client.go @@ -1,43 +1,39 @@ -// Copyright 2017 Mirantis -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* +Copyright 2017 The Kubernetes Authors All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ package e2e import ( + "bytes" "fmt" "os/exec" "regexp" "strconv" - - "time" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/pkg/api/v1" - "strings" - - "bytes" + "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" ) const ( - experimentalTillerImage string = "nebril/tiller" - rudderPodName string = "rudder" - rudderImage string = "nebril/rudder-fed" + tillerImage string = "tiller" ) // HelmManager provides functionality to install client/server helm and use it @@ -63,19 +59,14 @@ type BinaryHelmManager struct { Clientset kubernetes.Interface Namespace string HelmBin string - KubectlBin string + TillerHost string } func (m *BinaryHelmManager) InstallTiller() error { arg := make([]string, 0, 5) var err error - if enableRudder { - arg = append(arg, "create", "-f", "manifests/", "-n", m.Namespace) - _, err = m.executeUsingKubectl(arg...) - } else { - arg = append(arg, "init", "--tiller-namespace", m.Namespace) - _, err = m.executeUsingHelm(arg...) - } + arg = append(arg, "init", "--tiller-namespace", m.Namespace) + _, err = m.executeUsingHelm(arg...) if err != nil { return err } @@ -146,13 +137,12 @@ func (m *BinaryHelmManager) executeUsingHelmInNamespace(arg ...string) (string, } func (m *BinaryHelmManager) executeUsingHelm(arg ...string) (string, error) { + if m.TillerHost != "" { + arg = append(arg, "--host", m.TillerHost) + } return m.executeUsingBinary(m.HelmBin, arg...) } -func (m *BinaryHelmManager) executeUsingKubectl(arg ...string) (string, error) { - return m.executeUsingBinary(m.KubectlBin, arg...) -} - func (m *BinaryHelmManager) executeUsingBinary(binary string, arg ...string) (string, error) { cmd := exec.Command(binary, arg...) Logf("Running command %+v\n", cmd.Args) @@ -196,31 +186,6 @@ func regexpKeyFromStructuredOutput(key, output string) string { return result[1] } -func prepareRudder(clientset kubernetes.Interface, namespace string) { - rudder := &v1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: rudderPodName, - }, - Spec: v1.PodSpec{ - RestartPolicy: "Always", - Containers: []v1.Container{ - { - Name: "rudder-appcontroller", - Image: "helm/rudder-appcontroller", - ImagePullPolicy: v1.PullNever, - }, - }, - }, - } - _, err := clientset.Core().Pods(namespace).Create(rudder) - Expect(err).NotTo(HaveOccurred()) - WaitForPod(clientset, namespace, rudderPodName, v1.PodRunning) -} - -func deleteRudder(clientset kubernetes.Interface, namespace string) error { - return clientset.Core().Pods(namespace).Delete(rudderPodName, nil) -} - func getNameFromHelmOutput(output string) string { return regexpKeyFromStructuredOutput("NAME", output) } diff --git a/e2e/utils.go b/e2e/utils.go index fb37b60ab..4d4bb023d 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -1,42 +1,45 @@ -// Copyright 2017 Mirantis -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* +Copyright 2017 The Kubernetes Authors All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ package e2e import ( "flag" "fmt" + "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "time" - + "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - "k8s.io/client-go/pkg/api/v1" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" ) -// TODO move this variables under single object TestContext var url string -var enableRudder bool +var tillerHost string +var helmBinPath string +var localTiller bool func init() { flag.StringVar(&url, "cluster-url", "http://127.0.0.1:8080", "apiserver address to use with restclient") - flag.BoolVar(&enableRudder, "use-rudder", false, "Use to enable rudder") + flag.StringVar(&tillerHost, "tiller-host", "", "tiller address") + flag.StringVar(&helmBinPath, "helm-bin", "helm", "helm binary to test") + flag.BoolVar(&localTiller, "local-tiller", false, "wait for tiller pod") } func LoadConfig() *rest.Config { diff --git a/glide.lock b/glide.lock index 1ccdae61c..0978bfcbb 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ hash: d93f565214b112cf8560e9cd2da2f3ab7852a1f19544569fc112bd4fb2d1d506 -updated: 2018-03-08T14:06:06.497394911-08:00 +updated: 2018-03-08T23:39:31.661722573Z imports: - name: cloud.google.com/go version: 3b1ae45394a234c385be014e9a488f2bb6eef821 @@ -247,6 +247,49 @@ imports: version: ad45545899c7b13c020ea92b2072220eefad42b8 - name: github.com/naoina/go-stringutil version: 6b638e95a32d0c1131db0e7fe83775cbea4a0d0b +- name: github.com/onsi/ginkgo + version: 67b9df7f55fe1165fd9ad49aca7754cce01a42b8 + subpackages: + - config + - ginkgo + - ginkgo/convert + - ginkgo/interrupthandler + - ginkgo/nodot + - ginkgo/testrunner + - ginkgo/testsuite + - ginkgo/watch + - internal/codelocation + - internal/containernode + - internal/failer + - internal/leafnodes + - internal/remote + - internal/spec + - internal/spec_iterator + - internal/specrunner + - internal/suite + - internal/testingtproxy + - internal/writer + - reporters + - reporters/stenographer + - reporters/stenographer/support/go-colorable + - reporters/stenographer/support/go-isatty + - types +- name: github.com/onsi/gomega + version: d59fa0ac68bb5dd932ee8d24eed631cdd519efc3 + subpackages: + - format + - gstruct + - gstruct/errors + - internal/assertion + - internal/asyncassertion + - internal/oraclematcher + - internal/testingtsupport + - matchers + - matchers/support/goraph/bipartitegraph + - matchers/support/goraph/edge + - matchers/support/goraph/node + - matchers/support/goraph/util + - types - name: github.com/opencontainers/go-digest version: a6d0ee40d4207ea02364bd3b9e8e77b9159ba1eb - name: github.com/opencontainers/image-spec diff --git a/glide.yaml b/glide.yaml index 7d0fce978..d80a9210c 100644 --- a/glide.yaml +++ b/glide.yaml @@ -71,3 +71,9 @@ testImports: version: ^1.1.4 subpackages: - assert +- package: github.com/onsi/ginkgo + version: ^1.4.0 + subpackages: + - ginkgo +- package: github.com/onsi/gomega + version: ^1.2.0