Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write a python wrapper for Shell files unit testing #83

Closed
iranzo opened this issue Aug 5, 2017 · 6 comments
Closed

Write a python wrapper for Shell files unit testing #83

iranzo opened this issue Aug 5, 2017 · 6 comments
Assignees
Projects

Comments

@iranzo
Copy link
Member

iranzo commented Aug 5, 2017

Write a wrapper plugin in tests/ that can search for .sh tests with patterns:

test_$COMPONENT_fail.sh
test_$COMPONENT_pass.sh
test_$COMPONENT_skip.sh

that take care of creating fake files in a fake folder that is passed to citellus for checking that results are expected ones

@iranzo iranzo self-assigned this Aug 5, 2017
@iranzo
Copy link
Member Author

iranzo commented Aug 8, 2017

@larsks what do you think about something like this to get some kind of unit testing for shell scripts?

@larsks
Copy link
Contributor

larsks commented Aug 8, 2017

I think some sort of testing for the plugins would be a good idea. I'm not sure about this particular scheme, though, because $COMPONENT would be hard to specify (that is, if you want to test plugins/pacemaker/stonith_enabled.sh, what is $COMPONENT?).

An alternative would be to have the test look for a directory named after the plugin, and use that as the filesystem snapshot for testing the plugin. For example, for testing plugins/pacemaker/stonith_enabled.sh, we would look for a directory tests/snapshots/pacemaker/stonith_enabled.sh_pass, and then run:

docitellus(live=False, path=`tests/snapshots/pacemaker/stonith_enabled.sh_pass`, plugins=[the_plugin])

And then assert that the plugin result is successful.

How does that sound? I am making this up as I go along, but it seems to offer a fair amount of flexibility.

@iranzo
Copy link
Member Author

iranzo commented Aug 8, 2017

My idea was to write 'test_pacemaker_fail.sh so it precreates required files so the .sh file fails (actual test)

and use 'pacemaker' as filter for the plugins to use

The second approach is also good, but puts more 'data' in the git repo while the other, creates it on the fly

@larsks
Copy link
Contributor

larsks commented Aug 8, 2017

Well, you have the same data in both cases. In my case it lives on disk in files where it can be used as is, while in your example it lives in the scripts and is written out for each test run. I guess implement a couple of tests and see how things work out.

@iranzo
Copy link
Member Author

iranzo commented Aug 17, 2017

@larsks https://review.gerrithub.io/374645 check that one

@iranzo
Copy link
Member Author

iranzo commented Aug 30, 2017

Merged as separated tests per plugin

@iranzo iranzo closed this as completed Aug 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Risu
Awaiting triage
Development

No branches or pull requests

2 participants