move isAlmostEqual to utils

Signed-off-by: Prasanna Santhanam <tsp@apache.org>
This commit is contained in:
Prasanna Santhanam 2013-07-04 20:14:03 +05:30
parent 048cf5aae8
commit da9552b7f3
2 changed files with 56 additions and 56 deletions

View File

@ -20,7 +20,7 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.integration.lib.utils import *
from marvin.integration.lib.utils import isAlmostEqual
from marvin.integration.lib.base import *
from marvin.integration.lib.common import *
from nose.plugins.attrib import attr
@ -273,21 +273,6 @@ 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"""
@ -447,7 +432,7 @@ class TestServiceOfferings(cloudstackTestCase):
"Check CPU Speed for small offering"
)
self.assertTrue(
self.isAlmostEqual(int(int(total_mem)/1024),
isAlmostEqual(int(int(total_mem) / 1024),
int(self.small_offering.memory),
range=20
),

View File

@ -164,7 +164,7 @@ def get_process_status(hostip, port, username, password, linklocalip, process, h
else:
ssh_command = "ssh -i ~/.ssh/id_rsa.cloud -ostricthostkeychecking=no "
ssh_command = ssh_command + \
ssh_command = ssh_command +\
"-oUserKnownHostsFile=/dev/null -p 3922 %s %s" % (
linklocalip,
process)
@ -183,3 +183,18 @@ def get_process_status(hostip, port, username, password, linklocalip, process, h
time.sleep(5)
timeout = timeout - 1
return res
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