Skip to content

Commit

Permalink
Merge branch 'main' into initSetup
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi authored Mar 2, 2023
2 parents 68f570d + dbca2b1 commit b8bb70d
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 41 deletions.
7 changes: 6 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
codecov:
require_ci_to_pass: true
notify:
after_n_builds: 4 # 1 for unit tests + 3 for integration tests with different handlers
after_n_builds: 4 # 1 for unit tests + at least 3 for integration tests with different handlers
wait_for_ci: true

# https://docs.codecov.com/docs/coverage-configuration
Expand All @@ -24,6 +24,11 @@ coverage:
ignore:
- cmd

# https://docs.codecov.com/docs/flags#recommended-automatic-flag-management
flag_management:
default_rules:
carryforward: false

# https://docs.codecov.com/docs/pull-request-comments
comment:
layout: reach,diff,files,flags
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ jobs:
- name: Run init
run: bin/task init

- name: Run build-testcover
run: bin/task build-testcover
- name: Run build-local
run: bin/task build-local

- name: Wait for and setup environment
run: bin/task env-setup

- name: Start FerretDB in the background
run: >
bin/ferretdb-testcover
bin/ferretdb-local
--listen-addr=:27017
--proxy-addr=127.0.0.1:47017
--mode=diff-normal
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ vendor/
*.txt
*.out
**/testdata/fuzz/
records/
state.json
tmp/
website/build/
Expand Down
50 changes: 24 additions & 26 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ env:
GORACE: halt_on_error=1,history_size=2

vars:
INTEGRATIONTIME: 11m
BENCHTIME: 5s
FUZZTIME: 15s
FUZZCORPUS: ../fuzz-corpus
Expand All @@ -22,7 +23,7 @@ tasks:
desc: "Generate, format, build, test and lint code and documentation"
cmds:
- task: gen
- task: build-testcover
- task: build-local
- task: test
- task: lint
- task: security
Expand All @@ -43,13 +44,13 @@ tasks:
env:
CGO_ENABLED: 0

build-testcover:
desc: "Build bin/ferretdb-testcover{{exeExt}}"
build-local:
desc: "Build bin/ferretdb-local{{exeExt}} on the host"
run: once
deps: [gen-version]
cmds:
# do not trim paths to make debugging with delve easier
- go test -c -o=bin/ferretdb-testcover{{exeExt}} -trimpath=false {{.RACEFLAG}} -tags=ferretdb_testcover,{{.BUILDTAGS}} -coverpkg=./... ./cmd/ferretdb
- go test -c -o=bin/ferretdb-local{{exeExt}} -trimpath=false {{.RACEFLAG}} -tags=ferretdb_testcover,{{.BUILDTAGS}} -coverpkg=./... ./cmd/ferretdb

init-tools:
dir: tools
Expand Down Expand Up @@ -80,7 +81,7 @@ tasks:
- docker system prune --all --volumes
- bin/golangci-lint{{exeExt}} cache clean
- go clean -cache -testcache -modcache -fuzzcache
- rm -fr .cache .task tools/.task integration/.task records tmp
- rm -fr .cache .task tools/.task integration/.task tmp
- task: env-pull
- task: init

