2018-08-18 08:39:49 +08:00
|
|
|
// Test Union filesystem interface
|
|
|
|
package union_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-07-29 01:47:38 +08:00
|
|
|
_ "github.com/rclone/rclone/backend/local"
|
2021-09-30 18:11:46 +08:00
|
|
|
_ "github.com/rclone/rclone/backend/memory"
|
|
|
|
"github.com/rclone/rclone/backend/union"
|
2019-11-30 22:41:39 +08:00
|
|
|
"github.com/rclone/rclone/fstest"
|
2019-07-29 01:47:38 +08:00
|
|
|
"github.com/rclone/rclone/fstest/fstests"
|
2018-08-18 08:39:49 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// TestIntegration runs integration tests against the remote
|
|
|
|
func TestIntegration(t *testing.T) {
|
2019-11-30 22:41:39 +08:00
|
|
|
if *fstest.RemoteName == "" {
|
|
|
|
t.Skip("Skipping as -remote not set")
|
|
|
|
}
|
2018-08-18 08:39:49 +08:00
|
|
|
fstests.Run(t, &fstests.Opt{
|
2019-11-30 22:41:39 +08:00
|
|
|
RemoteName: *fstest.RemoteName,
|
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt", "DuplicateFiles"},
|
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestStandard(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2021-09-30 18:11:46 +08:00
|
|
|
dirs, clean := union.MakeTestDirs(t, 3)
|
2021-01-15 20:18:28 +08:00
|
|
|
defer clean()
|
|
|
|
upstreams := dirs[0] + " " + dirs[1] + " " + dirs[2]
|
2019-11-30 22:41:39 +08:00
|
|
|
name := "TestUnion"
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
|
|
|
RemoteName: name + ":",
|
|
|
|
ExtraConfig: []fstests.ExtraConfigItem{
|
|
|
|
{Name: name, Key: "type", Value: "union"},
|
|
|
|
{Name: name, Key: "upstreams", Value: upstreams},
|
|
|
|
{Name: name, Key: "action_policy", Value: "epall"},
|
|
|
|
{Name: name, Key: "create_policy", Value: "epmfs"},
|
|
|
|
{Name: name, Key: "search_policy", Value: "ff"},
|
|
|
|
},
|
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt", "DuplicateFiles"},
|
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRO(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2021-09-30 18:11:46 +08:00
|
|
|
dirs, clean := union.MakeTestDirs(t, 3)
|
2021-01-15 20:18:28 +08:00
|
|
|
defer clean()
|
|
|
|
upstreams := dirs[0] + " " + dirs[1] + ":ro " + dirs[2] + ":ro"
|
2019-11-30 22:41:39 +08:00
|
|
|
name := "TestUnionRO"
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
|
|
|
RemoteName: name + ":",
|
|
|
|
ExtraConfig: []fstests.ExtraConfigItem{
|
|
|
|
{Name: name, Key: "type", Value: "union"},
|
|
|
|
{Name: name, Key: "upstreams", Value: upstreams},
|
|
|
|
{Name: name, Key: "action_policy", Value: "epall"},
|
|
|
|
{Name: name, Key: "create_policy", Value: "epmfs"},
|
|
|
|
{Name: name, Key: "search_policy", Value: "ff"},
|
|
|
|
},
|
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt", "DuplicateFiles"},
|
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNC(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2021-09-30 18:11:46 +08:00
|
|
|
dirs, clean := union.MakeTestDirs(t, 3)
|
2021-01-15 20:18:28 +08:00
|
|
|
defer clean()
|
|
|
|
upstreams := dirs[0] + " " + dirs[1] + ":nc " + dirs[2] + ":nc"
|
2019-11-30 22:41:39 +08:00
|
|
|
name := "TestUnionNC"
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
|
|
|
RemoteName: name + ":",
|
|
|
|
ExtraConfig: []fstests.ExtraConfigItem{
|
|
|
|
{Name: name, Key: "type", Value: "union"},
|
|
|
|
{Name: name, Key: "upstreams", Value: upstreams},
|
|
|
|
{Name: name, Key: "action_policy", Value: "epall"},
|
|
|
|
{Name: name, Key: "create_policy", Value: "epmfs"},
|
|
|
|
{Name: name, Key: "search_policy", Value: "ff"},
|
|
|
|
},
|
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt", "DuplicateFiles"},
|
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPolicy1(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2021-09-30 18:11:46 +08:00
|
|
|
dirs, clean := union.MakeTestDirs(t, 3)
|
2021-01-15 20:18:28 +08:00
|
|
|
defer clean()
|
|
|
|
upstreams := dirs[0] + " " + dirs[1] + " " + dirs[2]
|
2019-11-30 22:41:39 +08:00
|
|
|
name := "TestUnionPolicy1"
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
|
|
|
RemoteName: name + ":",
|
|
|
|
ExtraConfig: []fstests.ExtraConfigItem{
|
|
|
|
{Name: name, Key: "type", Value: "union"},
|
|
|
|
{Name: name, Key: "upstreams", Value: upstreams},
|
|
|
|
{Name: name, Key: "action_policy", Value: "all"},
|
|
|
|
{Name: name, Key: "create_policy", Value: "lus"},
|
|
|
|
{Name: name, Key: "search_policy", Value: "all"},
|
|
|
|
},
|
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt", "DuplicateFiles"},
|
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPolicy2(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2021-09-30 18:11:46 +08:00
|
|
|
dirs, clean := union.MakeTestDirs(t, 3)
|
2021-01-15 20:18:28 +08:00
|
|
|
defer clean()
|
|
|
|
upstreams := dirs[0] + " " + dirs[1] + " " + dirs[2]
|
2019-11-30 22:41:39 +08:00
|
|
|
name := "TestUnionPolicy2"
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
|
|
|
RemoteName: name + ":",
|
|
|
|
ExtraConfig: []fstests.ExtraConfigItem{
|
|
|
|
{Name: name, Key: "type", Value: "union"},
|
|
|
|
{Name: name, Key: "upstreams", Value: upstreams},
|
|
|
|
{Name: name, Key: "action_policy", Value: "all"},
|
|
|
|
{Name: name, Key: "create_policy", Value: "rand"},
|
|
|
|
{Name: name, Key: "search_policy", Value: "ff"},
|
|
|
|
},
|
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt", "DuplicateFiles"},
|
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
2018-08-18 08:39:49 +08:00
|
|
|
})
|
|
|
|
}
|
2020-08-31 01:30:45 +08:00
|
|
|
|
|
|
|
func TestPolicy3(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2021-09-30 18:11:46 +08:00
|
|
|
dirs, clean := union.MakeTestDirs(t, 3)
|
2021-01-15 20:18:28 +08:00
|
|
|
defer clean()
|
|
|
|
upstreams := dirs[0] + " " + dirs[1] + " " + dirs[2]
|
2020-08-31 01:30:45 +08:00
|
|
|
name := "TestUnionPolicy3"
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
|
|
|
RemoteName: name + ":",
|
|
|
|
ExtraConfig: []fstests.ExtraConfigItem{
|
|
|
|
{Name: name, Key: "type", Value: "union"},
|
|
|
|
{Name: name, Key: "upstreams", Value: upstreams},
|
|
|
|
{Name: name, Key: "action_policy", Value: "all"},
|
|
|
|
{Name: name, Key: "create_policy", Value: "all"},
|
|
|
|
{Name: name, Key: "search_policy", Value: "all"},
|
|
|
|
},
|
|
|
|
UnimplementableFsMethods: []string{"OpenWriterAt", "DuplicateFiles"},
|
|
|
|
UnimplementableObjectMethods: []string{"MimeType"},
|
|
|
|
})
|
|
|
|
}
|