@@ -717,20 +717,20 @@ func testMetadataSizeExtension(ctx context.Context) {
717717 }
718718
719719 By ("skip metadata extension when policy set to Host" )
720- err := r .verifyMetadataSize (ctx , "vg1" , cfg .Name , "1024b " , convertMetadataSize (& cfg ))
720+ err := r .verifyMetadataSize (ctx , "vg1" , cfg .Name , "1024 " , convertMetadataSize (& cfg ))
721721 Expect (err ).NotTo (HaveOccurred (), "should not error if metadata size calculation policy is Host" )
722722
723723 By ("skip metadata extension when metadata size is same" )
724724 cfg .MetadataSizeCalculationPolicy = lvmv1alpha1 .MetadataSizePolicyStatic
725725 cfg .MetadataSize = ptr .To (resource .MustParse ("1Mi" ))
726- err = r .verifyMetadataSize (ctx , "vg1" , cfg .Name , fmt .Sprintf ("%vb " , cfg .MetadataSize .Value ()), convertMetadataSize (& cfg ))
726+ err = r .verifyMetadataSize (ctx , "vg1" , cfg .Name , fmt .Sprintf ("%v " , cfg .MetadataSize .Value ()), convertMetadataSize (& cfg ))
727727 Expect (err ).NotTo (HaveOccurred (), "should not error because metadata size is the same" )
728728
729729 By ("extend metadata size when provided is bigger than actual" )
730730 oldSize := cfg .MetadataSize
731731 cfg .MetadataSize = ptr .To (resource .MustParse ("1Gi" ))
732732 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 ))
733+ err = r .verifyMetadataSize (ctx , "vg1" , cfg .Name , fmt .Sprintf ("%v " , oldSize .Value ()), convertMetadataSize (& cfg ))
734734 Expect (err ).NotTo (HaveOccurred (), "should not error when metadata extended" )
735735}
736736
@@ -744,58 +744,40 @@ func testThinPoolExtension(ctx context.Context) {
744744 err := r .extendThinPool (ctx , "vg1" , "" , & lvmv1alpha1.ThinPoolConfig {})
745745 Expect (err ).To (HaveOccurred (), "should error if lvSize is empty" )
746746
747- err = r .extendThinPool (ctx , "vg1" , "1" , & lvmv1alpha1.ThinPoolConfig {})
748- Expect (err ).To (HaveOccurred (), "should error if lvSize has no unit" )
749-
750747 mockLVM .EXPECT ().GetVG (ctx , "vg1" ).Once ().Return (lvm.VolumeGroup {}, fmt .Errorf ("mocked error" ))
751- err = r .extendThinPool (ctx , "vg1" , "26.96g " , & lvmv1alpha1.ThinPoolConfig {})
748+ err = r .extendThinPool (ctx , "vg1" , "2147483648 " , & lvmv1alpha1.ThinPoolConfig {})
752749 Expect (err ).To (HaveOccurred (), "should error if GetVG fails" )
753750
754751 err = r .extendThinPool (ctx , "vg1" , "26.96gxxx" , & lvmv1alpha1.ThinPoolConfig {})
755752 Expect (err ).To (HaveOccurred (), "should error if lvSize is malformatted" )
756753
757754 lvmVG := lvm.VolumeGroup {Name : "vg1" }
758755 mockLVM .EXPECT ().GetVG (ctx , "vg1" ).Return (lvmVG , nil ).Once ()
759- err = r .extendThinPool (ctx , "vg1" , "2g " , & lvmv1alpha1.ThinPoolConfig {})
756+ err = r .extendThinPool (ctx , "vg1" , "2147483648 " , & lvmv1alpha1.ThinPoolConfig {})
760757 Expect (err ).To (HaveOccurred (), "should error if vgSize is empty" )
761758
762- lvmVG .VgSize = "1"
763- mockLVM .EXPECT ().GetVG (ctx , "vg1" ).Return (lvmVG , nil ).Once ()
764- err = r .extendThinPool (ctx , "vg1" , "2g" , & lvmv1alpha1.ThinPoolConfig {})
765- Expect (err ).To (HaveOccurred (), "should error if vgSize has no unit" )
766-
767- lvmVG .VgSize = "1m"
768- mockLVM .EXPECT ().GetVG (ctx , "vg1" ).Return (lvmVG , nil ).Once ()
769- err = r .extendThinPool (ctx , "vg1" , "2g" , & lvmv1alpha1.ThinPoolConfig {})
770- Expect (err ).To (HaveOccurred (), "should error if vg unit does not match lv unit" )
771-
772- lvmVG .VgSize = "1m"
773- mockLVM .EXPECT ().GetVG (ctx , "vg1" ).Return (lvmVG , nil ).Once ()
774- err = r .extendThinPool (ctx , "vg1" , "2m" , & lvmv1alpha1.ThinPoolConfig {})
775- Expect (err ).To (HaveOccurred (), "should error if unit is not gibibytes" )
776-
777759 lvmVG .VgSize = "1123xxg"
778760 mockLVM .EXPECT ().GetVG (ctx , "vg1" ).Return (lvmVG , nil ).Once ()
779- err = r .extendThinPool (ctx , "vg1" , "2g " , & lvmv1alpha1.ThinPoolConfig {})
761+ err = r .extendThinPool (ctx , "vg1" , "2147483648 " , & lvmv1alpha1.ThinPoolConfig {})
780762 Expect (err ).To (HaveOccurred (), "should error if vgSize is malformatted" )
781763
782- lvmVG .VgSize = "3g "
764+ lvmVG .VgSize = "3221225472 "
783765 mockLVM .EXPECT ().GetVG (ctx , "vg1" ).Return (lvmVG , nil ).Once ()
784- err = r .extendThinPool (ctx , "vg1" , "3g " , & lvmv1alpha1.ThinPoolConfig {})
766+ err = r .extendThinPool (ctx , "vg1" , "3221225472 " , & lvmv1alpha1.ThinPoolConfig {})
785767 Expect (err ).ToNot (HaveOccurred (), "should fast skip if no expansion is needed" )
786768
787- lvmVG .VgSize = "5g "
769+ lvmVG .VgSize = "5368709120 "
788770 thinPool := & lvmv1alpha1.ThinPoolConfig {Name : "thin-pool-1" , SizePercent : 90 }
789771 mockLVM .EXPECT ().GetVG (ctx , "vg1" ).Return (lvmVG , nil ).Once ()
790772 mockLVM .EXPECT ().ExtendLV (ctx , thinPool .Name , "vg1" , thinPool .SizePercent ).
791773 Once ().Return (fmt .Errorf ("failed to extend lv" ))
792- err = r .extendThinPool (ctx , "vg1" , "3g " , thinPool )
774+ err = r .extendThinPool (ctx , "vg1" , "3221225472 " , thinPool )
793775 Expect (err ).To (HaveOccurred (), "should fail if lvm extension fails" )
794776
795777 mockLVM .EXPECT ().GetVG (ctx , "vg1" ).Return (lvmVG , nil ).Once ()
796778 mockLVM .EXPECT ().ExtendLV (ctx , thinPool .Name , "vg1" , thinPool .SizePercent ).
797779 Once ().Return (nil )
798- err = r .extendThinPool (ctx , "vg1" , "3g " , thinPool )
780+ err = r .extendThinPool (ctx , "vg1" , "3221225472 " , thinPool )
799781 Expect (err ).ToNot (HaveOccurred (), "succeed if lvm extension succeeds" )
800782}
801783
@@ -841,9 +823,9 @@ func testThinPoolCreation(ctx context.Context) {
841823 err = r .addThinPoolToVG (ctx , "vg1" , thinPool )
842824 Expect (err ).ToNot (HaveOccurred (), "should create thin pool if it does not exist" )
843825
844- lvmVG := lvm.VolumeGroup {Name : "vg1" , VgSize : "5g " }
826+ lvmVG := lvm.VolumeGroup {Name : "vg1" , VgSize : "5368709120 " }
845827 mockLVM .EXPECT ().ListLVs (ctx , "vg1" ).Once ().Return (& lvm.LVReport {Report : []lvm.LVReportItem {{
846- Lv : []lvm.LogicalVolume {{Name : "thin-pool-1" , VgName : "vg1" , LvAttr : "twi---tz--" , LvSize : "3g " }},
828+ Lv : []lvm.LogicalVolume {{Name : "thin-pool-1" , VgName : "vg1" , LvAttr : "twi---tz--" , LvSize : "3221225472 " }},
847829 }}}, nil )
848830 mockLVM .EXPECT ().GetVG (ctx , "vg1" ).Once ().Return (lvmVG , nil )
849831 mockLVM .EXPECT ().ExtendLV (ctx , thinPool .Name , "vg1" , thinPool .SizePercent ).
@@ -962,7 +944,7 @@ func testReconcileFailure(ctx context.Context) {
962944 {Name : "/dev/sda" , KName : "/dev/sda" , FSType : "xfs" , PartLabel : "reserved" },
963945 }, nil )
964946 vgs := []lvm.VolumeGroup {
965- {Name : "vg1" , VgSize : "1g " },
947+ {Name : "vg1" , VgSize : "1073741824 " },
966948 }
967949 instances .LVM .EXPECT ().ListVGs (ctx , true ).Once ().Return (vgs , nil )
968950 instances .LVM .EXPECT ().ListPVs (ctx , "" ).Once ().Return (nil , nil )
0 commit comments