Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Richter <crichter@owncloud.com>
  • Loading branch information
dragonchaser committed Jul 13, 2022
1 parent 2160aea commit c9ee73a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
8 changes: 4 additions & 4 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def virtualViews():
"PATH_TO_CORE": "/drone/src/tmp/testrunner",
"TEST_SERVER_URL": "http://revad-services:20180",
"OCIS_REVA_DATA_ROOT": "/drone/src/tmp/reva/data/",
"DELETE_USER_DATA_CMD": "rm -rf /drone/src/tmp/reva/data/spaces/* /drone/src/tmp/reva/data/blobs/* /drone/src/tmp/reva/data/spacetypes/*",
"DELETE_USER_DATA_CMD": "rm -rf /drone/src/tmp/reva/data/spaces/* /drone/src/tmp/reva/data/blobs/* /drone/src/tmp/reva/data/indexes/by-type/*",
"STORAGE_DRIVER": "OCIS",
"SKELETON_DIR": "/drone/src/tmp/testing/data/apiSkeleton",
"TEST_REVA": "true",
Expand Down Expand Up @@ -756,7 +756,7 @@ def litmusOcisSpacesDav():
"commands": [
# The spaceid is randomly generated during the first login so we need this hack to construct the correct url.
"curl -s -k -u einstein:relativity -I http://revad-services:20080/remote.php/dav/files/einstein",
"export LITMUS_URL=http://revad-services:20080/remote.php/dav/spaces/$(ls /drone/src/tmp/reva/data/spacetypes/personal/)",
"export LITMUS_URL=http://revad-services:20080/remote.php/dav/spaces/$(ls /drone/src/tmp/reva/data/indexes/by-type/personal/)",
"/usr/local/bin/litmus-wrapper",
],
},
Expand Down Expand Up @@ -929,7 +929,7 @@ def ocisIntegrationTests(parallelRuns, skipExceptParts = []):
"environment": {
"TEST_SERVER_URL": "http://revad-services:20080",
"OCIS_REVA_DATA_ROOT": "/drone/src/tmp/reva/data/",
"DELETE_USER_DATA_CMD": "rm -rf /drone/src/tmp/reva/data/spaces/* /drone/src/tmp/reva/data/blobs/* /drone/src/tmp/reva/data/spacetypes/*",
"DELETE_USER_DATA_CMD": "rm -rf /drone/src/tmp/reva/data/spaces/* /drone/src/tmp/reva/data/blobs/* /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 Expand Up @@ -1008,7 +1008,7 @@ def s3ngIntegrationTests(parallelRuns, skipExceptParts = []):
"environment": {
"TEST_SERVER_URL": "http://revad-services:20080",
"OCIS_REVA_DATA_ROOT": "/drone/src/tmp/reva/data/",
"DELETE_USER_DATA_CMD": "rm -rf /drone/src/tmp/reva/data/spaces/* /drone/src/tmp/reva/data/blobs/* /drone/src/tmp/reva/data/spacetypes/*",
"DELETE_USER_DATA_CMD": "rm -rf /drone/src/tmp/reva/data/spaces/* /drone/src/tmp/reva/data/blobs/* /drone/src/tmp/reva/data/indexes/by-type/*",
"STORAGE_DRIVER": "S3NG",
"SKELETON_DIR": "/drone/src/tmp/testing/data/apiSkeleton",
"TEST_WITH_LDAP": "true",
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/grants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var _ = Describe("Grants", func() {
err := env.Fs.AddGrant(env.Ctx, ref, grant)
Expect(err).ToNot(HaveOccurred())

spaceTypesPath := filepath.Join(env.Root, "spacetypes")
spaceTypesPath := filepath.Join(env.Root, "indexes", "by-type")
tfs.root = spaceTypesPath
entries, err := fs.ReadDir(tfs, "share")
Expect(err).ToNot(HaveOccurred())
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ func (fs *Decomposedfs) DeleteStorageSpace(ctx context.Context, req *provider.De
return err
}
// remove type index
spaceTypePath := filepath.Join(fs.o.Root, "spacetypes", spaceType, spaceID)
spaceTypePath := filepath.Join(fs.o.Root, "indexes", "by-type", spaceType, spaceID)
if err := os.Remove(spaceTypePath); err != nil {
return err
}
Expand Down Expand Up @@ -629,7 +629,7 @@ func (fs *Decomposedfs) linkStorageSpaceType(ctx context.Context, spaceType stri
}

// link space in spacetypes
err := os.Symlink("../../../spaces/"+lookup.Pathify(spaceID, 1, 2)+"/nodes/"+lookup.Pathify(spaceID, 4, 2), filepath.Join(fs.o.Root, "spacetypes", spaceType, spaceID))
err := os.Symlink("../../../spaces/"+lookup.Pathify(spaceID, 1, 2)+"/nodes/"+lookup.Pathify(spaceID, 4, 2), filepath.Join(fs.o.Root, "indexes", "by-type", spaceType, spaceID))
if err != nil {
if isAlreadyExists(err) {
appctx.GetLogger(ctx).Debug().Err(err).Str("space", spaceID).Str("spacetype", spaceType).Msg("symlink already exists")
Expand Down
25 changes: 11 additions & 14 deletions pkg/storage/utils/decomposedfs/spaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package decomposedfs_test

import (
"os"
"path/filepath"

permissionsv1beta1 "github.com/cs3org/go-cs3apis/cs3/permissions/v1beta1"
rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
Expand Down Expand Up @@ -130,10 +129,7 @@ var _ = Describe("Spaces", func() {

DescribeTable("ReadSpaceAndNodeFromSpaceTypeLink",
func(link string, expectSpace string, expectedNode string, shouldErr bool) {
err := os.Symlink(link, filepath.Join(tmpdir, "link"))
Expect(err).ToNot(HaveOccurred())

space, node, err := decomposedfs.ReadSpaceAndNodeFromIndexLink(filepath.Join(tmpdir, "link"))
space, node, err := decomposedfs.ReadSpaceAndNodeFromIndexLink(link)
if shouldErr {
Expect(err).To(HaveOccurred())
} else {
Expand All @@ -143,15 +139,16 @@ var _ = Describe("Spaces", func() {
Expect(node).To(Equal(expectedNode))
},

Entry("invalid number of slashes", "../../spaces/sp_ace-id/nodes/sh/or/tn/od/eid", "", "", true),
Entry("does not contain spaces", "../../spac_s/sp/ace-id/nodes/sh/or/tn/od/eid", "", "", true),
Entry("does not contain nodes", "../../spaces/sp/ace-id/nod_s/sh/or/tn/od/eid", "", "", true),
Entry("does not start with ..", "_./../spaces/sp/ace-id/nodes/sh/or/tn/od/eid", "", "", true),
Entry("does not start with ../..", "../_./spaces/sp/ace-id/nodes/sh/or/tn/od/eid", "", "", true),
Entry("invalid", "../../spaces/space-id/nodes/sh/or/tn/od/eid", "", "", true),
Entry("uuid", "../../spaces/4c/510ada-c86b-4815-8820-42cdf82c3d51/nodes/4c/51/0a/da/-c86b-4815-8820-42cdf82c3d51", "4c510ada-c86b-4815-8820-42cdf82c3d51", "4c510ada-c86b-4815-8820-42cdf82c3d51", false),
Entry("uuid", "../../spaces/4c/510ada-c86b-4815-8820-42cdf82c3d51/nodes/4c/51/0a/da/-c86b-4815-8820-42cdf82c3d51.T.2022-02-24T12:35:18.196484592Z", "4c510ada-c86b-4815-8820-42cdf82c3d51", "4c510ada-c86b-4815-8820-42cdf82c3d51.T.2022-02-24T12:35:18.196484592Z", false),
Entry("short", "../../spaces/sp/ace-id/nodes/sh/or/tn/od/eid", "space-id", "shortnodeid", false),
Entry("invalid number of slashes", "../../../spaces/sp_ace-id/nodes/sh/or/tn/od/eid", "", "", true),
Entry("does not contain spaces", "../../../spac_s/sp/ace-id/nodes/sh/or/tn/od/eid", "", "", true),
Entry("does not contain nodes", "../../../spaces/sp/ace-id/nod_s/sh/or/tn/od/eid", "", "", true),
Entry("does not start with ..", "_./../../spaces/sp/ace-id/nodes/sh/or/tn/od/eid", "", "", true),
Entry("does not start with ../..", "../_./../spaces/sp/ace-id/nodes/sh/or/tn/od/eid", "", "", true),
Entry("does not start with ../../..", "../_./../spaces/sp/ace-id/nodes/sh/or/tn/od/eid", "", "", true),
Entry("invalid", "../../../spaces/space-id/nodes/sh/or/tn/od/eid", "", "", true),
Entry("uuid", "../../../spaces/4c/510ada-c86b-4815-8820-42cdf82c3d51/nodes/4c/51/0a/da/-c86b-4815-8820-42cdf82c3d51", "4c510ada-c86b-4815-8820-42cdf82c3d51", "4c510ada-c86b-4815-8820-42cdf82c3d51", false),
Entry("uuid", "../../../spaces/4c/510ada-c86b-4815-8820-42cdf82c3d51/nodes/4c/51/0a/da/-c86b-4815-8820-42cdf82c3d51.T.2022-02-24T12:35:18.196484592Z", "4c510ada-c86b-4815-8820-42cdf82c3d51", "4c510ada-c86b-4815-8820-42cdf82c3d51.T.2022-02-24T12:35:18.196484592Z", false),
Entry("short", "../../../spaces/sp/ace-id/nodes/sh/or/tn/od/eid", "space-id", "shortnodeid", false),
)
})
})
4 changes: 2 additions & 2 deletions tests/integration/grpc/gateway_storageprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ var _ = Describe("gateway", func() {
Expect(listRes.Status.Code).To(Equal(rpcv1beta1.Code_CODE_OK))
ssid, err := storagespace.ParseID(space.Id.OpaqueId)
Expect(err).ToNot(HaveOccurred())
_, err = os.Stat(path.Join(revads["storage"].StorageRoot, "/spacetypes/project", ssid.SpaceId))
_, err = os.Stat(path.Join(revads["storage"].StorageRoot, "/indexes/by-type/project", ssid.SpaceId))
Expect(err).To(HaveOccurred())
_, err = os.Stat(path.Join(revads["storage2"].StorageRoot, "/spacetypes/project", ssid.SpaceId))
_, err = os.Stat(path.Join(revads["storage2"].StorageRoot, "/indexes/by-type/project", ssid.SpaceId))
Expect(err).ToNot(HaveOccurred())
})

Expand Down

0 comments on commit c9ee73a

Please sign in to comment.