@@ -82,6 +82,7 @@ var _ = Describe("vgmanager controller", func() {
82
82
It ("should handle LVMD edge cases correctly" , testLVMD )
83
83
It ("should handle thin pool creation correctly" , testThinPoolCreation )
84
84
It ("should handle thin pool extension cases correctly" , testThinPoolExtension )
85
+ It ("should handle metadata size extension correctly" , testMetadataSizeExtension )
85
86
})
86
87
Context ("event tests" , func () {
87
88
It ("should correctly emit events" , testEvents )
@@ -703,6 +704,36 @@ func testLVMD(ctx context.Context) {
703
704
Expect (err ).To (HaveOccurred (), "should error if lvmd config cannot be saved" )
704
705
}
705
706
707
+ func testMetadataSizeExtension (ctx context.Context ) {
708
+ r := & Reconciler {Scheme : scheme .Scheme }
709
+ logger := zap .New (zap .WriteTo (GinkgoWriter ), zap .UseDevMode (true ))
710
+ ctx = log .IntoContext (ctx , logger )
711
+ mockLVM := lvmmocks .NewMockLVM (GinkgoT ())
712
+ r .LVM = mockLVM
713
+
714
+ cfg := lvmv1alpha1.ThinPoolConfig {
715
+ Name : "test" ,
716
+ MetadataSizeCalculationPolicy : lvmv1alpha1 .MetadataSizePolicyHost ,
717
+ }
718
+
719
+ By ("skip metadata extension when policy set to Host" )
720
+ err := r .verifyMetadataSize (ctx , "vg1" , cfg .Name , "1024b" , convertMetadataSize (& cfg ))
721
+ Expect (err ).NotTo (HaveOccurred (), "should not error if metadata size calculation policy is Host" )
722
+
723
+ By ("skip metadata extension when metadata size is same" )
724
+ cfg .MetadataSizeCalculationPolicy = lvmv1alpha1 .MetadataSizePolicyStatic
725
+ cfg .MetadataSize = ptr .To (resource .MustParse ("1Mi" ))
726
+ err = r .verifyMetadataSize (ctx , "vg1" , cfg .Name , fmt .Sprintf ("%vb" , cfg .MetadataSize .Value ()), convertMetadataSize (& cfg ))
727
+ Expect (err ).NotTo (HaveOccurred (), "should not error because metadata size is the same" )
728
+
729
+ By ("extend metadata size when provided is bigger than actual" )
730
+ oldSize := cfg .MetadataSize
731
+ cfg .MetadataSize = ptr .To (resource .MustParse ("1Gi" ))
732
+ mockLVM .EXPECT ().ExtendThinPoolMetadata (ctx , cfg .Name , "vg1" , cfg .MetadataSize .Value ()).Return (nil ).Once ()
733
+ err = r .verifyMetadataSize (ctx , "vg1" , cfg .Name , fmt .Sprintf ("%vb" , oldSize .Value ()), convertMetadataSize (& cfg ))
734
+ Expect (err ).NotTo (HaveOccurred (), "should not error when metadata extended" )
735
+ }
736
+
706
737
func testThinPoolExtension (ctx context.Context ) {
707
738
r := & Reconciler {Scheme : scheme .Scheme }
708
739
logger := zap .New (zap .WriteTo (GinkgoWriter ), zap .UseDevMode (true ))
0 commit comments