From e5a9925cdb9e801318ef32efb19a98ec55299866 Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Wed, 31 Jul 2024 18:50:43 +0400 Subject: [PATCH 1/9] Disable auth for now --- .github/workflows/dance.yml | 16 ++++++++-------- docker-compose.yml | 2 -- tools/go.mod | 2 +- tools/go.sum | 4 ++-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dance.yml b/.github/workflows/dance.yml index a31d76762..b21176a2e 100644 --- a/.github/workflows/dance.yml +++ b/.github/workflows/dance.yml @@ -51,21 +51,21 @@ jobs: - dotnet-plain - dotnet-scram - # - java - # - java-plain - # - java-scram + - java + - java-plain + - java-scram - python - python-plain - python-scram - # - mongo-tools + - mongo-tools - # - restheart - # - restheart-auth + - restheart + - restheart-auth - # - ycsb-workloada - # - ycsb-workloadc + - ycsb-workloada + - ycsb-workloadc steps: - name: Checkout code diff --git a/docker-compose.yml b/docker-compose.yml index 1d3838e75..745fae5ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,6 @@ services: - FERRETDB_HANDLER=postgresql - FERRETDB_POSTGRESQL_URL=postgres://user@postgres:5432/dance - FERRETDB_REPL_SET_NAME=rs0 - - FERRETDB_TEST_ENABLE_NEW_AUTH=true extra_hosts: - "host.docker.internal:host-gateway" @@ -29,7 +28,6 @@ services: - FERRETDB_HANDLER=sqlite - FERRETDB_SQLITE_URL=file:/state/?_pragma=busy_timeout(20000) - FERRETDB_REPL_SET_NAME=rs0 - - FERRETDB_TEST_ENABLE_NEW_AUTH=true extra_hosts: - "host.docker.internal:host-gateway" diff --git a/tools/go.mod b/tools/go.mod index 7cb8bc9a8..6dbbc67ba 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -307,7 +307,7 @@ require ( google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect google.golang.org/grpc v1.59.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect diff --git a/tools/go.sum b/tools/go.sum index f7853cfbb..efbdd1f35 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -1289,8 +1289,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From e1069597dde6f260db8adb9f1c6b0aeaae4ef01e Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Mon, 5 Aug 2024 13:32:32 +0400 Subject: [PATCH 2/9] Move --- docker-compose.yml | 55 +++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 745fae5ef..ffa270827 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,28 @@ --- services: - postgresql: + mongodb: + build: + context: ./build/deps + dockerfile: mongo7.Dockerfile + command: --config /etc/mongod.conf + container_name: dance_mongodb + restart: unless-stopped + ulimits: + nproc: 64000 + nofile: + soft: 64000 + hard: 64000 + ports: + - 27017:27017 + environment: + # Always UTC+05:45. Set to catch timezone problems. + - TZ=Asia/Kathmandu + extra_hosts: + - "host.docker.internal:host-gateway" + volumes: + - ./build/mongod.conf:/etc/mongod.conf + + ferretdb-postgresql: image: ${FERRETDB_IMAGE:-ferretdb-local} container_name: dance_postgresql restart: unless-stopped @@ -11,12 +33,12 @@ services: # Always UTC+05:45. Set to catch timezone problems. - TZ=Asia/Kathmandu - FERRETDB_HANDLER=postgresql - - FERRETDB_POSTGRESQL_URL=postgres://user@postgres:5432/dance + - FERRETDB_POSTGRESQL_URL=postgres://postgres_user:postgres_password@postgres:5432/dance - FERRETDB_REPL_SET_NAME=rs0 extra_hosts: - "host.docker.internal:host-gateway" - sqlite: + ferretdb-sqlite: image: ${FERRETDB_IMAGE:-ferretdb-local} container_name: dance_sqlite restart: unless-stopped @@ -42,33 +64,10 @@ services: environment: # UTC−03:30/−02:30. Set to catch timezone problems. - TZ=America/St_Johns - - POSTGRES_USER=user + - POSTGRES_USER=postgres_user + - POSTGRES_PASSWORD=postgres_password - POSTGRES_DB=dance - - POSTGRES_HOST_AUTH_METHOD=trust - - mongodb: - build: - context: ./build/deps - dockerfile: mongo7.Dockerfile - command: --config /etc/mongod.conf - container_name: dance_mongodb - restart: unless-stopped - ulimits: - nproc: 64000 - nofile: - soft: 64000 - hard: 64000 - ports: - - 27017:27017 - environment: - # Always UTC+05:45. Set to catch timezone problems. - - TZ=Asia/Kathmandu - extra_hosts: - - "host.docker.internal:host-gateway" - volumes: - - ./build/mongod.conf:/etc/mongod.conf - # never started normally, used only for mongosh, mongodump, etc. mongosh: build: context: ./build/deps From dceec2ecdfdb35177f5320f5e281805ac2bacb5d Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Mon, 5 Aug 2024 13:41:14 +0400 Subject: [PATCH 3/9] Update --- .github/workflows/dance-trust.yml | 4 ++-- .github/workflows/dance.yml | 4 ++-- CONTRIBUTING.md | 12 ++++++------ Taskfile.yaml | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dance-trust.yml b/.github/workflows/dance-trust.yml index b157fc663..905b38300 100644 --- a/.github/workflows/dance-trust.yml +++ b/.github/workflows/dance-trust.yml @@ -54,8 +54,8 @@ jobs: fail-fast: false matrix: db: - - postgresql - - sqlite + - ferretdb-postgresql + - ferretdb-sqlite - mongodb test: - enmeshed-runtime diff --git a/.github/workflows/dance.yml b/.github/workflows/dance.yml index b21176a2e..494895109 100644 --- a/.github/workflows/dance.yml +++ b/.github/workflows/dance.yml @@ -43,8 +43,8 @@ jobs: fail-fast: false matrix: db: - - postgresql - - sqlite + - ferretdb-postgresql + - ferretdb-sqlite - mongodb test: - dotnet diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 561e6b5fb..aae6236c7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,11 +25,11 @@ to include required submodules. ## Running tests ```sh -bin/task dance DB=postgresql TEST=mongo-go-driver +bin/task dance DB=ferretdb-postgresql TEST=mongo-go-driver ``` That command will run `mongo-go-driver` tests against FerretDB with PostgreSQL backend. -`DB` environment variable should have the value `postgresql`, `sqlite`, or `mongodb`. +`DB` environment variable should have the value `ferretdb-postgresql`, `ferretdb-sqlite`, or `mongodb`. It defines what tests are expected to pass and fail. For example, see [mongo-go-driver tests configuration](https://github.com/FerretDB/dance/blob/main/tests/mongo-go-driver.yml). `TEST` environment variable should have the value matching a YAML file in the `tests` directory, or be empty. @@ -42,18 +42,18 @@ bin/task env-up DB=mongodb ``` That command will start MongoDB in Docker container. -Please note that running `bin/task dance DB=postgresql` after that would run tests against that MongoDB, +Please note that running `bin/task dance DB=ferretdb-postgresql` after that would run tests against that MongoDB, but results would be compared against results expected for FerretDB. In short, that would be wrong. ```sh -bin/task env-up DB=postgresql +bin/task env-up DB=ferretdb-postgresql ``` or ```sh -bin/task env-up DB=sqlite +bin/task env-up DB=ferretdb-sqlite ``` That command will start FerretDB with a specified backend from `ferretdb-local` Docker image. @@ -78,7 +78,7 @@ For example if you wanted to add your Java application to dance, you would do th 4. Start the environment and test it locally before submitting a PR to ensure that it works correctly. Refer to the above [section](#starting-environment-with-docker-compose) on how to start the environment. -5. Run the test locally to verify the output `bin/task dance DB=postgresql TEST=my-app`. +5. Run the test locally to verify the output `bin/task dance DB=ferretdb-postgresql TEST=my-app`. 6. Submit a PR to with a title of the form "Add MyApp tests". See an example [shell script](https://github.com/FerretDB/dance/blob/main/tests/java-example.sh) diff --git a/Taskfile.yaml b/Taskfile.yaml index 172b73732..0252eb9d3 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -44,7 +44,7 @@ tasks: - task: init-user preconditions: - sh: "test {{.DB}}" - msg: "Please set DB variable to one of `postgresql`, `sqlite`, or `mongodb`" + msg: "Please set DB variable to one of `ferretdb-postgresql`, `ferretdb-sqlite`, or `mongodb`" env-pull: cmds: @@ -72,7 +72,7 @@ tasks: - go run ../cmd/dance -db={{.DB}} -p={{.PARALLEL}} {{.TEST}} preconditions: - sh: "test {{.DB}}" - msg: "Please set DB variable to one of `postgresql`, `sqlite`, or `mongodb`" + msg: "Please set DB variable to one of `ferretdb-postgresql`, `ferretdb-sqlite`, or `mongodb`" lint: desc: "Run linters" From 3e469b5138528b816b90bfb709f8f30bfae17510 Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Mon, 5 Aug 2024 13:49:06 +0400 Subject: [PATCH 4/9] Fix --- internal/config/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index ae4c8f9b7..8172e862e 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -134,11 +134,11 @@ func (c *Config) ForDB(dbName string) (*TestConfig, error) { func (r *Results) forDB(dbName string) (*TestConfig, error) { switch dbName { - case "postgresql": + case "ferretdb-postgresql": if c := r.PostgreSQL; c != nil { return c, nil } - case "sqlite": + case "ferretdb-sqlite": if c := r.SQLite; c != nil { return c, nil } From 4b9fad684ca099fe96458cfdffa553e85c7d2f2d Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Mon, 5 Aug 2024 13:58:26 +0400 Subject: [PATCH 5/9] Update --- tests/dotnet.yml | 8 ++------ tests/java.yml | 8 ++------ tests/python.yml | 8 ++------ tests/restheart.yml | 10 ++-------- 4 files changed, 8 insertions(+), 26 deletions(-) diff --git a/tests/dotnet.yml b/tests/dotnet.yml index c0156506a..0fd166423 100644 --- a/tests/dotnet.yml +++ b/tests/dotnet.yml @@ -5,16 +5,12 @@ args: [../_scripts/dotnet.sh] results: postgresql: - # TODO https://github.com/FerretDB/dance/issues/889 - default: fail stats: - fail: 1 + pass: 1 sqlite: - # TODO https://github.com/FerretDB/dance/issues/889 - default: fail stats: - fail: 1 + pass: 1 mongodb: stats: diff --git a/tests/java.yml b/tests/java.yml index acb98b092..814d1d668 100644 --- a/tests/java.yml +++ b/tests/java.yml @@ -5,16 +5,12 @@ args: [../../_scripts/java.sh] results: postgresql: - # TODO https://github.com/FerretDB/dance/issues/891 - default: fail stats: - fail: 1 + pass: 1 sqlite: - # TODO https://github.com/FerretDB/dance/issues/891 - default: fail stats: - fail: 1 + pass: 1 mongodb: stats: diff --git a/tests/python.yml b/tests/python.yml index b57a5b588..7897a3408 100644 --- a/tests/python.yml +++ b/tests/python.yml @@ -5,16 +5,12 @@ args: [../_scripts/python.sh] results: postgresql: - # TODO https://github.com/FerretDB/dance/issues/890 - default: fail stats: - fail: 1 + pass: 1 sqlite: - # TODO https://github.com/FerretDB/dance/issues/890 - default: fail stats: - fail: 1 + pass: 1 mongodb: stats: diff --git a/tests/restheart.yml b/tests/restheart.yml index 738084292..639d620a1 100644 --- a/tests/restheart.yml +++ b/tests/restheart.yml @@ -6,17 +6,11 @@ args: [../_scripts/restheart.sh] results: postgresql: stats: - # https://github.com/FerretDB/FerretDB/issues/2568 - fail: 1 - fail: - - restheart + pass: 1 sqlite: stats: - # https://github.com/FerretDB/FerretDB/issues/2568 - fail: 1 - fail: - - restheart + pass: 1 mongodb: stats: From c761baf12b95ece08bfe7d43bc6f3d380b80bb05 Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Mon, 5 Aug 2024 14:04:03 +0400 Subject: [PATCH 6/9] Refactor --- internal/config/config.go | 169 +--------------------------------- internal/config/testconfig.go | 167 +++++++++++++++++++++++++++++++++ internal/config/testresult.go | 28 ++++++ 3 files changed, 198 insertions(+), 166 deletions(-) create mode 100644 internal/config/testconfig.go create mode 100644 internal/config/testresult.go diff --git a/internal/config/config.go b/internal/config/config.go index 8172e862e..770590bc8 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -17,10 +17,6 @@ package config import ( "fmt" - "sort" - "strings" - - "golang.org/x/exp/maps" ) const ( @@ -73,22 +69,6 @@ type Results struct { MongoDB *TestConfig } -// TestConfig represents the configuration for tests categorized by status and regular expressions. -type TestConfig struct { - Default Status - Stats *Stats - Fail Tests - Skip Tests - Pass Tests - Ignore Tests -} - -// TestResult represents the outcome of a single test. -type TestResult struct { - Status Status - Output string -} - // TestResults represents the collection of results from multiple tests. type TestResults struct { // Test results by full test name. @@ -129,21 +109,17 @@ const ( // ForDB returns the database-specific test configuration based on the provided dbName. func (c *Config) ForDB(dbName string) (*TestConfig, error) { - return c.Results.forDB(dbName) -} - -func (r *Results) forDB(dbName string) (*TestConfig, error) { switch dbName { case "ferretdb-postgresql": - if c := r.PostgreSQL; c != nil { + if c := c.Results.PostgreSQL; c != nil { return c, nil } case "ferretdb-sqlite": - if c := r.SQLite; c != nil { + if c := c.Results.SQLite; c != nil { return c, nil } case "mongodb": - if c := r.MongoDB; c != nil { + if c := c.Results.MongoDB; c != nil { return c, nil } default: @@ -152,142 +128,3 @@ func (r *Results) forDB(dbName string) (*TestConfig, error) { return nil, fmt.Errorf("no expected results for %q", dbName) } - -// IndentedOutput returns the output of a test result with indented lines. -func (tr *TestResult) IndentedOutput() string { - return strings.ReplaceAll(tr.Output, "\n", "\n\t") -} - -// Compare compares two *TestResults and returns a *CompareResult containing the differences. -func (tc *TestConfig) Compare(results *TestResults) (*CompareResult, error) { - compareResult := &CompareResult{ - ExpectedFail: make(map[string]string), - ExpectedSkip: make(map[string]string), - ExpectedPass: make(map[string]string), - UnexpectedFail: make(map[string]string), - UnexpectedSkip: make(map[string]string), - UnexpectedPass: make(map[string]string), - Unknown: make(map[string]string), - } - - tcMap := tc.toMap() - - tests := maps.Keys(results.TestResults) - sort.Strings(tests) - - for _, test := range tests { - expectedRes := tc.Default - testRes := results.TestResults[test] - - for prefix := test; prefix != ""; prefix = nextPrefix(prefix) { - if res, ok := tcMap[prefix]; ok { - expectedRes = res - break - } - } - - testResOutput := testRes.IndentedOutput() - - switch expectedRes { - case Fail: - switch testRes.Status { - case Fail: - compareResult.ExpectedFail[test] = testResOutput - case Skip: - compareResult.UnexpectedSkip[test] = testResOutput - case Pass: - compareResult.UnexpectedPass[test] = testResOutput - case Ignore, Unknown: - fallthrough - default: - compareResult.Unknown[test] = testResOutput - } - case Skip: - switch testRes.Status { - case Fail: - compareResult.UnexpectedFail[test] = testResOutput - case Skip: - compareResult.ExpectedSkip[test] = testResOutput - case Pass: - compareResult.UnexpectedPass[test] = testResOutput - case Ignore, Unknown: - fallthrough - default: - compareResult.Unknown[test] = testResOutput - } - case Pass: - switch testRes.Status { - case Fail: - compareResult.UnexpectedFail[test] = testResOutput - case Skip: - compareResult.UnexpectedSkip[test] = testResOutput - case Pass: - compareResult.ExpectedPass[test] = testResOutput - case Ignore, Unknown: - fallthrough - default: - compareResult.Unknown[test] = testResOutput - } - case Ignore: - continue - case Unknown: - fallthrough - default: - panic(fmt.Sprintf("unexpected expectedRes: %q", expectedRes)) - } - } - - compareResult.Stats = Stats{ - UnexpectedFail: len(compareResult.UnexpectedFail), - UnexpectedSkip: len(compareResult.UnexpectedSkip), - UnexpectedPass: len(compareResult.UnexpectedPass), - ExpectedFail: len(compareResult.ExpectedFail), - ExpectedSkip: len(compareResult.ExpectedSkip), - ExpectedPass: len(compareResult.ExpectedPass), - Unknown: len(compareResult.Unknown), - } - - return compareResult, nil -} - -// toMap converts *TestConfig to the map of tests. -// The map stores test names as a keys and their status (fail|skip|pass), as their value. -func (tc *TestConfig) toMap() map[string]Status { - res := make(map[string]Status, len(tc.Pass.Names)+len(tc.Skip.Names)+len(tc.Fail.Names)) - - for _, tcat := range []struct { - testsStatus Status - tests Tests - }{ - {Fail, tc.Fail}, - {Skip, tc.Skip}, - {Pass, tc.Pass}, - {Ignore, tc.Ignore}, - } { - for _, t := range tcat.tests.Names { - res[t] = tcat.testsStatus - } - } - - return res -} - -// nextPrefix returns the next prefix of the given path, stopping on / and . -// It panics for empty string. -func nextPrefix(path string) string { - if path == "" { - panic("path is empty") - } - - if t := strings.TrimRight(path, "."); t != path { - return t - } - - if t := strings.TrimRight(path, "/"); t != path { - return t - } - - i := strings.LastIndexAny(path, "/.") - - return path[:i+1] -} diff --git a/internal/config/testconfig.go b/internal/config/testconfig.go new file mode 100644 index 000000000..a748dd945 --- /dev/null +++ b/internal/config/testconfig.go @@ -0,0 +1,167 @@ +// Copyright 2021 FerretDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package config + +import ( + "fmt" + "sort" + "strings" + + "golang.org/x/exp/maps" +) + +// TestConfig represents the configuration for tests categorized by status and regular expressions. +type TestConfig struct { + Default Status + Stats *Stats + Fail Tests + Skip Tests + Pass Tests + Ignore Tests +} + +// Compare compares two *TestResults and returns a *CompareResult containing the differences. +func (tc *TestConfig) Compare(results *TestResults) (*CompareResult, error) { + compareResult := &CompareResult{ + ExpectedFail: make(map[string]string), + ExpectedSkip: make(map[string]string), + ExpectedPass: make(map[string]string), + UnexpectedFail: make(map[string]string), + UnexpectedSkip: make(map[string]string), + UnexpectedPass: make(map[string]string), + Unknown: make(map[string]string), + } + + tcMap := tc.toMap() + + tests := maps.Keys(results.TestResults) + sort.Strings(tests) + + for _, test := range tests { + expectedRes := tc.Default + testRes := results.TestResults[test] + + for prefix := test; prefix != ""; prefix = nextPrefix(prefix) { + if res, ok := tcMap[prefix]; ok { + expectedRes = res + break + } + } + + testResOutput := testRes.IndentedOutput() + + switch expectedRes { + case Fail: + switch testRes.Status { + case Fail: + compareResult.ExpectedFail[test] = testResOutput + case Skip: + compareResult.UnexpectedSkip[test] = testResOutput + case Pass: + compareResult.UnexpectedPass[test] = testResOutput + case Ignore, Unknown: + fallthrough + default: + compareResult.Unknown[test] = testResOutput + } + case Skip: + switch testRes.Status { + case Fail: + compareResult.UnexpectedFail[test] = testResOutput + case Skip: + compareResult.ExpectedSkip[test] = testResOutput + case Pass: + compareResult.UnexpectedPass[test] = testResOutput + case Ignore, Unknown: + fallthrough + default: + compareResult.Unknown[test] = testResOutput + } + case Pass: + switch testRes.Status { + case Fail: + compareResult.UnexpectedFail[test] = testResOutput + case Skip: + compareResult.UnexpectedSkip[test] = testResOutput + case Pass: + compareResult.ExpectedPass[test] = testResOutput + case Ignore, Unknown: + fallthrough + default: + compareResult.Unknown[test] = testResOutput + } + case Ignore: + continue + case Unknown: + fallthrough + default: + panic(fmt.Sprintf("unexpected expectedRes: %q", expectedRes)) + } + } + + compareResult.Stats = Stats{ + UnexpectedFail: len(compareResult.UnexpectedFail), + UnexpectedSkip: len(compareResult.UnexpectedSkip), + UnexpectedPass: len(compareResult.UnexpectedPass), + ExpectedFail: len(compareResult.ExpectedFail), + ExpectedSkip: len(compareResult.ExpectedSkip), + ExpectedPass: len(compareResult.ExpectedPass), + Unknown: len(compareResult.Unknown), + } + + return compareResult, nil +} + +// toMap converts *TestConfig to the map of tests. +// The map stores test names as a keys and their status (fail|skip|pass), as their value. +func (tc *TestConfig) toMap() map[string]Status { + res := make(map[string]Status, len(tc.Pass.Names)+len(tc.Skip.Names)+len(tc.Fail.Names)) + + for _, tcat := range []struct { + testsStatus Status + tests Tests + }{ + {Fail, tc.Fail}, + {Skip, tc.Skip}, + {Pass, tc.Pass}, + {Ignore, tc.Ignore}, + } { + for _, t := range tcat.tests.Names { + res[t] = tcat.testsStatus + } + } + + return res +} + +// nextPrefix returns the next prefix of the given path, stopping on / and . +// It panics for empty string. +func nextPrefix(path string) string { + if path == "" { + panic("path is empty") + } + + if t := strings.TrimRight(path, "."); t != path { + return t + } + + if t := strings.TrimRight(path, "/"); t != path { + return t + } + + i := strings.LastIndexAny(path, "/.") + + return path[:i+1] +} diff --git a/internal/config/testresult.go b/internal/config/testresult.go new file mode 100644 index 000000000..78662f2d4 --- /dev/null +++ b/internal/config/testresult.go @@ -0,0 +1,28 @@ +// Copyright 2021 FerretDB Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package config + +import "strings" + +// TestResult represents the outcome of a single test. +type TestResult struct { + Status Status + Output string +} + +// IndentedOutput returns the output of a test result with indented lines. +func (tr *TestResult) IndentedOutput() string { + return strings.ReplaceAll(tr.Output, "\n", "\n\t") +} From 360e8625bfe4f18eb4c95cff028e441074576f31 Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Mon, 5 Aug 2024 14:07:10 +0400 Subject: [PATCH 7/9] Update --- tests/java.yml | 8 ++++++-- tests/restheart.yml | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/java.yml b/tests/java.yml index 814d1d668..acb98b092 100644 --- a/tests/java.yml +++ b/tests/java.yml @@ -5,12 +5,16 @@ args: [../../_scripts/java.sh] results: postgresql: + # TODO https://github.com/FerretDB/dance/issues/891 + default: fail stats: - pass: 1 + fail: 1 sqlite: + # TODO https://github.com/FerretDB/dance/issues/891 + default: fail stats: - pass: 1 + fail: 1 mongodb: stats: diff --git a/tests/restheart.yml b/tests/restheart.yml index 639d620a1..354bd7ccb 100644 --- a/tests/restheart.yml +++ b/tests/restheart.yml @@ -5,12 +5,14 @@ args: [../_scripts/restheart.sh] results: postgresql: + default: fail stats: - pass: 1 + fail: 1 sqlite: + default: fail stats: - pass: 1 + fail: 1 mongodb: stats: From 4ac3aa513bcbcf526bcbbdaf3e0655c3ccd7184d Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Mon, 5 Aug 2024 14:14:43 +0400 Subject: [PATCH 8/9] Fix --- tests/java-scram.yml | 3 ++- tests/java.yml | 3 ++- tests/python-plain.yml | 8 ++------ tests/restheart.yml | 3 ++- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/java-scram.yml b/tests/java-scram.yml index 712b09c68..51ccaea84 100644 --- a/tests/java-scram.yml +++ b/tests/java-scram.yml @@ -17,5 +17,6 @@ results: fail: 1 mongodb: + default: fail stats: - pass: 1 + fail: 1 diff --git a/tests/java.yml b/tests/java.yml index acb98b092..d0c08bf28 100644 --- a/tests/java.yml +++ b/tests/java.yml @@ -17,5 +17,6 @@ results: fail: 1 mongodb: + default: fail stats: - pass: 1 + fail: 1 diff --git a/tests/python-plain.yml b/tests/python-plain.yml index c7a58f9ec..f270d255c 100644 --- a/tests/python-plain.yml +++ b/tests/python-plain.yml @@ -5,16 +5,12 @@ args: [../_scripts/python-plain.sh] results: postgresql: - # TODO https://github.com/FerretDB/dance/issues/890 - default: fail stats: - fail: 1 + pass: 1 sqlite: - # TODO https://github.com/FerretDB/dance/issues/890 - default: fail stats: - fail: 1 + pass: 1 mongodb: # PLAIN is used in MongoDB to perform LDAP authentication diff --git a/tests/restheart.yml b/tests/restheart.yml index 354bd7ccb..1a9ceac6f 100644 --- a/tests/restheart.yml +++ b/tests/restheart.yml @@ -15,5 +15,6 @@ results: fail: 1 mongodb: + default: fail stats: - pass: 1 + fail: 1 From 5147e67142e37316f4cb9d9a62742c9c089fc32e Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Mon, 5 Aug 2024 14:38:32 +0400 Subject: [PATCH 9/9] Update --- .github/workflows/dance.yml | 14 +++++++------- internal/config/config.go | 4 +--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/dance.yml b/.github/workflows/dance.yml index 494895109..9af794437 100644 --- a/.github/workflows/dance.yml +++ b/.github/workflows/dance.yml @@ -48,21 +48,21 @@ jobs: - mongodb test: - dotnet - - dotnet-plain - - dotnet-scram + # - dotnet-plain + # - dotnet-scram - java - - java-plain - - java-scram + # - java-plain + # - java-scram - python - - python-plain - - python-scram + # - python-plain + # - python-scram - mongo-tools - restheart - - restheart-auth + # - restheart-auth - ycsb-workloada - ycsb-workloadc diff --git a/internal/config/config.go b/internal/config/config.go index 770590bc8..6d75a9085 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -15,9 +15,7 @@ // Package config provides functionality for handling and validating configuration data for test execution. package config -import ( - "fmt" -) +import "fmt" const ( // RunnerTypeCommand indicates a command-line test runner.