From a73f0d5d0108e2e10d89f93c7867addbe073add9 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Wed, 22 Nov 2023 13:16:21 +0700 Subject: all: refactoring HTTP endpoint for Execute Previously, the Execute endpoint wait for command execution to finish. In case the command takes longer than proxy or server write timeout, it will return with an timeout error to client. In this changes, we generate an execution ID for each request and return it immediately. The next commit will implement HTTP endpoint to fetch the latest status and/or output by execution ID. References: https://todo.sr.ht/~shulhan/awwan/5 --- testdata/http_server/execute/local.aww | 1 + testdata/http_server/execute/local_test.data | 22 +++++++++++++++++ .../http_server/play_ssh_config_changes/test.data | 28 +++++++--------------- 3 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 testdata/http_server/execute/local.aww create mode 100644 testdata/http_server/execute/local_test.data (limited to 'testdata') diff --git a/testdata/http_server/execute/local.aww b/testdata/http_server/execute/local.aww new file mode 100644 index 0000000..3832772 --- /dev/null +++ b/testdata/http_server/execute/local.aww @@ -0,0 +1 @@ +echo "test" diff --git a/testdata/http_server/execute/local_test.data b/testdata/http_server/execute/local_test.data new file mode 100644 index 0000000..1720bd8 --- /dev/null +++ b/testdata/http_server/execute/local_test.data @@ -0,0 +1,22 @@ + +>>> local:/local.aww:1- +{ + "mode": "local", + "script": "/local.aww", + "line_range": "1-" +} + +<<< local:/local.aww:1- +{ + "data": { + "mode": "local", + "script": "/local.aww", + "line_range": "1-", + "id": "local:/local.aww:1-:1701012060", + "begin_at": "2023-11-26T15:21:00Z", + "end_at": "", + "error": "", + "output": [] + }, + "code": 200 +} diff --git a/testdata/http_server/play_ssh_config_changes/test.data b/testdata/http_server/play_ssh_config_changes/test.data index 4f9d230..00a6941 100644 --- a/testdata/http_server/play_ssh_config_changes/test.data +++ b/testdata/http_server/play_ssh_config_changes/test.data @@ -19,22 +19,16 @@ Host oldhost "mode": "play", "script": "/oldhost/play.aww", "line_range": "1-", - "content": null, + "id": "play:/oldhost/play.aww:1-:1701012060", + "begin_at": "2023-11-26T15:21:00Z", + "end_at": "", "error": "", - "output": "LSBwbGF5LmF3dyAtLS0gU1NIIGNvbm5lY3Rpb246IGF3d2Fuc3NoQDEyNy4wLjAuMToxMDAyMgotIHBsYXkuYXd3IC0tLSBTU0ggaWRlbnRpdHkgZmlsZTogWy9ob21lL2F3d2FuLy5zc2gvaWRfZWQyNTUxOV0KLSBwbGF5LmF3dyA9PT0gQkVHSU46IHBsYXkgL29sZGhvc3QvcGxheS5hd3cgMS0KLSBwbGF5LmF3dyAtLT4gICAyOiBwd2QKL2hvbWUvYXd3YW5zc2gKLSBwbGF5LmF3dyAtLT4gICA1OiAjbG9jYWw6IHB3ZAovaG9tZS9hd3dhbi9zcmMKLSBwbGF5LmF3dyA9PT0gRU5ECg==" + "output": [] }, "code": 200 } <<< play_on_oldhost:output -- play.aww --- SSH connection: awwanssh@127.0.0.1:10022 -- play.aww --- SSH identity file: [/home/awwan/.ssh/id_ed25519] -- play.aww === BEGIN: play /oldhost/play.aww 1- -- play.aww --> 2: pwd -/home/awwanssh -- play.aww --> 5: #local: pwd -/home/awwan/src -- play.aww === END >>> .ssh/config:newhost Host oldhost @@ -62,19 +56,13 @@ Host newhost "mode": "play", "script": "/newhost/play.aww", "line_range": "1-", - "content": null, + "id": "play:/newhost/play.aww:1-:1701012060", + "begin_at": "2023-11-26T15:21:00Z", + "end_at": "", "error": "", - "output": "LSBwbGF5LmF3dyAtLS0gU1NIIGNvbm5lY3Rpb246IGF3d2Fuc3NoQDEyNy4wLjAuMToxMDAyMgotIHBsYXkuYXd3IC0tLSBTU0ggaWRlbnRpdHkgZmlsZTogWy9ob21lL2F3d2FuLy5zc2gvaWRfZWQyNTUxOV0KLSBwbGF5LmF3dyA9PT0gQkVHSU46IHBsYXkgL25ld2hvc3QvcGxheS5hd3cgMS0KLSBwbGF5LmF3dyAtLT4gICAyOiBwd2QKL2hvbWUvYXd3YW5zc2gKLSBwbGF5LmF3dyAtLT4gICA1OiAjbG9jYWw6IHB3ZAovaG9tZS9hd3dhbi9zcmMKLSBwbGF5LmF3dyA9PT0gRU5ECg==" + "output": [] }, "code": 200 } <<< play_on_newhost:output -- play.aww --- SSH connection: awwanssh@127.0.0.1:10022 -- play.aww --- SSH identity file: [/home/awwan/.ssh/id_ed25519] -- play.aww === BEGIN: play /newhost/play.aww 1- -- play.aww --> 2: pwd -/home/awwanssh -- play.aww --> 5: #local: pwd -/home/awwan/src -- play.aww === END -- cgit v1.3