Skip to content

Commit

Permalink
Merge pull request #4967 from aduffeck/posixfs-flakiness
Browse files Browse the repository at this point in the history
[tests-only] Fix posixfs flakiness
  • Loading branch information
aduffeck authored Nov 21, 2024
2 parents d2f84b6 + ad7679e commit 43de17f
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ def posixfsIntegrationTests(parallelRuns, skipExceptParts = []):
"environment": {
"TEST_SERVER_URL": "http://revad-services:20080",
"OCIS_REVA_DATA_ROOT": "/drone/src/tmp/reva/data/",
"DELETE_USER_DATA_CMD": "bash -cx 'for i in {1..30}; do rm -rf /drone/src/tmp/reva/data/users/* /drone/src/tmp/reva/data/indexes/by-type/* && break || sleep 5; done; sleep 1'",
"DELETE_USER_DATA_CMD": "bash -cx 'rm -rf /drone/src/tmp/reva/data/users/* /drone/src/tmp/reva/data/indexes/by-type/*'",
"STORAGE_DRIVER": "ocis",
"SKELETON_DIR": "/drone/src/tmp/testing/data/apiSkeleton",
"TEST_WITH_LDAP": "true",
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/fs/ocis/ocis.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func init() {

// New returns an implementation to of the storage.FS interface that talk to
// a local filesystem.
func New(m map[string]interface{}, stream events.Stream, _ *zerolog.Logger) (storage.FS, error) {
func New(m map[string]interface{}, stream events.Stream, log *zerolog.Logger) (storage.FS, error) {
o, err := options.New(m)
if err != nil {
return nil, err
Expand All @@ -47,5 +47,5 @@ func New(m map[string]interface{}, stream events.Stream, _ *zerolog.Logger) (sto
return nil, err
}

return decomposedfs.NewDefault(m, bs, stream)
return decomposedfs.NewDefault(m, bs, stream, log)
}
3 changes: 2 additions & 1 deletion pkg/storage/fs/ocis/ocis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/cs3org/reva/v2/pkg/storage/fs/ocis"
"github.com/cs3org/reva/v2/tests/helpers"
"github.com/rs/zerolog"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -53,7 +54,7 @@ var _ = Describe("Ocis", func() {

Describe("New", func() {
It("returns a new instance", func() {
_, err := ocis.New(options, nil, nil)
_, err := ocis.New(options, nil, &zerolog.Logger{})
Expect(err).ToNot(HaveOccurred())
})
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/fs/posix/posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func New(m map[string]interface{}, stream events.Stream, log *zerolog.Logger) (s
Trashbin: trashbin,
}

dfs, err := decomposedfs.New(&o.Options, aspects)
dfs, err := decomposedfs.New(&o.Options, aspects, log)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/storage/fs/posix/posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/cs3org/reva/v2/pkg/storage/fs/posix"
"github.com/cs3org/reva/v2/tests/helpers"
"github.com/rs/zerolog"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -56,7 +57,7 @@ var _ = Describe("Posix", func() {

Describe("New", func() {
It("returns a new instance", func() {
_, err := posix.New(options, nil, nil)
_, err := posix.New(options, nil, &zerolog.Logger{})
Expect(err).ToNot(HaveOccurred())
})
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/fs/posix/testhelpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func NewTestEnv(config map[string]interface{}) (*TestEnv, error) {
Permissions: permissions.NewPermissions(pmock, permissionsSelector),
Trashbin: tb,
}
fs, err := decomposedfs.New(&o.Options, aspects)
fs, err := decomposedfs.New(&o.Options, aspects, &logger)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/fs/s3ng/s3ng.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func init() {

// New returns an implementation to of the storage.FS interface that talk to
// a local filesystem.
func New(m map[string]interface{}, stream events.Stream, _ *zerolog.Logger) (storage.FS, error) {
func New(m map[string]interface{}, stream events.Stream, log *zerolog.Logger) (storage.FS, error) {
o, err := parseConfig(m)
if err != nil {
return nil, err
Expand All @@ -59,5 +59,5 @@ func New(m map[string]interface{}, stream events.Stream, _ *zerolog.Logger) (sto
return nil, err
}

return decomposedfs.NewDefault(m, bs, stream)
return decomposedfs.NewDefault(m, bs, stream, log)
}
5 changes: 3 additions & 2 deletions pkg/storage/fs/s3ng/s3ng_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/cs3org/reva/v2/pkg/storage/fs/s3ng"
"github.com/cs3org/reva/v2/tests/helpers"
"github.com/rs/zerolog"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -58,12 +59,12 @@ var _ = Describe("S3ng", func() {

Describe("New", func() {
It("fails on missing s3 configuration", func() {
_, err := s3ng.New(map[string]interface{}{}, nil, nil)
_, err := s3ng.New(map[string]interface{}{}, nil, &zerolog.Logger{})
Expect(err).To(MatchError("S3 configuration incomplete"))
})

It("works with complete configuration", func() {
_, err := s3ng.New(options, nil, nil)
_, err := s3ng.New(options, nil, &zerolog.Logger{})
Expect(err).ToNot(HaveOccurred())
})
})
Expand Down
12 changes: 7 additions & 5 deletions pkg/storage/utils/decomposedfs/decomposedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/jellydator/ttlcache/v2"
"github.com/pkg/errors"
"github.com/rs/zerolog"
tusd "github.com/tus/tusd/v2/pkg/handler"
microstore "go-micro.dev/v4/store"
"go.opentelemetry.io/otel"
Expand Down Expand Up @@ -125,10 +126,12 @@ type Decomposedfs struct {
userSpaceIndex *spaceidindex.Index
groupSpaceIndex *spaceidindex.Index
spaceTypeIndex *spaceidindex.Index

log *zerolog.Logger
}

// NewDefault returns an instance with default components
func NewDefault(m map[string]interface{}, bs tree.Blobstore, es events.Stream) (storage.FS, error) {
func NewDefault(m map[string]interface{}, bs tree.Blobstore, es events.Stream, log *zerolog.Logger) (storage.FS, error) {
o, err := options.New(m)
if err != nil {
return nil, err
Expand Down Expand Up @@ -169,14 +172,12 @@ func NewDefault(m map[string]interface{}, bs tree.Blobstore, es events.Stream) (
Trashbin: &DecomposedfsTrashbin{},
}

return New(o, aspects)
return New(o, aspects, log)
}

// New returns an implementation of the storage.FS interface that talks to
// a local filesystem.
func New(o *options.Options, aspects aspects.Aspects) (storage.FS, error) {
log := logger.New()

func New(o *options.Options, aspects aspects.Aspects, log *zerolog.Logger) (storage.FS, error) {
err := aspects.Tree.Setup()
if err != nil {
log.Error().Err(err).Msg("could not setup tree")
Expand Down Expand Up @@ -235,6 +236,7 @@ func New(o *options.Options, aspects aspects.Aspects) (storage.FS, error) {
userSpaceIndex: userSpaceIndex,
groupSpaceIndex: groupSpaceIndex,
spaceTypeIndex: spaceTypeIndex,
log: log,
}
fs.sessionStore = upload.NewSessionStore(fs, aspects, o.Root, o.AsyncFileUploads, o.Tokens)
if err = fs.trashbin.Setup(fs); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/decomposedfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var _ = Describe("Decomposed", func() {
_, err := decomposedfs.NewDefault(map[string]interface{}{
"root": env.Root,
"permissionssvc": "any",
}, bs, nil)
}, bs, nil, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Expand Down
3 changes: 2 additions & 1 deletion pkg/storage/utils/decomposedfs/testhelpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/store"
"github.com/google/uuid"
"github.com/rs/zerolog"
"github.com/stretchr/testify/mock"
"google.golang.org/grpc"

Expand Down Expand Up @@ -178,7 +179,7 @@ func NewTestEnv(config map[string]interface{}) (*TestEnv, error) {
Permissions: permissions.NewPermissions(pmock, permissionsSelector),
Trashbin: &decomposedfs.DecomposedfsTrashbin{},
}
fs, err := decomposedfs.New(o, aspects)
fs, err := decomposedfs.New(o, aspects, &zerolog.Logger{})
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/storage/utils/decomposedfs/upload_async_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/cs3org/reva/v2/pkg/store"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/cs3org/reva/v2/tests/helpers"
"github.com/rs/zerolog"
"github.com/stretchr/testify/mock"
"google.golang.org/grpc"

Expand Down Expand Up @@ -180,7 +181,7 @@ var _ = Describe("Async file uploads", Ordered, func() {
EventStream: stream.Chan{pub, con},
Trashbin: &DecomposedfsTrashbin{},
}
fs, err = New(o, aspects)
fs, err = New(o, aspects, &zerolog.Logger{})
Expect(err).ToNot(HaveOccurred())

resp, err := fs.CreateStorageSpace(ctx, &provider.CreateStorageSpaceRequest{Owner: user, Type: "personal"})
Expand Down
3 changes: 2 additions & 1 deletion pkg/storage/utils/decomposedfs/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/store"
"github.com/cs3org/reva/v2/tests/helpers"
"github.com/rs/zerolog"
"github.com/stretchr/testify/mock"
"google.golang.org/grpc"

Expand Down Expand Up @@ -144,7 +145,7 @@ var _ = Describe("File uploads", func() {
Permissions: permissions.NewPermissions(pmock, permissionsSelector),
Trashbin: &decomposedfs.DecomposedfsTrashbin{},
}
fs, err = decomposedfs.New(o, aspects)
fs, err = decomposedfs.New(o, aspects, &zerolog.Logger{})
Expect(err).ToNot(HaveOccurred())

resp, err := fs.CreateStorageSpace(ctx, &provider.CreateStorageSpaceRequest{Owner: user, Type: "personal"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ root = "/drone/src/tmp/reva/data"
permissionssvc = "localhost:10000"
treetime_accounting = true
treesize_accounting = true
personalspacepath_template = "users/{{.User.Username}}"
personalspacepath_template = "users/{{.User.Id.OpaqueId}}"
generalspacepath_template = "projects/{{.SpaceId}}"
watch_fs = true

Expand Down

0 comments on commit 43de17f

Please sign in to comment.