2018-08-18 00:39:49 +00:00
|
|
|
// Test Union filesystem interface
|
|
|
|
package union_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-07-28 17:47:38 +00:00
|
|
|
_ "github.com/rclone/rclone/backend/local"
|
2021-09-30 10:11:46 +00:00
|
|
|
_ "github.com/rclone/rclone/backend/memory"
|
|
|
|
"github.com/rclone/rclone/backend/union"
|
2019-11-30 14:41:39 +00:00
|
|
|
"github.com/rclone/rclone/fstest"
|
2019-07-28 17:47:38 +00:00
|
|
|
"github.com/rclone/rclone/fstest/fstests"
|
2018-08-18 00:39:49 +00:00
|
|
|
)
|
|
|
|
|
2023-05-12 10:44:01 +00:00
|
|
|
var (
|
2023-07-13 19:01:10 +00:00
|
|
|
unimplementableFsMethods = []string{"UnWrap", "WrapFs", "SetWrapper", "UserInfo", "Disconnect", "PublicLink", "PutUnchecked", "MergeDirs", "OpenWriterAt", "OpenChunkWriter"}
|
2023-05-12 10:44:01 +00:00
|
|
|
unimplementableObjectMethods = []string{}
|
|
|
|
)
|
|
|
|
|
2018-08-18 00:39:49 +00:00
|
|
|
// TestIntegration runs integration tests against the remote
|
|
|
|
func TestIntegration(t *testing.T) {
|
2019-11-30 14:41:39 +00:00
|
|
|
if *fstest.RemoteName == "" {
|
|
|
|
t.Skip("Skipping as -remote not set")
|
|
|
|
}
|
2018-08-18 00:39:49 +00:00
|
|
|
fstests.Run(t, &fstests.Opt{
|
2019-11-30 14:41:39 +00:00
|
|
|
RemoteName: *fstest.RemoteName,
|
2023-05-12 10:44:01 +00:00
|
|
|
UnimplementableFsMethods: unimplementableFsMethods,
|
|
|
|
UnimplementableObjectMethods: unimplementableObjectMethods,
|
2019-11-30 14:41:39 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestStandard(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2022-01-29 16:24:56 +00:00
|
|
|
dirs := union.MakeTestDirs(t, 3)
|
2021-01-15 12:18:28 +00:00
|
|
|
upstreams := dirs[0] + " " + dirs[1] + " " + dirs[2]
|
2019-11-30 14:41:39 +00: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 10:44:01 +00:00
|
|
|
UnimplementableFsMethods: unimplementableFsMethods,
|
|
|
|
UnimplementableObjectMethods: unimplementableObjectMethods,
|
2022-06-29 10:51:46 +00:00
|
|
|
QuickTestOK: true,
|
2019-11-30 14:41:39 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRO(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2022-01-29 16:24:56 +00:00
|
|
|
dirs := union.MakeTestDirs(t, 3)
|
2021-01-15 12:18:28 +00:00
|
|
|
upstreams := dirs[0] + " " + dirs[1] + ":ro " + dirs[2] + ":ro"
|
2019-11-30 14:41:39 +00: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 10:44:01 +00:00
|
|
|
UnimplementableFsMethods: unimplementableFsMethods,
|
|
|
|
UnimplementableObjectMethods: unimplementableObjectMethods,
|
2022-06-29 10:51:46 +00:00
|
|
|
QuickTestOK: true,
|
2019-11-30 14:41:39 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNC(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2022-01-29 16:24:56 +00:00
|
|
|
dirs := union.MakeTestDirs(t, 3)
|
2021-01-15 12:18:28 +00:00
|
|
|
upstreams := dirs[0] + " " + dirs[1] + ":nc " + dirs[2] + ":nc"
|
2019-11-30 14:41:39 +00: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 10:44:01 +00:00
|
|
|
UnimplementableFsMethods: unimplementableFsMethods,
|
|
|
|
UnimplementableObjectMethods: unimplementableObjectMethods,
|
2022-06-29 10:51:46 +00:00
|
|
|
QuickTestOK: true,
|
2019-11-30 14:41:39 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPolicy1(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2022-01-29 16:24:56 +00:00
|
|
|
dirs := union.MakeTestDirs(t, 3)
|
2021-01-15 12:18:28 +00:00
|
|
|
upstreams := dirs[0] + " " + dirs[1] + " " + dirs[2]
|
2019-11-30 14:41:39 +00: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 10:44:01 +00:00
|
|
|
UnimplementableFsMethods: unimplementableFsMethods,
|
|
|
|
UnimplementableObjectMethods: unimplementableObjectMethods,
|
2022-06-29 10:51:46 +00:00
|
|
|
QuickTestOK: true,
|
2019-11-30 14:41:39 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestPolicy2(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2022-01-29 16:24:56 +00:00
|
|
|
dirs := union.MakeTestDirs(t, 3)
|
2021-01-15 12:18:28 +00:00
|
|
|
upstreams := dirs[0] + " " + dirs[1] + " " + dirs[2]
|
2019-11-30 14:41:39 +00: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 10:44:01 +00:00
|
|
|
UnimplementableFsMethods: unimplementableFsMethods,
|
|
|
|
UnimplementableObjectMethods: unimplementableObjectMethods,
|
2022-06-29 10:51:46 +00:00
|
|
|
QuickTestOK: true,
|
2018-08-18 00:39:49 +00:00
|
|
|
})
|
|
|
|
}
|
2020-08-30 17:30:45 +00:00
|
|
|
|
|
|
|
func TestPolicy3(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("Skipping as -remote set")
|
|
|
|
}
|
2022-01-29 16:24:56 +00:00
|
|
|
dirs := union.MakeTestDirs(t, 3)
|
2021-01-15 12:18:28 +00:00
|
|
|
upstreams := dirs[0] + " " + dirs[1] + " " + dirs[2]
|
2020-08-30 17:30:45 +00: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 10:44:01 +00:00
|
|
|
UnimplementableFsMethods: unimplementableFsMethods,
|
|
|
|
UnimplementableObjectMethods: unimplementableObjectMethods,
|
2022-06-29 10:51:46 +00:00
|
|
|
QuickTestOK: true,
|
2020-08-30 17:30:45 +00:00
|
|
|
})
|
|
|
|
}
|