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 [filebeat.sh] #1180

Merged
merged 5 commits into from
Jan 19, 2022

Conversation

verdx
Copy link
Contributor

@verdx verdx commented Jan 19, 2022

closes #1179

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 filebeat
19/01/2022 12:20:11 INFO: Docker image found.
19/01/2022 12:20:11 INFO: Unit tests for filebeat.sh.
1..14
ok 1 - installFilebeat yum
ok 2 - ASSERT FAIL installFilebeat yum error
ok 3 - ASSERT FAIL installFilebeat zypper error
ok 4 - configureFilebeat one elastic node
ok 5 - installFilebeat zypper
ok 6 - copyCertificatesFilebeat distributed
ok 7 - ASSERT FAIL copyCertificatesFilebeat no tarfile
ok 8 - configureFilebeat more than one elastic node
ok 9 - configureFilebeatAIO no previous variables
ok 10 - copyCertificatesFilebeat AIO
ok 11 - ASSERT FAIL installFilebeat apt error
ok 12 - installFilebeat apt
ok 13 - configureFilebeat no previous variables
ok 14 - configureFilebeatAIO
# -----
# All tests: 14, failed: 0, skipped: 0
19/01/2022 12:20:15 INFO: All unit tests for the functions in filebeat.sh finished.
19/01/2022 12:20:15 INFO: Cleaning temporary files.
[verdx@verdx unit]$ 

@verdx verdx self-assigned this Jan 19, 2022
@verdx verdx requested review from DFolchA and alberpilot January 19, 2022 11:21
@verdx verdx marked this pull request as ready for review January 19, 2022 11:21
@alberpilot alberpilot merged commit 2332554 into unify-unattended Jan 19, 2022
@alberpilot alberpilot deleted the unify-unit-testing-filebeat branch January 19, 2022 15:11
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