diff --git a/test/integration/smoke/test_service_offerings.py b/test/integration/smoke/test_service_offerings.py index 0213c04cb02..8b6b0133f1c 100644 --- a/test/integration/smoke/test_service_offerings.py +++ b/test/integration/smoke/test_service_offerings.py @@ -273,6 +273,21 @@ class TestServiceOfferings(cloudstackTestCase): raise Exception("Warning: Exception during cleanup : %s" % e) return + def isAlmostEqual(self, first_digit, second_digit, range=0): + + digits_equal_within_range = False + + try: + if ((first_digit - range) < second_digit < (first_digit + range)): + digits_equal_within_range = True + + except Exception as e: + self.fail( + "%s: Failed while comparing the numbers %s & %s" % + (e, first_digit, second_digit)) + + return digits_equal_within_range + @attr(tags=["advanced", "advancedns", "smoke", "basic", "eip", "sg"]) def test_02_edit_service_offering(self): """Test to update existing service offering""" @@ -431,9 +446,11 @@ class TestServiceOfferings(cloudstackTestCase): self.small_offering.cpuspeed, "Check CPU Speed for small offering" ) - self.assertAlmostEqual( - int(total_mem) / 1024, # In MBs - int(self.small_offering.memory), + self.assertTrue( + self.isAlmostEqual(int(int(total_mem)/1024), + int(self.small_offering.memory), + range=20 + ), "Check Memory(kb) for small offering" ) return