Skip to content

Commit

Permalink
Merge branch 'main' into aggregation-pushdown-sqlite-3520
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi authored Oct 23, 2023
2 parents 80ba1ae + 05a2ee3 commit 8a4dd60
Show file tree
Hide file tree
Showing 28 changed files with 444 additions and 251 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ jobs:

# This step will fail with "Error: Resource not accessible by integration"
# while trying to add label and comment to PR, that is not possible for PRs from forks.
# See https://github.com/ActionsDesk/lfs-warning/issues/147.
# See https://github.com/ppremk/lfs-warning/issues/147.
# But the real issue will be right above that message: a list of files that should be added using Git LFS.
- name: Check LFS status
uses: actionsdesk/lfs-warning@v3.2
uses: ppremk/lfs-warning@v3.2
with:
filesizelimit: 102400b
labelName: use-git-lfs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/website-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
BRANCH: ${{ github.head_ref }} # see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
run: git checkout -b $BRANCH

# no actionsdesk/lfs-warning due to https://github.com/ActionsDesk/lfs-warning/issues/150
# no ppremk/lfs-warning due to https://github.com/ppremk/lfs-warning/issues/150

- name: Setup Go
uses: FerretDB/github-actions/setup-go@main
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
BRANCH: ${{ github.head_ref }} # see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
run: git checkout -b $BRANCH

# no actionsdesk/lfs-warning due to https://github.com/ActionsDesk/lfs-warning/issues/150
# no ppremk/lfs-warning due to https://github.com/ppremk/lfs-warning/issues/150

- name: Setup Go
uses: FerretDB/github-actions/setup-go@main
Expand Down
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ linters-settings:
- BUG
- FIXME
- HACK
- lala
- lalala
goheader:
# Please do not update it, including bumping a year.
template: |-
Expand Down
16 changes: 9 additions & 7 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ tasks:
- go mod tidy
- go mod verify
- task: gen-version
- task: build-envtool

env-reset:
desc: "Clean ALL Go and Docker data (caches, images, volumes), and reset environment"
Expand Down Expand Up @@ -100,7 +99,7 @@ tasks:
{{.SERVICES}}
env-setup:
deps: [gen-version, build-envtool]
deps: [gen-version]
cmds:
- bin/envtool{{exeExt}} setup

Expand Down Expand Up @@ -140,11 +139,8 @@ tasks:
gen-version:
run: once
cmds:
# those two should always be in sync
- go generate -x ./build/version

build-envtool:
run: once
cmds:
- go build -v -o bin/ ./cmd/envtool/

build-host:
Expand Down Expand Up @@ -200,6 +196,7 @@ tasks:

test-integration-postgresql:
desc: "Run integration tests for `postgresql` backend"
deps: [gen-version]
dir: integration
cmds:
- >
Expand All @@ -225,6 +222,7 @@ tasks:
test-integration-sqlite:
desc: "Run integration tests for `sqlite` backend"
deps: [gen-version]
dir: integration
cmds:
- >
Expand All @@ -250,6 +248,7 @@ tasks:
test-integration-hana:
desc: "Run integration tests for `hana` handler"
deps: [gen-version]
dir: integration
cmds:
- >
Expand All @@ -276,6 +275,7 @@ tasks:
test-integration-mongodb:
desc: "Run integration tests for MongoDB"
deps: [gen-version]
dir: integration
cmds:
- >
Expand Down Expand Up @@ -329,6 +329,7 @@ tasks:

fuzz-corpus:
desc: "Sync seed and generated fuzz corpora with FUZZ_CORPUS"
deps: [gen-version]
cmds:
- bin/envtool{{exeExt}} fuzz corpus generated {{.FUZZ_CORPUS}}
- bin/envtool{{exeExt}} fuzz corpus seed {{.FUZZ_CORPUS}}
Expand Down Expand Up @@ -608,8 +609,9 @@ tasks:
vars:
DOCKER_IMAGES: ferretdb-local
OUTPUT: type=docker
TARGET: "{{.FILE}}"
requires:
vars: [FILE, TARGET]
vars: [FILE]

# TODO https://github.com/FerretDB/FerretDB/issues/2212
docker-all-in-one-push:
Expand Down
2 changes: 2 additions & 0 deletions integration/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ linters-settings:
- BUG
- FIXME
- HACK
- lala
- lalala
goheader:
# Please do not update it, including bumping a year.
template: |-
Expand Down
6 changes: 3 additions & 3 deletions integration/indexes_command_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func TestDropIndexesCommandCompat(tt *testing.T) {
targetList := FetchAll(t, ctx, targetCursor)
compatList := FetchAll(t, ctx, compatCursor)

require.Equal(t, compatList, targetList)
require.ElementsMatch(t, compatList, targetList)
}

