diff --git a/changelog/unreleased/materialized-xattrs.md b/changelog/unreleased/materialized-xattrs.md index 1412b4e7f5..c42b475d06 100644 --- a/changelog/unreleased/materialized-xattrs.md +++ b/changelog/unreleased/materialized-xattrs.md @@ -2,4 +2,5 @@ Enhancement: Introduce ini file based metadata backend We added a new metadata backend for the decomposed storage driver that uses an additional `.ini` file to store file metadata. This allows scaling beyond some filesystem specific xattr limitations. -https://github.com/cs3org/reva/pull/3649 \ No newline at end of file +https://github.com/cs3org/reva/pull/3674 +https://github.com/cs3org/reva/pull/3649 diff --git a/pkg/storage/utils/decomposedfs/xattrs/backend/backend_suite_test.go b/pkg/storage/utils/decomposedfs/xattrs/backend/backend_suite_test.go new file mode 100644 index 0000000000..9c0695a325 --- /dev/null +++ b/pkg/storage/utils/decomposedfs/xattrs/backend/backend_suite_test.go @@ -0,0 +1,13 @@ +package backend_test + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestBackend(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Backend Suite") +} diff --git a/pkg/storage/utils/decomposedfs/xattrs/backend/backend_test.go b/pkg/storage/utils/decomposedfs/xattrs/backend/backend_test.go index dfa6ccf3a7..b2717143a2 100644 --- a/pkg/storage/utils/decomposedfs/xattrs/backend/backend_test.go +++ b/pkg/storage/utils/decomposedfs/xattrs/backend/backend_test.go @@ -58,7 +58,7 @@ var _ = Describe("Backend", func() { Describe("IniBackend", func() { BeforeEach(func() { - backend = xattrsBackend.IniBackend{} + backend = xattrsBackend.NewIniBackend() }) Describe("Set", func() { @@ -81,6 +81,15 @@ var _ = Describe("Backend", func() { Expect(err).ToNot(HaveOccurred()) Expect(string(content)).To(Equal("foo = baz\n")) }) + + It("encodes where needed", func() { + err := backend.Set(file, "user.ocis.cs.foo", "bar") + Expect(err).ToNot(HaveOccurred()) + + content, err := os.ReadFile(metafile) + Expect(err).ToNot(HaveOccurred()) + Expect(string(content)).To(Equal("user.ocis.cs.foo = YmFy\n")) + }) }) Describe("SetMultiple", func() { @@ -105,6 +114,20 @@ var _ = Describe("Backend", func() { lines := strings.Split(strings.Trim(string(content), "\n"), "\n") Expect(lines).To(ConsistOf("foo = bar", "baz = qux")) }) + + It("encodes where needed", func() { + err := backend.SetMultiple(file, map[string]string{ + "user.ocis.something.foo": "bar", + "user.ocis.cs.foo": "bar", + "user.ocis.md.foo": "bar", + "user.ocis.grant.foo": "bar", + }) + Expect(err).ToNot(HaveOccurred()) + + content, err := os.ReadFile(metafile) + Expect(err).ToNot(HaveOccurred()) + Expect(strings.ReplaceAll(string(content), " ", "")).To(Equal("user.ocis.something.foo=bar\nuser.ocis.cs.foo=YmFy\nuser.ocis.md.foo=YmFy\nuser.ocis.grant.foo=YmFy\n")) + }) }) Describe("All", func() { @@ -191,5 +214,21 @@ var _ = Describe("Backend", func() { Expect(err).To(HaveOccurred()) }) }) + + Describe("UsesExternalMetadataFile", func() { + It("returns true", func() { + Expect(backend.UsesExternalMetadataFile()).To(BeTrue()) + }) + }) + + Describe("IsMetaFile", func() { + It("returns true", func() { + Expect(backend.IsMetaFile("foo.ini")).To(BeTrue()) + }) + + It("returns false", func() { + Expect(backend.IsMetaFile("foo.txt")).To(BeFalse()) + }) + }) }) })