mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-08 13:19:58 -06:00
skip cs3 index in favor of integration tests. running them require a locally running storage-metadata service
This commit is contained in:
@@ -1,82 +1,83 @@
|
||||
package cs3
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/indexer/option"
|
||||
. "github.com/owncloud/ocis/accounts/pkg/indexer/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
const cs3RootFolder = "/var/tmp/ocis/storage/users/data"
|
||||
|
||||
func TestAutoincrementIndexAdd(t *testing.T) {
|
||||
dataDir, err := WriteIndexTestData(Data, "ID", cs3RootFolder)
|
||||
assert.NoError(t, err)
|
||||
cfg := generateConfig()
|
||||
|
||||
sut := NewAutoincrementIndex(
|
||||
option.WithTypeName(GetTypeFQN(User{})),
|
||||
option.WithIndexBy("UID"),
|
||||
option.WithDataURL(cfg.Repo.CS3.DataURL),
|
||||
option.WithDataPrefix(cfg.Repo.CS3.DataPrefix),
|
||||
option.WithJWTSecret(cfg.Repo.CS3.JWTSecret),
|
||||
option.WithProviderAddr(cfg.Repo.CS3.ProviderAddr),
|
||||
)
|
||||
|
||||
assert.NoError(t, sut.Init())
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
res, err := sut.Add("abcdefg-123", "")
|
||||
assert.NoError(t, err)
|
||||
t.Log(res)
|
||||
}
|
||||
|
||||
_ = os.RemoveAll(dataDir)
|
||||
}
|
||||
|
||||
func BenchmarkAutoincrementIndexAdd(b *testing.B) {
|
||||
dataDir, err := WriteIndexTestData(Data, "ID", cs3RootFolder)
|
||||
assert.NoError(b, err)
|
||||
cfg := generateConfig()
|
||||
|
||||
sut := NewAutoincrementIndex(
|
||||
option.WithTypeName(GetTypeFQN(User{})),
|
||||
option.WithIndexBy("UID"),
|
||||
option.WithDataURL(cfg.Repo.CS3.DataURL),
|
||||
option.WithDataPrefix(cfg.Repo.CS3.DataPrefix),
|
||||
option.WithJWTSecret(cfg.Repo.CS3.JWTSecret),
|
||||
option.WithProviderAddr(cfg.Repo.CS3.ProviderAddr),
|
||||
)
|
||||
|
||||
err = sut.Init()
|
||||
assert.NoError(b, err)
|
||||
|
||||
for n := 0; n < b.N; n++ {
|
||||
_, err := sut.Add("abcdefg-123", "")
|
||||
if err != nil {
|
||||
b.Error(err)
|
||||
}
|
||||
assert.NoError(b, err)
|
||||
}
|
||||
|
||||
_ = os.RemoveAll(dataDir)
|
||||
}
|
||||
|
||||
func generateConfig() config.Config {
|
||||
return config.Config{
|
||||
Repo: config.Repo{
|
||||
Disk: config.Disk{
|
||||
Path: "",
|
||||
},
|
||||
CS3: config.CS3{
|
||||
ProviderAddr: "0.0.0.0:9215",
|
||||
DataURL: "http://localhost:9216",
|
||||
DataPrefix: "data",
|
||||
JWTSecret: "Pive-Fumkiu4",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
//
|
||||
//import (
|
||||
// "os"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/owncloud/ocis/accounts/pkg/config"
|
||||
// "github.com/owncloud/ocis/accounts/pkg/indexer/option"
|
||||
// . "github.com/owncloud/ocis/accounts/pkg/indexer/test"
|
||||
// "github.com/stretchr/testify/assert"
|
||||
//)
|
||||
//
|
||||
//const cs3RootFolder = "/var/tmp/ocis/storage/users/data"
|
||||
//
|
||||
//func TestAutoincrementIndexAdd(t *testing.T) {
|
||||
// dataDir, err := WriteIndexTestData(Data, "ID", cs3RootFolder)
|
||||
// assert.NoError(t, err)
|
||||
// cfg := generateConfig()
|
||||
//
|
||||
// sut := NewAutoincrementIndex(
|
||||
// option.WithTypeName(GetTypeFQN(User{})),
|
||||
// option.WithIndexBy("UID"),
|
||||
// option.WithDataURL(cfg.Repo.CS3.DataURL),
|
||||
// option.WithDataPrefix(cfg.Repo.CS3.DataPrefix),
|
||||
// option.WithJWTSecret(cfg.Repo.CS3.JWTSecret),
|
||||
// option.WithProviderAddr(cfg.Repo.CS3.ProviderAddr),
|
||||
// )
|
||||
//
|
||||
// assert.NoError(t, sut.Init())
|
||||
//
|
||||
// for i := 0; i < 5; i++ {
|
||||
// res, err := sut.Add("abcdefg-123", "")
|
||||
// assert.NoError(t, err)
|
||||
// t.Log(res)
|
||||
// }
|
||||
//
|
||||
// _ = os.RemoveAll(dataDir)
|
||||
//}
|
||||
//
|
||||
//func BenchmarkAutoincrementIndexAdd(b *testing.B) {
|
||||
// dataDir, err := WriteIndexTestData(Data, "ID", cs3RootFolder)
|
||||
// assert.NoError(b, err)
|
||||
// cfg := generateConfig()
|
||||
//
|
||||
// sut := NewAutoincrementIndex(
|
||||
// option.WithTypeName(GetTypeFQN(User{})),
|
||||
// option.WithIndexBy("UID"),
|
||||
// option.WithDataURL(cfg.Repo.CS3.DataURL),
|
||||
// option.WithDataPrefix(cfg.Repo.CS3.DataPrefix),
|
||||
// option.WithJWTSecret(cfg.Repo.CS3.JWTSecret),
|
||||
// option.WithProviderAddr(cfg.Repo.CS3.ProviderAddr),
|
||||
// )
|
||||
//
|
||||
// err = sut.Init()
|
||||
// assert.NoError(b, err)
|
||||
//
|
||||
// for n := 0; n < b.N; n++ {
|
||||
// _, err := sut.Add("abcdefg-123", "")
|
||||
// if err != nil {
|
||||
// b.Error(err)
|
||||
// }
|
||||
// assert.NoError(b, err)
|
||||
// }
|
||||
//
|
||||
// _ = os.RemoveAll(dataDir)
|
||||
//}
|
||||
//
|
||||
//func generateConfig() config.Config {
|
||||
// return config.Config{
|
||||
// Repo: config.Repo{
|
||||
// Disk: config.Disk{
|
||||
// Path: "",
|
||||
// },
|
||||
// CS3: config.CS3{
|
||||
// ProviderAddr: "0.0.0.0:9215",
|
||||
// DataURL: "http://localhost:9216",
|
||||
// DataPrefix: "data",
|
||||
// JWTSecret: "Pive-Fumkiu4",
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,67 +1,68 @@
|
||||
package cs3
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/indexer/option"
|
||||
. "github.com/owncloud/ocis/accounts/pkg/indexer/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCS3NonUniqueIndex_FakeSymlink(t *testing.T) {
|
||||
dataDir, err := WriteIndexTestData(Data, "ID", cs3RootFolder)
|
||||
assert.NoError(t, err)
|
||||
cfg := config.Config{
|
||||
Repo: config.Repo{
|
||||
Disk: config.Disk{
|
||||
Path: "",
|
||||
},
|
||||
CS3: config.CS3{
|
||||
ProviderAddr: "0.0.0.0:9215",
|
||||
DataURL: "http://localhost:9216",
|
||||
DataPrefix: "data",
|
||||
JWTSecret: "Pive-Fumkiu4",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
sut := NewNonUniqueIndexWithOptions(
|
||||
option.WithTypeName(GetTypeFQN(User{})),
|
||||
option.WithIndexBy("UserName"),
|
||||
option.WithFilesDir(path.Join(cfg.Repo.Disk.Path, "/meta")),
|
||||
option.WithDataDir(cfg.Repo.Disk.Path),
|
||||
option.WithDataURL(cfg.Repo.CS3.DataURL),
|
||||
option.WithDataPrefix(cfg.Repo.CS3.DataPrefix),
|
||||
option.WithJWTSecret(cfg.Repo.CS3.JWTSecret),
|
||||
option.WithProviderAddr(cfg.Repo.CS3.ProviderAddr),
|
||||
)
|
||||
|
||||
err = sut.Init()
|
||||
assert.NoError(t, err)
|
||||
|
||||
res, err := sut.Add("abcdefg-123", "mikey")
|
||||
assert.NoError(t, err)
|
||||
t.Log(res)
|
||||
|
||||
resLookup, err := sut.Lookup("mikey")
|
||||
assert.NoError(t, err)
|
||||
t.Log(resLookup)
|
||||
|
||||
err = sut.Update("abcdefg-123", "mikey", "mickeyX")
|
||||
assert.NoError(t, err)
|
||||
|
||||
searchRes, err := sut.Search("m*")
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, searchRes, 1)
|
||||
assert.Equal(t, searchRes[0], "abcdefg-123")
|
||||
|
||||
resp, err := sut.Lookup("mikey")
|
||||
assert.Len(t, resp, 0)
|
||||
assert.NoError(t, err)
|
||||
|
||||
_ = os.RemoveAll(dataDir)
|
||||
|
||||
}
|
||||
//
|
||||
//import (
|
||||
// "os"
|
||||
// "path"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/owncloud/ocis/accounts/pkg/config"
|
||||
// "github.com/owncloud/ocis/accounts/pkg/indexer/option"
|
||||
// . "github.com/owncloud/ocis/accounts/pkg/indexer/test"
|
||||
// "github.com/stretchr/testify/assert"
|
||||
//)
|
||||
//
|
||||
//func TestCS3NonUniqueIndex_FakeSymlink(t *testing.T) {
|
||||
// dataDir, err := WriteIndexTestData(Data, "ID", cs3RootFolder)
|
||||
// assert.NoError(t, err)
|
||||
// cfg := config.Config{
|
||||
// Repo: config.Repo{
|
||||
// Disk: config.Disk{
|
||||
// Path: "",
|
||||
// },
|
||||
// CS3: config.CS3{
|
||||
// ProviderAddr: "0.0.0.0:9215",
|
||||
// DataURL: "http://localhost:9216",
|
||||
// DataPrefix: "data",
|
||||
// JWTSecret: "Pive-Fumkiu4",
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// sut := NewNonUniqueIndexWithOptions(
|
||||
// option.WithTypeName(GetTypeFQN(User{})),
|
||||
// option.WithIndexBy("UserName"),
|
||||
// option.WithFilesDir(path.Join(cfg.Repo.Disk.Path, "/meta")),
|
||||
// option.WithDataDir(cfg.Repo.Disk.Path),
|
||||
// option.WithDataURL(cfg.Repo.CS3.DataURL),
|
||||
// option.WithDataPrefix(cfg.Repo.CS3.DataPrefix),
|
||||
// option.WithJWTSecret(cfg.Repo.CS3.JWTSecret),
|
||||
// option.WithProviderAddr(cfg.Repo.CS3.ProviderAddr),
|
||||
// )
|
||||
//
|
||||
// err = sut.Init()
|
||||
// assert.NoError(t, err)
|
||||
//
|
||||
// res, err := sut.Add("abcdefg-123", "mikey")
|
||||
// assert.NoError(t, err)
|
||||
// t.Log(res)
|
||||
//
|
||||
// resLookup, err := sut.Lookup("mikey")
|
||||
// assert.NoError(t, err)
|
||||
// t.Log(resLookup)
|
||||
//
|
||||
// err = sut.Update("abcdefg-123", "mikey", "mickeyX")
|
||||
// assert.NoError(t, err)
|
||||
//
|
||||
// searchRes, err := sut.Search("m*")
|
||||
// assert.NoError(t, err)
|
||||
// assert.Len(t, searchRes, 1)
|
||||
// assert.Equal(t, searchRes[0], "abcdefg-123")
|
||||
//
|
||||
// resp, err := sut.Lookup("mikey")
|
||||
// assert.Len(t, resp, 0)
|
||||
// assert.NoError(t, err)
|
||||
//
|
||||
// _ = os.RemoveAll(dataDir)
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,106 +1,107 @@
|
||||
package cs3
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/indexer/option"
|
||||
. "github.com/owncloud/ocis/accounts/pkg/indexer/test"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCS3UniqueIndex_FakeSymlink(t *testing.T) {
|
||||
dataDir, err := WriteIndexTestData(Data, "ID", cs3RootFolder)
|
||||
assert.NoError(t, err)
|
||||
cfg := config.Config{
|
||||
Repo: config.Repo{
|
||||
Disk: config.Disk{
|
||||
Path: "",
|
||||
},
|
||||
CS3: config.CS3{
|
||||
ProviderAddr: "0.0.0.0:9215",
|
||||
DataURL: "http://localhost:9216",
|
||||
DataPrefix: "data",
|
||||
JWTSecret: "Pive-Fumkiu4",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
sut := NewUniqueIndexWithOptions(
|
||||
option.WithTypeName(GetTypeFQN(User{})),
|
||||
option.WithIndexBy("UserName"),
|
||||
option.WithFilesDir(path.Join(cfg.Repo.Disk.Path, "/meta")),
|
||||
option.WithDataDir(cfg.Repo.Disk.Path),
|
||||
option.WithDataURL(cfg.Repo.CS3.DataURL),
|
||||
option.WithDataPrefix(cfg.Repo.CS3.DataPrefix),
|
||||
option.WithJWTSecret(cfg.Repo.CS3.JWTSecret),
|
||||
option.WithProviderAddr(cfg.Repo.CS3.ProviderAddr),
|
||||
)
|
||||
|
||||
err = sut.Init()
|
||||
assert.NoError(t, err)
|
||||
|
||||
res, err := sut.Add("abcdefg-123", "mikey")
|
||||
assert.NoError(t, err)
|
||||
t.Log(res)
|
||||
|
||||
resLookup, err := sut.Lookup("mikey")
|
||||
assert.NoError(t, err)
|
||||
t.Log(resLookup)
|
||||
|
||||
err = sut.Update("abcdefg-123", "mikey", "mickeyX")
|
||||
assert.NoError(t, err)
|
||||
|
||||
searchRes, err := sut.Search("m*")
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, searchRes, 1)
|
||||
assert.Equal(t, searchRes[0], "abcdefg-123")
|
||||
|
||||
_ = os.RemoveAll(dataDir)
|
||||
}
|
||||
|
||||
func TestCS3UniqueIndexSearch(t *testing.T) {
|
||||
dataDir, err := WriteIndexTestData(Data, "ID", cs3RootFolder)
|
||||
assert.NoError(t, err)
|
||||
cfg := config.Config{
|
||||
Repo: config.Repo{
|
||||
Disk: config.Disk{
|
||||
Path: "",
|
||||
},
|
||||
CS3: config.CS3{
|
||||
ProviderAddr: "0.0.0.0:9215",
|
||||
DataURL: "http://localhost:9216",
|
||||
DataPrefix: "data",
|
||||
JWTSecret: "Pive-Fumkiu4",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
sut := NewUniqueIndexWithOptions(
|
||||
option.WithTypeName(GetTypeFQN(User{})),
|
||||
option.WithIndexBy("UserName"),
|
||||
option.WithFilesDir(path.Join(cfg.Repo.Disk.Path, "/meta")),
|
||||
option.WithDataDir(cfg.Repo.Disk.Path),
|
||||
option.WithDataURL(cfg.Repo.CS3.DataURL),
|
||||
option.WithDataPrefix(cfg.Repo.CS3.DataPrefix),
|
||||
option.WithJWTSecret(cfg.Repo.CS3.JWTSecret),
|
||||
option.WithProviderAddr(cfg.Repo.CS3.ProviderAddr),
|
||||
)
|
||||
|
||||
err = sut.Init()
|
||||
assert.NoError(t, err)
|
||||
|
||||
_, err = sut.Add("hijklmn-456", "mikey")
|
||||
assert.NoError(t, err)
|
||||
|
||||
_, err = sut.Add("ewf4ofk-555", "jacky")
|
||||
assert.NoError(t, err)
|
||||
|
||||
res, err := sut.Search("*y")
|
||||
assert.NoError(t, err)
|
||||
t.Log(res)
|
||||
|
||||
_ = os.RemoveAll(dataDir)
|
||||
}
|
||||
//
|
||||
//import (
|
||||
// "os"
|
||||
// "path"
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/owncloud/ocis/accounts/pkg/config"
|
||||
// "github.com/owncloud/ocis/accounts/pkg/indexer/option"
|
||||
// . "github.com/owncloud/ocis/accounts/pkg/indexer/test"
|
||||
// "github.com/stretchr/testify/assert"
|
||||
//)
|
||||
//
|
||||
//func TestCS3UniqueIndex_FakeSymlink(t *testing.T) {
|
||||
// dataDir, err := WriteIndexTestData(Data, "ID", cs3RootFolder)
|
||||
// assert.NoError(t, err)
|
||||
// cfg := config.Config{
|
||||
// Repo: config.Repo{
|
||||
// Disk: config.Disk{
|
||||
// Path: "",
|
||||
// },
|
||||
// CS3: config.CS3{
|
||||
// ProviderAddr: "0.0.0.0:9215",
|
||||
// DataURL: "http://localhost:9216",
|
||||
// DataPrefix: "data",
|
||||
// JWTSecret: "Pive-Fumkiu4",
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// sut := NewUniqueIndexWithOptions(
|
||||
// option.WithTypeName(GetTypeFQN(User{})),
|
||||
// option.WithIndexBy("UserName"),
|
||||
// option.WithFilesDir(path.Join(cfg.Repo.Disk.Path, "/meta")),
|
||||
// option.WithDataDir(cfg.Repo.Disk.Path),
|
||||
// option.WithDataURL(cfg.Repo.CS3.DataURL),
|
||||
// option.WithDataPrefix(cfg.Repo.CS3.DataPrefix),
|
||||
// option.WithJWTSecret(cfg.Repo.CS3.JWTSecret),
|
||||
// option.WithProviderAddr(cfg.Repo.CS3.ProviderAddr),
|
||||
// )
|
||||
//
|
||||
// err = sut.Init()
|
||||
// assert.NoError(t, err)
|
||||
//
|
||||
// res, err := sut.Add("abcdefg-123", "mikey")
|
||||
// assert.NoError(t, err)
|
||||
// t.Log(res)
|
||||
//
|
||||
// resLookup, err := sut.Lookup("mikey")
|
||||
// assert.NoError(t, err)
|
||||
// t.Log(resLookup)
|
||||
//
|
||||
// err = sut.Update("abcdefg-123", "mikey", "mickeyX")
|
||||
// assert.NoError(t, err)
|
||||
//
|
||||
// searchRes, err := sut.Search("m*")
|
||||
// assert.NoError(t, err)
|
||||
// assert.Len(t, searchRes, 1)
|
||||
// assert.Equal(t, searchRes[0], "abcdefg-123")
|
||||
//
|
||||
// _ = os.RemoveAll(dataDir)
|
||||
//}
|
||||
//
|
||||
//func TestCS3UniqueIndexSearch(t *testing.T) {
|
||||
// dataDir, err := WriteIndexTestData(Data, "ID", cs3RootFolder)
|
||||
// assert.NoError(t, err)
|
||||
// cfg := config.Config{
|
||||
// Repo: config.Repo{
|
||||
// Disk: config.Disk{
|
||||
// Path: "",
|
||||
// },
|
||||
// CS3: config.CS3{
|
||||
// ProviderAddr: "0.0.0.0:9215",
|
||||
// DataURL: "http://localhost:9216",
|
||||
// DataPrefix: "data",
|
||||
// JWTSecret: "Pive-Fumkiu4",
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// sut := NewUniqueIndexWithOptions(
|
||||
// option.WithTypeName(GetTypeFQN(User{})),
|
||||
// option.WithIndexBy("UserName"),
|
||||
// option.WithFilesDir(path.Join(cfg.Repo.Disk.Path, "/meta")),
|
||||
// option.WithDataDir(cfg.Repo.Disk.Path),
|
||||
// option.WithDataURL(cfg.Repo.CS3.DataURL),
|
||||
// option.WithDataPrefix(cfg.Repo.CS3.DataPrefix),
|
||||
// option.WithJWTSecret(cfg.Repo.CS3.JWTSecret),
|
||||
// option.WithProviderAddr(cfg.Repo.CS3.ProviderAddr),
|
||||
// )
|
||||
//
|
||||
// err = sut.Init()
|
||||
// assert.NoError(t, err)
|
||||
//
|
||||
// _, err = sut.Add("hijklmn-456", "mikey")
|
||||
// assert.NoError(t, err)
|
||||
//
|
||||
// _, err = sut.Add("ewf4ofk-555", "jacky")
|
||||
// assert.NoError(t, err)
|
||||
//
|
||||
// res, err := sut.Search("*y")
|
||||
// assert.NoError(t, err)
|
||||
// t.Log(res)
|
||||
//
|
||||
// _ = os.RemoveAll(dataDir)
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user