aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md19
-rw-r--r--src/lib/delivery/delivery_populate.c12
-rw-r--r--src/lib/delivery/delivery_test.c6
-rw-r--r--src/lib/delivery/include/delivery.h1
4 files changed, 29 insertions, 9 deletions
diff --git a/README.md b/README.md
index f6a89bd..c1a490d 100644
--- a/README.md
+++ b/README.md
@@ -283,16 +283,17 @@ Environment variables exported are _global_ to all programs executed by stasis.
Sections starting with `test:` will be used during the testing phase of the stasis pipeline. Where the value of `name` following the colon is an arbitrary value, and only used for reporting which test-run is executing. Section names must be unique.
-| Key | Type | Purpose | Required |
-|--------------|---------|-------------------------------------------------------------|----------|
+| Key | Type | Purpose | Required |
+|--------------|---------|----------------------------------------------------------|----------|
| disable | Boolean | Disable `script` execution (`script_setup` always executes) | N |
-| parallel | Boolean | Execute test block in parallel (default) or sequentially | N |
-| build_recipe | String | Git repository path to package's conda recipe | N |
-| repository | String | Git repository path or URL to clone | Y |
-| version | String | Git commit or tag to check out | Y |
-| runtime | List | Export environment variables specific to test context | Y |
-| script_setup | List | Body of a shell script that will install dependencies | N |
-| script | List | Body of a shell script that will execute the tests | Y |
+| parallel | Boolean | Execute test block in parallel (default) or sequentially | N |
+| timeout | String | Kill test script after `n[hms]` | N |
+| build_recipe | String | Git repository path to package's conda recipe | N |
+| repository | String | Git repository path or URL to clone | Y |
+| version | String | Git commit or tag to check out | Y |
+| runtime | List | Export environment variables specific to test context | Y |
+| script_setup | List | Body of a shell script that will install dependencies | N |
+| script | List | Body of a shell script that will execute the tests | Y |
### deploy:artifactory:_name_
diff --git a/src/lib/delivery/delivery_populate.c b/src/lib/delivery/delivery_populate.c
index 28b2480..15ab6bd 100644
--- a/src/lib/delivery/delivery_populate.c
+++ b/src/lib/delivery/delivery_populate.c
@@ -259,6 +259,18 @@ int populate_delivery_ini(struct Delivery *ctx, int render_mode) {
test->repository_remove_tags = ini_getval_strlist(ini, section_name, "repository_remove_tags", LINE_SEP, render_mode, &err);
test->build_recipe = ini_getval_str(ini, section_name, "build_recipe", render_mode, &err);
test->runtime.environ = ini_getval_strlist(ini, section_name, "runtime", LINE_SEP, render_mode, &err);
+ const char *timeout_str = ini_getval_str(ini, section_name, "timeout", render_mode, &err);
+ if (timeout_str) {
+ test->timeout = str_to_timeout((char *) timeout_str);
+ if (test->timeout == STR_TO_TIMEOUT_INVALID_TIME_SCALE) {
+ SYSERROR("In 'test:%s', invalid time scale format: %s. Use n[hms].", test->name, timeout_str);
+ return 1;
+ }
+ if (test->timeout == STR_TO_TIMEOUT_NEGATIVE) {
+ SYSERROR("In 'test:%s', timeout cannot be negative: %s", test->name, timeout_str);
+ return 1;
+ }
+ }
z++;
}
}
diff --git a/src/lib/delivery/delivery_test.c b/src/lib/delivery/delivery_test.c
index 6e0a226..500ade9 100644
--- a/src/lib/delivery/delivery_test.c
+++ b/src/lib/delivery/delivery_test.c
@@ -166,6 +166,12 @@ void delivery_tests_run(struct Delivery *ctx) {
}
exit(1);
}
+
+ // Apply timeout from test block
+ if (test->timeout) {
+ task->timeout = test->timeout;
+ }
+
guard_free(runner_cmd);
guard_free(cmd);
popd();
diff --git a/src/lib/delivery/include/delivery.h b/src/lib/delivery/include/delivery.h
index f8229ed..cae4b02 100644
--- a/src/lib/delivery/include/delivery.h
+++ b/src/lib/delivery/include/delivery.h
@@ -169,6 +169,7 @@ struct Delivery {
char *repository_info_tag; ///< Git tag (first parent)
struct StrList *repository_remove_tags; ///< Git tags to remove (to fix duplicate commit tags)
struct Runtime runtime; ///< Environment variables specific to the test context
+ int timeout; ///< Timeout in seconds
} tests[1000]; ///< An array of tests
struct Deploy {