All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] selftest/eSDK.py: Cleanup when there is an error in setUpClass
       [not found] <cover.1487769155.git.mariano.lopez@linux.intel.com>
@ 2017-02-22 13:12 ` mariano.lopez
  2017-02-23 15:53   ` akuster808
  0 siblings, 1 reply; 2+ messages in thread
From: mariano.lopez @ 2017-02-22 13:12 UTC (permalink / raw)
  To: openembedded-core

From: Mariano Lopez <mariano.lopez@linux.intel.com>

Lately autobuilders are experiencing hangs with selftest,
it seems it is cause if an error happens in setUpClass
method of oeSDKExtSelfTest class because HTTP server
keeps running in background.

This patch will ensure tearDownClass will be run if there
is an error in setUpClass.

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
 meta/lib/oeqa/selftest/eSDK.py | 46 +++++++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/meta/lib/oeqa/selftest/eSDK.py b/meta/lib/oeqa/selftest/eSDK.py
index ee1ca6a..b68e997 100644
--- a/meta/lib/oeqa/selftest/eSDK.py
+++ b/meta/lib/oeqa/selftest/eSDK.py
@@ -64,7 +64,7 @@ class oeSDKExtSelfTest(oeSelfTest):
         runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA))
 
         cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)
-       
+
         sstate_config="""
 SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS"
 SSTATE_MIRRORS =  "file://.* http://%s/PATH"
@@ -73,37 +73,41 @@ CORE_IMAGE_EXTRA_INSTALL = "perl"
 
         with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
             f.write(sstate_config)
-    
 
     @classmethod
     def setUpClass(cls):
-        # Start to serve sstate dir
-        sstate_dir = get_bb_var('SSTATE_DIR')
-        cls.http_service = HTTPService(sstate_dir)
-        cls.http_service.start()
+        # If there is an exception in setUpClass it will not run tearDownClass
+        # method and it leaves HTTP server running forever, so we need to be
+        # sure tearDownClass is run.
+        try:
+            cls.tmpdir_eSDKQA = tempfile.mkdtemp(prefix='eSDKQA')
 
-        cls.http_url = "http://127.0.0.1:%d" % cls.http_service.port
- 
-        cls.image = 'core-image-minimal'
+            # Start to serve sstate dir
+            sstate_dir = get_bb_var('SSTATE_DIR')
+            cls.http_service = HTTPService(sstate_dir)
+            cls.http_url = "http://127.0.0.1:%d" % cls.http_service.port
+            cls.http_service.start()
 
-        cls.tmpdir_eSDKQA = tempfile.mkdtemp(prefix='eSDKQA')
-        oeSDKExtSelfTest.generate_eSDK(cls.image)
+            cls.image = 'core-image-minimal'
+            oeSDKExtSelfTest.generate_eSDK(cls.image)
 
-        # Install eSDK
-        cls.ext_sdk_path = oeSDKExtSelfTest.get_eSDK_toolchain(cls.image)
-        runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA))
+            # Install eSDK
+            cls.ext_sdk_path = oeSDKExtSelfTest.get_eSDK_toolchain(cls.image)
+            runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA))
 
-        cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)
+            cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)
 
-        # Configure eSDK to use sstate mirror from poky
-        sstate_config="""
+            # Configure eSDK to use sstate mirror from poky
+            sstate_config="""
 SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS"
 SSTATE_MIRRORS =  "file://.* http://%s/PATH"
-        """ % cls.http_url
-        with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
-            f.write(sstate_config)
+            """ % cls.http_url
+            with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
+                f.write(sstate_config)
+        except:
+            cls.tearDownClass()
+            raise
 
-      
     @classmethod
     def tearDownClass(cls):
         shutil.rmtree(cls.tmpdir_eSDKQA)
-- 
2.6.6



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

* Re: [PATCH 1/1] selftest/eSDK.py: Cleanup when there is an error in setUpClass
  2017-02-22 13:12 ` [PATCH 1/1] selftest/eSDK.py: Cleanup when there is an error in setUpClass mariano.lopez
@ 2017-02-23 15:53   ` akuster808
  0 siblings, 0 replies; 2+ messages in thread
From: akuster808 @ 2017-02-23 15:53 UTC (permalink / raw)
  To: mariano.lopez, openembedded-core

Mariano,


On 02/22/2017 05:12 AM, mariano.lopez@linux.intel.com wrote:
> From: Mariano Lopez <mariano.lopez@linux.intel.com>
>
> Lately autobuilders are experiencing hangs with selftest,
> it seems it is cause if an error happens in setUpClass
> method of oeSDKExtSelfTest class because HTTP server
> keeps running in background.
Any issue if Morty gets this?
- armin
> This patch will ensure tearDownClass will be run if there
> is an error in setUpClass.
>
> Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
> ---
>   meta/lib/oeqa/selftest/eSDK.py | 46 +++++++++++++++++++++++-------------------
>   1 file changed, 25 insertions(+), 21 deletions(-)
>
> diff --git a/meta/lib/oeqa/selftest/eSDK.py b/meta/lib/oeqa/selftest/eSDK.py
> index ee1ca6a..b68e997 100644
> --- a/meta/lib/oeqa/selftest/eSDK.py
> +++ b/meta/lib/oeqa/selftest/eSDK.py
> @@ -64,7 +64,7 @@ class oeSDKExtSelfTest(oeSelfTest):
>           runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA))
>   
>           cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)
> -
> +
>           sstate_config="""
>   SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS"
>   SSTATE_MIRRORS =  "file://.* http://%s/PATH"
> @@ -73,37 +73,41 @@ CORE_IMAGE_EXTRA_INSTALL = "perl"
>   
>           with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
>               f.write(sstate_config)
> -
>   
>       @classmethod
>       def setUpClass(cls):
> -        # Start to serve sstate dir
> -        sstate_dir = get_bb_var('SSTATE_DIR')
> -        cls.http_service = HTTPService(sstate_dir)
> -        cls.http_service.start()
> +        # If there is an exception in setUpClass it will not run tearDownClass
> +        # method and it leaves HTTP server running forever, so we need to be
> +        # sure tearDownClass is run.
> +        try:
> +            cls.tmpdir_eSDKQA = tempfile.mkdtemp(prefix='eSDKQA')
>   
> -        cls.http_url = "http://127.0.0.1:%d" % cls.http_service.port
> -
> -        cls.image = 'core-image-minimal'
> +            # Start to serve sstate dir
> +            sstate_dir = get_bb_var('SSTATE_DIR')
> +            cls.http_service = HTTPService(sstate_dir)
> +            cls.http_url = "http://127.0.0.1:%d" % cls.http_service.port
> +            cls.http_service.start()
>   
> -        cls.tmpdir_eSDKQA = tempfile.mkdtemp(prefix='eSDKQA')
> -        oeSDKExtSelfTest.generate_eSDK(cls.image)
> +            cls.image = 'core-image-minimal'
> +            oeSDKExtSelfTest.generate_eSDK(cls.image)
>   
> -        # Install eSDK
> -        cls.ext_sdk_path = oeSDKExtSelfTest.get_eSDK_toolchain(cls.image)
> -        runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA))
> +            # Install eSDK
> +            cls.ext_sdk_path = oeSDKExtSelfTest.get_eSDK_toolchain(cls.image)
> +            runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA))
>   
> -        cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)
> +            cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)
>   
> -        # Configure eSDK to use sstate mirror from poky
> -        sstate_config="""
> +            # Configure eSDK to use sstate mirror from poky
> +            sstate_config="""
>   SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS"
>   SSTATE_MIRRORS =  "file://.* http://%s/PATH"
> -        """ % cls.http_url
> -        with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
> -            f.write(sstate_config)
> +            """ % cls.http_url
> +            with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
> +                f.write(sstate_config)
> +        except:
> +            cls.tearDownClass()
> +            raise
>   
> -
>       @classmethod
>       def tearDownClass(cls):
>           shutil.rmtree(cls.tmpdir_eSDKQA)



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

end of thread, other threads:[~2017-02-23 15:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1487769155.git.mariano.lopez@linux.intel.com>
2017-02-22 13:12 ` [PATCH 1/1] selftest/eSDK.py: Cleanup when there is an error in setUpClass mariano.lopez
2017-02-23 15:53   ` akuster808

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.