Expand Down Expand Up @@ -175,37 +176,34 @@ tasks:
dir: integration
cmds:
- >
go test -count=1 {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
go test -count=1 -timeout={{.INTEGRATIONTIME}} {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
-coverprofile=integration-pg.txt .
-target-backend=ferretdb-pg
-target-tls
-postgresql-url=postgres://username@127.0.0.1:5432/ferretdb
-compat-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=../build/certs/client.pem&tlsCaFile=../build/certs/rootCA-cert.pem'
-records-dir=../records
test-integration-tigris:
desc: "Run integration tests for Tigris handler"
dir: integration
cmds:
- >
go test -count=1 {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
go test -count=1 -timeout={{.INTEGRATIONTIME}} {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
-coverprofile=integration-tigris.txt .
-target-backend=ferretdb-tigris
{{.UNIXSOCKETFLAG}}
-tigris-urls=127.0.0.1:8081,127.0.0.1:8091,127.0.0.1:8092,127.0.0.1:8093,127.0.0.1:8094
-compat-url=mongodb://127.0.0.1:47017/
-records-dir=../records
test-integration-mongodb:
desc: "Run integration tests for MongoDB"
dir: integration
cmds:
- >
go test -count=1 {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
go test -count=1 -timeout={{.INTEGRATIONTIME}} {{.RACEFLAG}} -tags={{.BUILDTAGS}} -shuffle=on -coverpkg=../...
-coverprofile=integration-mongodb.txt .
-target-url=mongodb://127.0.0.1:47017/
-target-backend=mongodb
-records-dir=../records
bench-short:
desc: "Benchmark for about 25 seconds (with default BENCHTIME)"
Expand Down Expand Up @@ -251,36 +249,36 @@ tasks:

run:
desc: "Run FerretDB with `pg` handler"
deps: [build-testcover]
deps: [build-local]
cmds:
- >
bin/ferretdb-testcover{{exeExt}} -test.coverprofile=cover.txt --
bin/ferretdb-local{{exeExt}} -test.coverprofile=cover.txt --
--listen-addr=:27017
--proxy-addr=127.0.0.1:47017
--mode=diff-normal
--handler=pg
--postgresql-url=postgres://username@127.0.0.1:5432/ferretdb
--test-records-dir=records
--test-records-dir=tmp/records
run-tigris:
desc: "Run FerretDB with `tigris` handler"
deps: [build-testcover]
deps: [build-local]
cmds:
- >
bin/ferretdb-testcover{{exeExt}} -test.coverprofile=cover.txt --
bin/ferretdb-local{{exeExt}} -test.coverprofile=cover.txt --
--listen-addr=:27017
--proxy-addr=127.0.0.1:47017
--mode=diff-normal
--handler=tigris
--tigris-url=127.0.0.1:8081
--test-records-dir=records
--test-records-dir=tmp/records
run-secured:
desc: "Run FerretDB with `pg` handler (TLS, auth required)"
deps: [build-testcover]
deps: [build-local]
cmds:
- >
bin/ferretdb-testcover{{exeExt}} -test.coverprofile=cover.txt --
bin/ferretdb-local{{exeExt}} -test.coverprofile=cover.txt --
--listen-addr=''
--listen-tls=:27018
--listen-tls-cert-file=./build/certs/server-cert.pem
Expand All @@ -290,15 +288,15 @@ tasks:
--mode=diff-normal
--handler=pg
--postgresql-url=postgres://127.0.0.1:5433/ferretdb
--test-records-dir=records
--test-records-dir=tmp/records
# set FERRETDB_TIGRIS_CLIENT_ID and FERRETDB_TIGRIS_CLIENT_SECRET environment variables to use it
run-tigris-secured:
desc: "Run FerretDB with `tigris` handler (TLS, auth required; SaaS)"
deps: [build-testcover]
deps: [build-local]
cmds:
- >
bin/ferretdb-testcover{{exeExt}} -test.coverprofile=cover.txt --
bin/ferretdb-local{{exeExt}} -test.coverprofile=cover.txt --
--listen-addr=''
--listen-tls=:27018
--listen-tls-cert-file=./build/certs/server-cert.pem
Expand All @@ -308,20 +306,20 @@ tasks:
--mode=diff-normal
--handler=tigris
--tigris-url=api.preview.tigrisdata.cloud
--test-records-dir=records
--test-records-dir=tmp/records
run-proxy:
desc: "Run FerretDB in diff-proxy mode"
deps: [build-testcover]
deps: [build-local]
cmds:
- >
bin/ferretdb-testcover{{exeExt}} -test.coverprofile=cover.txt --
bin/ferretdb-local{{exeExt}} -test.coverprofile=cover.txt --
--listen-addr=:27017
--proxy-addr=127.0.0.1:47017
--mode=diff-proxy
--handler=pg
--postgresql-url=postgres://username@127.0.0.1:5432/ferretdb
--test-records-dir=records
--test-records-dir=tmp/records
lint:
desc: "Run linters"
Expand Down
4 changes: 2 additions & 2 deletions cmd/ferretdb/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func TestCover(t *testing.T) {
// TestMain ensures that command-line flags are initialized correctly when FerretDB is run with coverage enabled.
func TestMain(m *testing.M) {
// Split flags for kong and for `go test` by "--". For example:
// bin/ferretdb-testcover -test.coverprofile=cover.txt -- --test-records-dir=records --mode=diff-normal --listen-addr=:27017
// forKong: --test-records-dir=records --mode=diff-normal --listen-addr=:27017
// bin/ferretdb-local -test.coverprofile=cover.txt -- --test-records-dir=tmp/records --mode=diff-normal --listen-addr=:27017
// forKong: --test-records-dir=tmp/records --mode=diff-normal --listen-addr=:27017
// forTest: -test.coverprofile=cover.txt
forKong := os.Args[1:]
forTest := []string{}
Expand Down
5 changes: 0 additions & 5 deletions integration/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,25 @@ tasks:
-tags=ferretdb_testenvdata .
-compat-port=0
-postgresql-url=postgres://username@127.0.0.1:5432/ferretdb?pool_min_conns=1
-records-dir=../records
- >
go test -count=1 {{.RACEFLAG}} -run=TestEnvData -v
-tags=ferretdb_testenvdata .
-compat-port=0
-postgresql-url=postgres://username:password@127.0.0.1:5433/ferretdb?pool_min_conns=1
-records-dir=../records
- >
go test -count=1 {{.RACEFLAG}} -run=TestEnvData -v
-tags=ferretdb_testenvdata,ferretdb_tigris .
-compat-port=0
-tigris-urls=127.0.0.1:8081,127.0.0.1:8082,127.0.0.1:8083,127.0.0.1:8085,127.0.0.1:8086
-records-dir=../records
# - >
# go test -count=1 {{.RACEFLAG}} -run=TestEnvData -v
# -tags=ferretdb_testenvdata .
# -records-dir=../records
# -compat-port=0
# -target-port=47017
# - >
# go test -count=1 {{.RACEFLAG}} -run=TestEnvData -v
# -tags=ferretdb_testenvdata .
# -compat-port=0
# -records-dir=../records
# -target-port=47018

integration-gen:
Expand Down
2 changes: 1 addition & 1 deletion integration/setup/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func setupListener(tb testing.TB, ctx context.Context, logger *zap.Logger) (*mon
Metrics: metrics,
Handler: h,
Logger: logger,
TestRecordsDir: *recordsDirF,
TestRecordsDir: filepath.Join("..", "tmp", "records"),
}

if *targetProxyAddrF != "" {
Expand Down
1 change: 0 additions & 1 deletion integration/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ var (
debugSetupF = flag.Bool("debug-setup", false, "enable debug logs for tests setup")
logLevelF = zap.LevelFlag("log-level", zap.DebugLevel, "log level for tests")

recordsDirF = flag.String("records-dir", "", "directory for record files")
disablePushdownF = flag.Bool("disable-pushdown", false, "disable query pushdown")
)

Expand Down
2 changes: 1 addition & 1 deletion internal/wire/wire_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func fuzzMessages(f *testing.F, testCases []testCase) {
}

if !testing.Short() {
records, err := loadRecords(filepath.Join("..", "..", "records"))
records, err := loadRecords(filepath.Join("..", "..", "tmp", "records"))
require.NoError(f, err)

f.Logf("%d recorded messages were added to the seed corpus", len(records))
Expand Down

0 comments on commit b8bb70d

Please sign in to comment.