Helm specific test suite and options

pull/2846/head
Maciej Kwiek 8 years ago
parent d1dcc5963f
commit 0b007ef0ac

@ -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 (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestE2e(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "E2e Suite")
}

@ -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"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api/v1"
)
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())
})
})

@ -1,16 +1,17 @@
// 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
@ -35,9 +36,7 @@ import (
)
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 +62,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 +140,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 +189,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)
}

@ -1,16 +1,17 @@
// 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
@ -30,13 +31,16 @@ import (
"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 {

52
glide.lock generated

@ -1,5 +1,5 @@
hash: 54e64255ab9112d0183766264214969a8add57903fbe9e96034f9640b9c9cd82
updated: 2017-07-10T10:52:19.616678852-04:00
hash: e898f3f3c4f537e5181bf9d59a2f401f30187cf061d477389d634fc8d2b7d9cb
updated: 2017-08-17T15:21:32.21876387+02:00
imports:
- name: cloud.google.com/go
version: 3b1ae45394a234c385be014e9a488f2bb6eef821
@ -8,7 +8,7 @@ imports:
- name: github.com/asaskevich/govalidator
version: 7664702784775e51966f0885f5cd27435916517b
- name: github.com/Azure/go-autorest
version: d7c034a8af24eda120dd6460bfcd6d9ed14e43ca
version: 77a52603f06947221c672f10275abc9bf2c7d557
- name: github.com/beorn7/perks
version: 3ac7bf7a47d159a033b107610db8a1b6575507a4
subpackages:
@ -247,6 +247,9 @@ imports:
version: f2499483f923065a842d38eb4c7f1927e6fc6e6d
subpackages:
- context
- html
- html/atom
- html/charset
- http2
- http2/hpack
- idna
@ -264,8 +267,14 @@ imports:
subpackages:
- cases
- encoding
- encoding/charmap
- encoding/htmlindex
- encoding/internal
- encoding/internal/identifier
- encoding/japanese
- encoding/korean
- encoding/simplifiedchinese
- encoding/traditionalchinese
- encoding/unicode
- internal/tag
- internal/utf8internal
@ -338,7 +347,7 @@ imports:
- pkg/util/feature
- pkg/util/flag
- name: k8s.io/kubernetes
version: d3ada0119e776222f11ec7945e6d860061339aad
version: ebd4ffa39761a21ea5a2a206dc236e6003a8f9d1
subpackages:
- cmd/kubeadm/app/apis/kubeadm
- federation/apis/federation
@ -552,3 +561,38 @@ testImports:
version: e3a8ff8ce36581f87a15341206f205b1da467059
subpackages:
- assert
- name: github.com/onsi/ginkgo
version: 9eda700730cba42af70d53180f9dcce9266bc2bc
subpackages:
- config
- ginkgo
- 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: c893efa28eb45626cdaa76c9f653b62488858837
subpackages:
- format
- 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

@ -1,4 +1,7 @@
package: k8s.io/helm
ignore:
- k8s.io/client-go
- k8s.io/apimachinery
import:
- package: golang.org/x/net
subpackages:
@ -9,8 +12,6 @@ import:
version: 9ff6c6923cfffbcd502984b8e0c80539a94968b7
- package: github.com/Masterminds/vcs
version: ~1.11.0
# Pin version of mergo that is compatible with both sprig and Kubernetes
- package: github.com/imdario/mergo
version: 6633656539c1639d9d78127b7d47c622b5d7b6dc
- package: github.com/Masterminds/sprig
@ -52,11 +53,9 @@ import:
vcs: git
- package: github.com/docker/distribution
version: ~2.4.0
# hacks for kubernetes v1.7
- package: cloud.google.com/go
- package: github.com/Azure/go-autorest
version: d7c034a8af24eda120dd6460bfcd6d9ed14e43ca
version: 77a52603f06947221c672f10275abc9bf2c7d557
- package: github.com/dgrijalva/jwt-go
- package: github.com/docker/spdystream
- package: github.com/go-openapi/analysis
@ -77,13 +76,12 @@ import:
- package: gopkg.in/inf.v0
- package: github.com/go-openapi/strfmt
- package: github.com/mitchellh/mapstructure
- package: gopkg.in/mgo.v2/bson
ignore:
- k8s.io/client-go
- k8s.io/apimachinery
testImports:
- package: github.com/stretchr/testify
version: ^1.1.4
- package: gopkg.in/mgo.v2
subpackages:
- bson
- package: github.com/onsi/ginkgo
version: ^1.4.0
subpackages:
- assert
- ginkgo
- package: github.com/onsi/gomega
version: ^1.2.0

Loading…
Cancel
Save