add unit tests and upgrade minikube, helm and k8s; set automountServiceAccountToken for 2.9.0 compatibility

This commit is contained in:
Cedric Meury 2018-04-27 14:41:59 +02:00
parent 2a1cdb0253
commit e4c016142d
3 changed files with 33 additions and 24 deletions

View File

@ -35,34 +35,30 @@ jobs:
- attach_workspace: - attach_workspace:
at: ~/build at: ~/build
- run: cp ~/build/helmfile ~/project/helmfile - run: cp ~/build/helmfile ~/project/helmfile
- run:
name: Install kubectl
command: |
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.8.4/bin/linux/amd64/kubectl
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
- run:
name: Install minikube
command: |
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.25.0/minikube-linux-amd64
chmod +x minikube
sudo mv minikube /usr/local/bin/
- run: - run:
name: Install helm name: Install helm
environment:
HELM_VERSION: v2.9.0
command: | command: |
HELM_VERSION=v2.8.2
HELM_FILENAME="helm-${HELM_VERSION}-linux-amd64.tar.gz" HELM_FILENAME="helm-${HELM_VERSION}-linux-amd64.tar.gz"
curl -Lo ${HELM_FILENAME} "https://kubernetes-helm.storage.googleapis.com/${HELM_FILENAME}" curl -Lo ${HELM_FILENAME} "https://kubernetes-helm.storage.googleapis.com/${HELM_FILENAME}"
tar zxf ${HELM_FILENAME} linux-amd64/helm tar zxf ${HELM_FILENAME} linux-amd64/helm
chmod +x linux-amd64/helm chmod +x linux-amd64/helm
sudo mv linux-amd64/helm /usr/local/bin/ sudo mv linux-amd64/helm /usr/local/bin/
- run: - run:
name: Start minikube name: Deploy minikube
environment:
CHANGE_MINIKUBE_NONE_USER: true
K8S_VERSION: v1.9.0
MINIKUBE_VERSION: v0.25.2
command: | command: |
sudo minikube start --vm-driver=none curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl
sudo chown -R $USER.$USER ~/.minikube chmod +x kubectl && sudo mv kubectl /usr/local/bin/
sudo chown -R $USER.$USER ~/.kube curl -Lo minikube https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64
minikube update-context chmod +x minikube && sudo mv minikube /usr/local/bin/
sudo minikube config set WantReportErrorPrompt false
sudo -E minikube start --vm-driver=none --kubernetes-version=${K8S_VERSION}
sudo -E minikube update-context
- run: - run:
name: Wait for nodes to become ready name: Wait for nodes to become ready
command: JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done command: JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done

View File

@ -32,6 +32,19 @@ func TestReadFromYaml(t *testing.T) {
} }
} }
func TestReadFromYaml_StrictUnmarshalling(t *testing.T) {
yamlFile := "example/path/to/yaml/file"
yamlContent := []byte(`releases:
- name: myrelease
namespace: mynamespace
releases: mychart
`)
_, err := readFromYaml(yamlContent, yamlFile)
if err == nil {
t.Error("expected an error for wrong key 'releases' which is not in struct")
}
}
func TestReadFromYaml_DeprecatedReleaseReferences(t *testing.T) { func TestReadFromYaml_DeprecatedReleaseReferences(t *testing.T) {
yamlFile := "example/path/to/yaml/file" yamlFile := "example/path/to/yaml/file"
yamlContent := []byte(`charts: yamlContent := []byte(`charts:
@ -569,10 +582,9 @@ func TestHelmState_SyncRepos(t *testing.T) {
} }
} }
func TestHelmState_SyncReleases(t *testing.T) { func TestHelmState_SyncReleases(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
releases []ReleaseSpec releases []ReleaseSpec
helm *mockHelmExec helm *mockHelmExec
wantReleases []string wantReleases []string
@ -581,11 +593,11 @@ func TestHelmState_SyncReleases(t *testing.T) {
name: "normal release", name: "normal release",
releases: []ReleaseSpec{ releases: []ReleaseSpec{
{ {
Name: "releaseName", Name: "releaseName",
Chart: "foo", Chart: "foo",
}, },
}, },
helm: &mockHelmExec{}, helm: &mockHelmExec{},
wantReleases: []string{"releaseName"}, wantReleases: []string{"releaseName"},
}, },
} }

View File

@ -32,9 +32,10 @@ function wait_deploy_ready() {
set -e set -e
info "Using namespace: ${test_ns}" info "Using namespace: ${test_ns}"
info "Using Helm version: $(helm version --short --client | grep -o v.*$)" info "Using Helm version: $(helm version --short --client | grep -o v.*$)"
$helm init --wait $helm init --wait --override spec.template.spec.automountServiceAccountToken=true
$helmfile -v $helmfile -v
$kubectl get namespace ${test_ns} &> /dev/null && warn "Namespace ${test_ns} exists, from a previous test run?" $kubectl get namespace ${test_ns} &> /dev/null && warn "Namespace ${test_ns} exists, from a previous test run?"
$kubectl create namespace ${test_ns} || fail "Could not create namespace ${test_ns}"
trap "{ $kubectl delete namespace ${test_ns}; }" EXIT # remove namespace whenever we exit this script trap "{ $kubectl delete namespace ${test_ns}; }" EXIT # remove namespace whenever we exit this script