Skip to content

Commit

Permalink
Add deleteSeries skeleton to return bad request
Browse files Browse the repository at this point in the history
Signed-off-by: darshanime <deathbullet@gmail.com>
  • Loading branch information
darshanime committed Apr 27, 2020
1 parent 67ca693 commit 995c489
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
6 changes: 6 additions & 0 deletions pkg/query/api/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ func (api *API) Register(r *route.Router, tracer opentracing.Tracer, logger log.
r.Get("/series", instr("series", api.series))
r.Post("/series", instr("series", api.series))

r.Post("/delete_series", instr("delete_series", api.deleteSeries))

r.Get("/labels", instr("label_names", api.labelNames))
r.Post("/labels", instr("label_names", api.labelNames))
}
Expand Down Expand Up @@ -536,6 +538,10 @@ func (api *API) series(r *http.Request) (interface{}, []error, *ApiError) {
return metrics, warnings, nil
}

func (api *API) deleteSeries(r *http.Request) (interface{}, []error, *ApiError) {
return nil, nil, &ApiError{errorBadData, errors.New("delete_series is not implemented yet")}
}

func Respond(w http.ResponseWriter, data interface{}, warnings []error) {
w.Header().Set("Content-Type", "application/json")
if len(warnings) > 0 {
Expand Down
47 changes: 27 additions & 20 deletions pkg/query/api/v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,13 @@ func TestEndpoints(t *testing.T) {
errType: errorBadData,
method: http.MethodPost,
},
// deleteSeries should return bad request.
{
endpoint: api.deleteSeries,
query: url.Values{},
method: http.MethodPost,
errType: errorBadData,
},
}

for _, test := range tests {
Expand Down Expand Up @@ -1095,44 +1102,44 @@ func TestParseDownsamplingParamMillis(t *testing.T) {
{
maxSourceResolutionParam: "0s",
enableAutodownsampling: false,
step: time.Hour,
result: int64(compact.ResolutionLevelRaw),
fail: false,
step: time.Hour,
result: int64(compact.ResolutionLevelRaw),
fail: false,
},
{
maxSourceResolutionParam: "5m",
step: time.Hour,
enableAutodownsampling: false,
result: int64(compact.ResolutionLevel5m),
fail: false,
step: time.Hour,
enableAutodownsampling: false,
result: int64(compact.ResolutionLevel5m),
fail: false,
},
{
maxSourceResolutionParam: "1h",
step: time.Hour,
enableAutodownsampling: false,
result: int64(compact.ResolutionLevel1h),
fail: false,
step: time.Hour,
enableAutodownsampling: false,
result: int64(compact.ResolutionLevel1h),
fail: false,
},
{
maxSourceResolutionParam: "",
enableAutodownsampling: true,
step: time.Hour,
result: int64(time.Hour / (5 * 1000 * 1000)),
fail: false,
step: time.Hour,
result: int64(time.Hour / (5 * 1000 * 1000)),
fail: false,
},
{
maxSourceResolutionParam: "",
enableAutodownsampling: true,
step: time.Hour,
result: int64((1 * time.Hour) / 6),
fail: true,
step: time.Hour,
result: int64((1 * time.Hour) / 6),
fail: true,
},
{
maxSourceResolutionParam: "",
enableAutodownsampling: true,
step: time.Hour,
result: int64((1 * time.Hour) / 6),
fail: true,
step: time.Hour,
result: int64((1 * time.Hour) / 6),
fail: true,
},
}

Expand Down

0 comments on commit 995c489

Please sign in to comment.