@@ -757,3 +757,49 @@ func TestListSubvolumesInGroup(t *testing.T) {
757757 assert .Empty (t , ret )
758758 })
759759}
760+
761+ func TestAllowStandbyReplay (t * testing.T ) {
762+ cephFSName := "myfs"
763+ newContext := func (standbyWanted bool , standbyCount int32 ) * clusterd.Context {
764+ t .Helper ()
765+
766+ executor := & exectest.MockExecutor {
767+ MockExecuteCommandWithOutput : func (command string , args ... string ) (string , error ) {
768+ t .Logf ("Command: %s %v" , command , args )
769+ if args [0 ] == "fs" && args [1 ] == "set" && args [2 ] == cephFSName {
770+ switch args [3 ] {
771+ case "allow_standby_replay" :
772+ if args [4 ] == fmt .Sprint (standbyWanted ) {
773+ return "" , nil
774+ }
775+ case "standby_count_wanted" :
776+ if args [4 ] == fmt .Sprint (standbyCount ) {
777+ return "" , nil
778+ }
779+ }
780+ }
781+ panic (fmt .Sprintf ("unhandled command %q %v" , command , args ))
782+ },
783+ }
784+
785+ return & clusterd.Context {Executor : executor }
786+ }
787+
788+ t .Run ("no standby mds" , func (t * testing.T ) {
789+ ctx := newContext (false , 0 )
790+ err := AllowStandbyReplay (ctx , AdminTestClusterInfo ("mycluster" ), cephFSName , false , int32 (1 ))
791+ assert .NoError (t , err )
792+ })
793+
794+ t .Run ("standby mds" , func (t * testing.T ) {
795+ ctx := newContext (true , 1 )
796+ err := AllowStandbyReplay (ctx , AdminTestClusterInfo ("mycluster" ), cephFSName , true , int32 (1 ))
797+ assert .NoError (t , err )
798+ })
799+
800+ t .Run ("standby mds multiple" , func (t * testing.T ) {
801+ ctx := newContext (true , 3 )
802+ err := AllowStandbyReplay (ctx , AdminTestClusterInfo ("mycluster" ), cephFSName , true , int32 (3 ))
803+ assert .NoError (t , err )
804+ })
805+ }
0 commit comments