Basic testing workflow for CI/CD of project.
Supported environment variables:
- EDEN_TEST_SETUP -- "y" performs the EDEN setup steps ("y" by default);
- EDEN_TEST_STOP -- "y" stops EDEN after tests ("n" by default);
- EDEN_TEST -- flavour of test set: "small", "medium"(default) and "large";
- EDEN_TEST_USB_PT -- "y" enables USB Passthrough test (disabled by default).
- EDEN_TEST_AUDIO_PT -- "y" enables AUDIO Passthrough test (disabled by default).
Example of running:
EDEN_TEST_SETUP=n EDEN_TEST_STOP=y EDEN_TEST_USB_PT=y EDEN_TEST=large eden test tests/workflow/ -v debug
Each testset or individual test should contain:
- A makefile that builds the test
- A template eden-config.tmpl. A template contains the nessesary information about binaries, config of the environment where the test runs, test scenario
- A test scenario file named eden..tests.txt A scenario can contain one or more tests. A scenario allows to run bash scripts, escripts and go binaries
Test may contain
- Go files
- Escript files in ./testdata catalogue
To run the test use eden test ./tests/<testfolder>
Should have the following targets:
- clean
- test
- build
- setup
- help
build happens whenever one calls make build
in the eden directory
clean happens whenever one calls make clean
or eden clean
in the eden directory
Example
eden:
#test binary
test-bin: "eden.escript.test"
#test scenario
test-scenario: "eden.workflow.tests.txt"
test:
controller: adam://{{EdenConfig "adam.ip"}}:{{EdenConfig "adam.port"}}
eve:
{{EdenConfig "eve.name"}}:
onboard-cert: {{EdenConfigPath "eve.cert"}}
serial: "{{EdenConfig "eve.serial"}}"
model: {{EdenConfig "eve.devmodel"}}
A template file contains 2 sections: eden and test
Eden section specifies the name of the test and the scenario. The scenario is the file that is presented in the test root directory and that will be executed line-by-line by escript interpreter. Escript interpreter can be considered as an extended version of bash interpreter + some additional features. It is described in https://github.com/lf-edge/eden/blob/master/tests/escript/ESCRIPTS.md
Test section describes the environment required for the test. This data goes to config that the test sends to eve It is recommended to use parameters from EdenConfig which is the current config file.
A scenario runs one or more binaries or escripts. A scenario is also processed by escript. Using scenario one can create a set of test runs or sequentially execute smaller tests.
An example of test scenario is:
#Set up a variable
{{$tests := 4}}
# Print the line "Eden setup 1/4" Uses echo command
/bin/echo Eden setup (1/{{$tests}})
# Runs the escript ./testdata/eden_setup.txt
eden.escript.test -test.run TestEdenScripts/eden_setup
/bin/echo Eden start (2/{{$tests}})
eden.escript.test -test.run TestEdenScripts/eden_start
/bin/echo Eden onboard (3/{{$tests}})
eden.escript.test -test.run TestEdenScripts/eden_onboard
/bin/echo Eden Log test (4/{{$tests}})
# Runs the escript ../lim/testdata/log_test.txt As it is from the other test folder we need -testdata parameter
eden.escript.test -test.run TestEdenScripts/log_test -testdata ../lim/testdata/
Containes escript tests (consider as individual tests) They can be also called from another scenario. Note that environment(template) will be used from calling test
The predefined workflow test script supports the EDEN_TEST environment variable for setting of test variants:
- The default variant without setting the 'EDEN_TEST' variable -- optimized for the usual test suite of CI / CD tasks. You need to reset/clean
eden
before running. - Variant 'small' -- optimized for quick testing of coomon development workflow. No cleaning and reinitialization required between test cycles.
- Variant 'large' -- complete set of tests for full testing. You need to reset/clean
eden
before running.
The test variant can be selected at runtime by setting the environment variable:
EDEN_TEST=small eden test tests/workflow/
or by chosing of autogenerated by eden
template machinery workflow scenario:
workflow.default.txt
workflow.small.txt
workflow.large.txt
For example:
eden test tests/workflow/ -s workflow.large