-
Notifications
You must be signed in to change notification settings - Fork 49
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
Automated testing script #215
Automated testing script #215
Conversation
Feel free to add your suggestions. The script has 2 optional parameter invocation sets:
If the script is invoked without arguments, it will use the default configuration and name the test jail Legend:
Environment variables control the test behavior:
Type of RunIn A special shorthand option exists Single RunBy default, a single run in non-interactive mode will run, it runs from whatever CWD path the shell is in. Full TestThe Full test, starts with the single run (whether interactive or not), if successful, it continues to perform non-interactive tests with the following parameters:
Example invocation:Single run, interactive mode, cd ${SCALE_POOL_ROOT:?must define this before running}/jailmaker \
&& sudo STOP=i SCALE_POOL_ROOT=$SCALE_POOL_ROOT $SCALE_POOL_ROOT/jailmaker/test/test-jlmkr nixos Full test, default settings, cd ${JLMKR_PATH:?must define this before running} \
&& sudo FULL_TEST=1 ./test/test-jlmkr nixos What to expectA full non-interactive test run with The report summary outputs what type of run it was with CWD and path to config file and for each step, a green checkmark indicating ✅ Success, a red X symbol following the exit code❌( |
Thanks as always! I gave the test script a quick spin and I like it :)
I think we can and should make the script fully non-interactive. Testing
And edit could be tested this way Would you mind taking a look at my initial attempt at an automatic test script? This runs on each commit and PR (you can unfold I had to override the |
P.S. the develop branch already contains the code to pass args to |
NP, I'll rebase on develop, and kick out any changes that might conflict. |
7b69ff9
to
722a1d8
Compare
Cleaned up the branch, it now only included the shell script. |
That's aweseom, and yes I agree - testing these test-cases would be helpful. Still need to think about how to properly test commits to new configs. Next, I'll add your notes about |
Add non-interactive testing of shell and edit to the default. |
Yeah that or preprocess the config files with sed from the GitHub actions test script. If you like you can experiment with this since pushing new commits in this PR will trigger the automatic testing action: https://github.com/Jip-Hop/jailmaker/pull/215/checks |
f7d2644
to
eaae736
Compare
e229c53
to
69c24db
Compare
@Jip-Hop I some changes to the script so it would run properly form NOTE - that it's currently just running the 'Single Run' test, which seems to be the one you'll want to run frequently. |
The script has 2 optional parameter invocation sets: * `<jail type>` [`<jail name>`] * `<template/path>` `<jail name>` Legend: | Arg name | Description | |-|-| | `<jail type>` | The template dir-name in `$SCALE_POOL_ROOT/jailmaker/templates` (it will load the `config` file within it) | | `<jail name>`\* | The name of the jail that will be created and destroyed during the testing. <br/> If not supplied, the default is `<jail type>-test` | | `<template/path>` | relative or absolute path to a config template. (`<jail name>` must be supplied) | > PRE-REQUISITE: > \* WARNING: If `<jail name>` exists, it will be removed. Environment variables control the test behavior: | Variable name | Default |Description | |-|:-:|-| |`SCALE_POOL_ROOT`|N/A, must be exported|Env var must be defined and valid pointing to the root of the ZFS dataset hosting the `jailmaker` script dir. | |`STOP`|0| `0` - perform all non-blocking tests<br/>`l` - only list and images, nothing else<br/>`i` - interactive test, includ console-blocking waiting for input tests (edit and shell)| |`FULL_TEST`|0|`0` - perform a single run<br/>`1`* - perform a full-test| > \* `FULL_TEST=1` will perform a full run ONLY when passing a `<jail type>` (will not work with `<template/path>`) -- Type of Run In `STOP=0` (the default) all steps, except the interactive steps will be performed. The interactive steps are steps which prompt the user for input. These are `shell` and `edit`. In `STOP=i` all steps will be performed. A special shorthand option exists `STOP-l` which will just run `list` and `images`, this is to test basic invocation of the script regardless of specific jails. This is also the only non-destructive mode. -- Single Run By default, a single run in non-interactive mode will run, it runs from whatever CWD path the shell is in. -- Full Test The Full test, starts with the single run (whether interactive or not), if successful, it continues to perform non-interactive tests with the following parameters: | S | F | CWD | Path to template | |:-:|:-:|-|-| |+|+|`$SCALE_POOL_ROOT/jailmaker`|`./templates/$JAIL_TYPE/config`| ||+|`$SCALE_POOL_ROOT/jailmaker`|`templates/$JAIL_TYPE/config`| ||+|`$SCALE_POOL_ROOT/jailmaker`|`$SCALE_POOL_ROOT/jailmaker/$JAIL_CONFIG`| ||+| ~ |`$SCALE_POOL_ROOT/jailmaker/$JAIL_CONFIG`| ||+| ~ | a _temporary file_, it's contents will be copied form the `<jail type>`'s config file. | > S - Single Run | F - Full Test --- Example invocation: Single run, interactive mode, `nixos` jail type: ```bash cd ${SCALE_POOL_ROOT:?must define this before running}/jailmaker \ && sudo STOP=i SCALE_POOL_ROOT=$SCALE_POOL_ROOT $SCALE_POOL_ROOT/jailmaker/test/test-jlmkr nixos ``` Full test, default settings, `nixos` jail type: ```bash cd ${SCALE_POOL_ROOT:?must define this before running}/jailmaker \ && sudo FULL_TEST=1 SCALE_POOL_ROOT=$SCALE_POOL_ROOT $SCALE_POOL_ROOT/jailmaker/test/test-jlmkr nixos ``` --- What to expect A full non-interactive test run with `nixos` (which is rather lean, yet tests both pre hook and init scripts) ran for ~280 seconds. The report summary outputs what type of run it was with CWD and path to config file and for each step, a green checkmark indicating ✅ Success, a red X symbol following the exit code❌(`<error code>`) for erros. Both follow the command executed. In the case a step wasn't performed, a blank checkbox 🔳 followed by the name of the step will be listed. The report is always listed in alphabetic order (although the steps are performed in an order that allows testing as much as possible while taking into account dependent steps.
- fixed: if a failure happened, report will not print - added: remove will always be attempted, even if failure would occurr
Modifying test-jlmkr to allow running from current dir
69c24db
to
3320bb6
Compare
Looks good and it's quick! Could you add a docker and/or podman test too? They are currently failing for reasons unknown to me: #220 (comment) I don't think the additional docker/podman test needs to go through the whole suite of |
I've updated the instructions in the comment above. |
I agree, but I would suggest we start using it as is, and modify this later. Would you be ok opening a set of issues to tackle each requirement? |
Merged! For now it runs both test scripts.
I put it in a readme. See develop branch.
Even better, haha!
Please do! :) P.S. another bug slipped by manual testing :( |
I created this script to test my changes with #210.
log
andstatus
so that interactive features ofjoutnalctl
could be avoided.How the test-jlmkr bash script works is detailed in the next comment.