Skip to content

Commit

Permalink
Add basic tests for sloth (#116)
Browse files Browse the repository at this point in the history
* add basic tests

* Update tests/ats/test_sloth.py

* Update tests/ats/test_sloth.py
  • Loading branch information
QuentinBisson authored Sep 23, 2024
1 parent a086a9e commit fb745c6
Show file tree
Hide file tree
Showing 11 changed files with 608 additions and 35 deletions.
36 changes: 36 additions & 0 deletions .ats/main.yaml
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: monitoring

smoke-tests-cluster-type: kind

upgrade-tests-cluster-type: kind
upgrade-tests-app-catalog-url: https://giantswarm.github.io/control-plane-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"
70 changes: 37 additions & 33 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,62 @@ 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/sloth
helm dep up
helm template .
workflows:
build:
jobs:
- template-chart:
name: "template-chart-test"
filters:
branches:
ignore:
- main

# Ensure that for every commit to master and for every
# release tag, there is an app version in the catalog.
- architect/push-to-app-catalog:
context: architect
name: push-sloth-app-to-control-plane-catalog-master
executor: app-build-suite
name: package-and-push-chart
app_catalog: "control-plane-catalog"
app_catalog_test: "control-plane-test-catalog"
chart: "sloth"
persist_chart_archive: true
filters:
tags:
only: /^v.*/
- architect/push-to-app-collection:
name: aws-app-collection
context: "architect"
app_catalog: control-plane-catalog
app_name: "sloth"
app_namespace: monitoring
app_collection_repo: "aws-app-collection"

- architect/run-tests-with-ats:
name: run-tests-with-ats
## TODO Remove once new architect orb is released
app-test-suite_version: "v0.8.0"
app-test-suite_container_tag: "0.8.0"
requires:
- push-sloth-app-to-control-plane-catalog-master
- "package-and-push-chart"
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
ignore:
- main

- architect/push-to-app-collection:
name: azure-app-collection
name: aws-app-collection
context: "architect"
app_catalog: control-plane-catalog
app_name: "sloth"
app_namespace: monitoring
app_collection_repo: "azure-app-collection"
app_collection_repo: "aws-app-collection"
requires:
- push-sloth-app-to-control-plane-catalog-master
- run-tests-with-ats
filters:
branches:
ignore: /.*/
Expand All @@ -55,7 +73,7 @@ workflows:
app_namespace: monitoring
app_collection_repo: "vsphere-app-collection"
requires:
- push-sloth-app-to-control-plane-catalog-master
- run-tests-with-ats
filters:
branches:
ignore: /.*/
Expand All @@ -70,7 +88,7 @@ workflows:
app_namespace: monitoring
app_collection_repo: "cloud-director-app-collection"
requires:
- push-sloth-app-to-control-plane-catalog-master
- run-tests-with-ats
filters:
branches:
ignore: /.*/
Expand All @@ -85,7 +103,7 @@ workflows:
app_namespace: monitoring
app_collection_repo: "capa-app-collection"
requires:
- push-sloth-app-to-control-plane-catalog-master
- run-tests-with-ats
filters:
branches:
ignore: /.*/
Expand All @@ -100,24 +118,10 @@ workflows:
app_namespace: monitoring
app_collection_repo: "capz-app-collection"
requires:
- push-sloth-app-to-control-plane-catalog-master
- run-tests-with-ats
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/

- architect/push-to-app-collection:
context: architect
name: push-to-gcp-app-collection
app_catalog: control-plane-catalog
app_name: "sloth"
app_namespace: monitoring
app_collection_repo: "gcp-app-collection"
requires:
- push-sloth-app-to-control-plane-catalog-master
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/()
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project's packages adheres to [Semantic Versioning](http://semver.org/s

## [Unreleased]

### Added

- Add helm chart templating test in ci pipeline.
- Add tests with ats in ci pipeline.

## [1.4.5] - 2024-06-12

### Changed
Expand Down
3 changes: 2 additions & 1 deletion helm/sloth/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
apiVersion: v2
name: sloth
description: Base chart for Sloth.
icon: https://s.giantswarm.io/app-icons/sloth/1/light-icon.svg
type: application
home: https://github.com/slok/sloth
kubeVersion: ">= 1.19.0-0"
version: [[ .Version ]]
version: 1.4.5
annotations:
application.giantswarm.io/team: "atlas"
7 changes: 6 additions & 1 deletion helm/sloth/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ spec:
- name: sloth-common-sli-plugins
# Default path for git-sync.
mountPath: /git
- name: tmp
# Default path for git files to be created.
mountPath: /tmp
{{- with .Values.securityContext.container }}
securityContext:
{{- toYaml . | nindent 12 }}
Expand All @@ -109,10 +112,12 @@ spec:
{{- end }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
{{ include "sloth.imagePullSecrets" . | trim | indent 8 }}
{{ include "sloth.imagePullSecrets" . | trim | nindent 8 }}
{{- end }}
{{- if or .Values.commonPlugins.enabled .Values.customSloConfig.enabled }}
volumes:
- name: tmp
emptyDir: {}
{{- if .Values.commonPlugins.enabled }}
- name: sloth-common-sli-plugins
emptyDir: {}
Expand Down
1 change: 1 addition & 0 deletions helm/sloth/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ securityContext:
type: RuntimeDefault
container:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
seccompProfile:
type: RuntimeDefault
capabilities:
Expand Down
12 changes: 12 additions & 0 deletions tests/ats/Pipfile
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"
Loading

0 comments on commit fb745c6

Please sign in to comment.