From 68e09defdf76cfbeb7918036e6ad673efea4f3ed Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Mon, 28 Aug 2023 07:40:10 +0800 Subject: [PATCH] test: add v3 curl test to cover maintenance hash/hashkv REST API Signed-off-by: Benjamin Wang Signed-off-by: Wei Fu --- tests/e2e/v3_curl_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/e2e/v3_curl_test.go b/tests/e2e/v3_curl_test.go index 00194af88..1b012c313 100644 --- a/tests/e2e/v3_curl_test.go +++ b/tests/e2e/v3_curl_test.go @@ -381,6 +381,34 @@ func testV3CurlMaintenanceAlarmMissiongAlarm(cx ctlCtx) { } } +func TestV3CurlMaintenanceHash(t *testing.T) { + testCtl(t, testV3CurlMaintenanceHash, withCfg(*newConfigNoTLS())) +} + +func testV3CurlMaintenanceHash(cx ctlCtx) { + if err := cURLPost(cx.epc, cURLReq{ + endpoint: "/v3/maintenance/hash", + value: "{}", + expected: `,"revision":"1","raft_term":"2"},"hash":`, + }); err != nil { + cx.t.Fatalf("failed post maintenance hash request (%s) (%v)", cx.apiPrefix, err) + } +} + +func TestV3CurlMaintenanceHashKV(t *testing.T) { + testCtl(t, testV3CurlMaintenanceHashKV, withCfg(*newConfigNoTLS())) +} + +func testV3CurlMaintenanceHashKV(cx ctlCtx) { + if err := cURLPost(cx.epc, cURLReq{ + endpoint: "/v3/maintenance/hashkv", + value: `{"revision": 1}`, + expected: `,"compact_revision":`, + }); err != nil { + cx.t.Fatalf("failed post maintenance hashKV request (%s) (%v)", cx.apiPrefix, err) + } +} + // to manually decode; JSON marshals integer fields with // string types, so can't unmarshal with epb.CampaignResponse type campaignResponse struct {