2014-07-24 23:50:11 +02:00
|
|
|
// Test S3 filesystem interface
|
2018-09-07 13:02:27 +02:00
|
|
|
package s3
|
2014-07-24 23:50:11 +02:00
|
|
|
|
|
|
|
import (
|
2023-12-03 01:12:54 +01:00
|
|
|
"context"
|
|
|
|
"net/http"
|
2014-07-24 23:50:11 +02:00
|
|
|
"testing"
|
|
|
|
|
2024-08-03 12:35:32 +02:00
|
|
|
"github.com/aws/aws-sdk-go-v2/aws"
|
2019-07-28 19:47:38 +02:00
|
|
|
"github.com/rclone/rclone/fs"
|
2022-09-26 08:59:57 +02:00
|
|
|
"github.com/rclone/rclone/fstest"
|
2019-07-28 19:47:38 +02:00
|
|
|
"github.com/rclone/rclone/fstest/fstests"
|
2024-08-03 12:35:32 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
2014-07-24 23:50:11 +02:00
|
|
|
)
|
|
|
|
|
2023-12-03 01:12:54 +01:00
|
|
|
func SetupS3Test(t *testing.T) (context.Context, *Options, *http.Client) {
|
|
|
|
ctx, opt := context.Background(), new(Options)
|
|
|
|
opt.Provider = "AWS"
|
|
|
|
client := getClient(ctx, opt)
|
|
|
|
return ctx, opt, client
|
|
|
|
}
|
|
|
|
|
2018-04-07 19:48:11 +02:00
|
|
|
// TestIntegration runs integration tests against the remote
|
|
|
|
func TestIntegration(t *testing.T) {
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
2019-09-09 21:44:50 +02:00
|
|
|
RemoteName: "TestS3:",
|
|
|
|
NilObject: (*Object)(nil),
|
|
|
|
TiersToTest: []string{"STANDARD", "STANDARD_IA"},
|
2018-09-07 13:02:27 +02:00
|
|
|
ChunkedUpload: fstests.ChunkedUploadConfig{
|
|
|
|
MinChunkSize: minChunkSize,
|
|
|
|
},
|
2018-04-07 19:48:11 +02:00
|
|
|
})
|
2014-07-24 23:50:11 +02:00
|
|
|
}
|
2018-09-07 13:02:27 +02:00
|
|
|
|
2022-09-26 08:59:57 +02:00
|
|
|
func TestIntegration2(t *testing.T) {
|
|
|
|
if *fstest.RemoteName != "" {
|
|
|
|
t.Skip("skipping as -remote is set")
|
|
|
|
}
|
|
|
|
name := "TestS3"
|
|
|
|
fstests.Run(t, &fstests.Opt{
|
|
|
|
RemoteName: name + ":",
|
|
|
|
NilObject: (*Object)(nil),
|
|
|
|
TiersToTest: []string{"STANDARD", "STANDARD_IA"},
|
|
|
|
ChunkedUpload: fstests.ChunkedUploadConfig{
|
|
|
|
MinChunkSize: minChunkSize,
|
|
|
|
},
|
|
|
|
ExtraConfig: []fstests.ExtraConfigItem{
|
|
|
|
{Name: name, Key: "directory_markers", Value: "true"},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-12-03 01:12:54 +01:00
|
|
|
func TestAWSDualStackOption(t *testing.T) {
|
|
|
|
{
|
|
|
|
// test enabled
|
|
|
|
ctx, opt, client := SetupS3Test(t)
|
|
|
|
opt.UseDualStack = true
|
2024-08-03 12:35:32 +02:00
|
|
|
s3Conn, err := s3Connection(ctx, opt, client)
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, aws.DualStackEndpointStateEnabled, s3Conn.Options().EndpointOptions.UseDualStackEndpoint)
|
2023-12-03 01:12:54 +01:00
|
|
|
}
|
|
|
|
{
|
|
|
|
// test default case
|
|
|
|
ctx, opt, client := SetupS3Test(t)
|
2024-08-03 12:35:32 +02:00
|
|
|
s3Conn, err := s3Connection(ctx, opt, client)
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, aws.DualStackEndpointStateDisabled, s3Conn.Options().EndpointOptions.UseDualStackEndpoint)
|
2023-12-03 01:12:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-07 13:02:27 +02:00
|
|
|
func (f *Fs) SetUploadChunkSize(cs fs.SizeSuffix) (fs.SizeSuffix, error) {
|
|
|
|
return f.setUploadChunkSize(cs)
|
|
|
|
}
|
|
|
|
|
2018-11-26 22:09:23 +01:00
|
|
|
func (f *Fs) SetUploadCutoff(cs fs.SizeSuffix) (fs.SizeSuffix, error) {
|
|
|
|
return f.setUploadCutoff(cs)
|
|
|
|
}
|
|
|
|
|
2023-11-24 13:36:48 +01:00
|
|
|
func (f *Fs) SetCopyCutoff(cs fs.SizeSuffix) (fs.SizeSuffix, error) {
|
|
|
|
return f.setCopyCutoff(cs)
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
_ fstests.SetUploadChunkSizer = (*Fs)(nil)
|
|
|
|
_ fstests.SetUploadCutoffer = (*Fs)(nil)
|
|
|
|
_ fstests.SetCopyCutoffer = (*Fs)(nil)
|
|
|
|
)
|