Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3587f4ae94 |
@@ -10,30 +10,44 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"sneak.berlin/go/vaultik/internal/log"
|
"sneak.berlin/go/vaultik/internal/log"
|
||||||
|
"sneak.berlin/go/vaultik/internal/snapshot"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestNukeRemoteLeavesNoFiles checks that remote nuke leaves no file
|
// TestNukeRemoteLeavesNoFiles checks that remote nuke leaves no file
|
||||||
// under a file:// destination, including the `.partial` file an upload
|
// under a file:// destination, including the `.partial` files uploads
|
||||||
// killed part-way leaves next to where its blob would have been.
|
// killed part-way leave next to a snapshot's metadata and next to where a
|
||||||
|
// blob would have been.
|
||||||
func TestNukeRemoteLeavesNoFiles(t *testing.T) {
|
func TestNukeRemoteLeavesNoFiles(t *testing.T) {
|
||||||
log.Initialize(log.Config{})
|
log.Initialize(log.Config{})
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
storeDir := filepath.Join(t.TempDir(), "store")
|
storeDir := filepath.Join(t.TempDir(), "store")
|
||||||
v, _, _ := backUpToFileDestination(ctx, t, storeDir)
|
v, repos, _ := backUpToFileDestination(ctx, t, storeDir)
|
||||||
|
|
||||||
|
snapshots, err := repos.Snapshots.ListRecent(ctx, listRecentTestLimit)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, snapshots, 1)
|
||||||
|
|
||||||
|
snapshotKey := snapshot.RemoteSnapshotKey(snapshots[0].ID.String())
|
||||||
hash := testBlobHashA
|
hash := testBlobHashA
|
||||||
leftover := filepath.Join(storeDir, "blobs", hash[:2], hash[2:4],
|
leftovers := []string{
|
||||||
hash+"-123456.partial")
|
filepath.Join(storeDir, "metadata", snapshotKey,
|
||||||
require.NoError(t, os.MkdirAll(filepath.Dir(leftover), 0o750))
|
"db.zst.age-123456.partial"),
|
||||||
require.NoError(t, os.WriteFile(leftover, []byte("half a blob"), 0o600))
|
filepath.Join(storeDir, "blobs", hash[:2], hash[2:4],
|
||||||
|
hash+"-123456.partial"),
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, leftover := range leftovers {
|
||||||
|
require.NoError(t, os.MkdirAll(filepath.Dir(leftover), 0o750))
|
||||||
|
require.NoError(t, os.WriteFile(leftover, []byte("half an upload"), 0o600))
|
||||||
|
}
|
||||||
|
|
||||||
require.NoError(t, v.NukeRemote(true))
|
require.NoError(t, v.NukeRemote(true))
|
||||||
|
|
||||||
var files []string
|
var files []string
|
||||||
|
|
||||||
err := filepath.WalkDir(storeDir,
|
err = filepath.WalkDir(storeDir,
|
||||||
func(path string, entry fs.DirEntry, err error) error {
|
func(path string, entry fs.DirEntry, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user