Skip to content

Commit

Permalink
Rename testing flag (FerretDB#2437)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi authored and fenogentov committed Apr 17, 2023
1 parent be92f42 commit 22545b5
Show file tree
Hide file tree
Showing 23 changed files with 54 additions and 52 deletions.
10 changes: 5 additions & 5 deletions cmd/ferretdb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ var cli struct {
Telemetry telemetry.Flag `default:"undecided" help:"Enable or disable basic telemetry. See https://beacon.ferretdb.io."`

Test struct {
RecordsDir string `default:"" help:"Experimental: directory for record files."`
DisablePushdown bool `default:"false" help:"Experimental: disable query pushdown."`
EnableCursors bool `default:"false" help:"Experimental: enable cursors."`
RecordsDir string `default:"" help:"Experimental: directory for record files."`
DisableFilterPushdown bool `default:"false" help:"Experimental: disable filter pushdown."`
EnableCursors bool `default:"false" help:"Experimental: enable cursors."`

//nolint:lll // for readability
Telemetry struct {
Expand Down Expand Up @@ -338,8 +338,8 @@ func run() {
HANAURL: hanaFlags.HANAURL,

TestOpts: registry.TestOpts{
DisablePushdown: cli.Test.DisablePushdown,
EnableCursors: cli.Test.EnableCursors,
DisableFilterPushdown: cli.Test.DisableFilterPushdown,
EnableCursors: cli.Test.EnableCursors,
},
})
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions ferretdb/ferretdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ type FerretDB struct {

// New creates a new instance of embeddable FerretDB implementation.
func New(config *Config) (*FerretDB, error) {
version.Get().Package = "embedded"

if config.Listener.TCP == "" &&
config.Listener.Unix == "" &&
config.Listener.TLS == "" {
Expand Down
4 changes: 2 additions & 2 deletions integration/setup/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ func setupListener(tb testing.TB, ctx context.Context, logger *zap.Logger) (*mon
TigrisURL: nextTigrisUrl(),

TestOpts: registry.TestOpts{
DisablePushdown: *disablePushdownF,
EnableCursors: *enableCursorsF,
DisableFilterPushdown: *disableFilterPushdownF,
EnableCursors: *enableCursorsF,
},
}
h, err := registry.NewHandler(handler, handlerOpts)
Expand Down
4 changes: 2 additions & 2 deletions integration/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ var (
debugSetupF = flag.Bool("debug-setup", false, "enable debug logs for tests setup")
logLevelF = zap.LevelFlag("log-level", zap.DebugLevel, "log level for tests")

disablePushdownF = flag.Bool("disable-pushdown", false, "disable query pushdown")
enableCursorsF = flag.Bool("enable-cursors", false, "enable cursors")
disableFilterPushdownF = flag.Bool("disable-filter-pushdown", false, "disable filter pushdown")
enableCursorsF = flag.Bool("enable-cursors", false, "enable cursors")
)

// Other globals.
Expand Down
2 changes: 1 addition & 1 deletion integration/setup/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ func TigrisOnlyWithReason(tb testing.TB, reason string) {

// IsPushdownDisabled returns if FerretDB pushdowns are disabled.
func IsPushdownDisabled() bool {
return *disablePushdownF
return *disableFilterPushdownF
}
2 changes: 1 addition & 1 deletion internal/handlers/pg/msg_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (h *Handler) MsgCount(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, e

var resDocs []*types.Document
err = dbPool.InTransaction(ctx, func(tx pgx.Tx) error {
resDocs, err = fetchAndFilterDocs(ctx, &fetchParams{tx, &qp, h.DisablePushdown})
resDocs, err = fetchAndFilterDocs(ctx, &fetchParams{tx, &qp, h.DisableFilterPushdown})
return err
})

Expand Down
12 changes: 6 additions & 6 deletions internal/handlers/pg/msg_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (h *Handler) MsgDelete(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg,
return nil, err
}

del, err := execDelete(ctx, &execDeleteParams{dbPool, &qp, h.DisablePushdown, limited})
del, err := execDelete(ctx, &execDeleteParams{dbPool, &qp, h.DisableFilterPushdown, limited})
if err == nil {
deleted += del
continue
Expand Down Expand Up @@ -178,10 +178,10 @@ func (h *Handler) prepareDeleteParams(deleteDoc *types.Document) (*types.Documen

// execDeleteParams contains parameters for execDelete function.
type execDeleteParams struct {
dbPool *pgdb.Pool
qp *pgdb.QueryParams
disablePushdown bool
limited bool
dbPool *pgdb.Pool
qp *pgdb.QueryParams
disableFilterPushdown bool
limited bool
}

// execDelete fetches documents, filters them out, limits them (if needed) and deletes them.
Expand All @@ -194,7 +194,7 @@ func execDelete(ctx context.Context, dp *execDeleteParams) (int32, error) {
// qp.Filter is used to filter documents on the PostgreSQL side (query pushdown).
filter := dp.qp.Filter

if dp.disablePushdown {
if dp.disableFilterPushdown {
dp.qp.Filter = nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/pg/msg_distinct.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (h *Handler) MsgDistinct(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg

var resDocs []*types.Document
err = dbPool.InTransaction(ctx, func(tx pgx.Tx) error {
resDocs, err = fetchAndFilterDocs(ctx, &fetchParams{tx, &qp, h.DisablePushdown})
resDocs, err = fetchAndFilterDocs(ctx, &fetchParams{tx, &qp, h.DisableFilterPushdown})
return err
})

Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/pg/msg_explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (h *Handler) MsgExplain(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg,
qp.Filter = aggregations.GetPushdownQuery(stagesDocs)
}

if h.DisablePushdown {
if h.DisableFilterPushdown {
qp.Filter = nil
}

Expand Down
10 changes: 5 additions & 5 deletions internal/handlers/pg/msg_find.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (h *Handler) MsgFind(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, er
}
}

if !h.DisablePushdown {
if !h.DisableFilterPushdown {
qp.Filter = params.Filter
}

Expand Down Expand Up @@ -166,9 +166,9 @@ func (h *Handler) MsgFind(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, er

// fetchParams is used to pass parameters to fetchAndFilterDocs.
type fetchParams struct {
tx pgx.Tx
qp *pgdb.QueryParams
disablePushdown bool
tx pgx.Tx
qp *pgdb.QueryParams
disableFilterPushdown bool
}

// fetchAndFilterDocs fetches documents from the database and filters them using the provided sqlParam.Filter.
Expand All @@ -177,7 +177,7 @@ func fetchAndFilterDocs(ctx context.Context, fp *fetchParams) ([]*types.Document
// qp.Filter is used to filter documents on the PostgreSQL side (query pushdown).
filter := fp.qp.Filter

if fp.disablePushdown {
if fp.disableFilterPushdown {
fp.qp.Filter = nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/pg/msg_findandmodify.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (h *Handler) MsgFindAndModify(ctx context.Context, msg *wire.OpMsg) (*wire.
var reply wire.OpMsg
err = dbPool.InTransaction(ctx, func(tx pgx.Tx) error {
var resDocs []*types.Document
resDocs, err = fetchAndFilterDocs(ctx, &fetchParams{tx, &qp, h.DisablePushdown})
resDocs, err = fetchAndFilterDocs(ctx, &fetchParams{tx, &qp, h.DisableFilterPushdown})
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/pg/msg_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (h *Handler) MsgUpdate(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg,

qp.Filter = q

resDocs, err := fetchAndFilterDocs(ctx, &fetchParams{tx, &qp, h.DisablePushdown})
resDocs, err := fetchAndFilterDocs(ctx, &fetchParams{tx, &qp, h.DisableFilterPushdown})
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/handlers/pg/pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ type NewOpts struct {
StateProvider *state.Provider

// test options
DisablePushdown bool
EnableCursors bool
DisableFilterPushdown bool
EnableCursors bool
}

// New returns a new handler.
Expand Down
8 changes: 4 additions & 4 deletions internal/handlers/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ type NewHandlerOpts struct {

// TestOpts represents experimental configuration options.
type TestOpts struct {
DisablePushdown bool
EnableCursors bool
DisableFilterPushdown bool
EnableCursors bool
}

// NewHandler constructs a new handler.
Expand Down Expand Up @@ -100,8 +100,8 @@ func init() {
Metrics: opts.Metrics,
StateProvider: opts.StateProvider,

DisablePushdown: opts.DisablePushdown,
EnableCursors: opts.EnableCursors,
DisableFilterPushdown: opts.DisableFilterPushdown,
EnableCursors: opts.EnableCursors,
}
return pg.New(handlerOpts)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/handlers/registry/tigris.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func init() {
Metrics: opts.Metrics,
StateProvider: opts.StateProvider,

DisablePushdown: opts.DisablePushdown,
EnableCursors: opts.EnableCursors,
DisableFilterPushdown: opts.DisableFilterPushdown,
EnableCursors: opts.EnableCursors,
}
return tigris.New(handlerOpts)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/tigris/msg_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (h *Handler) MsgCount(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, e
)
}

resDocs, err := fetchAndFilterDocs(ctx, &fetchParams{dbPool, &qp, h.DisablePushdown})
resDocs, err := fetchAndFilterDocs(ctx, &fetchParams{dbPool, &qp, h.DisableFilterPushdown})
if err != nil {
return nil, err
}
Expand Down
12 changes: 6 additions & 6 deletions internal/handlers/tigris/msg_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (h *Handler) MsgDelete(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg,
return nil, err
}

del, err := execDelete(ctx, &deleteParams{dbPool, &qp, h.DisablePushdown, limited})
del, err := execDelete(ctx, &deleteParams{dbPool, &qp, h.DisableFilterPushdown, limited})
if err == nil {
deleted += del
continue
Expand Down Expand Up @@ -174,10 +174,10 @@ func (h *Handler) prepareDeleteParams(deleteDoc *types.Document) (*types.Documen

// deleteParams contains parameters for execDelete function.
type deleteParams struct {
dbPool *tigrisdb.TigrisDB
qp *tigrisdb.QueryParams
disablePushdown bool
limited bool
dbPool *tigrisdb.TigrisDB
qp *tigrisdb.QueryParams
disableFilterPushdown bool
limited bool
}

// execDelete fetches documents, filter them out and limiting with the given limit value.
Expand All @@ -193,7 +193,7 @@ func execDelete(ctx context.Context, dp *deleteParams) (int32, error) {
// qp.Filter is used to filter documents on the Tigris side (query pushdown).
filter := dp.qp.Filter

if dp.disablePushdown {
if dp.disableFilterPushdown {
dp.qp.Filter = nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/tigris/msg_distinct.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (h *Handler) MsgDistinct(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg
Filter: dp.Filter,
}

resDocs, err := fetchAndFilterDocs(ctx, &fetchParams{dbPool, &qp, h.DisablePushdown})
resDocs, err := fetchAndFilterDocs(ctx, &fetchParams{dbPool, &qp, h.DisableFilterPushdown})
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/tigris/msg_explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (h *Handler) MsgExplain(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg,
filter = aggregations.GetPushdownQuery(stagesDocs)
}

if h.DisablePushdown {
if h.DisableFilterPushdown {
filter = nil
}

Expand Down
10 changes: 5 additions & 5 deletions internal/handlers/tigris/msg_find.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (h *Handler) MsgFind(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, er
Filter: params.Filter,
}

if !h.DisablePushdown {
if !h.DisableFilterPushdown {
qp.Filter = params.Filter
}

Expand Down Expand Up @@ -136,9 +136,9 @@ func (h *Handler) MsgFind(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, er

// fetchParams is used to pass parameters to fetchAndFilterDocs.
type fetchParams struct {
dbPool *tigrisdb.TigrisDB
qp *tigrisdb.QueryParams
disablePushdown bool
dbPool *tigrisdb.TigrisDB
qp *tigrisdb.QueryParams
disableFilterPushdown bool
}

// fetchAndFilterDocs fetches documents from the database and filters them using the provided QueryParams.Filter.
Expand All @@ -147,7 +147,7 @@ func fetchAndFilterDocs(ctx context.Context, fp *fetchParams) ([]*types.Document
// qp.Filter is used to filter documents on the Tigris side (query pushdown).
filter := fp.qp.Filter

if fp.disablePushdown {
if fp.disableFilterPushdown {
fp.qp.Filter = nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/tigris/msg_findandmodify.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (h *Handler) MsgFindAndModify(ctx context.Context, msg *wire.OpMsg) (*wire.
Filter: params.Query,
}

resDocs, err := fetchAndFilterDocs(ctx, &fetchParams{dbPool, &qp, h.DisablePushdown})
resDocs, err := fetchAndFilterDocs(ctx, &fetchParams{dbPool, &qp, h.DisableFilterPushdown})
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/tigris/msg_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (h *Handler) MsgUpdate(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg,
return nil, err
}

resDocs, err := fetchAndFilterDocs(ctx, &fetchParams{dbPool, &qp, h.DisablePushdown})
resDocs, err := fetchAndFilterDocs(ctx, &fetchParams{dbPool, &qp, h.DisableFilterPushdown})
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/handlers/tigris/tigris.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ type NewOpts struct {
StateProvider *state.Provider

// test options
DisablePushdown bool
EnableCursors bool
DisableFilterPushdown bool
EnableCursors bool
}

// AuthParams represents authentication parameters.
Expand Down

0 comments on commit 22545b5

Please sign in to comment.