From c7290b7ffefc50c6ae002546d979bfa7649c5ab6 Mon Sep 17 00:00:00 2001 From: Steve Wilkerson Date: Wed, 26 Jun 2019 09:25:47 -0500 Subject: [PATCH] Grafana: Remove tests that query API This removes the tests that query the Grafana API for checking whether the prometheus datasource has been provisioned and for checking the number of active dashboards against the number of expected dashboards determined via the chart's values.yaml. The reason for removing these is that Grafana can be configured to use data source types beyond just Prometheus and additional dashboards can be added to Grafana via the Grafana UI. In cases where dashboards are added via the Grafana UI, they are persisted in the grafana database which will cause helm test failures during upgrade scenarios. Now that we have selenium tests executed as part of the Grafana helm tests that validate Grafana is functional, these API tests add little value Change-Id: I9f20ca28e9c840fb3f4fa0707a43c9419fafa2c1 Signed-off-by: Steve Wilkerson --- grafana/templates/bin/_helm-tests.sh.tpl | 50 ------------------------ grafana/templates/configmap-bin.yaml | 2 - grafana/templates/pod-helm-tests.yaml | 28 ------------- grafana/values.yaml | 1 - 4 files changed, 81 deletions(-) delete mode 100644 grafana/templates/bin/_helm-tests.sh.tpl diff --git a/grafana/templates/bin/_helm-tests.sh.tpl b/grafana/templates/bin/_helm-tests.sh.tpl deleted file mode 100644 index 9d0a76a42..000000000 --- a/grafana/templates/bin/_helm-tests.sh.tpl +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -{{/* -Copyright 2017 The Openstack-Helm Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/}} - - -set -ex - -function check_datasource () { - echo "Verifying prometheus datasource configured" - datasource_type=$(curl -K- <<< "--user ${GF_SECURITY_ADMIN_USER}:${GF_SECURITY_ADMIN_PASSWORD}" \ - "${GRAFANA_ENDPOINT}/api/datasources" \ - | python -c "import sys, json; print json.load(sys.stdin)[0]['type']") - if [ "$datasource_type" == "prometheus" ]; - then - echo "PASS: Prometheus datasource found!"; - else - echo "FAIL: Prometheus datasource not found!"; - exit 1; - fi -} - -function check_dashboard_count () { - echo "Verifying number of configured dashboards" - dashboard_count=$(curl -K- <<< "--user ${GF_SECURITY_ADMIN_USER}:${GF_SECURITY_ADMIN_PASSWORD}" \ - "${GRAFANA_ENDPOINT}/api/admin/stats" \ - | python -c "import sys, json; print json.load(sys.stdin)['dashboards']") - if [ "$dashboard_count" == "$DASHBOARD_COUNT" ]; - then - echo "PASS: Reported number:$dashboard_count, expected number: $DASHBOARD_COUNT"; - else - echo "FAIL: Reported number:$dashboard_count, expected number: $DASHBOARD_COUNT"; - exit 1; - fi -} - -check_datasource -check_dashboard_count diff --git a/grafana/templates/configmap-bin.yaml b/grafana/templates/configmap-bin.yaml index 22e9cf7a1..775f406c2 100644 --- a/grafana/templates/configmap-bin.yaml +++ b/grafana/templates/configmap-bin.yaml @@ -28,8 +28,6 @@ data: {{ tuple "bin/_db-session-sync.py.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} image-repo-sync.sh: | {{- include "helm-toolkit.scripts.image_repo_sync" . | indent 4 }} - helm-tests.sh: | -{{ tuple "bin/_helm-tests.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} grafana.sh: | {{ tuple "bin/_grafana.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} selenium-tests.py: | diff --git a/grafana/templates/pod-helm-tests.yaml b/grafana/templates/pod-helm-tests.yaml index 74017cec9..a1049311b 100644 --- a/grafana/templates/pod-helm-tests.yaml +++ b/grafana/templates/pod-helm-tests.yaml @@ -39,34 +39,6 @@ spec: initContainers: {{ tuple $envAll "tests" list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 4 }} containers: - - name: {{.Release.Name}}-helm-tests -{{ tuple $envAll "helm_tests" | include "helm-toolkit.snippets.image" | indent 6 }} -{{ tuple $envAll $envAll.Values.pod.resources.jobs.tests | include "helm-toolkit.snippets.kubernetes_resources" | indent 6 }} -{{ dict "envAll" $envAll "application" "test" "container" "helm_tests" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 6 }} - command: - - /tmp/helm-tests.sh - env: - - name: DASHBOARD_COUNT - value: {{ $dashboardCount | quote }} - - name: GF_SECURITY_ADMIN_USER - valueFrom: - secretKeyRef: - name: grafana-admin-creds - key: GRAFANA_ADMIN_USERNAME - - name: GF_SECURITY_ADMIN_PASSWORD - valueFrom: - secretKeyRef: - name: grafana-admin-creds - key: GRAFANA_ADMIN_PASSWORD - - name: GRAFANA_ENDPOINT - value: {{ tuple "grafana" "internal" "grafana" . | include "helm-toolkit.endpoints.host_and_port_endpoint_uri_lookup" }} - volumeMounts: - - name: pod-tmp - mountPath: /tmp - - name: grafana-bin - mountPath: /tmp/helm-tests.sh - subPath: helm-tests.sh - readOnly: true - name: {{.Release.Name}}-selenium-tests {{ tuple $envAll "selenium_tests" | include "helm-toolkit.snippets.image" | indent 6 }} {{ tuple $envAll $envAll.Values.pod.resources.jobs.tests | include "helm-toolkit.snippets.kubernetes_resources" | indent 6 }} diff --git a/grafana/values.yaml b/grafana/values.yaml index 5a19d18a3..283d9e8c4 100644 --- a/grafana/values.yaml +++ b/grafana/values.yaml @@ -22,7 +22,6 @@ images: dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.3.1 db_init: docker.io/openstackhelm/heat:newton-ubuntu_xenial grafana_db_session_sync: docker.io/openstackhelm/heat:newton-ubuntu_xenial - helm_tests: docker.io/openstackhelm/heat:newton-ubuntu_xenial selenium_tests: docker.io/openstackhelm/osh-selenium:latest-ubuntu_xenial image_repo_sync: docker.io/docker:17.07.0 pull_policy: IfNotPresent