Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
[elasticsearch] Add upgrade integration test
Browse files Browse the repository at this point in the history
This test will install the latest chart release and then attempt to
upgrade to what is currently in git. This is designed to test two
things.

1. That any changes do not happen to the statefulset that isn't allowed
by Kubernetes. An example of this happening is #94 where the change
was not caught as part of pull request testing but was luckily caught
during manual testing before the release.
2. That a rolling upgrade actually works and results in a healthy
cluster at the end. The test will always override the
"terminationGracePeriod" to make sure that a rolling upgrade is always
done even if there are no changes.

Kubectl and helm have also been updated to the latest releases. Oddly
enough there was a breaking change in the mock value used for release
names where it is now lowercased for some reason.

The kubectl upgraded was needed to get the handy timeout flag for the
`kubectl rollout status`command to make sure that jobs don't hang
forever if something does actually go wrong. This command is needed
because the `helm --wait` flag only works `apps/v1` resources. See
helm/helm#3173 for more information.
  • Loading branch information
Crazybus committed May 1, 2019
1 parent 8d6aa26 commit 268ed4e
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 4 deletions.
22 changes: 22 additions & 0 deletions elasticsearch/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
default: test

include ../../../helpers/examples.mk

RELEASE := helm-es-upgrade

# Right now the version is hardcoded because helm install will ignore
# anything with an alpha tag when trying to install the latest release
# This hardcoding can be removed once we drop the alpha tag
# The "--set terminationGracePeriod=121" always makes sure that a rolling
# upgrade is forced for this test
install:
helm repo add elastic https://helm.elastic.co && \
helm upgrade --wait --timeout=600 --install $(RELEASE) elastic/elasticsearch --version 7.0.0-alpha1 --set clusterName=upgrade ; \
kubectl rollout status sts/upgrade-master --timeout=600s
helm upgrade --wait --timeout=600 --set terminationGracePeriod=121 --install $(RELEASE) ../../ --set clusterName=upgrade ; \
kubectl rollout status sts/upgrade-master --timeout=600s

test: install goss

purge:
helm del --purge $(RELEASE)
17 changes: 17 additions & 0 deletions elasticsearch/examples/upgrade/test/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
http:
http://localhost:9200/_cluster/health:
status: 200
timeout: 2000
body:
- 'green'
- '"number_of_nodes":3'
- '"number_of_data_nodes":3'

http://localhost:9200:
status: 200
timeout: 2000
body:
- '"number" : "7.0.0"'
- '"cluster_name" : "upgrade"'
- '"name" : "upgrade-master-0"'
- 'You Know, for Search'
6 changes: 4 additions & 2 deletions helpers/helm-tester/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM python:2.7-onbuild

RUN wget https://storage.googleapis.com/kubernetes-helm/helm-v2.7.2-linux-amd64.tar.gz && \
tar xfv helm-v2.7.2-linux-amd64.tar.gz && \
ENV HELM_VERSION=2.13.1

RUN wget https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-linux-amd64.tar.gz && \
tar xfv helm-v${HELM_VERSION}-linux-amd64.tar.gz && \
mv linux-amd64/helm /usr/local/bin/ && \
rm -rf linux-amd64
1 change: 1 addition & 0 deletions helpers/matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ES_SUITE:
- default
- multi
- security
- upgrade
- 5.x
- 6.x
KIBANA_SUITE:
Expand Down
2 changes: 1 addition & 1 deletion helpers/terraform/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM centos:7

ENV VAULT_VERSION 0.9.3
ENV TERRAFORM_VERSION=0.11.7
ENV KUBECTL_VERSION=1.10.7
ENV KUBECTL_VERSION=1.14.1
ENV HELM_VERSION=2.13.1

RUN yum -y install \
Expand Down
2 changes: 1 addition & 1 deletion kibana/tests/kibana_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from helpers import helm_template
import yaml

name = 'RELEASE-NAME-kibana'
name = 'release-name-kibana'
elasticsearchHosts = 'http://elasticsearch-master:9200'


Expand Down

0 comments on commit 268ed4e

Please sign in to comment.