Skip to content

Commit e16820f

Browse files
committed
test/libcephfs: include inode type change test for snapdiff
Signed-off-by: Venky Shankar <[email protected]>
1 parent 33c6f23 commit e16820f

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

src/test/libcephfs/snapdiff.cc

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ class TestMount {
188188
auto file_path = make_file_path(relpath);
189189
return ceph_unlink(cmount, file_path.c_str());
190190
}
191+
int symlink(const char* relpath, const char* target)
192+
{
193+
auto src_path = make_file_path(relpath);
194+
auto target_path = make_file_path(target);
195+
return ceph_symlink(cmount, target_path.c_str(), src_path.c_str());
196+
}
191197

192198
int test_open(const char* relpath)
193199
{
@@ -431,29 +437,35 @@ void TestMount::print_snap_diff(const char* relpath,
431437
- xN denotes file 'x' version N.
432438
- X denotes folder name
433439
- * denotes no/removed file/folder
434-
435-
# snap1 snap2
436-
# fileA1 | fileA2 |
437-
# * | fileB2 |
438-
# fileC1 | * |
439-
# fileD1 | fileD1 |
440-
# dirA | dirA |
441-
# dirA/fileA1 | dirA/fileA2 |
442-
# * | dirB |
443-
# * | dirB/fileb2 |
444-
# dirC | * |
445-
# dirC/filec1 | * |
446-
# dirD | dirD |
447-
# dirD/fileD1 | dirD/fileD1 |
440+
- x(i) denotes file 'x' inode number 'i'
441+
- x(t) denotes file 'x' type 't' (symlink, reg)
442+
443+
# snap1 snap2
444+
# fileA1 | fileA2 |
445+
# * | fileB2 |
446+
# fileC1 | * |
447+
# fileD1 | fileD1 |
448+
# fileE1(i) | fileE1(i') |
449+
# dirA | dirA |
450+
# dirA/fileA1 | dirA/fileA2 |
451+
# dirA/fileB1(t) | dirA/FileB1(t') |
452+
# * | dirB |
453+
# * | dirB/fileb2 |
454+
# dirC | * |
455+
# dirC/filec1 | * |
456+
# dirD | dirD |
457+
# dirD/fileD1 | dirD/fileD1 |
448458
*/
449459
void TestMount::prepareSnapDiffLib1Cases()
450460
{
451461
//************ snap1 *************
452462
ASSERT_LE(0, write_full("fileA", "hello world"));
453463
ASSERT_LE(0, write_full("fileC", "hello world to be removed"));
454464
ASSERT_LE(0, write_full("fileD", "hello world unmodified"));
465+
ASSERT_LE(0, write_full("fileE", "hello world inode i"));
455466
ASSERT_EQ(0, mkdir("dirA"));
456467
ASSERT_LE(0, write_full("dirA/fileA", "file 'A/a' v1"));
468+
ASSERT_EQ(0, symlink("dirA/fileB", "dirA/fileA"));
457469
ASSERT_EQ(0, mkdir("dirC"));
458470
ASSERT_LE(0, write_full("dirC/filec", "file 'C/c' v1"));
459471
ASSERT_EQ(0, mkdir("dirD"));
@@ -465,8 +477,12 @@ void TestMount::prepareSnapDiffLib1Cases()
465477
ASSERT_LE(0, write_full("fileA", "hello world again in A"));
466478
ASSERT_LE(0, write_full("fileB", "hello world in B"));
467479
ASSERT_EQ(0, unlink("fileC"));
480+
ASSERT_EQ(0, unlink("fileE"));
481+
ASSERT_LE(0, write_full("fileE", "hello world inode i'"));
468482

469483
ASSERT_LE(0, write_full("dirA/fileA", "file 'A/a' v2"));
484+
ASSERT_EQ(0, unlink("dirA/fileB"));
485+
ASSERT_LE(0, write_full("dirA/fileB", "file 'A/b' v1"));
470486
ASSERT_EQ(0, purge_dir("dirC"));
471487
ASSERT_EQ(0, mkdir("dirB"));
472488
ASSERT_LE(0, write_full("dirB/fileb", "file 'B/b' v2"));
@@ -506,6 +522,7 @@ TEST(LibCephFS, SnapDiffLib)
506522
expected.push_back("fileA");
507523
expected.push_back("fileC");
508524
expected.push_back("fileD");
525+
expected.push_back("fileE");
509526
expected.push_back("dirA");
510527
expected.push_back("dirC");
511528
expected.push_back("dirD");
@@ -523,6 +540,7 @@ TEST(LibCephFS, SnapDiffLib)
523540
expected.push_back("fileA");
524541
expected.push_back("fileB");
525542
expected.push_back("fileD");
543+
expected.push_back("fileE");
526544
expected.push_back("dirA");
527545
expected.push_back("dirB");
528546
expected.push_back("dirD");
@@ -543,6 +561,8 @@ TEST(LibCephFS, SnapDiffLib)
543561
expected.emplace_back("fileA", snapid2);
544562
expected.emplace_back("fileB", snapid2);
545563
expected.emplace_back("fileC", snapid1);
564+
expected.emplace_back("fileE", snapid1);
565+
expected.emplace_back("fileE", snapid2);
546566
expected.emplace_back("dirA", snapid2);
547567
expected.emplace_back("dirB", snapid2);
548568
expected.emplace_back("dirC", snapid1);
@@ -579,6 +599,8 @@ TEST(LibCephFS, SnapDiffLib)
579599
{
580600
vector<pair<string, uint64_t>> expected;
581601
expected.emplace_back("fileA", snapid2);
602+
expected.emplace_back("fileB", snapid1);
603+
expected.emplace_back("fileB", snapid2);
582604
test_mount.verify_snap_diff(expected, "dirA", "snap1", "snap2");
583605
}
584606

@@ -893,6 +915,7 @@ TEST(LibCephFS, SnapDiffLib2)
893915
vector<pair<string, uint64_t>> snap1_3_diff_expected;
894916
snap1_3_diff_expected.emplace_back("fileA", snapid3);
895917
snap1_3_diff_expected.emplace_back("fileB", snapid3);
918+
snap1_3_diff_expected.emplace_back("fileC", snapid1);
896919
snap1_3_diff_expected.emplace_back("fileC", snapid3);
897920
snap1_3_diff_expected.emplace_back("fileD", snapid3);
898921
snap1_3_diff_expected.emplace_back("fileE", snapid3);
@@ -1534,6 +1557,7 @@ TEST(LibCephFS, SnapDiffCases1_3)
15341557
expected.emplace_back("e", snapid1); // file 'e' is removed in snap3
15351558
expected.emplace_back("f", snapid1); // file 'f' is removed in snap3
15361559
expected.emplace_back("ff", snapid1); // file 'ff' is removed in snap3
1560+
expected.emplace_back("g", snapid1); // file 'g' removed in snap2
15371561
expected.emplace_back("g", snapid3); // file 'g' removed in snap2 and
15381562
// re-appeared in snap3
15391563
expected.emplace_back("S", snapid3); // folder 'S' is present in snap3 hence reported

0 commit comments

Comments
 (0)