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:
at: ~/build
- 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:
name: Install helm
environment:
HELM_VERSION: v2.9.0
command: |
HELM_VERSION=v2.8.2
HELM_FILENAME="helm-${HELM_VERSION}-linux-amd64.tar.gz"
curl -Lo ${HELM_FILENAME} "https://kubernetes-helm.storage.googleapis.com/${HELM_FILENAME}"
tar zxf ${HELM_FILENAME} linux-amd64/helm
chmod +x linux-amd64/helm
sudo mv linux-amd64/helm /usr/local/bin/
- run:
name: Start minikube
name: Deploy minikube
environment:
CHANGE_MINIKUBE_NONE_USER: true
K8S_VERSION: v1.9.0
MINIKUBE_VERSION: v0.25.2
command: |
sudo minikube start --vm-driver=none
sudo chown -R $USER.$USER ~/.minikube
sudo chown -R $USER.$USER ~/.kube
minikube update-context
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl
chmod +x kubectl && sudo mv kubectl /usr/local/bin/
curl -Lo minikube https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64
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:
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

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) {
yamlFile := "example/path/to/yaml/file"
yamlContent := []byte(`charts:
@ -569,10 +582,9 @@ func TestHelmState_SyncRepos(t *testing.T) {
}
}
func TestHelmState_SyncReleases(t *testing.T) {
tests := []struct {
name string
name string
releases []ReleaseSpec
helm *mockHelmExec
wantReleases []string
@ -581,11 +593,11 @@ func TestHelmState_SyncReleases(t *testing.T) {
name: "normal release",
releases: []ReleaseSpec{
{
Name: "releaseName",
Chart: "foo",
Name: "releaseName",
Chart: "foo",
},
},
helm: &mockHelmExec{},
helm: &mockHelmExec{},
wantReleases: []string{"releaseName"},
},
}

View File

@ -32,9 +32,10 @@ function wait_deploy_ready() {
set -e
info "Using namespace: ${test_ns}"
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
$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