def connection_getCellsFreeMemory(params): """ test API for getCellsFreeMemory in class virConnect """ logger = params['logger'] fail = 0 nodeset = utils.file_read(NODE_ONLINE) logger.info("host exist node is %s" % nodeset) node_tuple = utils.param_to_tuple_nolength(nodeset) if not node_tuple: logger.info("error in function param_to_tuple_nolength") return 1 try: conn = libvirt.open(params['conn']) logger.info("get connection cells free memory") for n in range(len(node_tuple)): if not node_tuple[n]: continue D = utils.get_standard_deviation(getnodemem, virtgetmem, \ '/sys/devices/system/node/node%d/meminfo' % n, [conn,n]) logger.info("Standard Deviation for node %d is %d" % (n, D)) """ expectations 177 is a average collected in a x86_64 low load machine""" if D > 177 * 5: fail = 1 logger.info("FAIL: Standard Deviation is too big \ (biger than %d) for node %d" % (177 * 5, n)) except libvirtError, e: logger.error("API error message: %s" % e.message) fail = 1
def connection_getCellsFreeMemory(params): """ test API for getCellsFreeMemory in class virConnect """ logger = params['logger'] fail = 0 nodeset = utils.file_read(NODE_ONLINE) logger.info("host exist node is %s" % nodeset) node_tuple = utils.param_to_tuple_nolength(nodeset) if not node_tuple: logger.info("error in function param_to_tuple_nolength") return 1 try: conn = libvirt.open(params['conn']) logger.info("get connection cells free memory") for n in range(len(node_tuple)): if not node_tuple[n]: continue D = utils.get_standard_deviation(getnodemem, virtgetmem, "/sys/devices/system/node/node%d/meminfo" % n, [conn, n]) logger.info("Standard Deviation for node %d is %d" % (n, D)) """ expectations 177 is a average collected in a x86_64 low load machine""" if D > 177 * 5: fail = 1 logger.info("FAIL: Standard Deviation is too big \ (biger than %d) for node %d" % (177 * 5, n)) except libvirtError as e: logger.error("API error message: %s" % e.message) fail = 1 return fail
def connection_getMemoryStats(params): """ test API for getMemoryStats in class virConnect """ logger = params['logger'] fail = 0 nodeset = utils.file_read(NODE_ONLINE) logger.info("host exist node is %s" % nodeset) node_tuple = utils.param_to_tuple_nolength(nodeset) if not node_tuple: logger.info("error in function param_to_tuple_nolength") return 1 try: conn = libvirt.open(params['conn']) logger.info("get connection cells memory status") for n in range(len(node_tuple)): if not node_tuple[n]: continue D = utils.get_standard_deviation(getsysmem, virtgetmem, \ ['/sys/devices/system/node/node%d/meminfo' % n,1,3], [conn,n,'free']) logger.info("Standard Deviation for free memory in node %d is %d" % (n, D)) """ expectations 177 is a average collected in a x86_64 low load machine""" if D > 177 * 5: fail = 1 logger.info("FAIL: Standard Deviation is too big \ (biger than %d) for node %d free memory" % (177 * 5, n)) a1 = ['/sys/devices/system/node/node%d/meminfo' % n, 0, 3] a2 = [conn, n, 'total'] if long(getsysmem(a1)) != long(virtgetmem(a2)): fail = 1 logger.info("FAIL: Total memory in node %d is not right" % n) D = utils.get_standard_deviation(getsysmem, virtgetmem, \ [MEMINFO, 3, 1], [conn, -1, 'buffers']) logger.info("Standard Deviation for host buffers is %d" % D) """ expectations 30 is a average collected in a x86_64 low load machine""" if D > 30 * 5: fail = 1 logger.info("FAIL: Standard Deviation is too big \ (biger than %d) for host buffers" % 30 * 5) D = utils.get_standard_deviation(getsysmem, virtgetmem, \ [MEMINFO,4,1], [conn,-1,'cached']) logger.info("Standard Deviation for host cached is %d" % D) """ expectations 32 is a average collected in a x86_64 low load machine""" if D > 32 * 5: fail = 1 logger.info("FAIL: Standard Deviation is too big \ (biger than %d) for host cached" % 32 * 5) D = utils.get_standard_deviation(getsysmem, virtgetmem, \ [MEMINFO,1,1], [conn,-1,'free']) logger.info("Standard Deviation for host free memory is %d" % D) """ expectations 177 is a average collected in a x86_64 low load machine""" if D > 177 * 5: fail = 1 logger.info("FAIL: Standard Deviation is too big \ (biger than %d) for host free memory" % 177 * 5) if long(getsysmem([MEMINFO, 0, 1])) != long( virtgetmem([conn, -1, 'total'])): fail = 1 logger.info("FAIL: Total memory for host is not right" % n) except libvirtError, e: logger.error("API error message: %s" % e.message) fail = 1
def cpu_status(params): """ test API for getCPUStats in class virDomain """ logger = params["logger"] fail = 0 cpu = utils.file_read(ONLINE_CPU) logger.info("host online cpulist is %s" % cpu) cpu_tuple = utils.param_to_tuple_nolength(cpu) if not cpu_tuple: logger.info("error in function param_to_tuple_nolength") return 1 try: conn = libvirt.open(params["conn"]) logger.info("get connection to libvirtd") guest = params["guestname"] vm = conn.lookupByName(guest) vcpus = vm.info()[3] for n in range(len(cpu_tuple)): if not cpu_tuple[n]: continue D = utils.get_standard_deviation( getcputime, virtgetcputime, [CGROUP_PERCPU % guest, n], [vm, n, "cpu_time"] ) logger.info("Standard Deviation for host cpu %d cputime is %d" % (n, D)) """ expectations 403423 is a average collected in a x86_64 low load machine""" if D > 403423 * 5: fail = 1 logger.info( "FAIL: Standard Deviation is too big \ (biger than %d) for host cpu %d" % (403423 * 5, n) ) D = utils.get_standard_deviation(getvcputime, virtgetcputime, [vcpus, guest, n], [vm, n, "vcpu_time"]) logger.info("Standard Deviation for host cpu %d vcputime is %d" % (n, D)) """ expectations 4034 is a average collected in a x86_64 low load machine""" if D > 4034 * 5 * vcpus: fail = 1 logger.info( "FAIL: Standard Deviation is too big \ (biger than %d) for host cpu time %d" % (4034 * 5 * vcpus, n) ) D = utils.get_standard_deviation(getcputime, virtgettotalcputime, [CGROUP_USAGE % guest, 0], [vm, "cpu_time"]) logger.info("Standard Deviation for host cpu total cputime is %d" % D) """ expectations 313451 is a average collected in a x86_64 low load machine""" if D > 313451 * 5 * len(cpu_tuple): fail = 1 logger.info( "FAIL: Standard Deviation is too big \ (biger than %d) for host cpu time %d" % (313451 * 5 * len(cpu_tuple), n) ) D = utils.get_standard_deviation( getcputime, virtgettotalcputime2, [CGROUP_STAT % guest, 3], [vm, "system_time"] ) logger.info("Standard Deviation for host cpu total system time is %d" % D) """ expectations 10 is a average collected in a x86_64 low load machine""" if D > 10 * 5: fail = 1 logger.info( "FAIL: Standard Deviation is too big \ (biger than %d) for host system cpu time %d" % (10 * 5, n) ) D = utils.get_standard_deviation(getcputime, virtgettotalcputime2, [CGROUP_STAT % guest, 1], [vm, "user_time"]) logger.info("Standard Deviation for host cpu total user time is %d" % D) """ expectations 10 is a average collected in a x86_64 low load machine""" if D > 10 * 5: fail = 1 logger.info( "FAIL: Standard Deviation is too big \ (biger than %d) for host user cpu time %d" % (10 * 5, n) ) except libvirtError, e: logger.error("API error message: %s" % e.message) fail = 1
def connection_getMemoryStats(params): """ test API for getMemoryStats in class virConnect """ logger = params['logger'] fail = 0 nodeset = utils.file_read(NODE_ONLINE) logger.info("host exist node is %s" % nodeset) node_tuple = utils.param_to_tuple_nolength(nodeset) if not node_tuple: logger.info("error in function param_to_tuple_nolength") return 1 try: conn = libvirt.open(params['conn']) logger.info("get connection cells memory status") for n in range(len(node_tuple)): if not node_tuple[n]: continue D = utils.get_standard_deviation( getsysmem, virtgetmem, ['/sys/devices/system/node/node%d/meminfo' % n, 1, 3], [conn, n, 'free']) logger.info( "Standard Deviation for free memory in node %d is %d" % (n, D)) """ expectations 177 is a average collected in a x86_64 low load machine""" if D > 177 * 5: fail = 1 logger.info( "FAIL: Standard Deviation is too big " "(biger than %d) for node %d free memory" % (177 * 5, n)) a1 = ['/sys/devices/system/node/node%d/meminfo' % n, 0, 3] a2 = [conn, n, 'total'] if long(getsysmem(a1)) != long(virtgetmem(a2)): fail = 1 logger.info("FAIL: Total memory in node %d is not right" % n) D = utils.get_standard_deviation( getsysmem, virtgetmem, [ MEMINFO, 3, 1], [ conn, -1, 'buffers']) logger.info("Standard Deviation for host buffers is %d" % D) """ expectations 30 is a average collected in a x86_64 low load machine""" if D > 30 * 5: fail = 1 logger.info("FAIL: Standard Deviation is too big " "(biger than %d) for host buffers" % 30 * 5) D = utils.get_standard_deviation(getsysmem, virtgetmem, [MEMINFO, 4, 1], [conn, -1, 'cached']) logger.info("Standard Deviation for host cached is %d" % D) """ expectations 32 is a average collected in a x86_64 low load machine""" if D > 32 * 5: fail = 1 logger.info("FAIL: Standard Deviation is too big " "(biger than %d) for host cached" % 32 * 5) D = utils.get_standard_deviation(getsysmem, virtgetmem, [MEMINFO, 1, 1], [conn, -1, 'free']) logger.info("Standard Deviation for host free memory is %d" % D) """ expectations 177 is a average collected in a x86_64 low load machine""" if D > 177 * 5: fail = 1 logger.info("FAIL: Standard Deviation is too big " " (biger than %d) for host free memory" % 177 * 5) if long(getsysmem([MEMINFO, 0, 1])) != long( virtgetmem([conn, -1, 'total'])): fail = 1 logger.info("FAIL: Total memory for host is not right" % n) except libvirtError as e: logger.error("API error message: %s" % e.message) fail = 1 return fail
def cpu_status(params): """ test API for getCPUStats in class virDomain """ logger = params['logger'] fail = 0 cpu = utils.file_read(ONLINE_CPU) logger.info("host online cpulist is %s" % cpu) cpu_tuple = utils.param_to_tuple_nolength(cpu) if not cpu_tuple: logger.info("error in function param_to_tuple_nolength") return 1 try: conn = libvirt.open(params['conn']) logger.info("get connection to libvirtd") guest = params['guestname'] vm = conn.lookupByName(guest) vcpus = vm.info()[3] for n in range(len(cpu_tuple)): if not cpu_tuple[n]: continue D = utils.get_standard_deviation(getcputime, virtgetcputime, \ [CGROUP_PERCPU % guest, n], [vm,n,'cpu_time']) logger.info("Standard Deviation for host cpu %d cputime is %d" % (n, D)) """ expectations 403423 is a average collected in a x86_64 low load machine""" if D > 403423 * 5: fail = 1 logger.info("FAIL: Standard Deviation is too big \ (biger than %d) for host cpu %d" % (403423 * 5, n)) D = utils.get_standard_deviation(getvcputime, virtgetcputime, \ [vcpus, guest, n], [vm,n,'vcpu_time']) logger.info("Standard Deviation for host cpu %d vcputime is %d" % (n, D)) """ expectations 4034 is a average collected in a x86_64 low load machine""" if D > 4034 * 5 * vcpus: fail = 1 logger.info("FAIL: Standard Deviation is too big \ (biger than %d) for host cpu time %d" % (4034 * 5 * vcpus, n)) D = utils.get_standard_deviation(getcputime, virtgettotalcputime, \ [CGROUP_USAGE % guest, 0], [vm,'cpu_time']) logger.info("Standard Deviation for host cpu total cputime is %d" % D) """ expectations 313451 is a average collected in a x86_64 low load machine""" if D > 313451 * 5 * len(cpu_tuple): fail = 1 logger.info("FAIL: Standard Deviation is too big \ (biger than %d) for host cpu time %d" % (313451 * 5 * len(cpu_tuple), n)) D = utils.get_standard_deviation(getcputime, virtgettotalcputime2, \ [CGROUP_STAT % guest, 3], [vm,'system_time']) logger.info("Standard Deviation for host cpu total system time is %d" % D) """ expectations 10 is a average collected in a x86_64 low load machine""" if D > 10 * 5: fail = 1 logger.info("FAIL: Standard Deviation is too big \ (biger than %d) for host system cpu time %d" % (10 * 5, n)) D = utils.get_standard_deviation(getcputime, virtgettotalcputime2, \ [CGROUP_STAT % guest, 1], [vm,'user_time']) logger.info("Standard Deviation for host cpu total user time is %d" % D) """ expectations 10 is a average collected in a x86_64 low load machine""" if D > 10 * 5: fail = 1 logger.info("FAIL: Standard Deviation is too big \ (biger than %d) for host user cpu time %d" % (10 * 5, n)) except libvirtError, e: logger.error("API error message: %s" % e.message) fail = 1