diff options
author | Valery Piashchynski <[email protected]> | 2021-07-23 15:51:54 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-07-23 15:51:54 +0300 |
commit | e88dfd5cd10662f0ad68e69f9d9de2f66ddf26d0 (patch) | |
tree | 0f5c18d6c1205d7499523a35740f4054a9aa9904 /tests/plugins/jobs/helpers.go | |
parent | 9079cc51599d6e21ac59e34573f7bbf2e2e87b9e (diff) |
Add AMQP initial durability test
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'tests/plugins/jobs/helpers.go')
-rw-r--r-- | tests/plugins/jobs/helpers.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/plugins/jobs/helpers.go b/tests/plugins/jobs/helpers.go index 5ef5f022..27b2d1e0 100644 --- a/tests/plugins/jobs/helpers.go +++ b/tests/plugins/jobs/helpers.go @@ -1,13 +1,16 @@ package jobs import ( + "bytes" "net" + "net/http" "net/rpc" "testing" goridgeRpc "github.com/spiral/goridge/v3/pkg/rpc" jobsv1beta "github.com/spiral/roadrunner/v2/proto/jobs/v1beta" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func resumePipes(pipes ...string) func(t *testing.T) { @@ -113,3 +116,43 @@ func destroyPipelines(pipes ...string) func(t *testing.T) { assert.NoError(t, err) } } + +func enableProxy(name string, t *testing.T) { + buf := new(bytes.Buffer) + buf.WriteString(`{"enabled":true}`) + + resp, err := http.Post("http://localhost:8474/proxies/"+name, "application/json", buf) //nolint:noctx + require.NoError(t, err) + require.Equal(t, 200, resp.StatusCode) + if resp.Body != nil { + _ = resp.Body.Close() + } +} + +func disableProxy(name string, t *testing.T) { + buf := new(bytes.Buffer) + buf.WriteString(`{"enabled":false}`) + + resp, err := http.Post("http://localhost:8474/proxies/"+name, "application/json", buf) //nolint:noctx + require.NoError(t, err) + require.Equal(t, 200, resp.StatusCode) + if resp.Body != nil { + _ = resp.Body.Close() + } +} + +func deleteProxy(name string, t *testing.T) { + client := &http.Client{} + + req, err := http.NewRequest(http.MethodDelete, "http://localhost:8474/proxies/"+name, nil) //nolint:noctx + require.NoError(t, err) + + resp, err := client.Do(req) + require.NoError(t, err) + + require.NoError(t, err) + require.Equal(t, 204, resp.StatusCode) + if resp.Body != nil { + _ = resp.Body.Close() + } +} |