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

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlrt committed Nov 17, 2020
1 parent 7e3ea19 commit 7f90783
Show file tree
Hide file tree
Showing 23 changed files with 442 additions and 81 deletions.
8 changes: 2 additions & 6 deletions apm-server/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ default: test
include ../../../helpers/examples.mk

RELEASE := helm-apm-server-upgrade
PREVIOUS_VERSION := 7.7.0

install:
helm upgrade --wait --timeout=900s --install $(RELEASE) --version $(PREVIOUS_VERSION)
./scripts/upgrade.sh --release $(RELEASE)

upgrade:
helm upgrade --wait --timeout=900s --install $(RELEASE) ../../

test: install upgrade goss
test: install goss

purge:
helm del $(RELEASE)
59 changes: 59 additions & 0 deletions apm-server/examples/upgrade/scripts/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash

set -euo pipefail

usage() {
cat <<-EOF
USAGE:
$0 [--release <release-name>] [--from <apm-server-version>]
$0 --help
OPTIONS:
--release <release-name>
Name of the Helm release to install
--from <apm-server-version>
apm-server version to use for first install
EOF
exit 1
}

RELEASE="helm-apm-server-upgrade"
FROM=""

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

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

# APM Server has been released in 7.6.0
FROM="7.6.0"

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

# Initial install
printf "Installing apm-server chart %s\n" "$FROM"
helm upgrade --wait --timeout=600s --install "$RELEASE" elastic/apm-server --version "$FROM" --values values.yaml
kubectl rollout status deploy/helm-apm-server-upgrade-apm-server --timeout=600s

# Upgrade
printf "Upgrading apm-server chart\n"
helm upgrade --wait --timeout=600s --set terminationGracePeriod=121 --install "$RELEASE" ../../ --set imageTag=7.10.0 --values values.yaml
kubectl rollout status deploy/helm-apm-server-upgrade-apm-server --timeout=600s
2 changes: 1 addition & 1 deletion apm-server/examples/upgrade/test/goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ http:
status: 200
timeout: 2000
body:
- '8.0.0'
- '7.10.0'
11 changes: 11 additions & 0 deletions apm-server/examples/upgrade/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apmConfig:
apm-server.yml: |
apm-server:
host: "0.0.0.0:8200"
queue: {}
output.file:
enabled: false
output.elasticsearch:
hosts: ["http://upgrade-master:9200"]
11 changes: 2 additions & 9 deletions elasticsearch/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@ default: test
include ../../../helpers/examples.mk

RELEASE := helm-es-upgrade
PREVIOUS_VERSION := 7.7.0

install:
helm repo add elastic https://helm.elastic.co && \
helm upgrade --wait --timeout=900s --install $(RELEASE) elastic/elasticsearch --version $(PREVIOUS_VERSION) --set clusterName=upgrade ; \
kubectl rollout status sts/upgrade-master --timeout=600s
./scripts/upgrade.sh --release $(RELEASE)

upgrade:
helm upgrade --wait --timeout=900s --set terminationGracePeriod=121 --install $(RELEASE) ../../ --set clusterName=upgrade ; \
kubectl rollout status sts/upgrade-master --timeout=600s

test: install upgrade goss
test: install goss

purge:
helm del $(RELEASE)
76 changes: 76 additions & 0 deletions elasticsearch/examples/upgrade/scripts/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash

set -euo pipefail

usage() {
cat <<-EOF
USAGE:
$0 [--release <release-name>] [--from <elasticsearch-version>]
$0 --help
OPTIONS:
--release <release-name>
Name of the Helm release to install
--from <elasticsearch-version>
Elasticsearch version to use for first install
EOF
exit 1
}

RELEASE="helm-es-upgrade"
FROM=""

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

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

if ! command -v jq > /dev/null
then
echo 'jq is required to use this script'
echo 'please check https://stedolan.github.io/jq/download/ to install it'
exit 1
fi

# Elasticsearch chart < 7.4.0 are not compatible with K8S >= 1.16)
if [[ -z $FROM ]]
then
KUBE_MINOR_VERSION=$(kubectl version -o json | jq --raw-output --exit-status '.serverVersion.minor' | sed 's/[^0-9]*//g')

if [ "$KUBE_MINOR_VERSION" -lt 16 ]
then
FROM="7.0.0-alpha1"
else
FROM="7.4.0"
fi
fi

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

# Initial install
printf "Installing Elasticsearch chart %s\n" "$FROM"
helm upgrade --wait --timeout=600s --install "$RELEASE" elastic/elasticsearch --version "$FROM" --set clusterName=upgrade
kubectl rollout status sts/upgrade-master --timeout=600s

