diff --git a/src/query/api/v1/handler/database/create_test.go b/src/query/api/v1/handler/database/create_test.go index b20c5c0403..03c2d8b4b9 100644 --- a/src/query/api/v1/handler/database/create_test.go +++ b/src/query/api/v1/handler/database/create_test.go @@ -38,6 +38,7 @@ import ( "github.com/m3db/m3/src/cluster/services" dbconfig "github.com/m3db/m3/src/cmd/services/m3dbnode/config" "github.com/m3db/m3/src/cmd/services/m3query/config" + "github.com/m3db/m3/src/query/api/v1/handler" "github.com/m3db/m3/src/query/api/v1/handler/namespace" "github.com/m3db/m3/src/x/instrument" xtest "github.com/m3db/m3/src/x/test" @@ -51,6 +52,11 @@ var ( testDBCfg = &dbconfig.DBConfiguration{ ListenAddress: "0.0.0.0:9000", } + svcDefaultOptions = []handler.ServiceOptionsDefault{ + func(o handler.ServiceOptions) handler.ServiceOptions { + return o + }, + } ) func SetupDatabaseTest( @@ -92,7 +98,7 @@ func testLocalType(t *testing.T, providedType string, placementExists bool) { mockClient, mockKV, mockPlacementService := SetupDatabaseTest(t, ctrl) mockClient.EXPECT().Store(gomock.Any()).Return(mockKV, nil).AnyTimes() createHandler, err := NewCreateHandler(mockClient, config.Configuration{}, - testDBCfg, instrument.NewOptions()) + testDBCfg, svcDefaultOptions, instrument.NewOptions()) require.NoError(t, err) w := httptest.NewRecorder() @@ -206,7 +212,7 @@ func TestLocalTypeClusteredPlacementAlreadyExists(t *testing.T) { mockClient, _, mockPlacementService := SetupDatabaseTest(t, ctrl) createHandler, err := NewCreateHandler(mockClient, config.Configuration{}, - testDBCfg, instrument.NewOptions()) + testDBCfg, svcDefaultOptions, instrument.NewOptions()) require.NoError(t, err) w := httptest.NewRecorder() @@ -253,7 +259,7 @@ func TestLocalTypeWithNumShards(t *testing.T) { mockClient, mockKV, mockPlacementService := SetupDatabaseTest(t, ctrl) mockClient.EXPECT().Store(gomock.Any()).Return(mockKV, nil).AnyTimes() createHandler, err := NewCreateHandler(mockClient, config.Configuration{}, - testDBCfg, instrument.NewOptions()) + testDBCfg, svcDefaultOptions, instrument.NewOptions()) require.NoError(t, err) w := httptest.NewRecorder() @@ -364,7 +370,7 @@ func TestLocalWithBlockSizeNanos(t *testing.T) { mockClient, mockKV, mockPlacementService := SetupDatabaseTest(t, ctrl) mockClient.EXPECT().Store(gomock.Any()).Return(mockKV, nil).AnyTimes() createHandler, err := NewCreateHandler(mockClient, config.Configuration{}, - testDBCfg, instrument.NewOptions()) + testDBCfg, svcDefaultOptions, instrument.NewOptions()) require.NoError(t, err) w := httptest.NewRecorder() @@ -475,7 +481,7 @@ func TestLocalWithBlockSizeExpectedSeriesDatapointsPerHour(t *testing.T) { mockClient, mockKV, mockPlacementService := SetupDatabaseTest(t, ctrl) mockClient.EXPECT().Store(gomock.Any()).Return(mockKV, nil).AnyTimes() createHandler, err := NewCreateHandler(mockClient, config.Configuration{}, - testDBCfg, instrument.NewOptions()) + testDBCfg, svcDefaultOptions, instrument.NewOptions()) require.NoError(t, err) w := httptest.NewRecorder() @@ -598,7 +604,7 @@ func TestClusterTypeHostsPlacementAlreadyExistsHostsProvided(t *testing.T) { mockClient, _, mockPlacementService := SetupDatabaseTest(t, ctrl) mockClient.EXPECT().Store(gomock.Any()).Return(nil, nil).AnyTimes() createHandler, err := NewCreateHandler(mockClient, config.Configuration{}, - testDBCfg, instrument.NewOptions()) + testDBCfg, svcDefaultOptions, instrument.NewOptions()) require.NoError(t, err) w := httptest.NewRecorder() @@ -654,7 +660,7 @@ func TestClusterTypeHostsPlacementAlreadyExistsExistingIsLocal(t *testing.T) { mockClient, _, mockPlacementService := SetupDatabaseTest(t, ctrl) createHandler, err := NewCreateHandler(mockClient, config.Configuration{}, - testDBCfg, instrument.NewOptions()) + testDBCfg, svcDefaultOptions, instrument.NewOptions()) require.NoError(t, err) w := httptest.NewRecorder() @@ -701,7 +707,7 @@ func testClusterTypeHosts(t *testing.T, placementExists bool) { mockClient, mockKV, mockPlacementService := SetupDatabaseTest(t, ctrl) mockClient.EXPECT().Store(gomock.Any()).Return(mockKV, nil).AnyTimes() createHandler, err := NewCreateHandler(mockClient, config.Configuration{}, - testDBCfg, instrument.NewOptions()) + testDBCfg, svcDefaultOptions, instrument.NewOptions()) require.NoError(t, err) w := httptest.NewRecorder() @@ -849,7 +855,7 @@ func TestClusterTypeHostsWithIsolationGroup(t *testing.T) { mockClient.EXPECT().Store(gomock.Any()).Return(mockKV, nil) createHandler, err := NewCreateHandler(mockClient, config.Configuration{}, - testDBCfg, instrument.NewOptions()) + testDBCfg, svcDefaultOptions, instrument.NewOptions()) require.NoError(t, err) w := httptest.NewRecorder() @@ -980,7 +986,7 @@ func TestClusterTypeMissingHostnames(t *testing.T) { mockPlacementService.EXPECT().Placement().Return(nil, kv.ErrNotFound) createHandler, err := NewCreateHandler(mockClient, config.Configuration{}, - testDBCfg, instrument.NewOptions()) + testDBCfg, svcDefaultOptions, instrument.NewOptions()) require.NoError(t, err) w := httptest.NewRecorder() @@ -1011,7 +1017,7 @@ func TestBadType(t *testing.T) { mockPlacementService.EXPECT().Placement().Return(nil, kv.ErrNotFound) createHandler, err := NewCreateHandler(mockClient, config.Configuration{}, - nil, instrument.NewOptions()) + nil, svcDefaultOptions, instrument.NewOptions()) require.NoError(t, err) w := httptest.NewRecorder() diff --git a/src/query/api/v1/handler/namespace/add_test.go b/src/query/api/v1/handler/namespace/add_test.go index 03f93d0f92..c361ec49a8 100644 --- a/src/query/api/v1/handler/namespace/add_test.go +++ b/src/query/api/v1/handler/namespace/add_test.go @@ -83,7 +83,7 @@ func TestNamespaceAddHandler(t *testing.T) { req := httptest.NewRequest("POST", "/namespace", strings.NewReader(jsonInput)) require.NotNil(t, req) - addHandler.ServeHTTP(w, req) + addHandler.ServeHTTP(svcDefaults, w, req) resp := w.Result() body, err := ioutil.ReadAll(resp.Body) @@ -100,7 +100,7 @@ func TestNamespaceAddHandler(t *testing.T) { mockKV.EXPECT().Get(M3DBNodeNamespacesKey).Return(nil, kv.ErrNotFound) mockKV.EXPECT().CheckAndSet(M3DBNodeNamespacesKey, gomock.Any(), gomock.Not(nil)).Return(1, nil) - addHandler.ServeHTTP(w, req) + addHandler.ServeHTTP(svcDefaults, w, req) resp = w.Result() body, _ = ioutil.ReadAll(resp.Body) @@ -147,7 +147,7 @@ func TestNamespaceAddHandler_Conflict(t *testing.T) { mockKV.EXPECT().Get(M3DBNodeNamespacesKey).Return(mockValue, nil) w := httptest.NewRecorder() - addHandler.ServeHTTP(w, req) + addHandler.ServeHTTP(svcDefaults, w, req) resp := w.Result() assert.Equal(t, http.StatusConflict, resp.StatusCode) } diff --git a/src/query/api/v1/handler/namespace/schema_test.go b/src/query/api/v1/handler/namespace/schema_test.go index 7fbb447edb..876898c126 100644 --- a/src/query/api/v1/handler/namespace/schema_test.go +++ b/src/query/api/v1/handler/namespace/schema_test.go @@ -34,6 +34,7 @@ import ( nsproto "github.com/m3db/m3/src/dbnode/generated/proto/namespace" "github.com/m3db/m3/src/dbnode/namespace" "github.com/m3db/m3/src/dbnode/namespace/kvadmin" + apihandler "github.com/m3db/m3/src/query/api/v1/handler" "github.com/m3db/m3/src/x/instrument" "github.com/golang/mock/gomock" @@ -94,6 +95,12 @@ message ImportedMessage { ` ) +var ( + svcDefaults = apihandler.ServiceNameAndDefaults{ + ServiceName: "m3db", + } +) + func genTestJSON(t *testing.T) string { tempDir, err := ioutil.TempDir("", "schema_deploy_test") require.NoError(t, err) @@ -144,7 +151,7 @@ func TestSchemaDeploy_KVKeyNotFound(t *testing.T) { require.NotNil(t, req) mockKV.EXPECT().Get(M3DBNodeNamespacesKey).Return(nil, kv.ErrNotFound) - addHandler.ServeHTTP(w, req) + addHandler.ServeHTTP(svcDefaults, w, req) resp := w.Result() body, err := ioutil.ReadAll(resp.Body) @@ -186,7 +193,7 @@ func TestSchemaDeploy(t *testing.T) { req := httptest.NewRequest("POST", "/schema", strings.NewReader(testSchemaJSON)) require.NotNil(t, req) - schemaHandler.ServeHTTP(w, req) + schemaHandler.ServeHTTP(svcDefaults, w, req) resp := w.Result() body, _ := ioutil.ReadAll(resp.Body) @@ -239,7 +246,7 @@ func TestSchemaDeploy_NamespaceNotFound(t *testing.T) { mockKV.EXPECT().Get(M3DBNodeNamespacesKey).Return(mockValue, nil) w := httptest.NewRecorder() - schemaHandler.ServeHTTP(w, req) + schemaHandler.ServeHTTP(svcDefaults, w, req) resp := w.Result() body, _ := ioutil.ReadAll(resp.Body) assert.Equal(t, http.StatusNotFound, resp.StatusCode) @@ -270,7 +277,7 @@ func TestSchemaReset(t *testing.T) { req := httptest.NewRequest("DELETE", "/schema", strings.NewReader(jsonInput)) require.NotNil(t, req) - schemaHandler.ServeHTTP(w, req) + schemaHandler.ServeHTTP(svcDefaults, w, req) resp := w.Result() body, _ := ioutil.ReadAll(resp.Body) @@ -281,7 +288,7 @@ func TestSchemaReset(t *testing.T) { require.NotNil(t, req) req.Header.Add("Force", "true") - schemaHandler.ServeHTTP(w, req) + schemaHandler.ServeHTTP(svcDefaults, w, req) resp = w.Result() body, _ = ioutil.ReadAll(resp.Body) diff --git a/src/query/api/v1/httpd/handler_test.go b/src/query/api/v1/httpd/handler_test.go index 7778d285fd..f08430484b 100644 --- a/src/query/api/v1/httpd/handler_test.go +++ b/src/query/api/v1/httpd/handler_test.go @@ -57,6 +57,11 @@ var ( defaultLookbackDuration = time.Minute defaultCPUProfileduration = 5 * time.Second defaultPlacementServices = []string{"m3db"} + svcDefaultOptions = []handler.ServiceOptionsDefault{ + func(o handler.ServiceOptions) handler.ServiceOptions { + return o + }, + } ) func makeTagOptions() models.TagOptions { @@ -95,7 +100,8 @@ func setupHandler(store storage.Storage) (*Handler, error) { models.QueryContextOptions{}, instrumentOpts, defaultCPUProfileduration, - defaultPlacementServices) + defaultPlacementServices, + svcDefaultOptions) } func TestHandlerFetchTimeoutError(t *testing.T) { @@ -107,9 +113,21 @@ func TestHandlerFetchTimeoutError(t *testing.T) { dbconfig := &dbconfig.DBConfiguration{Client: client.Configuration{FetchTimeout: &negValue}} engine := newEngine(storage, time.Minute, nil, instrument.NewOptions()) cfg := config.Configuration{LookbackDuration: &defaultLookbackDuration} - _, err := NewHandler(downsamplerAndWriter, makeTagOptions(), engine, nil, nil, - cfg, dbconfig, nil, handler.NewFetchOptionsBuilder(handler.FetchOptionsBuilderOptions{}), - models.QueryContextOptions{}, instrument.NewOptions(), defaultCPUProfileduration, defaultPlacementServices) + _, err := NewHandler( + downsamplerAndWriter, + makeTagOptions(), + engine, + nil, + nil, + cfg, + dbconfig, + nil, + handler.NewFetchOptionsBuilder(handler.FetchOptionsBuilderOptions{}), + models.QueryContextOptions{}, + instrument.NewOptions(), + defaultCPUProfileduration, + defaultPlacementServices, + svcDefaultOptions) require.Error(t, err) } @@ -123,9 +141,21 @@ func TestHandlerFetchTimeout(t *testing.T) { dbconfig := &dbconfig.DBConfiguration{Client: client.Configuration{FetchTimeout: &fourMin}} engine := newEngine(storage, time.Minute, nil, instrument.NewOptions()) cfg := config.Configuration{LookbackDuration: &defaultLookbackDuration} - h, err := NewHandler(downsamplerAndWriter, makeTagOptions(), engine, - nil, nil, cfg, dbconfig, nil, handler.NewFetchOptionsBuilder(handler.FetchOptionsBuilderOptions{}), - models.QueryContextOptions{}, instrument.NewOptions(), defaultCPUProfileduration, defaultPlacementServices) + h, err := NewHandler( + downsamplerAndWriter, + makeTagOptions(), + engine, + nil, + nil, + cfg, + dbconfig, + nil, + handler.NewFetchOptionsBuilder(handler.FetchOptionsBuilderOptions{}), + models.QueryContextOptions{}, + instrument.NewOptions(), + defaultCPUProfileduration, + defaultPlacementServices, + svcDefaultOptions) require.NoError(t, err) assert.Equal(t, 4*time.Minute, h.timeoutOpts.FetchTimeout) }