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
|
|
|
)
|
|
|
|
|
2023-05-12 18:44:01 +08:00
|
|
|
var (
|
|
|
|
unimplementableFsMethods = []string{"UnWrap", "WrapFs", "SetWrapper", "UserInfo", "Disconnect", "PublicLink", "PutUnchecked", "MergeDirs", "OpenWriterAt"}
|
|
|
|
unimplementableObjectMethods = []string{}
|
|
|
|
)
|
|
|
|
|
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,
|
2023-05-12 18:44:01 +08:00
|
|
|
UnimplementableFsMethods: unimplementableFsMethods,
|
|
|
|
UnimplementableObjectMethods: unimplementableObjectMethods,
|
2019-11-30 22:41:39 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestStandard(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2022-01-30 00:24:56 +08:00
|
|
|
dirs := union.MakeTestDirs(t, 3)
|
2021-01-15 20:18:28 +08:00
|
|
|
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"},
|
|
|
|
},
|
2023-05-12 18:44:01 +08:00
|
|
|
UnimplementableFsMethods: unimplementableFsMethods,
|
|
|
|
UnimplementableObjectMethods: unimplementableObjectMethods,
|
2022-06-29 18:51:46 +08:00
|
|
|
QuickTestOK: true,
|
2019-11-30 22:41:39 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRO(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2022-01-30 00:24:56 +08:00
|
|
|
dirs := union.MakeTestDirs(t, 3)
|
2021-01-15 20:18:28 +08:00
|
|
|
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"},
|
|
|
|
},
|
2023-05-12 18:44:01 +08:00
|
|
|
UnimplementableFsMethods: unimplementableFsMethods,
|
|
|
|
UnimplementableObjectMethods: unimplementableObjectMethods,
|
2022-06-29 18:51:46 +08:00
|
|
|
QuickTestOK: true,
|
2019-11-30 22:41:39 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNC(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2022-01-30 00:24:56 +08:00
|
|
|
dirs := union.MakeTestDirs(t, 3)
|
2021-01-15 20:18:28 +08:00
|
|
|
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"},
|
|
|
|
},
|
2023-05-12 18:44:01 +08:00
|
|
|
UnimplementableFsMethods: unimplementableFsMethods,
|
|
|
|
UnimplementableObjectMethods: unimplementableObjectMethods,
|
2022-06-29 18:51:46 +08:00
|
|
|
QuickTestOK: true,
|
2019-11-30 22:41:39 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPolicy1(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2022-01-30 00:24:56 +08:00
|
|
|
dirs := union.MakeTestDirs(t, 3)
|
2021-01-15 20:18:28 +08:00
|
|
|
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"},
|
|
|
|
},
|
2023-05-12 18:44:01 +08:00
|
|
|
UnimplementableFsMethods: unimplementableFsMethods,
|
|
|
|
UnimplementableObjectMethods: unimplementableObjectMethods,
|
2022-06-29 18:51:46 +08:00
|
|
|
QuickTestOK: true,
|
2019-11-30 22:41:39 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPolicy2(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2022-01-30 00:24:56 +08:00
|
|
|
dirs := union.MakeTestDirs(t, 3)
|
2021-01-15 20:18:28 +08:00
|
|
|
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"},
|
|
|
|
},
|
2023-05-12 18:44:01 +08:00
|
|
|
UnimplementableFsMethods: unimplementableFsMethods,
|
|
|
|
UnimplementableObjectMethods: unimplementableObjectMethods,
|
2022-06-29 18:51:46 +08:00
|
|
|
QuickTestOK: true,
|
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")
|
|
|
|
}
|
2022-01-30 00:24:56 +08:00
|
|
|
dirs := union.MakeTestDirs(t, 3)
|
2021-01-15 20:18:28 +08:00
|
|
|
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"},
|
|
|
|
},
|
2023-05-12 18:44:01 +08:00
|
|
|
UnimplementableFsMethods: unimplementableFsMethods,
|
|
|
|
UnimplementableObjectMethods: unimplementableObjectMethods,
|
2022-06-29 18:51:46 +08:00
|
|
|
QuickTestOK: true,
|
2020-08-31 01:30:45 +08:00
|
|
|
})
|
|
|
|
}
|