Conversation
…sing test
```
$ ./bash_unit test_read_configs.sh
Running tests in test_read_configs.sh
Running test_simple_all_conf_dirs_content ... SUCCESS ✓
Overall result: SUCCESS ✓
```
…gs.include.sh for ease of testing
Had to change test PWD to same as COMPOSE_DIR to be able to discover all
component/config/*/docker-compose-extra.yml.
```
$ ./bash_unit test_read_configs.sh
Running tests in test_read_configs.sh
Running test_simple_all_conf_dirs ... SUCCESS ✓
Running test_simple_compose_conf_list ... SUCCESS ✓
Overall result: SUCCESS ✓
```
…nstead of calling directly `bump2version` To harmonize with section "Tagging Policy" right above.
E2E Test ResultsDACCS-iac Pipeline ResultsBuild URL : http://daccs-jenkins.crim.ca:80/job/DACCS-iac-birdhouse/1386/Result : failure BIRDHOUSE_DEPLOY_BRANCH : add-test-for-component-load-order DACCS_CONFIGS_BRANCH : master PAVICS_E2E_WORKFLOW_TESTS_BRANCH : master PAVICS_SDI_BRANCH : master DESTROY_INFRA_ON_EXIT : true PAVICS_HOST : https://host-140-67.rdext.crim.ca PAVICS-e2e-workflow-tests Pipeline ResultsTests URL : http://daccs-jenkins.crim.ca:80/job/PAVICS-e2e-workflow-tests/job/master/1037/NOTEBOOK TEST RESULTS |
There was a problem hiding this comment.
I'd suggest defining a requirements file with pytest + pytest-shell-utilities.
Then, it is easier to extend advanced tests and checks with everything pytest supports natively (filtering by markers, collect, report statistics, output, colors, etc.), without worrying about parsing sh specific calls. It also allows us to combine test suites in a language agnostic manner (run python test + bash tests at the same time).
import os
import pytest
from pytestshellutils.shell import Subprocess
CUR_DIR = os.path.abspath(os.path.dirname(__file__))
ROOT_DIR = os.path.dirname(os.path.dirname(CUR_DIR))
@pytest.mark.functional
@pytest.mark.shell
def test_something(shell: Subprocess) -> None:
env = {"SOME_VAR": ""}
ret = shell.run("run-some-script.sh", "[param1]", env=env, cwd=ROOT_DIR)
assert ret.returncode == 0
assert ret.stderr == ""
assert "expected output" in ret.stdout
lines = ret.stdout.splitlines()
assert len(lines) == 123
assert lines[-1] == "expected last line"Consider adding the test suite in some .github/workflows/tests.yml definition to auto-validate it each time.
| ./config/postgres | ||
|
|
||
| ./config/wps_outputs-volume | ||
|
|
||
| ./config/data-volume |
There was a problem hiding this comment.
Should be before the proxy and the birds since they depend on these?
There was a problem hiding this comment.
Yes that should hopefully be fixed if my suggested algo change does what I think it does.
@fmigneault Note we do not want to test the entire I see "platform code" as |
|
@tlvu I agree we should focus on minimal tests without booting the stack here. We can add more or less items to that test suite as we encounter new problems or add new features. |
@fmigneault
I still have an issue, I had to factor out the @mishaschwartz anything you would like to change before merging this into your PR and we will have tests for your PR. |
|
I agree with @fmigneault that pytest is the better option and should replace bash_unit. I have taken your the tests from this PR and I'm adapting them into pytests which I will include in #304. I'm mostly done but I won't have time to finish up the tests fully by the end of the day. I'll likely be pushing the changes to the load-components-in-defined-order branch tomorrow morning. Also... writing the tests have already helped me fix some bugs in the algorithm! Thanks for suggesting these and writing the first drafts! |
This PR should merge to @mishaschwartz PR #304.
Proper component load order is a core feature allowing the user to customize all default behavior of the stack. This is worth to have tests to prevent accidental regressions.
Currently I made the tests passed with the current wrong load order that should be fixed.
Running the tests look like this:
The test framework is from https://github.com/pgrange/bash_unit/blob/master/bash_unit.
I also looked at https://github.com/bats-core/bats-core, which seems more popular but also more complex to use and setup. bash_unit is one single file to add while bats-core requires multiple git submodules! KISS for the win.
In order to test the
COMPOSE_CONF_LIST, I had to move its logic toread-configs.include.inc. Probably the wrong location and a better location is a brand new.include.incfile. Name suggestion?I also updated the "Release Instructions" in the README to use
make bump major|minor|patchcommand instead of directly callingbump2versionto harmonize with the section "Tagging policy" right above.