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