From 1b6bcc405acf6943243229f32d4d5b3549839acd Mon Sep 17 00:00:00 2001 From: QuentinBisson Date: Thu, 19 Sep 2024 15:59:19 +0200 Subject: [PATCH] add basic tests --- .ats/main.yaml | 36 ++++ .circleci/config.yml | 67 ++++---- CHANGELOG.md | 5 + helm/sloth/Chart.yaml | 3 +- helm/sloth/values.yaml | 1 + tests/ats/Pipfile | 12 ++ tests/ats/Pipfile.lock | 359 ++++++++++++++++++++++++++++++++++++++++ tests/ats/pytest.ini | 6 + tests/ats/test_sloth.py | 140 ++++++++++++++++ tests/test-values.yaml | 0 10 files changed, 595 insertions(+), 34 deletions(-) create mode 100644 .ats/main.yaml create mode 100644 tests/ats/Pipfile create mode 100644 tests/ats/Pipfile.lock create mode 100644 tests/ats/pytest.ini create mode 100644 tests/ats/test_sloth.py create mode 100644 tests/test-values.yaml diff --git a/.ats/main.yaml b/.ats/main.yaml new file mode 100644 index 0000000..7f52e45 --- /dev/null +++ b/.ats/main.yaml @@ -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" diff --git a/.circleci/config.yml b/.circleci/config.yml index cd597bd..c259a37 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,44 +3,59 @@ version: 2.1 orbs: architect: giantswarm/architect@5.8.0 +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 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: /.*/ @@ -55,7 +70,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: /.*/ @@ -70,7 +85,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: /.*/ @@ -85,7 +100,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: /.*/ @@ -100,24 +115,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.*/() diff --git a/CHANGELOG.md b/CHANGELOG.md index 421dc49..b8e3546 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/helm/sloth/Chart.yaml b/helm/sloth/Chart.yaml index 75860e9..394b4ec 100644 --- a/helm/sloth/Chart.yaml +++ b/helm/sloth/Chart.yaml @@ -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" diff --git a/helm/sloth/values.yaml b/helm/sloth/values.yaml index 81019d6..f1c1f16 100644 --- a/helm/sloth/values.yaml +++ b/helm/sloth/values.yaml @@ -80,6 +80,7 @@ securityContext: type: RuntimeDefault container: allowPrivilegeEscalation: false + readOnlyRootFilesystem: true seccompProfile: type: RuntimeDefault capabilities: diff --git a/tests/ats/Pipfile b/tests/ats/Pipfile new file mode 100644 index 0000000..977a904 --- /dev/null +++ b/tests/ats/Pipfile @@ -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" diff --git a/tests/ats/Pipfile.lock b/tests/ats/Pipfile.lock new file mode 100644 index 0000000..c9083a5 --- /dev/null +++ b/tests/ats/Pipfile.lock @@ -0,0 +1,359 @@ +{ + "_meta": { + "hash": { + "sha256": "5773e715b0013edff328bf43351daa2cc4e94bf83adb158a3246e7f43ed206b2" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.9" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "certifi": { + "hashes": [ + "sha256:922820b53db7a7257ffbda3f597266d435245903d80737e34f8a45ff3e3230d8", + "sha256:bec941d2aa8195e248a60b31ff9f0558284cf01a52591ceda73ea9afffd69fd9" + ], + "markers": "python_version >= '3.6'", + "version": "==2024.8.30" + }, + "charset-normalizer": { + "hashes": [ + "sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027", + "sha256:06a81e93cd441c56a9b65d8e1d043daeb97a3d0856d177d5c90ba85acb3db087", + "sha256:0a55554a2fa0d408816b3b5cedf0045f4b8e1a6065aec45849de2d6f3f8e9786", + "sha256:0b2b64d2bb6d3fb9112bafa732def486049e63de9618b5843bcdd081d8144cd8", + "sha256:10955842570876604d404661fbccbc9c7e684caf432c09c715ec38fbae45ae09", + "sha256:122c7fa62b130ed55f8f285bfd56d5f4b4a5b503609d181f9ad85e55c89f4185", + "sha256:1ceae2f17a9c33cb48e3263960dc5fc8005351ee19db217e9b1bb15d28c02574", + "sha256:1d3193f4a680c64b4b6a9115943538edb896edc190f0b222e73761716519268e", + "sha256:1f79682fbe303db92bc2b1136016a38a42e835d932bab5b3b1bfcfbf0640e519", + "sha256:2127566c664442652f024c837091890cb1942c30937add288223dc895793f898", + "sha256:22afcb9f253dac0696b5a4be4a1c0f8762f8239e21b99680099abd9b2b1b2269", + "sha256:25baf083bf6f6b341f4121c2f3c548875ee6f5339300e08be3f2b2ba1721cdd3", + "sha256:2e81c7b9c8979ce92ed306c249d46894776a909505d8f5a4ba55b14206e3222f", + "sha256:3287761bc4ee9e33561a7e058c72ac0938c4f57fe49a09eae428fd88aafe7bb6", + "sha256:34d1c8da1e78d2e001f363791c98a272bb734000fcef47a491c1e3b0505657a8", + "sha256:37e55c8e51c236f95b033f6fb391d7d7970ba5fe7ff453dad675e88cf303377a", + "sha256:3d47fa203a7bd9c5b6cee4736ee84ca03b8ef23193c0d1ca99b5089f72645c73", + "sha256:3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc", + "sha256:42cb296636fcc8b0644486d15c12376cb9fa75443e00fb25de0b8602e64c1714", + "sha256:45485e01ff4d3630ec0d9617310448a8702f70e9c01906b0d0118bdf9d124cf2", + "sha256:4a78b2b446bd7c934f5dcedc588903fb2f5eec172f3d29e52a9096a43722adfc", + "sha256:4ab2fe47fae9e0f9dee8c04187ce5d09f48eabe611be8259444906793ab7cbce", + "sha256:4d0d1650369165a14e14e1e47b372cfcb31d6ab44e6e33cb2d4e57265290044d", + "sha256:549a3a73da901d5bc3ce8d24e0600d1fa85524c10287f6004fbab87672bf3e1e", + "sha256:55086ee1064215781fff39a1af09518bc9255b50d6333f2e4c74ca09fac6a8f6", + "sha256:572c3763a264ba47b3cf708a44ce965d98555f618ca42c926a9c1616d8f34269", + "sha256:573f6eac48f4769d667c4442081b1794f52919e7edada77495aaed9236d13a96", + "sha256:5b4c145409bef602a690e7cfad0a15a55c13320ff7a3ad7ca59c13bb8ba4d45d", + "sha256:6463effa3186ea09411d50efc7d85360b38d5f09b870c48e4600f63af490e56a", + "sha256:65f6f63034100ead094b8744b3b97965785388f308a64cf8d7c34f2f2e5be0c4", + "sha256:663946639d296df6a2bb2aa51b60a2454ca1cb29835324c640dafb5ff2131a77", + "sha256:6897af51655e3691ff853668779c7bad41579facacf5fd7253b0133308cf000d", + "sha256:68d1f8a9e9e37c1223b656399be5d6b448dea850bed7d0f87a8311f1ff3dabb0", + "sha256:6ac7ffc7ad6d040517be39eb591cac5ff87416c2537df6ba3cba3bae290c0fed", + "sha256:6b3251890fff30ee142c44144871185dbe13b11bab478a88887a639655be1068", + "sha256:6c4caeef8fa63d06bd437cd4bdcf3ffefe6738fb1b25951440d80dc7df8c03ac", + "sha256:6ef1d82a3af9d3eecdba2321dc1b3c238245d890843e040e41e470ffa64c3e25", + "sha256:753f10e867343b4511128c6ed8c82f7bec3bd026875576dfd88483c5c73b2fd8", + "sha256:7cd13a2e3ddeed6913a65e66e94b51d80a041145a026c27e6bb76c31a853c6ab", + "sha256:7ed9e526742851e8d5cc9e6cf41427dfc6068d4f5a3bb03659444b4cabf6bc26", + "sha256:7f04c839ed0b6b98b1a7501a002144b76c18fb1c1850c8b98d458ac269e26ed2", + "sha256:802fe99cca7457642125a8a88a084cef28ff0cf9407060f7b93dca5aa25480db", + "sha256:80402cd6ee291dcb72644d6eac93785fe2c8b9cb30893c1af5b8fdd753b9d40f", + "sha256:8465322196c8b4d7ab6d1e049e4c5cb460d0394da4a27d23cc242fbf0034b6b5", + "sha256:86216b5cee4b06df986d214f664305142d9c76df9b6512be2738aa72a2048f99", + "sha256:87d1351268731db79e0f8e745d92493ee2841c974128ef629dc518b937d9194c", + "sha256:8bdb58ff7ba23002a4c5808d608e4e6c687175724f54a5dade5fa8c67b604e4d", + "sha256:8c622a5fe39a48f78944a87d4fb8a53ee07344641b0562c540d840748571b811", + "sha256:8d756e44e94489e49571086ef83b2bb8ce311e730092d2c34ca8f7d925cb20aa", + "sha256:8f4a014bc36d3c57402e2977dada34f9c12300af536839dc38c0beab8878f38a", + "sha256:9063e24fdb1e498ab71cb7419e24622516c4a04476b17a2dab57e8baa30d6e03", + "sha256:90d558489962fd4918143277a773316e56c72da56ec7aa3dc3dbbe20fdfed15b", + "sha256:923c0c831b7cfcb071580d3f46c4baf50f174be571576556269530f4bbd79d04", + "sha256:95f2a5796329323b8f0512e09dbb7a1860c46a39da62ecb2324f116fa8fdc85c", + "sha256:96b02a3dc4381e5494fad39be677abcb5e6634bf7b4fa83a6dd3112607547001", + "sha256:9f96df6923e21816da7e0ad3fd47dd8f94b2a5ce594e00677c0013018b813458", + "sha256:a10af20b82360ab00827f916a6058451b723b4e65030c5a18577c8b2de5b3389", + "sha256:a50aebfa173e157099939b17f18600f72f84eed3049e743b68ad15bd69b6bf99", + "sha256:a981a536974bbc7a512cf44ed14938cf01030a99e9b3a06dd59578882f06f985", + "sha256:a9a8e9031d613fd2009c182b69c7b2c1ef8239a0efb1df3f7c8da66d5dd3d537", + "sha256:ae5f4161f18c61806f411a13b0310bea87f987c7d2ecdbdaad0e94eb2e404238", + "sha256:aed38f6e4fb3f5d6bf81bfa990a07806be9d83cf7bacef998ab1a9bd660a581f", + "sha256:b01b88d45a6fcb69667cd6d2f7a9aeb4bf53760d7fc536bf679ec94fe9f3ff3d", + "sha256:b261ccdec7821281dade748d088bb6e9b69e6d15b30652b74cbbac25e280b796", + "sha256:b2b0a0c0517616b6869869f8c581d4eb2dd83a4d79e0ebcb7d373ef9956aeb0a", + "sha256:b4a23f61ce87adf89be746c8a8974fe1c823c891d8f86eb218bb957c924bb143", + "sha256:bd8f7df7d12c2db9fab40bdd87a7c09b1530128315d047a086fa3ae3435cb3a8", + "sha256:beb58fe5cdb101e3a055192ac291b7a21e3b7ef4f67fa1d74e331a7f2124341c", + "sha256:c002b4ffc0be611f0d9da932eb0f704fe2602a9a949d1f738e4c34c75b0863d5", + "sha256:c083af607d2515612056a31f0a8d9e0fcb5876b7bfc0abad3ecd275bc4ebc2d5", + "sha256:c180f51afb394e165eafe4ac2936a14bee3eb10debc9d9e4db8958fe36afe711", + "sha256:c235ebd9baae02f1b77bcea61bce332cb4331dc3617d254df3323aa01ab47bd4", + "sha256:cd70574b12bb8a4d2aaa0094515df2463cb429d8536cfb6c7ce983246983e5a6", + "sha256:d0eccceffcb53201b5bfebb52600a5fb483a20b61da9dbc885f8b103cbe7598c", + "sha256:d965bba47ddeec8cd560687584e88cf699fd28f192ceb452d1d7ee807c5597b7", + "sha256:db364eca23f876da6f9e16c9da0df51aa4f104a972735574842618b8c6d999d4", + "sha256:ddbb2551d7e0102e7252db79ba445cdab71b26640817ab1e3e3648dad515003b", + "sha256:deb6be0ac38ece9ba87dea880e438f25ca3eddfac8b002a2ec3d9183a454e8ae", + "sha256:e06ed3eb3218bc64786f7db41917d4e686cc4856944f53d5bdf83a6884432e12", + "sha256:e27ad930a842b4c5eb8ac0016b0a54f5aebbe679340c26101df33424142c143c", + "sha256:e537484df0d8f426ce2afb2d0f8e1c3d0b114b83f8850e5f2fbea0e797bd82ae", + "sha256:eb00ed941194665c332bf8e078baf037d6c35d7c4f3102ea2d4f16ca94a26dc8", + "sha256:eb6904c354526e758fda7167b33005998fb68c46fbc10e013ca97f21ca5c8887", + "sha256:eb8821e09e916165e160797a6c17edda0679379a4be5c716c260e836e122f54b", + "sha256:efcb3f6676480691518c177e3b465bcddf57cea040302f9f4e6e191af91174d4", + "sha256:f27273b60488abe721a075bcca6d7f3964f9f6f067c8c4c605743023d7d3944f", + "sha256:f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5", + "sha256:fb69256e180cb6c8a894fee62b3afebae785babc1ee98b81cdf68bbca1987f33", + "sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519", + "sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561" + ], + "markers": "python_full_version >= '3.7.0'", + "version": "==3.3.2" + }, + "deprecated": { + "hashes": [ + "sha256:6fac8b097794a90302bdbb17b9b815e732d3c4720583ff1b198499d78470466c", + "sha256:e5323eb936458dccc2582dc6f9c322c852a775a27065ff2b0c4970b9d53d01b3" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.2.14" + }, + "exceptiongroup": { + "hashes": [ + "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b", + "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc" + ], + "markers": "python_version < '3.11'", + "version": "==1.2.2" + }, + "idna": { + "hashes": [ + "sha256:050b4e5baadcd44d760cedbd2b8e639f2ff89bbc7a5730fcc662954303377aac", + "sha256:d838c2c0ed6fced7693d5e8ab8e734d5f8fda53a039c0164afb0b82e771e3603" + ], + "markers": "python_version >= '3.6'", + "version": "==3.8" + }, + "iniconfig": { + "hashes": [ + "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", + "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374" + ], + "markers": "python_version >= '3.7'", + "version": "==2.0.0" + }, + "packaging": { + "hashes": [ + "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002", + "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124" + ], + "markers": "python_version >= '3.8'", + "version": "==24.1" + }, + "pluggy": { + "hashes": [ + "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1", + "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669" + ], + "markers": "python_version >= '3.8'", + "version": "==1.5.0" + }, + "pykube-ng": { + "hashes": [ + "sha256:46de8e17ed87c1a1014667d60e7d94a1f3fa2b8037b41e67d32c28b5869af35d", + "sha256:63f20f634bfcd83966edec32f892286f75dffb817a2c097434ecc039e558ec8f" + ], + "index": "pypi", + "markers": "python_version >= '3.8' and python_version < '4'", + "version": "==23.6.0" + }, + "pytest": { + "hashes": [ + "sha256:4ba08f9ae7dcf84ded419494d229b48d0903ea6407b030eaec46df5e6a73bba5", + "sha256:c132345d12ce551242c87269de812483f5bcc87cdbb4722e48487ba194f9fdce" + ], + "index": "pypi", + "markers": "python_version >= '3.8'", + "version": "==8.3.2" + }, + "pytest-helm-charts": { + "hashes": [ + "sha256:f6baddceee2541bdee5159cccadf0c9d0e04e4a80fc946a407196593d2d844a1", + "sha256:f74d4ca7513f176bc4e958100371c41bec023fce0c85747f311a2f2c09741417" + ], + "index": "pypi", + "markers": "python_full_version >= '3.8.1' and python_full_version < '4.0.0'", + "version": "==1.2.0" + }, + "pyyaml": { + "hashes": [ + "sha256:01179a4a8559ab5de078078f37e5c1a30d76bb88519906844fd7bdea1b7729ff", + "sha256:0833f8694549e586547b576dcfaba4a6b55b9e96098b36cdc7ebefe667dfed48", + "sha256:0a9a2848a5b7feac301353437eb7d5957887edbf81d56e903999a75a3d743086", + "sha256:0b69e4ce7a131fe56b7e4d770c67429700908fc0752af059838b1cfb41960e4e", + "sha256:0ffe8360bab4910ef1b9e87fb812d8bc0a308b0d0eef8c8f44e0254ab3b07133", + "sha256:11d8f3dd2b9c1207dcaf2ee0bbbfd5991f571186ec9cc78427ba5bd32afae4b5", + "sha256:17e311b6c678207928d649faa7cb0d7b4c26a0ba73d41e99c4fff6b6c3276484", + "sha256:1e2120ef853f59c7419231f3bf4e7021f1b936f6ebd222406c3b60212205d2ee", + "sha256:1f71ea527786de97d1a0cc0eacd1defc0985dcf6b3f17bb77dcfc8c34bec4dc5", + "sha256:23502f431948090f597378482b4812b0caae32c22213aecf3b55325e049a6c68", + "sha256:24471b829b3bf607e04e88d79542a9d48bb037c2267d7927a874e6c205ca7e9a", + "sha256:29717114e51c84ddfba879543fb232a6ed60086602313ca38cce623c1d62cfbf", + "sha256:2e99c6826ffa974fe6e27cdb5ed0021786b03fc98e5ee3c5bfe1fd5015f42b99", + "sha256:39693e1f8320ae4f43943590b49779ffb98acb81f788220ea932a6b6c51004d8", + "sha256:3ad2a3decf9aaba3d29c8f537ac4b243e36bef957511b4766cb0057d32b0be85", + "sha256:3b1fdb9dc17f5a7677423d508ab4f243a726dea51fa5e70992e59a7411c89d19", + "sha256:41e4e3953a79407c794916fa277a82531dd93aad34e29c2a514c2c0c5fe971cc", + "sha256:43fa96a3ca0d6b1812e01ced1044a003533c47f6ee8aca31724f78e93ccc089a", + "sha256:50187695423ffe49e2deacb8cd10510bc361faac997de9efef88badc3bb9e2d1", + "sha256:5ac9328ec4831237bec75defaf839f7d4564be1e6b25ac710bd1a96321cc8317", + "sha256:5d225db5a45f21e78dd9358e58a98702a0302f2659a3c6cd320564b75b86f47c", + "sha256:6395c297d42274772abc367baaa79683958044e5d3835486c16da75d2a694631", + "sha256:688ba32a1cffef67fd2e9398a2efebaea461578b0923624778664cc1c914db5d", + "sha256:68ccc6023a3400877818152ad9a1033e3db8625d899c72eacb5a668902e4d652", + "sha256:70b189594dbe54f75ab3a1acec5f1e3faa7e8cf2f1e08d9b561cb41b845f69d5", + "sha256:797b4f722ffa07cc8d62053e4cff1486fa6dc094105d13fea7b1de7d8bf71c9e", + "sha256:7c36280e6fb8385e520936c3cb3b8042851904eba0e58d277dca80a5cfed590b", + "sha256:7e7401d0de89a9a855c839bc697c079a4af81cf878373abd7dc625847d25cbd8", + "sha256:80bab7bfc629882493af4aa31a4cfa43a4c57c83813253626916b8c7ada83476", + "sha256:82d09873e40955485746739bcb8b4586983670466c23382c19cffecbf1fd8706", + "sha256:8388ee1976c416731879ac16da0aff3f63b286ffdd57cdeb95f3f2e085687563", + "sha256:8824b5a04a04a047e72eea5cec3bc266db09e35de6bdfe34c9436ac5ee27d237", + "sha256:8b9c7197f7cb2738065c481a0461e50ad02f18c78cd75775628afb4d7137fb3b", + "sha256:9056c1ecd25795207ad294bcf39f2db3d845767be0ea6e6a34d856f006006083", + "sha256:936d68689298c36b53b29f23c6dbb74de12b4ac12ca6cfe0e047bedceea56180", + "sha256:9b22676e8097e9e22e36d6b7bda33190d0d400f345f23d4065d48f4ca7ae0425", + "sha256:a4d3091415f010369ae4ed1fc6b79def9416358877534caf6a0fdd2146c87a3e", + "sha256:a8786accb172bd8afb8be14490a16625cbc387036876ab6ba70912730faf8e1f", + "sha256:a9f8c2e67970f13b16084e04f134610fd1d374bf477b17ec1599185cf611d725", + "sha256:bc2fa7c6b47d6bc618dd7fb02ef6fdedb1090ec036abab80d4681424b84c1183", + "sha256:c70c95198c015b85feafc136515252a261a84561b7b1d51e3384e0655ddf25ab", + "sha256:cc1c1159b3d456576af7a3e4d1ba7e6924cb39de8f67111c735f6fc832082774", + "sha256:ce826d6ef20b1bc864f0a68340c8b3287705cae2f8b4b1d932177dcc76721725", + "sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e", + "sha256:d7fded462629cfa4b685c5416b949ebad6cec74af5e2d42905d41e257e0869f5", + "sha256:d84a1718ee396f54f3a086ea0a66d8e552b2ab2017ef8b420e92edbc841c352d", + "sha256:d8e03406cac8513435335dbab54c0d385e4a49e4945d2909a581c83647ca0290", + "sha256:e10ce637b18caea04431ce14fabcf5c64a1c61ec9c56b071a4b7ca131ca52d44", + "sha256:ec031d5d2feb36d1d1a24380e4db6d43695f3748343d99434e6f5f9156aaa2ed", + "sha256:ef6107725bd54b262d6dedcc2af448a266975032bc85ef0172c5f059da6325b4", + "sha256:efdca5630322a10774e8e98e1af481aad470dd62c3170801852d752aa7a783ba", + "sha256:f753120cb8181e736c57ef7636e83f31b9c0d1722c516f7e86cf15b7aa57ff12", + "sha256:ff3824dc5261f50c9b0dfb3be22b4567a6f938ccce4587b38952d85fd9e9afe4" + ], + "markers": "python_version >= '3.8'", + "version": "==6.0.2" + }, + "requests": { + "hashes": [ + "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760", + "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6" + ], + "markers": "python_version >= '3.8'", + "version": "==2.32.3" + }, + "tomli": { + "hashes": [ + "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", + "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f" + ], + "markers": "python_version < '3.11'", + "version": "==2.0.1" + }, + "urllib3": { + "hashes": [ + "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472", + "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168" + ], + "markers": "python_version >= '3.8'", + "version": "==2.2.2" + }, + "wrapt": { + "hashes": [ + "sha256:0d2691979e93d06a95a26257adb7bfd0c93818e89b1406f5a28f36e0d8c1e1fc", + "sha256:14d7dc606219cdd7405133c713f2c218d4252f2a469003f8c46bb92d5d095d81", + "sha256:1a5db485fe2de4403f13fafdc231b0dbae5eca4359232d2efc79025527375b09", + "sha256:1acd723ee2a8826f3d53910255643e33673e1d11db84ce5880675954183ec47e", + "sha256:1ca9b6085e4f866bd584fb135a041bfc32cab916e69f714a7d1d397f8c4891ca", + "sha256:1dd50a2696ff89f57bd8847647a1c363b687d3d796dc30d4dd4a9d1689a706f0", + "sha256:2076fad65c6736184e77d7d4729b63a6d1ae0b70da4868adeec40989858eb3fb", + "sha256:2a88e6010048489cda82b1326889ec075a8c856c2e6a256072b28eaee3ccf487", + "sha256:3ebf019be5c09d400cf7b024aa52b1f3aeebeff51550d007e92c3c1c4afc2a40", + "sha256:418abb18146475c310d7a6dc71143d6f7adec5b004ac9ce08dc7a34e2babdc5c", + "sha256:43aa59eadec7890d9958748db829df269f0368521ba6dc68cc172d5d03ed8060", + "sha256:44a2754372e32ab315734c6c73b24351d06e77ffff6ae27d2ecf14cf3d229202", + "sha256:490b0ee15c1a55be9c1bd8609b8cecd60e325f0575fc98f50058eae366e01f41", + "sha256:49aac49dc4782cb04f58986e81ea0b4768e4ff197b57324dcbd7699c5dfb40b9", + "sha256:5eb404d89131ec9b4f748fa5cfb5346802e5ee8836f57d516576e61f304f3b7b", + "sha256:5f15814a33e42b04e3de432e573aa557f9f0f56458745c2074952f564c50e664", + "sha256:5f370f952971e7d17c7d1ead40e49f32345a7f7a5373571ef44d800d06b1899d", + "sha256:66027d667efe95cc4fa945af59f92c5a02c6f5bb6012bff9e60542c74c75c362", + "sha256:66dfbaa7cfa3eb707bbfcd46dab2bc6207b005cbc9caa2199bcbc81d95071a00", + "sha256:685f568fa5e627e93f3b52fda002c7ed2fa1800b50ce51f6ed1d572d8ab3e7fc", + "sha256:6906c4100a8fcbf2fa735f6059214bb13b97f75b1a61777fcf6432121ef12ef1", + "sha256:6a42cd0cfa8ffc1915aef79cb4284f6383d8a3e9dcca70c445dcfdd639d51267", + "sha256:6dcfcffe73710be01d90cae08c3e548d90932d37b39ef83969ae135d36ef3956", + "sha256:6f6eac2360f2d543cc875a0e5efd413b6cbd483cb3ad7ebf888884a6e0d2e966", + "sha256:72554a23c78a8e7aa02abbd699d129eead8b147a23c56e08d08dfc29cfdddca1", + "sha256:73870c364c11f03ed072dda68ff7aea6d2a3a5c3fe250d917a429c7432e15228", + "sha256:73aa7d98215d39b8455f103de64391cb79dfcad601701a3aa0dddacf74911d72", + "sha256:75ea7d0ee2a15733684badb16de6794894ed9c55aa5e9903260922f0482e687d", + "sha256:7bd2d7ff69a2cac767fbf7a2b206add2e9a210e57947dd7ce03e25d03d2de292", + "sha256:807cc8543a477ab7422f1120a217054f958a66ef7314f76dd9e77d3f02cdccd0", + "sha256:8e9723528b9f787dc59168369e42ae1c3b0d3fadb2f1a71de14531d321ee05b0", + "sha256:9090c9e676d5236a6948330e83cb89969f433b1943a558968f659ead07cb3b36", + "sha256:9153ed35fc5e4fa3b2fe97bddaa7cbec0ed22412b85bcdaf54aeba92ea37428c", + "sha256:9159485323798c8dc530a224bd3ffcf76659319ccc7bbd52e01e73bd0241a0c5", + "sha256:941988b89b4fd6b41c3f0bfb20e92bd23746579736b7343283297c4c8cbae68f", + "sha256:94265b00870aa407bd0cbcfd536f17ecde43b94fb8d228560a1e9d3041462d73", + "sha256:98b5e1f498a8ca1858a1cdbffb023bfd954da4e3fa2c0cb5853d40014557248b", + "sha256:9b201ae332c3637a42f02d1045e1d0cccfdc41f1f2f801dafbaa7e9b4797bfc2", + "sha256:a0ea261ce52b5952bf669684a251a66df239ec6d441ccb59ec7afa882265d593", + "sha256:a33a747400b94b6d6b8a165e4480264a64a78c8a4c734b62136062e9a248dd39", + "sha256:a452f9ca3e3267cd4d0fcf2edd0d035b1934ac2bd7e0e57ac91ad6b95c0c6389", + "sha256:a86373cf37cd7764f2201b76496aba58a52e76dedfaa698ef9e9688bfd9e41cf", + "sha256:ac83a914ebaf589b69f7d0a1277602ff494e21f4c2f743313414378f8f50a4cf", + "sha256:aefbc4cb0a54f91af643660a0a150ce2c090d3652cf4052a5397fb2de549cd89", + "sha256:b3646eefa23daeba62643a58aac816945cadc0afaf21800a1421eeba5f6cfb9c", + "sha256:b47cfad9e9bbbed2339081f4e346c93ecd7ab504299403320bf85f7f85c7d46c", + "sha256:b935ae30c6e7400022b50f8d359c03ed233d45b725cfdd299462f41ee5ffba6f", + "sha256:bb2dee3874a500de01c93d5c71415fcaef1d858370d405824783e7a8ef5db440", + "sha256:bc57efac2da352a51cc4658878a68d2b1b67dbe9d33c36cb826ca449d80a8465", + "sha256:bf5703fdeb350e36885f2875d853ce13172ae281c56e509f4e6eca049bdfb136", + "sha256:c31f72b1b6624c9d863fc095da460802f43a7c6868c5dda140f51da24fd47d7b", + "sha256:c5cd603b575ebceca7da5a3a251e69561bec509e0b46e4993e1cac402b7247b8", + "sha256:d2efee35b4b0a347e0d99d28e884dfd82797852d62fcd7ebdeee26f3ceb72cf3", + "sha256:d462f28826f4657968ae51d2181a074dfe03c200d6131690b7d65d55b0f360f8", + "sha256:d5e49454f19ef621089e204f862388d29e6e8d8b162efce05208913dde5b9ad6", + "sha256:da4813f751142436b075ed7aa012a8778aa43a99f7b36afe9b742d3ed8bdc95e", + "sha256:db2e408d983b0e61e238cf579c09ef7020560441906ca990fe8412153e3b291f", + "sha256:db98ad84a55eb09b3c32a96c576476777e87c520a34e2519d3e59c44710c002c", + "sha256:dbed418ba5c3dce92619656802cc5355cb679e58d0d89b50f116e4a9d5a9603e", + "sha256:dcdba5c86e368442528f7060039eda390cc4091bfd1dca41e8046af7c910dda8", + "sha256:decbfa2f618fa8ed81c95ee18a387ff973143c656ef800c9f24fb7e9c16054e2", + "sha256:e4fdb9275308292e880dcbeb12546df7f3e0f96c6b41197e0cf37d2826359020", + "sha256:eb1b046be06b0fce7249f1d025cd359b4b80fc1c3e24ad9eca33e0dcdb2e4a35", + "sha256:eb6e651000a19c96f452c85132811d25e9264d836951022d6e81df2fff38337d", + "sha256:ed867c42c268f876097248e05b6117a65bcd1e63b779e916fe2e33cd6fd0d3c3", + "sha256:edfad1d29c73f9b863ebe7082ae9321374ccb10879eeabc84ba3b69f2579d537", + "sha256:f2058f813d4f2b5e3a9eb2eb3faf8f1d99b81c3e51aeda4b168406443e8ba809", + "sha256:f6b2d0c6703c988d334f297aa5df18c45e97b0af3679bb75059e0e0bd8b1069d", + "sha256:f8212564d49c50eb4565e502814f694e240c55551a5f1bc841d4fcaabb0a9b8a", + "sha256:ffa565331890b90056c01db69c0fe634a776f8019c143a5ae265f9c6bc4bd6d4" + ], + "markers": "python_version >= '3.6'", + "version": "==1.16.0" + } + }, + "develop": {} +} diff --git a/tests/ats/pytest.ini b/tests/ats/pytest.ini new file mode 100644 index 0000000..8511972 --- /dev/null +++ b/tests/ats/pytest.ini @@ -0,0 +1,6 @@ +[pytest] +markers = + smoke + functional + upgrade + flaky diff --git a/tests/ats/test_sloth.py b/tests/ats/test_sloth.py new file mode 100644 index 0000000..68b22b5 --- /dev/null +++ b/tests/ats/test_sloth.py @@ -0,0 +1,140 @@ +import logging +from typing import List + +import pytest +import pykube +from pytest_helm_charts.clusters import Cluster +from pytest_helm_charts.k8s.deployment import wait_for_deployments_to_run +from pytest_helm_charts.utils import wait_for_objects_condition + +logger = logging.getLogger(__name__) + +namespace_name = "monitoring" +deployment_name = "sloth" + +timeout: int = 900 + +class PrometheusServiceLevel(pykube.objects.NamespacedAPIObject): + version = "sloth.slok.dev/v1" + endpoint = "prometheusservicelevels" + kind = "PrometheusServiceLevel" + +class PrometheusRules(pykube.objects.NamespacedAPIObject): + version = "monitoring.coreos.com/v1" + endpoint = "prometheusrules" + kind = "PrometheusRule" + +@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 sloth's deployment is present on the cluster +@pytest.fixture(scope="module") +def deployments(kube_cluster: Cluster) -> List[pykube.Deployment]: + logger.info("Waiting for sloth to be deployed..") + + deployments = wait_for_deployments(kube_cluster) + + logger.info("sloth is deployed..") + + return deployments + +def wait_for_deployments(kube_cluster: Cluster) -> List[pykube.Deployment]: + deployments = wait_for_deployments_to_run( + kube_cluster.kube_client, + [deployment_name], + namespace_name, + timeout, + ) + return (deployments) + +# when we start the tests on circleci, we have to wait for pods to be available, hence +# this additional delay and retries +# -- Checking that sloth pods are available +@pytest.mark.smoke +@pytest.mark.upgrade +@pytest.mark.flaky(reruns=5, reruns_delay=10) +def test_sloth_creates_prometheus_rules(kube_cluster: Cluster, deployments: List[pykube.Deployment]): + # loop over the list of deployments to make sure the pods are running + for d in deployments: + assert int(d.obj["status"]["readyReplicas"]) == int(d.obj["spec"]["replicas"]) + + logger.info("Creating PrometheusServiceLevel..") + name = "test-slo" + prometheusservicelevel = { + "apiVersion": "sloth.slok.dev/v1", + "kind": "PrometheusServiceLevel", + "metadata": { + "name": name, + "namespace": "monitoring", + }, + "spec": { + "labels": { + "owner": "slo", + }, + "service": "test-service", + "slos": [ + { + "alerting": { + "labels": { + "team": "slo", + }, + "name": name, + "pageAlert": { + "disable": False, + "labels": { + "team": "slo", + }, + }, + "ticketAlert": { + "disable": False, + "labels": { + "severity": "notify", + "slack_channel": "#team-slo", + }, + }, + }, + "description": "Test slo", + "name": name, + "objective": 95, + "sli": { + "events": { + "errorQuery": "avg_over_time(up{cluster_id=\"test\"}[{{.window}}]) > 80", + "totalQuery": "avg_over_time(up{cluster_id=\"test\"}[{{.window}}])", + }, + }, + }, + ], + }, + } + PrometheusServiceLevel(kube_cluster.kube_client, prometheusservicelevel).create() + logger.info("PrometheusServiceLevel created..") + logger.info("Waiting for PrometheusRules to be created..") + result = wait_for_objects_condition( + kube_cluster.kube_client, + PrometheusRules, + [name], + namespace_name, + _prometheus_rules_running, + timeout, + True, + ) + logging.info("PrometheusRule created successfully..") + logging.info(result) + assert len(result) == 1 + +def _prometheus_rules_running(rule: PrometheusRules) -> bool: + complete = ( + "metadata" in rule.obj + ) + return complete diff --git a/tests/test-values.yaml b/tests/test-values.yaml new file mode 100644 index 0000000..e69de29