mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
fix tests
This commit is contained in:
parent
42969c9c62
commit
f6a9ad8001
|
@ -87,19 +87,18 @@ func (rs *FilerRemoteStorage) FindMountDirectory(p util.FullPath) (mountDir util
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *FilerRemoteStorage) FindRemoteStorageClient(p util.FullPath) (client remote_storage.RemoteStorageClient, remoteConf *filer_pb.RemoteConf, found bool) {
|
func (rs *FilerRemoteStorage) FindRemoteStorageClient(p util.FullPath) (client remote_storage.RemoteStorageClient, remoteConf *filer_pb.RemoteConf, found bool) {
|
||||||
var storageLocation string
|
var storageLocation *filer_pb.RemoteStorageLocation
|
||||||
rs.rules.MatchPrefix([]byte(p), func(key []byte, value interface{}) bool {
|
rs.rules.MatchPrefix([]byte(p), func(key []byte, value interface{}) bool {
|
||||||
storageLocation = value.(string)
|
storageLocation = value.(*filer_pb.RemoteStorageLocation)
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
if storageLocation == "" {
|
if storageLocation == nil {
|
||||||
|
found = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
loc := remote_storage.ParseLocation(storageLocation)
|
return rs.GetRemoteStorageClient(storageLocation.Name)
|
||||||
|
|
||||||
return rs.GetRemoteStorageClient(loc.Name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *FilerRemoteStorage) GetRemoteStorageClient(storageName string) (client remote_storage.RemoteStorageClient, remoteConf *filer_pb.RemoteConf, found bool) {
|
func (rs *FilerRemoteStorage) GetRemoteStorageClient(storageName string) (client remote_storage.RemoteStorageClient, remoteConf *filer_pb.RemoteConf, found bool) {
|
||||||
|
|
|
@ -14,7 +14,11 @@ func TestFilerRemoteStorage_FindRemoteStorageClient(t *testing.T) {
|
||||||
rs := NewFilerRemoteStorage()
|
rs := NewFilerRemoteStorage()
|
||||||
rs.storageNameToConf[conf.Name] = conf
|
rs.storageNameToConf[conf.Name] = conf
|
||||||
|
|
||||||
rs.mapDirectoryToRemoteStorage("/a/b/c", "s7")
|
rs.mapDirectoryToRemoteStorage("/a/b/c", &filer_pb.RemoteStorageLocation{
|
||||||
|
Name: "s7",
|
||||||
|
Bucket: "some",
|
||||||
|
Path: "/dir",
|
||||||
|
})
|
||||||
|
|
||||||
_, _, found := rs.FindRemoteStorageClient("/a/b/c/d/e/f")
|
_, _, found := rs.FindRemoteStorageClient("/a/b/c/d/e/f")
|
||||||
assert.Equal(t, true, found, "find storage client")
|
assert.Equal(t, true, found, "find storage client")
|
||||||
|
|
|
@ -130,17 +130,15 @@ func (c *commandRemoteMount) findRemoteStorageConfiguration(commandEnv *CommandE
|
||||||
func (c *commandRemoteMount) pullMetadata(commandEnv *CommandEnv, writer io.Writer, dir string, nonEmpty bool, remoteConf *filer_pb.RemoteConf, remote *filer_pb.RemoteStorageLocation) error {
|
func (c *commandRemoteMount) pullMetadata(commandEnv *CommandEnv, writer io.Writer, dir string, nonEmpty bool, remoteConf *filer_pb.RemoteConf, remote *filer_pb.RemoteStorageLocation) error {
|
||||||
|
|
||||||
// find existing directory, and ensure the directory is empty
|
// find existing directory, and ensure the directory is empty
|
||||||
var mountToDir *filer_pb.Entry
|
|
||||||
err := commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err := commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
||||||
parent, name := util.FullPath(dir).DirAndName()
|
parent, name := util.FullPath(dir).DirAndName()
|
||||||
resp, lookupErr := client.LookupDirectoryEntry(context.Background(), &filer_pb.LookupDirectoryEntryRequest{
|
_, lookupErr := client.LookupDirectoryEntry(context.Background(), &filer_pb.LookupDirectoryEntryRequest{
|
||||||
Directory: parent,
|
Directory: parent,
|
||||||
Name: name,
|
Name: name,
|
||||||
})
|
})
|
||||||
if lookupErr != nil {
|
if lookupErr != nil {
|
||||||
return fmt.Errorf("lookup %s: %v", dir, lookupErr)
|
return fmt.Errorf("lookup %s: %v", dir, lookupErr)
|
||||||
}
|
}
|
||||||
mountToDir = resp.Entry
|
|
||||||
|
|
||||||
mountToDirIsEmpty := true
|
mountToDirIsEmpty := true
|
||||||
listErr := filer_pb.SeaweedList(client, dir, "", func(entry *filer_pb.Entry, isLast bool) error {
|
listErr := filer_pb.SeaweedList(client, dir, "", func(entry *filer_pb.Entry, isLast bool) error {
|
||||||
|
|
Loading…
Reference in a new issue