stackstorm-k8s icon indicating copy to clipboard operation
stackstorm-k8s copied to clipboard

Helm chart Unit Tests

Open arm4b opened this issue 7 years ago • 3 comments

Apart of Helm Chart Integration Testing in #27 which could be ran only against real K8s cluster and deployed release, consider adding Unit Tests for smaller item checks which is available as a Helm plugin: ~https://github.com/lrills/helm-unittest~ https://github.com/quintush/helm-unittest

arm4b avatar Oct 09 '18 19:10 arm4b

Though not a unittest, I just experimented with using https://github.com/bats-core/bats-detik to have the inegration tests query k8s to ensure things are setup correctly. Seems to work ok.

cognifloyd avatar Dec 30 '21 20:12 cognifloyd

I looked into the helm-unittest plugin. There are a chain of repos where one person and then another is maintaining it. And I don't relish writing unit tests in YAML even though everything else is in YAML.

Looking farther, it looks like the airflow folks pioneered using pytest to unit test helm charts instead of using helm-unittest: https://github.com/helm-unittest/helm-unittest/issues/110

Luckily airflow (and in particular the helm chart + tests) is Apache 2.0 licensed. So, we could use this utility file and start writing pytest-style unit tests. https://github.com/apache/airflow/blob/main/chart/tests/helm_template_generator.py

cognifloyd avatar Feb 16 '22 00:02 cognifloyd

I've added a bunch of tests in #288.

Other tests that I think would be good (I'm listing values) in no particular order:

  • [x] env and envFromSecrets
    • st2*.env and jobs.env
    • st2actionrunner.envFromSecrets,
    • st2sensorcontainer.envFromSecrets,
    • st2client.envFromSecrets,
    • and jobs.envFromSecrets
  • [ ] st2*.extra_volumes (all except st2chatops have it)
  • [x] st2.packs.volumes
  • [ ] st2chatops
    • st2chatops.enabled
    • st2chatops.env (some special handling of api key var)
    • st2chatops.hubotScriptsVolume
  • [ ] config
    • st2.config
    • st2client.st2clientConfig
    • jobs.st2clientConfig
  • [ ] HTTPS in st2web (st2web.env.ST2WEB_HTTPS and st2web.extra_volumes)
  • [ ] image
    • image.repository
    • image.tag
    • st2*.image.tag and jobs.image.tag
  • [ ] st2*.replicas (some things can only ever have 1, others can have multiple...)
  • [ ] st2 security
    • st2.username and st2.password
    • st2.system_user.user and st2.system_user.ssh_key_file
  • [ ] st2.datastore_crypto_key
  • [ ] st2.rbac
  • [ ] st2.packs.configs
  • [ ] st2.packs.images
  • [x] st2.packs.sensors
  • [ ] jobs.preRegisterContentCommand
  • [ ] jobs.skip
  • anything to do with external charts

Help wanted!

cognifloyd avatar Feb 23 '22 08:02 cognifloyd