From 16e6235dfa5d5f37c751523cd477bdecbc37d816 Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Mon, 22 Jul 2019 17:59:51 -0700 Subject: [PATCH] In backup tests, check the number of manifests equals number of dirs. 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. --- ee/backup/tests/filesystem/backup_test.go | 11 +++++++++-- ee/backup/tests/minio/backup_test.go | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ee/backup/tests/filesystem/backup_test.go b/ee/backup/tests/filesystem/backup_test.go index 562f0d6d89d..532f932302c 100644 --- a/ee/backup/tests/filesystem/backup_test.go +++ b/ee/backup/tests/filesystem/backup_test.go @@ -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 } diff --git a/ee/backup/tests/minio/backup_test.go b/ee/backup/tests/minio/backup_test.go index 8658513e077..58dd716a69c 100644 --- a/ee/backup/tests/minio/backup_test.go +++ b/ee/backup/tests/minio/backup_test.go @@ -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 }