-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update ats tests #229
update ats tests #229
Changes from 3 commits
415a8f5
e1673fa
011b7dd
eed72c1
47576bc
91773fd
b3dd30b
4facda8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
skip-steps: smoke | ||
app-tests-app-config-file: tests/test-values.yaml | ||
app-tests-deploy-namespace: monitoring | ||
|
||
functional-tests-cluster-type: kind | ||
smoke-tests-cluster-type: kind | ||
|
||
upgrade-tests-cluster-type: kind | ||
upgrade-tests-app-catalog-url: https://giantswarm.github.io/giantswarm-catalog | ||
upgrade-tests-app-config-file: tests/test-values.yaml | ||
|
||
skip-steps: [functional] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
version: 2.1 | ||
orbs: | ||
architect: giantswarm/[email protected] | ||
jobs: | ||
template-chart: | ||
docker: | ||
- image: giantswarm/helm-chart-testing:v3.11.0 | ||
steps: | ||
- checkout | ||
- run: cd helm/grafana && helm dep up | ||
- run: helm template helm/grafana | ||
|
||
workflows: | ||
package-and-push-chart-on-tag: | ||
|
@@ -32,6 +40,25 @@ workflows: | |
tags: | ||
only: /^v.*/ | ||
|
||
- template-chart: | ||
name: "template-chart" | ||
filters: | ||
branches: | ||
ignore: | ||
- master | ||
requires: | ||
- "app-catalog" | ||
|
||
- architect/run-tests-with-ats: | ||
name: run-chart-tests-with-ats | ||
filters: | ||
# Do not trigger the job on merge to master. | ||
branches: | ||
ignore: | ||
- master | ||
requires: | ||
- "app-catalog" | ||
|
||
- architect/push-to-app-collection: | ||
context: "architect" | ||
name: aws-app-collection | ||
|
@@ -139,12 +166,3 @@ workflows: | |
ignore: /.*/ | ||
tags: | ||
only: /^v.*/ | ||
# - architect/run-tests-with-ats: | ||
# name: execute chart tests | ||
# filters: | ||
# # Do not trigger the job on merge to master. | ||
# branches: | ||
# ignore: | ||
# - master | ||
# requires: | ||
# - "package and push grafana chart" |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[pytest] | ||
markers = | ||
smoke | ||
functional | ||
upgrade |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,69 @@ | ||
from typing import cast | ||
import logging | ||
from typing import List | ||
|
||
import pykube | ||
import pytest | ||
from pytest_helm_charts.clusters import Cluster | ||
from pytest_helm_charts.k8s.deployment import wait_for_deployments_to_run | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
# when grafana pod is up, it might be still starting and returning 503 | ||
@pytest.mark.flaky(reruns=10, reruns_delay=10) | ||
@pytest.mark.functional | ||
def test_grafana_login_page_available(kube_cluster: Cluster) -> None: | ||
srv = cast(pykube.Service, pykube.Service.objects(kube_cluster.kube_client).get_or_none(name="grafana")) | ||
if srv is None: | ||
raise ValueError("'grafana service not found in the 'default' namespace") | ||
login_page_res = srv.proxy_http_get("/login") | ||
assert login_page_res.ok | ||
namespace_name = "monitoring" | ||
deployment_name= "grafana" | ||
|
||
timeout: int = 560 | ||
|
||
@pytest.mark.smoke | ||
def test_api_working(kube_cluster: Cluster) -> None: | ||
"""Very minimalistic example of using the [kube_cluster](pytest_helm_charts.fixtures.kube_cluster) | ||
fixture to get an instance of [Cluster](pytest_helm_charts.clusters.Cluster) under test | ||
and access its [kube_client](pytest_helm_charts.clusters.Cluster.kube_client) property | ||
to get access to Kubernetes API of cluster under test. | ||
Please refer to [pykube](https://pykube.readthedocs.io/en/latest/api/pykube.html) to get docs | ||
for [HTTPClient](https://pykube.readthedocs.io/en/latest/api/pykube.html#pykube.http.HTTPClient). | ||
""" | ||
assert kube_cluster.kube_client is not None | ||
assert len(pykube.Node.objects(kube_cluster.kube_client)) >= 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not absolutely necessary but still nice to make sure that the apiserver is reachable before proceeding with any further tests right ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, why not, but then that's what the comment should say. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the comment. |
||
|
||
# scope "module" means this is run only once, for the first test case requesting! It might be tricky | ||
# if you want to assert this multiple times | ||
@pytest.fixture(scope="module") | ||
def ic_deployment(kube_cluster: Cluster) -> List[pykube.Deployment]: | ||
logger.info("Waiting for grafana deployment..") | ||
|
||
deployment_ready = wait_for_ic_deployment(kube_cluster) | ||
|
||
logger.info("grafana deployment looks satisfied..") | ||
|
||
return deployment_ready | ||
|
||
def wait_for_ic_deployment(kube_cluster: Cluster) -> List[pykube.Deployment]: | ||
deployments = wait_for_deployments_to_run( | ||
kube_cluster.kube_client, | ||
[deployment_name], | ||
namespace_name, | ||
timeout, | ||
) | ||
return deployments | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def pods(kube_cluster: Cluster) -> List[pykube.Pod]: | ||
pods = pykube.Pod.objects(kube_cluster.kube_client) | ||
|
||
pods = pods.filter(namespace=namespace_name, selector={ | ||
'app.kubernetes.io/name': 'grafana', 'app.kubernetes.io/instance': 'grafana'}) | ||
|
||
return pods | ||
|
||
# when we start the tests on circleci, we have to wait for pods to be available, hence | ||
# this additional delay and retries | ||
QuantumEnigmaa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
@pytest.mark.smoke | ||
@pytest.mark.upgrade | ||
@pytest.mark.flaky(reruns=5, reruns_delay=10) | ||
def test_pods_available(ic_deployment: List[pykube.Deployment]): | ||
for s in ic_deployment: | ||
assert int(s.obj["status"]["readyReplicas"]) == int( | ||
s.obj["spec"]["replicas"]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
global: | ||
imageRegistry: gsoci.azurecr.io | ||
grafana: | ||
dashboardProviders: | ||
dashboardproviders.yaml: | ||
apiVersion: 1 | ||
providers: | ||
- allowUiUpdates: false | ||
disableDeletion: true | ||
editable: false | ||
folder: Giant Swarm private dashboards | ||
folderUid: GMtRhFeGz | ||
name: private | ||
options: | ||
path: /var/lib/grafana/dashboards/private | ||
type: file | ||
updateIntervalSeconds: 60 | ||
- allowUiUpdates: false | ||
disableDeletion: true | ||
editable: false | ||
folder: Giant Swarm public dashboards | ||
folderUid: b6utHHg7z | ||
name: public | ||
options: | ||
path: /var/lib/grafana/dashboards/public | ||
type: file | ||
updateIntervalSeconds: 60 | ||
- allowUiUpdates: false | ||
disableDeletion: true | ||
editable: false | ||
folder: Your dashboards | ||
folderUid: customerDashboards | ||
name: customer-provided | ||
options: | ||
path: /var/lib/grafana/dashboards/customer | ||
type: file | ||
updateIntervalSeconds: 60 | ||
grafana.ini: | ||
analytics: | ||
check_for_updates: false | ||
feedback_links_enabled: false | ||
reporting_enabled: false | ||
auth: | ||
disable_login_form: true | ||
disable_signout_menu: true | ||
auth.basic: | ||
enabled: true | ||
auth.generic_oauth: | ||
allow_assign_grafana_admin: true | ||
allow_sign_up: true | ||
api_url: https://dex.grizzly.gaws.gigantic.io/userinfo | ||
auth_url: https://dex.grizzly.gaws.gigantic.io/auth | ||
auto_login: true | ||
client_id: 2qRgNb5qQBk3QqWxI1WLgB5zTQ1M4eB+ | ||
enabled: true | ||
name: grafana-dex | ||
role_attribute_path: contains(groups, 'giantswarm-ad:giantswarm-admins') && | ||
'GrafanaAdmin' || contains(groups, 'customer:giantswarm:Employees') && 'Viewer' | ||
|| contains (groups, 'giantswarm-github:giantswarm:giantswarm-admins') && | ||
'GrafanaAdmin' | ||
role_attribute_strict: true | ||
scopes: openid profile email groups offline_access | ||
token_url: https://dex.grizzly.gaws.gigantic.io/token | ||
use_refresh_token: true | ||
dashboards: | ||
default_home_dashboard_path: /var/lib/grafana/dashboards/public/home/home.json | ||
public_dashboards: | ||
enabled: false | ||
security: | ||
cookie_secure: true | ||
disable_gravatar: true | ||
server: | ||
protocol: http | ||
root_url: https://grafana.grizzly.gaws.gigantic.io | ||
users: | ||
allow_org_create: false | ||
allow_sign_up: false | ||
viewers_can_edit: true | ||
image: | ||
repository: giantswarm/grafana | ||
ingress: | ||
annotations: | ||
cert-manager.io/cluster-issuer: letsencrypt-giantswarm | ||
kubernetes.io/tls-acme: "true" | ||
enabled: true | ||
hosts: | ||
- grafana.grizzly.gaws.gigantic.io | ||
ingressClassName: nginx | ||
tls: | ||
- hosts: | ||
- grafana.grizzly.gaws.gigantic.io | ||
secretName: grafana-tls | ||
rbac: | ||
pspEnabled: false | ||
serviceMonitor: | ||
enabled: true | ||
sidecar: | ||
dashboards: | ||
SCProvider: false | ||
enabled: true | ||
folder: /var/lib/grafana/dashboards | ||
label: app.giantswarm.io/kind | ||
labelValue: dashboard | ||
searchNamespace: ALL | ||
datasources: | ||
enabled: true | ||
label: app.giantswarm.io/kind | ||
labelValue: datasource | ||
resource: both | ||
searchNamespace: ALL | ||
image: | ||
repository: giantswarm/k8s-sidecar | ||
|
||
QuantumEnigmaa marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean main right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have preferred but unfortunately, this repo's "main" branch is called "master" :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it? Maybe we should change it then :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would totally agree :)