[libvirt] [libvirt-test-api][PATCH 2/3] Add getCellsFreeMemory test case
hujianwei
jiahu at redhat.com
Fri Apr 24 08:11:23 UTC 2015
On 22/04/15 21:00, Luyao Huang wrote:
> It is hard to check if the free memory for each node is right, because
> memory change too fast in most machine (even machine in low load).
> Get this free memory 1000 times and get the Standard Deviation via
> get_standard_deviation().
>
> 177 is a expectations get from 1000 times test in a low load machine,
> so this case may still get fail in some big machine.
>
> Signed-off-by: Luyao Huang <lhuang at redhat.com>
> ---
> cases/test_connection.conf | 4 ++
> repos/virconn/connection_getCellsFreeMemory.py | 53 ++++++++++++++++++++++++++
> 2 files changed, 57 insertions(+)
> create mode 100644 repos/virconn/connection_getCellsFreeMemory.py
>
> diff --git a/cases/test_connection.conf b/cases/test_connection.conf
> index 5719937..1dc98e7 100644
> --- a/cases/test_connection.conf
> +++ b/cases/test_connection.conf
> @@ -57,3 +57,7 @@ virconn:connection_getDomainCapabilities
> pc-i440fx-rhel7.0.0
> virttype
> kvm
> +
> +virconn:connection_getCellsFreeMemory
> + conn
> + qemu:///system
> diff --git a/repos/virconn/connection_getCellsFreeMemory.py b/repos/virconn/connection_getCellsFreeMemory.py
> new file mode 100644
> index 0000000..a14e5aa
> --- /dev/null
> +++ b/repos/virconn/connection_getCellsFreeMemory.py
> @@ -0,0 +1,53 @@
> +#!/usr/bin/env python
> +import libvirt
> +from libvirt import libvirtError
> +from utils import utils
> +
> +required_params = ()
> +optional_params = {'conn': ''}
> +
> +NODE_ONLINE = '/sys/devices/system/node/online'
> +
> +def getnodemem(path):
> + return open(path).read().splitlines()[1].split()[3]
> +
> +def virtgetmem(a):
> + return a[0].getCellsFreeMemory(a[1], a[1] + 1)[0]/1024
> +
> +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))
I don't think a const 177 is here, could you generate a** value
**dynamically based on a specified machine? And percent is recommended.*//*
> +
> + except libvirtError, e:
> + logger.error("API error message: %s" % e.message)
> + fail=1
> + return fail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150424/f0bf251b/attachment-0001.htm>
More information about the libvir-list
mailing list