Home > Software design >  Helm unittest works on my machine but not in github action for parent helm chart. dependent charts w
Helm unittest works on my machine but not in github action for parent helm chart. dependent charts w

Time:11-18

I have the following chart hierarchy

Main

  • alpha
  • beta
  • gamma
  • delta
  • epsilon

Main is the parent chart and the above 5 are dependent subcharts

helm test plugin

I am able to run helm unittest on my MacBook

yash@yash charts % helm unittest --helm3 charts/main
 PASS  Testing commands charts/main/tests/temp_test.yaml

Charts:      1 passed, 1 total
Test Suites: 1 passed, 1 total
Tests:       3 passed, 3 total
Snapshot:    0 passed, 0 total
Time:        78.808291ms

Github action run

 helm unittest --helm3 ./charts/main
  shell: /usr/bin/bash -e {0}
### Chart [ main ] ./charts/main

 FAIL  Testing install commands charts/main/tests/readme_command_test.yaml
    - check Readme install command under "alpha" example

        - asserts[0] `equal` fail
            Error:
                template "main/charts/alpha/templates/secrets.yaml" not exists or not selected in test suite

        - asserts[1] `matchRegex` fail
            Error:
                template "main/charts/alpha/templates/configmap.yaml" not exists or not selected in test suite

        - asserts[2] `matchRegex` fail
            Error:
                template "main/charts/alpha/templates/configmap.yaml" not exists or not selected in test suite

        - asserts[3] `contains` fail
            Error:
                template "main/charts/alpha/templates/daemonset.yaml" not exists or not selected in test suite

    - check Readme install command under "beta" example

        - asserts[0] `equal` fail
            Error:
                template "main/charts/beta/templates/secrets.yaml" not exists or not selected in test suite

        - asserts[1] `equal` fail
            Error:
                template "main/charts/beta/templates/configmap-benchmark-runner.yaml" not exists or not selected in test suite

    - check Readme install command under "gamma" example

        - asserts[0] `equal` fail
            Error:
                template "main/charts/gamma/templates/secrets.yaml" not exists or not selected in test suite

        - asserts[1] `equal` fail
            Error:
                template "main/charts/gamma/templates/secrets.yaml" not exists or not selected in test suite


Charts:      1 failed, 0 passed, 1 total
Test Suites: 1 failed, 0 passed, 1 total
Tests:       3 failed, 0 passed, 3 total
Snapshot:    0 passed, 0 total
Time:        5.984704ms

Error: plugin "unittest" exited with error
Error: Process completed with exit code 1.

The tests on the sub-charts alpha to epsilon work fine both on the MacBook and the GitHub action.

I also checked .gitignore and .helmignore but couldn't find anything that would be causing this over there.

CodePudding user response:

The parent chart needed a helm dependency update

helm dep update charts/main

made the same modification in github actions and it was working well.

      - name: Update dependencies for main
        run: helm dep update charts/main

      - name: Test node-analyzer
        run: helm unittest --helm3 ./charts/main

My assumption is that the reason why it was working before locally is that at some point I must have done a dependency update and so the tests were working as expected.

  • Related