Files
seaweedfs/weed/filer/remote_mapping_test.go
T
Chris LuandGitHub db5a086d04 read cold remote objects straight from the origin while caching (#10731)
* refactor: extract remote mount resolution into shared helpers

* refactor: share the adaptive remote cache wait policy

* filer: stream cold remote reads from the origin while caching

* s3: stream cold remote reads from the origin instead of 503 retries

* test: cover the S3 origin stream-through path

* remote mounts: match on path components and prefer the longest mount

* fail short origin streams instead of silently truncating

* s3: try the origin before failing a cold read on a local cache error

* s3: gate origin streaming on the entry's resolved version

* return the cache RPC's NotFound as a canonical status and classify it everywhere

* filer: keep multipart-range cold reads on the retry path
2026-08-12 23:00:10 -07:00

49 lines
1.3 KiB
Go

package filer
import (
"testing"
"github.com/seaweedfs/seaweedfs/weed/pb/remote_pb"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestFindMountedRemoteMapping(t *testing.T) {
mappings := &remote_pb.RemoteStorageMapping{
Mappings: map[string]*remote_pb.RemoteStorageLocation{
"/buckets/b": {Name: "outer"},
"/buckets/b/sub": {Name: "inner"},
"/buckets/foo": {Name: "foo"},
},
}
tests := []struct {
dir string
wantMount string
wantName string
wantErr bool
}{
{dir: "/buckets/b", wantMount: "/buckets/b", wantName: "outer"},
{dir: "/buckets/b/other", wantMount: "/buckets/b", wantName: "outer"},
{dir: "/buckets/b/sub", wantMount: "/buckets/b/sub", wantName: "inner"},
{dir: "/buckets/b/sub/deep", wantMount: "/buckets/b/sub", wantName: "inner"},
{dir: "/buckets/foo/x", wantMount: "/buckets/foo", wantName: "foo"},
// a sibling sharing a name prefix is not under the mount
{dir: "/buckets/foobar", wantErr: true},
{dir: "/buckets/other", wantErr: true},
}
for _, tt := range tests {
t.Run(tt.dir, func(t *testing.T) {
mount, loc, err := FindMountedRemoteMapping(mappings, tt.dir)
if tt.wantErr {
require.Error(t, err)
return
}
require.NoError(t, err)
assert.Equal(t, tt.wantMount, mount)
assert.Equal(t, tt.wantName, loc.Name)
})
}
}