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

Unit testing using Bach [kibana.sh] #1182

Merged
merged 7 commits into from
Jan 19, 2022

Conversation

verdx
Copy link
Contributor

@verdx verdx commented Jan 19, 2022

closes #1181

Description

Used https://bach.sh/ to create unit tests for each function. In the directory tests/unattended there is a file called test-{script-name}.sh for each script in unattended installer. Inside that file are defined the unit tests for each function of {script-name}.sh. To call them we use the auxiliary script unit-test.sh, which creates a docker environment in which to run the tests.

Example of output:

[verdx@verdx unit]$ bash unit-tests.sh -f kibana
19/01/2022 14:49:33 INFO: Docker image found.
19/01/2022 14:49:33 INFO: Unit tests for kibana.sh.
1..20
ok 1 - installKibana zypper
ok 2 - configureKibana dist two kibana nodes two elastic nodes
ok 3 - ASSERT FAIL installKibana zypper error
ok 4 - ASSERT FAIL configureKibana dist error downloading plugin
ok 5 - installKibana apt
ok 6 - ASSERT FAIL installKibana apt error
ok 7 - ASSERT FAIL initializeKibana distributed one kibana node one wazuh node curl error
ok 8 - initializeKibana distributed two kibana nodes two wazuh nodes curl correct
ok 9 - initializeKibana distributed one kibana node one wazuh node curl correct
ok 10 - ASSERT FAIL initializeKibana distributed two kibana nodes two wazuh nodes curl error
ok 11 - configureKibana AIO
ok 12 - modifyKibanaLogin
ok 13 - ASSERT FAIL installKibana yum error
ok 14 - ASSERT FAIL configureKibanaAIO error downloading plugin
ok 15 - copyKibanacerts
ok 16 - configureKibana dist one kibana node one elastic node
ok 17 - ASSERT FAIL initializeKibanaAIO curl error
ok 18 - ASSERT FAIL copyKibanacerts no tarfile
ok 19 - installKibana yum
ok 20 - initializeKibanaAIO curl correct
# -----
# All tests: 20, failed: 0, skipped: 0
19/01/2022 14:49:39 INFO: All unit tests for the functions in kibana.sh finished.
19/01/2022 14:49:39 INFO: Cleaning temporary files.
[verdx@verdx unit]$ 

@alberpilot alberpilot merged commit d555806 into unify-unattended Jan 19, 2022
@alberpilot alberpilot deleted the unify-unit-testing-kibana branch January 19, 2022 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants