Hey folks, 
I've written a little utility to help us test Helm charts.  It is a CLI 
that backs onto Mocha (a popular test framework) and allows you to write 
assertions on the result of a `helm template`.  It's helped me massively 
when working on helm charts which contain logic, as a programmer it felt 
like I was coding without tests and that freaked me out!

I'm posting it here as I'd really like some feedback from other helm users, 
you can install it with `npm install -g helm-test`, or check out the GitHub 
page: https://github.com/Stono/helm-test

You simply put a `tests/configmaps.js` file that looks something like this:

'use strict';
describe('Config Map', () => {
  before(done => {
    helm
    .withValueFile('tests/configmap/values.yaml')
    .go(done);
  });

  describe('Manifest', () => {
    let map;
    before(() => {
      map = results.ofType('ConfigMap')[0];
    });
    it('should be apiVersion 1', () => {
      map.apiVersion.should.eql('v1');
    });
    it('should have standard labels', () => {
      map.metadata.labels.should.eql({
        app: 'your-web-app',
        version: '1',
        heritage: 'Tiller',
        release: 'RELEASE-NAME',
        chart: 'helm-your-web-app-0.1.0'
      });
    });
    it('should have valid metadata', () => {
      map.metadata.name.should.eql('your-web-app');
    });
    it('should have a docker-host key', () => {
      map.data['some-key'].should.eql('some-value');
    });
  });
});

And then run helm-test from the command line:

❯ helm-test
  helm-test [info] Welcome to helm-test v0.1.13! +0ms
  helm-test [info] Testing... +0ms


  Config Map
    ✓ should have one manifest
    Manifest
      ✓ should be apiVersion 1
      ✓ should have standard labels
      ✓ should have valid metadata
      ✓ should have a docker-host key

  Deployment
    Manifest
      Stateful
        ✓ should have standard labels
        ✓ should have version metadata
        ✓ should have valid metadata.name
        ✓ should have configured replicas
        ✓ should have a selector that matches the template
        ✓ should be the correct api vers
        ✓ should have the istio init containers
        ✓ should have a serviceName
        ✓ should have a rollingUpdate strategy
        ✓ should have a volumeClaimTemplate
        ✓ should have volume mounts
        Disruption Budget
          ✓ should have a pod disruption budget
          ✓ name should be suffixed with pdb
          ✓ should target the right selector
          ✓ should have standard labels
        Container
          ✓ should be be called master
          ✓ should always pull the image
          ✓ should have the right image

Hope you like
Ta
Karl

-- 
You received this message because you are subscribed to the Google Groups 
"Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to kubernetes-users+unsubscr...@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to