File: memory_internal_test.go

package info (click to toggle)
rclone 1.69.3%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 45,712 kB
  • sloc: sh: 1,115; xml: 857; python: 754; javascript: 612; makefile: 299; ansic: 101; php: 74
file content (40 lines) | stat: -rw-r--r-- 1,057 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package memory

import (
	"context"
	"fmt"
	"testing"

	_ "github.com/rclone/rclone/backend/local"
	"github.com/rclone/rclone/fs/operations"
	"github.com/rclone/rclone/fstest"
	"github.com/rclone/rclone/fstest/fstests"
	"github.com/stretchr/testify/require"
)

var t1 = fstest.Time("2001-02-03T04:05:06.499999999Z")

// InternalTest dispatches all internal tests
func (f *Fs) InternalTest(t *testing.T) {
	t.Run("PurgeListDeadlock", func(t *testing.T) {
		testPurgeListDeadlock(t)
	})
}

// test that Purge fallback does not result in deadlock from concurrently listing and removing
func testPurgeListDeadlock(t *testing.T) {
	ctx := context.Background()
	r := fstest.NewRunIndividual(t)
	r.Mkdir(ctx, r.Fremote)
	r.Fremote.Features().Disable("Purge") // force fallback-purge

	// make a lot of files to prevent it from finishing too quickly
	for i := 0; i < 100; i++ {
		dst := "file" + fmt.Sprint(i) + ".txt"
		r.WriteObject(ctx, dst, "hello", t1)
	}

	require.NoError(t, operations.Purge(ctx, r.Fremote, ""))
}

var _ fstests.InternalTester = (*Fs)(nil)