Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions R/api_client.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ R6_orderlyweb_api_client <- R6::R6Class(
self$request(httr::POST, ...)
},

DELETE = function(...) {
self$request(httr::DELETE, ...)
},

request = function(verb, path, ..., download = NULL) {
self$authorise()
if (!grepl("^/", path)) {
Expand Down
4 changes: 4 additions & 0 deletions R/orderly.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ R6_orderlyweb_remote <- R6::R6Class(
progress = progress, instance = instance)
},

kill = function(key) {
private$client$report_kill(key)
},

bundle_pack = function(name, parameters = NULL, instance = NULL,
progress = TRUE) {
private$client$bundle_pack(name, parameters, instance, progress)
Expand Down
8 changes: 8 additions & 0 deletions R/orderlyweb.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ R6_orderlyweb <- R6::R6Class(
progress = progress)
},

report_kill = function(key) {
if (inherits(key, "orderlyweb_run")) {
key <- key$key
}
path <- sprintf("/reports/%s/kill/", key)
self$api_client$DELETE(path)
},

data_download = function(hash, csv = FALSE, dest = NULL,
progress = TRUE) {
path <- sprintf("/data/%s/%s", if (csv) "csv" else "rds", hash)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ For end-to-end testing, we need a copy of orderlyweb running. This is most easi

To install `orderly-web` (the command line tool) use `pip3 install orderly-web`

A token is also needed to login with github; that can be found in the `vimc` vault as `secret/vimc-robot/vault-token` and should be available as the environment variable `ORDERLYWEB_TEST_TOKEN` (this is available on travis as an encrypted environment variable).
A token is also needed to login with github; that can be found in the `mrc-ide` vault as `secret/vimc-robot/orderlyweb-test-token` and should be available as the environment variable `ORDERLYWEB_TEST_TOKEN` (this is available on github actions as an encrypted environment variable).

To stop the server, use `orderly-web stop inst/config --volumes --kill`

Expand Down
19 changes: 19 additions & 0 deletions tests/testthat/test-integration.R
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,22 @@ test_that("queue status", {
expect_equal(res$tasks[[1]]$key, run$key)
expect_equal(res$tasks[[1]]$status, "running")
})

test_that("report can be killed", {
cl <- test_orderlyweb()
ans <- cl$report_run("slow10", wait = FALSE)
Sys.sleep(2) ## Ensure report gets started
res <- cl$report_kill(ans)
expect_true(res$killed)
expect_null(res$message)
})

test_that("failed to kill report returns message", {
cl <- test_orderlyweb()
out <- cl$report_run("minimal", wait = FALSE)
output <- cl$report_run_wait(out, progress = FALSE)

res <- cl$report_kill(out)
expect_false(res$killed)
expect_match(res$message, "Failed to kill")
})
13 changes: 13 additions & 0 deletions tests/testthat/test-orderly.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,16 @@ test_that("queue status", {
expect_equal(res$tasks[[1]]$key, out$key)
expect_equal(res$tasks[[1]]$status, "running")
})

test_that("can kill report run", {
skip_if_no_orderlyweb_server()
token <- Sys.getenv("ORDERLYWEB_TEST_TOKEN")
remote <- orderlyweb_remote(host = "localhost", port = 8888,
token = token, https = FALSE)
out <- remote$run("slow3", open = FALSE, progress = FALSE, wait = FALSE)
Sys.sleep(2) ## Ensure report gets started

res <- remote$kill(out)
expect_true(res$killed)
expect_null(res$message)
})