From 815648fe32628696f5a401f000d310f3b1483fa0 Mon Sep 17 00:00:00 2001 From: Cesar Celis Hernandez Date: Wed, 23 Feb 2022 23:49:35 -0500 Subject: [PATCH] Adding the restart API test (#1617) --- integration/buckets_test.go | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/integration/buckets_test.go b/integration/buckets_test.go index af049e5f9..a121668da 100644 --- a/integration/buckets_test.go +++ b/integration/buckets_test.go @@ -2816,3 +2816,44 @@ func TestPutObjectsLegalholdStatus(t *testing.T) { }) } } + +func RestartService() (*http.Response, error) { + /* + Helper function to restart service + HTTP Verb: POST + URL: /api/v1/service/restart + */ + request, err := http.NewRequest( + "POST", + "http://localhost:9090/api/v1/service/restart", + nil, + ) + if err != nil { + log.Println(err) + } + request.Header.Add("Cookie", fmt.Sprintf("token=%s", token)) + request.Header.Add("Content-Type", "application/json") + client := &http.Client{ + Timeout: 2000 * time.Second, // increased timeout since restart takes time, more than other APIs. + } + response, err := client.Do(request) + return response, err +} + +func TestRestartService(t *testing.T) { + assert := assert.New(t) + restartResponse, restartError := RestartService() + assert.Nil(restartError) + if restartError != nil { + log.Println(restartError) + return + } + addObjRsp := inspectHTTPResponse(restartResponse) + if restartResponse != nil { + assert.Equal( + 204, + restartResponse.StatusCode, + addObjRsp, + ) + } +}