Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test getMore integration test using one connection pool #2878

Merged
merged 35 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
913cb04
set pool size in client
chilagrow Jun 21, 2023
f916843
expose ClientOption to setup
chilagrow Jun 21, 2023
3e00842
rename and comment update
chilagrow Jun 23, 2023
04c75a6
use url.Values
chilagrow Jun 23, 2023
40a511f
tidy up
chilagrow Jun 26, 2023
2f1b735
add same client and different client connection tests
chilagrow Jun 26, 2023
5d0a147
update error message for same client tests
chilagrow Jun 26, 2023
9de04ca
skip test for feature not supported by FerretDB
chilagrow Jun 26, 2023
734d5bf
comment update
chilagrow Jun 26, 2023
962ed96
run subtests in parallel
chilagrow Jun 26, 2023
0a74652
merge
chilagrow Jun 27, 2023
b0e8761
test setup handles merging url with extra url.Values option
chilagrow Jun 27, 2023
733b144
use stresstest.Stress
chilagrow Jun 27, 2023
e6a30e5
add batchSize test for find and getMore
chilagrow Jun 27, 2023
c6811fe
add getMore test for using different client
chilagrow Jun 27, 2023
1b450c7
update test
chilagrow Jun 27, 2023
a21acef
Merge branch 'main' into issue-1807-analysis
chilagrow Jun 27, 2023
405e8c9
update commnet
chilagrow Jun 27, 2023
805fcb2
cleanup
chilagrow Jun 27, 2023
9e6b8e9
do not run session related tests in parallel
chilagrow Jun 27, 2023
1e1f975
refactor
chilagrow Jun 27, 2023
fe31dfd
fix
chilagrow Jun 27, 2023
baf6065
Merge branch 'main' into issue-1807-analysis
chilagrow Jun 27, 2023
aae64c8
separate mongodburi and setup listener from extra options
chilagrow Jun 28, 2023
a22d37c
refactoring func name
chilagrow Jun 28, 2023
1a65aac
update comments and rename
chilagrow Jun 28, 2023
0e7adb8
cleanup
chilagrow Jun 28, 2023
bb965f5
Merge branch 'main' into issue-1807-analysis
chilagrow Jun 28, 2023
a9ea919
Merge branch 'main' into issue-1807-analysis
AlekSi Jun 28, 2023
c2397d2
fix new linter
chilagrow Jun 28, 2023
d7d3b8e
Merge branch 'issue-1807-analysis' of github.com:chilagrow/FerretDB i…
chilagrow Jun 28, 2023
02f1d08
Merge branch 'main' into issue-1807-analysis
AlekSi Jun 28, 2023
d5df4e0
Tweak comment
AlekSi Jun 28, 2023
17db130
Simplify
AlekSi Jun 28, 2023
676af8a
Refactor
AlekSi Jun 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup
  • Loading branch information
chilagrow committed Jun 27, 2023
commit 805fcb2d348f6e5d255f79d961f9efc26bdf12aa
5 changes: 0 additions & 5 deletions integration/commands_diagnostic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,6 @@ func TestCommandWhatsMyURIConnection(t *testing.T) {
u, err := url.Parse(s.MongoDBURI)
require.NoError(t, err)

q2 := u.Query()
q2.Set("maxPoolSize", "1")
q2.Set("minPoolSize", "1")
u.RawQuery = q2.Encode()

client2, err := mongo.Connect(s.Ctx, options.Client().ApplyURI(u.String()))
require.NoError(t, err)

Expand Down
5 changes: 0 additions & 5 deletions integration/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1396,11 +1396,6 @@ func TestQueryCommandGetMoreConnection(t *testing.T) {
u, err := url.Parse(s.MongoDBURI)
require.NoError(t, err)

q2 := u.Query()
q2.Set("maxPoolSize", "1")
q2.Set("minPoolSize", "1")
u.RawQuery = q2.Encode()

client2, err := mongo.Connect(s.Ctx, options.Client().ApplyURI(u.String()))
require.NoError(t, err)

Expand Down
10 changes: 10 additions & 0 deletions integration/setup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type mongoDBURIOpts struct {
hostPort string // for TCP and TLS
unixSocketPath string
tlsAndAuth bool
maxPoolSize string
minPoolSize string
}

// mongoDBURI builds MongoDB URI with given options.
Expand Down Expand Up @@ -65,6 +67,14 @@ func mongoDBURI(tb testing.TB, opts *mongoDBURIOpts) string {
user = url.UserPassword("username", "password")
}

if opts.maxPoolSize != "" {
q.Set("maxPoolSize", opts.maxPoolSize)
}

if opts.minPoolSize != "" {
q.Set("minPoolSize", opts.minPoolSize)
}

// TODO https://github.com/FerretDB/FerretDB/issues/1507
u := &url.URL{
Scheme: "mongodb",
Expand Down
8 changes: 6 additions & 2 deletions integration/setup/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package setup
import (
"context"
"errors"
"net/url"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -65,7 +66,7 @@ func unixSocketPath(tb testing.TB) string {

// setupListener starts in-process FerretDB server that runs until ctx is canceled.
// It returns client and MongoDB URI of that listener.
func setupListener(tb testing.TB, ctx context.Context, logger *zap.Logger) (*mongo.Client, string) {
func setupListener(tb testing.TB, ctx context.Context, extraOpts url.Values, logger *zap.Logger) (*mongo.Client, string) {
tb.Helper()

_, span := otel.Tracer("").Start(ctx, "setupListener")
Expand Down Expand Up @@ -196,7 +197,10 @@ func setupListener(tb testing.TB, ctx context.Context, logger *zap.Logger) (*mon
<-runDone
})

var clientOpts mongoDBURIOpts
clientOpts := mongoDBURIOpts{
maxPoolSize: extraOpts.Get("maxPoolSize"),
minPoolSize: extraOpts.Get("minPoolSize"),
}

switch {
case *targetTLSF:
Expand Down
6 changes: 3 additions & 3 deletions integration/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func SetupWithOpts(tb testing.TB, opts *SetupOpts) *SetupResult {
var uri string

if *targetURLF == "" {
client, uri = setupListener(tb, setupCtx, logger)
client, uri = setupListener(tb, setupCtx, opts.ExtraOptions, logger)
} else {
u, err := url.Parse(*targetURLF)
require.NoError(tb, err)
Expand All @@ -153,8 +153,8 @@ func SetupWithOpts(tb testing.TB, opts *SetupOpts) *SetupResult {
}

u.RawQuery = q.Encode()
client = setupClient(tb, setupCtx, u.String())
uri = *targetURLF
uri = u.String()
client = setupClient(tb, setupCtx, uri)
}

// register cleanup function after setupListener registers its own to preserve full logs
Expand Down
2 changes: 1 addition & 1 deletion integration/setup/setup_compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func SetupCompatWithOpts(tb testing.TB, opts *SetupCompatOpts) *SetupCompatResul

var targetClient *mongo.Client
if *targetURLF == "" {
targetClient, _ = setupListener(tb, setupCtx, logger)
targetClient, _ = setupListener(tb, setupCtx, nil, logger)
} else {
targetClient = setupClient(tb, setupCtx, *targetURLF)
}
Expand Down