Recently we've been using the
saltcheck module to handle this use case. I've recently submitted a bunch of fixes and documentation improvements to make it work even better for our needs, so future releases should just work, but for now I'd suggest backporting the saltcheck module to your environment.
Saltcheck allows you to write tests for your states in a very similar yaml (or supported renderer of choice) syntax, including having access to the same pillars and grains.
For example, if you had a salt state which managed linux users where the data comes from a pillar, you could use:
# /srv/salt/users/init.sls
{% for user, uid in pillar.get('users', {}).items() %}
{{user}}:
user.present:
- uid: {{uid}}
{% endfor %}
You could then create a saltcheck-tests directory in the same location as your states, and create a users.tst file inside with the content:
# /srv/salt/users/saltcheck-tests/init.tst
{% for user, uid in pillar.get('users', {}).items() %}
check-user-{{ user }}:
args:
- {{ user }}
assertion: assertEqual
expected-return: {{ uid }}
assertion_section: uid
{% endfor %}
If your state was run with:
salt <minion-id> state.sls users
The saltcheck could be run as:
salt <minion-id> saltcheck.run_state_tests users
The cool thing is that it uses the standard salt modules to perform all the checks, so you have all the power of salt behind your tests (it's just checking the output of user.info in this case). This example validates all users defined in the pillar have been added, so it works for 1 or 100 just as easily. This also allows you to output the results as you would any other salt command, so you can use the standard human text output to view green or red success messages, or output as json for further processing.
We started using saltcheck recently to validate application deployments to hadoop clusters using the hadoop.dfs and s3 modules. Where our QA team would spend time manually checking files in various locations, this task is now accomplished in seconds with greater reliability.
Saltcheck validations can then be combined with test kitchen or Jenkins pipelines for CI, but it's also a simple to use but super powerful tool for validating state results.
Hopefully that helps!