aboutsummaryrefslogtreecommitdiff
path: root/testdata/http_server/execute
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-12-22 02:57:21 +0700
committerShulhan <ms@kilabit.info>2023-12-22 03:08:04 +0700
commitaa64efe9e8957da6c122f9decaaa78dca83d14ee (patch)
treea6b60b025b369c21d9d4e4efce957c313be38c69 /testdata/http_server/execute
parentc0d336ca456093b2b7c0b585dbe08f62cbc8ca83 (diff)
downloadawwan-aa64efe9e8957da6c122f9decaaa78dca83d14ee.tar.xz
all: implement HTTP API to stop local or play execution
The HTTP API for stopping execution have the following signature, DELETE /awwan/api/execute?id=<string> If the ID is exist, the execution will be cancelled and return HTTP status 200 with the following body, Content-Type: application/json { "code": 200, } Otherwise it will return HTTP status 404 with error message. References: https://todo.sr.ht/~shulhan/awwan/9
Diffstat (limited to 'testdata/http_server/execute')
-rw-r--r--testdata/http_server/execute/cancel.aww1
-rw-r--r--testdata/http_server/execute/cancel_test.data55
2 files changed, 56 insertions, 0 deletions
diff --git a/testdata/http_server/execute/cancel.aww b/testdata/http_server/execute/cancel.aww
new file mode 100644
index 0000000..46a443f
--- /dev/null
+++ b/testdata/http_server/execute/cancel.aww
@@ -0,0 +1 @@
+sleep 300
diff --git a/testdata/http_server/execute/cancel_test.data b/testdata/http_server/execute/cancel_test.data
new file mode 100644
index 0000000..4611da6
--- /dev/null
+++ b/testdata/http_server/execute/cancel_test.data
@@ -0,0 +1,55 @@
+Test cancelling Execute using HTTP API.
+The SSE data is quoted to make the string viewable.
+
+>>> local:/cancel.aww:1-
+{
+ "mode": "local",
+ "script": "/cancel.aww",
+ "line_range": "1-"
+}
+
+<<< local:/cancel.aww:1-
+{
+ "data": {
+ "mode": "local",
+ "script": "/cancel.aww",
+ "line_range": "1-",
+ "id": "local:/cancel.aww:1-:1701012060",
+ "begin_at": "2023-11-26T15:21:00Z",
+ "end_at": "",
+ "error": "",
+ "output": []
+ },
+ "code": 200
+}
+
+<<< local:/cancel.aww:1-:tail
+event: open
+
+event: begin
+data: "2023-11-26T15:21:00Z"
+
+event: message
+data: "----/--/-- --:--:-- === BEGIN: local /cancel.aww 1-\n"
+id: 0
+
+event: message
+data: "----/--/-- --:--:-- --> 1: sleep 300\n"
+id: 1
+
+event: message
+data: "----/--/-- --:--:-- !!! ExecLocal: signal: killed\n"
+id: 2
+
+event: message
+data: "Local: ExecLocal: signal: killed"
+id: 2
+
+event: end
+data: "2023-11-26T15:21:00Z"
+id: 2
+
+
+
+<<< local:/cancel.aww:1-:response
+{"message":"execution ID \"local:/cancel.aww:1-:1701012060\" has been cancelled","code":200}