targetCommand := bson.D{
Expand Down Expand Up @@ -451,7 +451,7 @@ func TestDropIndexesCommandCompat(tt *testing.T) {
require.Nil(t, compatRes)
}

require.Equal(t, compatRes, targetRes)
require.ElementsMatch(t, compatRes, targetRes)

if compatErr == nil {
nonEmptyResults = true
Expand All @@ -474,7 +474,7 @@ func TestDropIndexesCommandCompat(tt *testing.T) {
targetList := FetchAll(t, ctx, targetCursor)
compatList := FetchAll(t, ctx, compatCursor)

assert.Equal(t, compatList, targetList)
assert.ElementsMatch(t, compatList, targetList)
})
}

Expand Down
4 changes: 2 additions & 2 deletions integration/indexes_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func TestCreateIndexesCompat(tt *testing.T) {
targetIndexes := FetchAll(t, ctx, targetCursor)
compatIndexes := FetchAll(t, ctx, compatCursor)

assert.Equal(t, compatIndexes, targetIndexes)
assert.ElementsMatch(t, compatIndexes, targetIndexes)

// List specifications to check they are identical after creation.
targetSpec, targetErr := targetCollection.Indexes().ListSpecifications(ctx)
Expand All @@ -295,7 +295,7 @@ func TestCreateIndexesCompat(tt *testing.T) {
require.NoError(t, targetErr)

require.NotEmpty(t, compatSpec)
assert.Equal(t, compatSpec, targetSpec)
assert.ElementsMatch(t, compatSpec, targetSpec)
})
}

Expand Down
13 changes: 7 additions & 6 deletions internal/backends/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
package backends

import (
"cmp"
"context"
"slices"
"time"

"github.com/FerretDB/FerretDB/internal/types"
Expand Down Expand Up @@ -319,12 +321,11 @@ func (cc *collectionContract) ListIndexes(ctx context.Context, params *ListIndex
res, err := cc.c.ListIndexes(ctx, params)
checkError(err, ErrorCodeCollectionDoesNotExist)

// TODO https://github.com/FerretDB/FerretDB/issues/3589
// if res != nil && len(res.Indexes) > 0 {
// must.BeTrue(slices.IsSortedFunc(res.Indexes, func(a, b IndexInfo) int {
// return cmp.Compare(a.Name, b.Name)
// }))
// }
if res != nil && len(res.Indexes) > 0 {
must.BeTrue(slices.IsSortedFunc(res.Indexes, func(a, b IndexInfo) int {
return cmp.Compare(a.Name, b.Name)
}))
}

return res, err
}
Expand Down
27 changes: 13 additions & 14 deletions internal/backends/decorators/oplog/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package oplog provides decorators that add OpLog functionality to the backend.
package oplog

import (
Expand All @@ -26,58 +25,58 @@ import (

// backend implements backends.Backend interface by delegating all methods to the wrapped backend.
type backend struct {
b backends.Backend
l *zap.Logger
origB backends.Backend
l *zap.Logger
}

// NewBackend creates a new backend that wraps the given backend.
func NewBackend(b backends.Backend, l *zap.Logger) backends.Backend {
func NewBackend(origB backends.Backend, l *zap.Logger) backends.Backend {
return &backend{
b: b,
l: l,
origB: origB,
l: l,
}
}

// Close implements backends.Backend interface.
func (b *backend) Close() {
b.b.Close()
b.origB.Close()
}

// Status implements backends.Backend interface.
func (b *backend) Status(ctx context.Context, params *backends.StatusParams) (*backends.StatusResult, error) {
return b.b.Status(ctx, params)
return b.origB.Status(ctx, params)
}

// Database implements backends.Backend interface.
func (b *backend) Database(name string) (backends.Database, error) {
db, err := b.b.Database(name)
origDB, err := b.origB.Database(name)
if err != nil {
return nil, err
}

return newDatabase(db, name, b.l), nil
return newDatabase(origDB, name, b, b.l), nil
}

// ListDatabases implements backends.Backend interface.
//
//nolint:lll // for readability
func (b *backend) ListDatabases(ctx context.Context, params *backends.ListDatabasesParams) (*backends.ListDatabasesResult, error) {
return b.b.ListDatabases(ctx, params)
return b.origB.ListDatabases(ctx, params)
}

// DropDatabase implements backends.Backend interface.
func (b *backend) DropDatabase(ctx context.Context, params *backends.DropDatabaseParams) error {
return b.b.DropDatabase(ctx, params)
return b.origB.DropDatabase(ctx, params)
}

// Describe implements prometheus.Collector.
func (b *backend) Describe(ch chan<- *prometheus.Desc) {
b.b.Describe(ch)
b.origB.Describe(ch)
}

// Collect implements prometheus.Collector.
func (b *backend) Collect(ch chan<- prometheus.Metric) {
b.b.Collect(ch)
b.origB.Collect(ch)
}

// check interfaces
Expand Down
Loading

0 comments on commit 8a4dd60

Please sign in to comment.