@@ -549,7 +549,8 @@ def test_cephfs_mirror_stats(self):
549549
550550 # create a bunch of files in a directory to snap
551551 self .mount_a .run_shell (["mkdir" , "d0" ])
552- self .mount_a .create_n_files ('d0/file' , 50 , sync = True )
552+ for i in range (50 ):
553+ self .mount_a .write_n_mb (os .path .join ('d0' , f'file.{ i } ' ), 1 )
553554
554555 self .enable_mirroring (self .primary_fs_name , self .primary_fs_id )
555556 self .add_directory (self .primary_fs_name , self .primary_fs_id , '/d0' )
@@ -567,17 +568,20 @@ def test_cephfs_mirror_stats(self):
567568 "client.mirror_remote@ceph" , '/d0' , 'snap0' , 1 )
568569 self .verify_snapshot ('d0' , 'snap0' )
569570
570- # check snaps_synced
571+ # check perf counters
571572 res = self .mirror_daemon_command (f'counter dump for fs: { self .primary_fs_name } ' , 'counter' , 'dump' )
572573 second = res [TestMirroring .PERF_COUNTER_KEY_NAME_CEPHFS_MIRROR_PEER ][0 ]
573574 self .assertGreater (second ["counters" ]["snaps_synced" ], first ["counters" ]["snaps_synced" ])
575+ self .assertGreater (second ["counters" ]["last_synced_start" ], first ["counters" ]["last_synced_start" ])
576+ self .assertGreater (second ["counters" ]["last_synced_end" ], second ["counters" ]["last_synced_start" ])
577+ self .assertGreater (second ["counters" ]["last_synced_duration" ], 0 )
578+ self .assertEquals (second ["counters" ]["last_synced_bytes" ], 52428800 ) # last_synced_bytes = 50 files of 1MB size each
574579
575580 # some more IO
576- self . mount_a . run_shell ([ "mkdir" , "d0/d00" ])
577- self .mount_a .run_shell ([ "mkdir" , "d0/d01" ] )
581+ for i in range ( 75 ):
582+ self .mount_a .write_n_mb ( os . path . join ( 'd0' , f'more_file. { i } ' ), 1 )
578583
579- self .mount_a .create_n_files ('d0/d00/more_file' , 20 , sync = True )
580- self .mount_a .create_n_files ('d0/d01/some_more_file' , 75 , sync = True )
584+ time .sleep (60 )
581585
582586 # take another snapshot
583587 self .mount_a .run_shell (["mkdir" , "d0/.snap/snap1" ])
@@ -587,10 +591,14 @@ def test_cephfs_mirror_stats(self):
587591 "client.mirror_remote@ceph" , '/d0' , 'snap1' , 2 )
588592 self .verify_snapshot ('d0' , 'snap1' )
589593
590- # check snaps_synced
594+ # check perf counters
591595 res = self .mirror_daemon_command (f'counter dump for fs: { self .primary_fs_name } ' , 'counter' , 'dump' )
592596 third = res [TestMirroring .PERF_COUNTER_KEY_NAME_CEPHFS_MIRROR_PEER ][0 ]
593597 self .assertGreater (third ["counters" ]["snaps_synced" ], second ["counters" ]["snaps_synced" ])
598+ self .assertGreater (third ["counters" ]["last_synced_start" ], second ["counters" ]["last_synced_end" ])
599+ self .assertGreater (third ["counters" ]["last_synced_end" ], third ["counters" ]["last_synced_start" ])
600+ self .assertGreater (third ["counters" ]["last_synced_duration" ], 0 )
601+ self .assertEquals (third ["counters" ]["last_synced_bytes" ], 78643200 ) # last_synced_bytes = 75 files of 1MB size each
594602
595603 # delete a snapshot
596604 self .mount_a .run_shell (["rmdir" , "d0/.snap/snap0" ])
0 commit comments