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

[meta] upgrade test (#907) [7.x] #920

Merged
merged 2 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apm-server/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
default: test

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

CHART := apm-server
RELEASE := helm-apm-server-upgrade
FROM := 7.6.0 # 7.6.0 is the first release for apm-server

install:
../../../helpers/upgrade.sh --chart $(CHART) --release $(RELEASE) --from $(FROM)

test: install goss

purge:
helm del $(RELEASE)
21 changes: 21 additions & 0 deletions apm-server/examples/upgrade/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Upgrade

This example will deploy APM Server chart using an old chart version,
then upgrade it.


## Usage

* Add the Elastic Helm charts repo: `helm repo add elastic https://helm.elastic.co`

* Deploy [Elasticsearch Helm chart][]: `helm install elasticsearch elastic/elasticsearch`

* Deploy and upgrade APM Server chart with the default values: `make install`


## Testing

You can also run [goss integration tests][] using `make test`.


[goss integration tests]: https://github.com/elastic/helm-charts/tree/master/apm-server/examples/upgrade/test/goss.yaml
6 changes: 6 additions & 0 deletions apm-server/examples/upgrade/test/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
http:
http://localhost:8200?pretty:
status: 200
timeout: 2000
body:
- "7.11.0"
12 changes: 12 additions & 0 deletions apm-server/examples/upgrade/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apmConfig:
apm-server.yml: |
apm-server:
host: "0.0.0.0:8200"

queue: {}
output.file:
enabled: false

output.elasticsearch:
hosts: ["http://upgrade-master:9200"]
4 changes: 3 additions & 1 deletion elasticsearch/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ default: test

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

CHART := elasticsearch
RELEASE := helm-es-upgrade
FROM := 7.4.0 # versions before 7.4.O aren't compatible with Kubernetes >= 1.16.0

install:
./scripts/upgrade.sh --release $(RELEASE)
../../../helpers/upgrade.sh --chart $(CHART) --release $(RELEASE) --from $(FROM)

test: install goss

Expand Down
18 changes: 4 additions & 14 deletions elasticsearch/examples/upgrade/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
# Upgrade

This example will deploy a 3 node Elasticsearch cluster using an old chart version,
then upgrade it to version 7.11.0-SNAPSHOT.

The following upgrades are tested:
- Upgrade from [7.0.0-alpha1][] version on K8S <1.16
- Upgrade from [7.4.0][] version on K8S >=1.16 (Elasticsearch chart < 7.4.0 are
not compatible with K8S >= 1.16)
This example will deploy a 3 node Elasticsearch cluster chart using an old chart
version, then upgrade it.


## Usage

Running `make install` command will do first install and 7.11.0-SNAPSHOT upgrade.

Note: [jq][] is a requirement for this make target.
* Deploy and upgrade Elasticsearch chart with the default values: `make install`


## Testing

You can also run [goss integration tests][] using `make test`.


[7.0.0-alpha1]: https://github.com/elastic/helm-charts/releases/tag/7.0.0-alpha1
[7.4.0]: https://github.com/elastic/helm-charts/releases/tag/7.4.0
[goss integration tests]: https://github.com/elastic/helm-charts/tree/7.x/elasticsearch/examples/upgrade/test/goss.yaml
[jq]: https://stedolan.github.io/jq/
[goss integration tests]: https://github.com/elastic/helm-charts/tree/master/elasticsearch/examples/upgrade/test/goss.yaml
4 changes: 2 additions & 2 deletions elasticsearch/examples/upgrade/test/goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ http:
status: 200
timeout: 2000
body:
- 'green'
- "green"
- '"number_of_nodes":3'
- '"number_of_data_nodes":3'

Expand All @@ -14,4 +14,4 @@ http:
- '"number" : "7.11.0-SNAPSHOT"'
- '"cluster_name" : "upgrade"'
- '"name" : "upgrade-master-0"'
- 'You Know, for Search'
- "You Know, for Search"
2 changes: 2 additions & 0 deletions elasticsearch/examples/upgrade/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
clusterName: upgrade
15 changes: 15 additions & 0 deletions filebeat/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
default: test

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

CHART := filebeat
RELEASE := helm-filebeat-upgrade
FROM := 7.9.0 # registry file version 1 not supported error with previous version

install:
../../../helpers/upgrade.sh --chart $(CHART) --release $(RELEASE) --from $(FROM)

test: install goss

purge:
helm del $(RELEASE)
21 changes: 21 additions & 0 deletions filebeat/examples/upgrade/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Upgrade

This example will deploy Filebeat chart using an old chart version,
then upgrade it.


## Usage

* Add the Elastic Helm charts repo: `helm repo add elastic https://helm.elastic.co`

* Deploy [Elasticsearch Helm chart][]: `helm install elasticsearch elastic/elasticsearch`

* Deploy and upgrade Filebeat chart with the default values: `make install`


## Testing

You can also run [goss integration tests][] using `make test`.


[goss integration tests]: https://github.com/elastic/helm-charts/tree/master/filebeat/examples/upgrade/test/goss.yaml
45 changes: 45 additions & 0 deletions filebeat/examples/upgrade/test/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
port:
tcp:5066:
listening: true
ip:
- "127.0.0.1"

mount:
/usr/share/filebeat/data:
exists: true
/run/docker.sock:
exists: true
/var/lib/docker/containers:
exists: true
opts:
- ro
/usr/share/filebeat/filebeat.yml:
exists: true
opts:
- ro

user:
filebeat:
exists: true
uid: 1000
gid: 1000

http:
http://upgrade-master:9200/_cat/indices:
status: 200
timeout: 2000
body:
- "filebeat-7.11.0"

file:
/usr/share/filebeat/filebeat.yml:
exists: true
contains:
- "add_kubernetes_metadata"
- "output.elasticsearch"

command:
cd /usr/share/filebeat && filebeat test output:
exit-status: 0
stdout:
- "elasticsearch: http://upgrade-master:9200"
4 changes: 4 additions & 0 deletions filebeat/examples/upgrade/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
extraEnvs:
- name: ELASTICSEARCH_HOSTS
value: upgrade-master:9200
11 changes: 8 additions & 3 deletions helpers/matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,29 @@ KIBANA_SUITE:
- default
- oss
- security
- upgrade
FILEBEAT_SUITE:
- default
- oss
- security
- upgrade
METRICBEAT_SUITE:
- default
- oss
- security
#- upgrade TODO: uncomment after 7.10.0 release
LOGSTASH_SUITE:
- default
- oss
- elasticsearch
- security
- upgrade
APM_SERVER_SUITE:
- default
- oss
- security
- upgrade
KUBERNETES_VERSION:
- '1.15'
- '1.16'
- '1.17'
- "1.15"
- "1.16"
- "1.17"
73 changes: 73 additions & 0 deletions helpers/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash
#
# upgrade.sh deploy some Helm chart to a specific released version,
# then upgrade it.
#
# An optional version can be specified for Docker image tag to use for upgrade.
# This is required for master branch because upgrade from Elasticsearch 7.X
# to 8.0.0-SNAPSHOT doesn't work.
#
set -euo pipefail

TO=""

usage() {
cat <<-EOF
USAGE:
$0 --chart <chart-name> --release <release-name> --from <version> [--to <docker-image-version>]
$0 --help

OPTIONS:
--chart <chart-name>
Name of the Elastic Helm chart to install (ie: elasticsearch)
--release <release-name>
Name of the Helm release to install (ie: helm-upgrade-elasticsearch)
--from <version>
Version to use for first install (ie: 7.7.0)
--to <docker-image-version>
Version of the Docker images to use for upgrade (ie: 7.10.0)
EOF
exit 1
}

while [[ $# -gt 0 ]]
do
key="$1"

case $key in
--help)
usage
;;
--chart)
CHART="$2"
shift 2
;;
--release)
RELEASE="$2"
shift 2
;;
--from)
FROM="$2"
shift 2
;;
--to)
TO="--set imageTag=$2"
shift 2
;;
*)
log "Unrecognized argument: '$key'"
usage
;;
esac
done

