test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH V1] framework/virt_base: reduce dpdk complie times in vm at same suite
@ 2019-10-21 19:13 lihong
  2019-11-04  2:41 ` Tu, Lijuan
  0 siblings, 1 reply; 2+ messages in thread
From: lihong @ 2019-10-21 19:13 UTC (permalink / raw)
  To: dts; +Cc: zhaoyan.chen, lihong

Add global variable to record all the vm image name in each dut and suite,
in same suite, same vm only compile one times.

Signed-off-by: lihong <lihongx.ma@intel.com>
---
 framework/virt_base.py | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/framework/virt_base.py b/framework/virt_base.py
index 6e3462c..31623be 100644
--- a/framework/virt_base.py
+++ b/framework/virt_base.py
@@ -31,6 +31,7 @@
 import os
 import sys
 import traceback
+import threading
 from random import randint
 from itertools import imap
 
@@ -47,6 +48,8 @@ ST_NOTSTART = "NOTSTART"
 ST_PAUSE = "PAUSE"
 ST_RUNNING = "RUNNING"
 ST_UNKNOWN = "UNKNOWN"
+VM_IMG_LIST = []
+mutex_vm_list = threading.Lock()
 
 class VirtBase(object):
     """
@@ -388,6 +391,20 @@ class VirtBase(object):
         """
         NotImplemented
 
+    def get_vm_img(self):
+        """
+        get current vm img name from params
+        get format like: 10.67.110.11:TestVhostMultiQueueQemu:/home/img/Ub1604.img
+        """
+        param_len = len(self.params)
+        for i in range(param_len):
+            if 'disk' in self.params[i].keys():
+                value = self.params[i]['disk'][0]
+                if 'file' in value.keys():
+                    host_ip = self.host_dut.get_ip_address()
+                    return host_ip + ':' + self.host_dut.test_classname + ':' + value['file']
+        return None
+
     def instantiate_vm_dut(self, set_target=True, cpu_topo='', bind_dev=True, autodetect_topo=True):
         """
         Instantiate the Dut class for VM.
@@ -427,9 +444,11 @@ class VirtBase(object):
 
         read_cache = False
         skip_setup = self.host_dut.skip_setup
+        vm_img = self.get_vm_img()
         # if current vm is migration vm, skip compile dpdk
-        if self.migration_vm:
-	        skip_setup = True
+        # if VM_IMG_list include the vm_img, it means the vm have complie the dpdk ok, skip it
+        if self.migration_vm or vm_img in VM_IMG_LIST:
+            skip_setup = True
         base_dir = self.host_dut.base_dir
         vm_dut.set_speedup_options(read_cache, skip_setup)
 
@@ -449,6 +468,12 @@ class VirtBase(object):
             raise exception.VirtDutInitException(vm_dut)
             return None
 
+        # after prerequisites and set_target, the dpdk compile is ok, add this vm img to list
+        if vm_img not in VM_IMG_LIST:
+            mutex_vm_list.acquire()
+            VM_IMG_LIST.append(vm_img)
+            mutex_vm_list.release()
+
         self.vm_dut = vm_dut
         return vm_dut
 
-- 
2.7.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dts] [PATCH V1] framework/virt_base: reduce dpdk complie times in vm at same suite
  2019-10-21 19:13 [dts] [PATCH V1] framework/virt_base: reduce dpdk complie times in vm at same suite lihong
@ 2019-11-04  2:41 ` Tu, Lijuan
  0 siblings, 0 replies; 2+ messages in thread
From: Tu, Lijuan @ 2019-11-04  2:41 UTC (permalink / raw)
  To: Ma, LihongX, dts; +Cc: Chen, Zhaoyan, Ma, LihongX

Applied, thanks

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of lihong
> Sent: Tuesday, October 22, 2019 3:14 AM
> To: dts@dpdk.org
> Cc: Chen, Zhaoyan <zhaoyan.chen@intel.com>; Ma, LihongX
> <lihongx.ma@intel.com>
> Subject: [dts] [PATCH V1] framework/virt_base: reduce dpdk complie times
> in vm at same suite
> 
> Add global variable to record all the vm image name in each dut and suite, in
> same suite, same vm only compile one times.
> 
> Signed-off-by: lihong <lihongx.ma@intel.com>
> ---
>  framework/virt_base.py | 29 +++++++++++++++++++++++++++--
>  1 file changed, 27 insertions(+), 2 deletions(-)
> 
> diff --git a/framework/virt_base.py b/framework/virt_base.py index
> 6e3462c..31623be 100644
> --- a/framework/virt_base.py
> +++ b/framework/virt_base.py
> @@ -31,6 +31,7 @@
>  import os
>  import sys
>  import traceback
> +import threading
>  from random import randint
>  from itertools import imap
> 
> @@ -47,6 +48,8 @@ ST_NOTSTART = "NOTSTART"
>  ST_PAUSE = "PAUSE"
>  ST_RUNNING = "RUNNING"
>  ST_UNKNOWN = "UNKNOWN"
> +VM_IMG_LIST = []
> +mutex_vm_list = threading.Lock()
> 
>  class VirtBase(object):
>      """
> @@ -388,6 +391,20 @@ class VirtBase(object):
>          """
>          NotImplemented
> 
> +    def get_vm_img(self):
> +        """
> +        get current vm img name from params
> +        get format like:
> 10.67.110.11:TestVhostMultiQueueQemu:/home/img/Ub1604.img
> +        """
> +        param_len = len(self.params)
> +        for i in range(param_len):
> +            if 'disk' in self.params[i].keys():
> +                value = self.params[i]['disk'][0]
> +                if 'file' in value.keys():
> +                    host_ip = self.host_dut.get_ip_address()
> +                    return host_ip + ':' + self.host_dut.test_classname + ':' +
> value['file']
> +        return None
> +
>      def instantiate_vm_dut(self, set_target=True, cpu_topo='', bind_dev=True,
> autodetect_topo=True):
>          """
>          Instantiate the Dut class for VM.
> @@ -427,9 +444,11 @@ class VirtBase(object):
> 
>          read_cache = False
>          skip_setup = self.host_dut.skip_setup
> +        vm_img = self.get_vm_img()
>          # if current vm is migration vm, skip compile dpdk
> -        if self.migration_vm:
> -	        skip_setup = True
> +        # if VM_IMG_list include the vm_img, it means the vm have complie the
> dpdk ok, skip it
> +        if self.migration_vm or vm_img in VM_IMG_LIST:
> +            skip_setup = True
>          base_dir = self.host_dut.base_dir
>          vm_dut.set_speedup_options(read_cache, skip_setup)
> 
> @@ -449,6 +468,12 @@ class VirtBase(object):
>              raise exception.VirtDutInitException(vm_dut)
>              return None
> 
> +        # after prerequisites and set_target, the dpdk compile is ok, add this vm
> img to list
> +        if vm_img not in VM_IMG_LIST:
> +            mutex_vm_list.acquire()
> +            VM_IMG_LIST.append(vm_img)
> +            mutex_vm_list.release()
> +
>          self.vm_dut = vm_dut
>          return vm_dut
> 
> --
> 2.7.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-04  2:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-21 19:13 [dts] [PATCH V1] framework/virt_base: reduce dpdk complie times in vm at same suite lihong
2019-11-04  2:41 ` Tu, Lijuan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).