Skip to content

Commit

Permalink
In backup tests, check the number of manifests equals number of dirs. (
Browse files Browse the repository at this point in the history
…#3706)

The filesystem backup tests are a bit flaky in TeamCity. As a first
step, this change adds verification that the number of manifests equals
the number of expected backup directories.
  • Loading branch information
martinmr authored Jul 23, 2019
1 parent a8c4234 commit b7beb08
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions ee/backup/tests/filesystem/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,21 @@ func runBackupInternal(t *testing.T, forceFull bool, numExpectedFiles,

// Verify that the right amount of files and directories were created.
copyToLocalFs()

files := x.WalkPathFunc(copyBackupDir, func(path string, isdir bool) bool {
return !isdir && strings.HasSuffix(path, ".backup")
})
require.True(t, len(files) == numExpectedFiles)
require.Equal(t, numExpectedFiles, len(files))

dirs := x.WalkPathFunc(copyBackupDir, func(path string, isdir bool) bool {
return isdir && strings.HasPrefix(path, "data/backups_copy/dgraph.")
})
require.True(t, len(dirs) == numExpectedDirs)
require.Equal(t, numExpectedDirs, len(dirs))

manifests := x.WalkPathFunc(copyBackupDir, func(path string, isdir bool) bool {
return !isdir && strings.Contains(path, "manifest.json")
})
require.Equal(t, numExpectedDirs, len(manifests))

return dirs
}
Expand Down
11 changes: 9 additions & 2 deletions ee/backup/tests/minio/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,21 @@ func runBackupInternal(t *testing.T, forceFull bool, numExpectedFiles,

// Verify that the right amount of files and directories were created.
copyToLocalFs(t)

files := x.WalkPathFunc(backupDir, func(path string, isdir bool) bool {
return !isdir && strings.HasSuffix(path, ".backup")
})
require.True(t, len(files) == numExpectedFiles)
require.Equal(t, numExpectedFiles, len(files))

dirs := x.WalkPathFunc(backupDir, func(path string, isdir bool) bool {
return isdir && strings.HasPrefix(path, "data/backups/dgraph.")
})
require.True(t, len(dirs) == numExpectedDirs)
require.Equal(t, numExpectedDirs, len(dirs))

manifests := x.WalkPathFunc(backupDir, func(path string, isdir bool) bool {
return !isdir && strings.Contains(path, "manifest.json")
})
require.Equal(t, numExpectedDirs, len(manifests))

return dirs
}
Expand Down

0 comments on commit b7beb08

Please sign in to comment.