generated from giantswarm/template-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cbac966
commit 9deb030
Showing
8 changed files
with
518 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
app-tests-app-config-file: tests/test-values.yaml | ||
app-tests-deploy-namespace: kube-system | ||
|
||
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] | ||
|
||
# -------- | ||
# Uncomment values below this line to be able to execute app-test-suite against an externally created | ||
# Kubernetes cluster. | ||
# Comment out everything above | ||
|
||
# If you want to create a kind cluster, use the line below | ||
# kind create cluster --config tests/kind-config.yaml --kubeconfig kube.config | ||
# -------- | ||
|
||
# app-tests-app-config-file: tests/test-values.yaml | ||
# app-tests-deploy-namespace: loki | ||
|
||
# upgrade-tests-app-catalog-url: https://giantswarm.github.io/giantswarm-catalog | ||
# upgrade-tests-app-config-file: tests/test-values.yaml | ||
|
||
# skip-steps: [functional, upgrade] | ||
|
||
# smoke-tests-cluster-type: external | ||
# functional-tests-cluster-type: external | ||
# upgrade-tests-cluster-type: external | ||
# external-cluster-kubeconfig-path: kube.config | ||
# external-cluster-type: kind | ||
# external-cluster-version: 1.24.0 | ||
|
||
# app-tests-skip-app-delete: "Yes" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,18 +2,46 @@ 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/alloy | ||
helm dep up | ||
helm template . | ||
workflows: | ||
package-and-push-chart-on-tag: | ||
jobs: | ||
- template-chart: | ||
name: "template-chart-test" | ||
filters: | ||
branches: | ||
ignore: | ||
- main | ||
|
||
- architect/push-to-app-catalog: | ||
context: architect | ||
executor: app-build-suite | ||
name: package-and-push-chart | ||
app_catalog: giantswarm-catalog | ||
app_catalog_test: giantswarm-test-catalog | ||
chart: "alloy" | ||
persist_chart_archive: true | ||
ct_config: ".circleci/ct-config.yaml" | ||
# Trigger job on git tag. | ||
filters: | ||
tags: | ||
only: /^v.*/ | ||
|
||
- architect/run-tests-with-ats: | ||
name: run-tests-with-ats | ||
requires: | ||
- "package-and-push-chart" | ||
filters: | ||
branches: | ||
ignore: | ||
- main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[[source]] | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[packages] | ||
pytest-helm-charts = ">=1.0.2" | ||
pytest = ">=6.2.5" | ||
pykube-ng = ">=22.1.0" | ||
|
||
[requires] | ||
python_version = "3.9" |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[pytest] | ||
markers = | ||
smoke | ||
functional | ||
upgrade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
alloy: | ||
alloy: | ||
controller: | ||
type: statefulset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import logging | ||
from typing import List, Tuple | ||
|
||
import pytest | ||
import pykube | ||
from pytest_helm_charts.clusters import Cluster | ||
from pytest_helm_charts.k8s.stateful_set import wait_for_stateful_sets_to_run | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
namespace_name = "kube-system" | ||
statefulset_name = "alloy" | ||
|
||
timeout: int = 900 | ||
|
||
@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 | ||
|
||
# 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 | ||
# -- Checking that mimir's statefulset is present on the cluster | ||
@pytest.fixture(scope="module") | ||
def components(kube_cluster: Cluster) -> List[pykube.StatefulSet]: | ||
logger.info("Waiting for alloy statefulset component to be deployed..") | ||
|
||
components_ready = wait_for_components(kube_cluster) | ||
|
||
logger.info("alloy component are deployed..") | ||
|
||
return components_ready | ||
|
||
def wait_for_components(kube_cluster: Cluster) -> List[pykube.StatefulSet]: | ||
statefulsets = wait_for_stateful_sets_to_run( | ||
kube_cluster.kube_client, | ||
[statefulset_name], | ||
namespace_name, | ||
timeout, | ||
) | ||
return (statefulsets) | ||
|
||
@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': 'alloy', 'app.kubernetes.io/instance': 'alloy'}) | ||
|
||
return pods | ||
|
||
# when we start the tests on circleci, we have to wait for pods to be available, hence | ||
# this additional delay and retries | ||
# -- Checking that all pods from alloy's statefulset are available (i.e in "Ready" state) | ||
@pytest.mark.smoke | ||
@pytest.mark.upgrade | ||
@pytest.mark.flaky(reruns=5, reruns_delay=10) | ||
def test_pods_available(components: List[pykube.StatefulSet]): | ||
# loop over the list of deployments | ||
for d in components: | ||
assert int(d.obj["status"]["readyReplicas"]) == int(d.obj["spec"]["replicas"]) |