helm repo add elastic https://helm.elastic.co

# Initial install
printf "Installing %s %s\n" "$RELEASE" "$FROM"
helm upgrade --wait --timeout=1200s --install --version "$FROM" --values values.yaml "$RELEASE" elastic/"$CHART"

# Upgrade
printf "Upgrading %s\n" "$RELEASE"
# shellcheck disable=SC2086
helm upgrade --wait --timeout=1200s --install --set terminationGracePeriod=121 $TO --values values.yaml "$RELEASE" ../../
16 changes: 16 additions & 0 deletions kibana/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
default: test

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

CHART := kibana
RELEASE := helm-kibana-upgrade
FROM := 7.4.0 # versions before 7.4.O aren't compatible with Kubernetes >= 1.16.0
TO := 7.10.0 # required to use with Elasticsearch 7.10.0

install:
../../../helpers/upgrade.sh --chart $(CHART) --release $(RELEASE) --from $(FROM) --to $(TO)

test: install goss

purge:
helm del $(RELEASE)
21 changes: 21 additions & 0 deletions kibana/examples/upgrade/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Upgrade

This example will deploy Kibana chart using an old chart version,
then upgrade it.


## Usage

* Add the Elastic Helm charts repo: `helm repo add elastic https://helm.elastic.co`

* Deploy [Elasticsearch Helm chart][]: `helm install elasticsearch elastic/elasticsearch`

* Deploy and upgrade Kibana chart with the default values: `make install`


## Testing

You can also run [goss integration tests][] using `make test`.


[goss integration tests]: https://github.com/elastic/helm-charts/tree/master/kibana/examples/upgrade/test/goss.yaml
14 changes: 14 additions & 0 deletions kibana/examples/upgrade/test/goss.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
http:
http://localhost:5601/api/status:
status: 200
timeout: 2000
body:
- '"number":"7.10.0"'

http://localhost:5601/app/kibana:
status: 200
timeout: 2000

http://helm-kibana-upgrade-kibana:5601/app/kibana:
status: 200
timeout: 2000
2 changes: 2 additions & 0 deletions kibana/examples/upgrade/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
elasticsearchHosts: "http://upgrade-master:9200"
15 changes: 15 additions & 0 deletions logstash/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
default: test

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

CHART := logstash
RELEASE := helm-logstash-upgrade
FROM := 7.9.0 # upgrade from version < 7.9.0 is failing due to headless service breaking change

install:
../../../helpers/upgrade.sh --chart $(CHART) --release $(RELEASE) --from $(FROM)

test: install goss

purge:
helm del $(RELEASE)
Loading