# Upgrade
printf "Upgrading Elasticsearch chart\n"
helm upgrade --wait --timeout=600s --set terminationGracePeriod=121 --install "$RELEASE" ../../ --set clusterName=upgrade --set imageTag=7.10.0
kubectl rollout status sts/upgrade-master --timeout=600s
3 changes: 2 additions & 1 deletion elasticsearch/examples/upgrade/test/goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ http:
status: 200
timeout: 2000
body:
- '"number" : "8.0.0"'
- '"number" : "7.10.0"'
- '"cluster_name" : "upgrade"'
- '"name" : "upgrade-master-0"'
- 'You Know, for Search'
8 changes: 2 additions & 6 deletions filebeat/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ default: test
include ../../../helpers/examples.mk

RELEASE := helm-filebeat-upgrade
PREVIOUS_VERSION := 7.7.0

install:
helm upgrade --wait --timeout=900s --install $(RELEASE) --version $(PREVIOUS_VERSION)
./scripts/upgrade.sh --release $(RELEASE)

upgrade:
helm upgrade --wait --timeout=900s --install $(RELEASE) ../../

test: install upgrade goss
test: install goss

purge:
helm del $(RELEASE)
58 changes: 58 additions & 0 deletions filebeat/examples/upgrade/scripts/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash

set -euo pipefail

usage() {
cat <<-EOF
USAGE:
$0 [--release <release-name>] [--from <filebeat-version>]
$0 --help
OPTIONS:
--release <release-name>
Name of the Helm release to install
--from <filebeat-version>
filebeat version to use for first install
EOF
exit 1
}

RELEASE="helm-filebeat-upgrade"
FROM=""

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

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

FROM="7.9.0"

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

# Initial install
printf "Installing filebeat chart %s\n" "$FROM"
helm upgrade --wait --timeout=600s --install "$RELEASE" elastic/filebeat --version "$FROM" --set clusterName=upgrade --values values.yaml
kubectl rollout status ds/helm-filebeat-upgrade-filebeat --timeout=600s

# Upgrade
printf "Upgrading filebeat chart\n"
helm upgrade --wait --timeout=600s --set terminationGracePeriod=121 --install "$RELEASE" ../../ --set clusterName=upgrade --set imageTag=7.10.0 --values values.yaml
kubectl rollout status ds/helm-filebeat-upgrade-filebeat --timeout=600s
13 changes: 6 additions & 7 deletions filebeat/examples/upgrade/test/goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ port:
tcp:5066:
listening: true
ip:
- '127.0.0.1'
- "127.0.0.1"

mount:
/usr/share/filebeat/data:
Expand All @@ -25,22 +25,21 @@ user:
gid: 1000

http:
http://oss-master:9200/_cat/indices:
http://upgrade-master:9200/_cat/indices:
status: 200
timeout: 2000
body:
- 'filebeat-8.0.0'
- "filebeat-7.10.0"

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

command:
cd /usr/share/filebeat && filebeat test output:
exit-status: 0
stdout:
- 'elasticsearch: http://oss-master:9200'
- "elasticsearch: http://upgrade-master:9200"
3 changes: 3 additions & 0 deletions filebeat/examples/upgrade/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extraEnvs:
- name: ELASTICSEARCH_HOSTS
value: upgrade-master:9200
9 changes: 3 additions & 6 deletions kibana/examples/upgrade/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
default: test

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

RELEASE := helm-kibana-upgrade
PREVIOUS_VERSION := 7.7.0

install:
helm upgrade --wait --timeout=900s --install $(RELEASE) --version $(PREVIOUS_VERSION)

upgrade:
helm upgrade --wait --timeout=900s --install $(RELEASE) ../../
./scripts/upgrade.sh --release $(RELEASE)

test: install upgrade goss
test: install goss

purge:
helm del $(RELEASE)
58 changes: 58 additions & 0 deletions kibana/examples/upgrade/scripts/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash

set -euo pipefail

usage() {
cat <<-EOF
USAGE:
$0 [--release <release-name>] [--from <kibana-version>]
$0 --help
OPTIONS:
--release <release-name>
Name of the Helm release to install
--from <kibana-version>
kibana version to use for first install
EOF
exit 1
}

RELEASE="helm-kibana-upgrade"
FROM=""

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

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

FROM="7.4.0"

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

# Initial install
printf "Installing kibana chart %s\n" "$FROM"
helm upgrade --wait --timeout=600s --install "$RELEASE" elastic/kibana --version "$FROM" --set clusterName=upgrade --values values.yaml
kubectl rollout status deploy/helm-kibana-upgrade-kibana --timeout=600s

# Upgrade
printf "Upgrading kibana chart\n"
helm upgrade --wait --timeout=600s --set terminationGracePeriod=121 --install "$RELEASE" ../../ --set clusterName=upgrade --set imageTag=7.10.0 --values values.yaml
kubectl rollout status deploy/helm-kibana-upgrade-kibana --timeout=600s
Loading

0 comments on commit 7f90783

Please sign in to comment.