Skip to contentSkip to conversation

Sanity testing network connectivity

RFC PATCH In review Joshua Lock 2 participants 6 messages Jun 18, 2011 – Jun 20, 2011

lore
Share & tools
lore
#0 lore raw

cover Sanity testing network connectivity

In response to a Yocto Bugzilla request[1] I've written a sanity test to check whether BitBake is able to fecth from http, https and git sources. The idea being that if the user is behing a proxy and this test fails we can more easily help them diagnose and fix their problem.

I've built on the existing infrastructure for less frequent sanity tests so whilst this test is reasonably heavy it will only run when TMPDIR changes (usually first run?). Further I added a variable to disable just this sanity check. People shipping offline installs to customers should just be able to set the variable in their shipped configuration and not worry about this sanity check irritating people.

The error message points to a wiki page[2] which is pretty vanilla right now but the intention would be to flesh it out with guidance on common proxy/nat/etc issues.

Please review the following changes for suitability for inclusion. If you have any objections or suggestions for improvement, please respond to the patches. If you agree with the changes, please provide your Acked-by.

The following changes since commit 835d817f1ba7b99167743fdb86ba80f3a07bd82d:

systemtap: remove non-core COMPATIBLE_MACHINES (2011-06-16 22:12:40 +0100)

are available in the git repository at:
git://git.openembedded.org/openembedded-core-contrib josh/connection-test
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=josh/connection-test

Joshua Lock (2):
sanity.bbclass: pass the data object to the less frequent test
harnesses
sanity: implement network connectivity test

 meta/classes/sanity.bbclass |   45 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 37 insertions(+), 8 deletions(-)
Signature · 1 line
1.7.5.4
#2 lore raw

RFC PATCH 2/2 sanity: implement network connectivity test

Sanity test to verify files can be fetched from the network using git, http and https fetchers point users at a page to help get set up in the case of a failure

Addresses [YOCTO #933]

---
 meta/classes/sanity.bbclass |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
meta/classes/sanity.bbclass +29 -0
index bffa4f5..83a9887 100644
@@ -35,6 +35,8 @@ def check_sanity_tmpdir_change(tmpdir, data):
 
     # Check that TMPDIR isn't on a filesystem with limited filename length (eg. eCryptFS)
     testmsg = check_create_long_filename(tmpdir, "TMPDIR")
+    # Check that we can fetch from various network transports
+    testmsg = testmsg + check_connectivity(data)
     return testmsg
         
 def check_sanity_version_change(data):
@@ -75,6 +77,33 @@ def check_create_long_filename(filepath, pathname):
             return "Failed to create a file in %s: %s" % (pathname, strerror)
     return ""
 
+def check_connectivity(d):
+    test_uris= ["http://yoctoproject.org/about",
+                "https://eula-downloads.yoctoproject.org/crownbay/crownbay-bernard-5.0.0",
+                "git://git.yoctoproject.org/yocto-firewall-test;protocol=git;rev=HEAD"]
+    retval = ""
+
+    # Only check connectivity if network and this check enabled
+    # Because it's a fairy heavy test allow disabling of just this sanity test
+    # by setting DISABLE_NETWORK_SANITY
+    data = bb.data.createCopy(d)
+    network_disabled = not bb.data.getVar('BB_NO_NETWORK', data, True)
+    check_disabled = bb.data.getVar('DISABLE_NETWORK_SANITY', data, True)
+    if check_disabled or network_disabled:
+        dldir = bb.data.expand('${TMPDIR}/sanity', data)
+        bb.data.setVar('DL_DIR', dldir, data)
+
+        try:
+            fetcher = bb.fetch2.Fetch(test_uris, data)
+            fetcher.download()
+	    fetcher.clean(test_uris)
+        except Exception, e:
+            retval = "Error connecting to the network to fetch, http/https and git checked.\nPlease check the wiki (https://wiki.yoctoproject.org/wiki/Connectivity%20Troubleshooting) for more suggestions.\n" % e
+        finally:
+            # Make sure we tidy up the cruft
+            oe.path.remove(dldir)
+    return retval
+
 def check_sanity(e):
     from bb import note, error, data, __version__
 
Signature · 1 line
1.7.5.4
#1 lore raw

RFC PATCH 1/2 sanity.bbclass: pass the data object to the less frequent test harnesses

In reply to Joshua Lock

By passing the data object to the less frequently run test harnesses (check_sanity_tmpdir_change(), check_sanity_sstate_dir_change() and check_sanity_version_change()) we can run tests against BitBake data here too.

---
 meta/classes/sanity.bbclass |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
meta/classes/sanity.bbclass +8 -8
index fc005aa..bffa4f5 100644
@@ -21,7 +21,7 @@ def check_conf_exists(fn, data):
             return True
     return False
 
-def check_sanity_sstate_dir_change(sstate_dir):
+def check_sanity_sstate_dir_change(sstate_dir, data):
     # Sanity checks to be done when the value of SSTATE_DIR changes
 
     # Check that SSTATE_DIR isn't on a filesystem with limited filename length (eg. eCryptFS)
@@ -30,14 +30,14 @@ def check_sanity_sstate_dir_change(sstate_dir):
         testmsg = check_create_long_filename(sstate_dir, "SSTATE_DIR")
     return testmsg
 
-def check_sanity_tmpdir_change(tmpdir):
+def check_sanity_tmpdir_change(tmpdir, data):
     # Sanity checks to be done when the value of TMPDIR changes
 
     # Check that TMPDIR isn't on a filesystem with limited filename length (eg. eCryptFS)
     testmsg = check_create_long_filename(tmpdir, "TMPDIR")
     return testmsg
         
-def check_sanity_version_change():
+def check_sanity_version_change(data):
     # Sanity checks to be done when SANITY_VERSION changes
     return ""
 
@@ -262,14 +262,14 @@ def check_sanity(e):
     
     sanity_version = int(data.getVar('SANITY_VERSION', e.data, True) or 1)
     if last_sanity_version < sanity_version: 
-        messages = messages + check_sanity_version_change()
-        messages = messages + check_sanity_tmpdir_change(tmpdir)
-        messages = messages + check_sanity_sstate_dir_change(sstate_dir)
+        messages = messages + check_sanity_version_change(e.data)
+        messages = messages + check_sanity_tmpdir_change(tmpdir, e.data)
+        messages = messages + check_sanity_sstate_dir_change(sstate_dir, e.data)
     else: 
         if last_tmpdir != tmpdir:
-            messages = messages + check_sanity_tmpdir_change(tmpdir)
+            messages = messages + check_sanity_tmpdir_change(tmpdir, e.data)
         if last_sstate_dir != sstate_dir:
-            messages = messages + check_sanity_sstate_dir_change(sstate_dir)
+            messages = messages + check_sanity_sstate_dir_change(sstate_dir, e.data)
 
     if os.path.exists("conf"):
         f = file(sanityverfile, 'w')
Signature · 1 line
1.7.5.4
#5 lore raw
In reply to Joshua Lock
Quoted 12 lines · Joshua Lock

In response to a Yocto Bugzilla request[1] I've written a sanity test to check whether BitBake is able to fecth from http, https and git sources. The idea being that if the user is behing a proxy and this test fails we can more easily help them diagnose and fix their problem.

I've built on the existing infrastructure for less frequent sanity tests so whilst this test is reasonably heavy it will only run when TMPDIR changes (usually first run?). Further I added a variable to disable just this sanity check. People shipping offline installs to customers should just be able to set the variable in their shipped configuration and not worry about this sanity check irritating people.

Quoted 3 lines

The error message points to a wiki page[2] which is pretty vanilla right now but the intention would be to flesh it out with guidance on common proxy/nat/etc issues.

I cunningly forgot the url's I referenced. Friday evening, sorry.

1. http://bugzilla.pokylinux.org/show_bug.cgi?id=933
2. https://wiki.yoctoproject.org/wiki/Connectivity_Troubleshooting

Joshua

Signature · 3 lines
Joshua Lock
        Yocto Build System Monkey
        Intel Open Source Technology Centre
#3 lore raw

Re: [RFC PATCH 2/2] sanity: implement network connectivity test

In reply to Joshua Lock

meta/classes/sanity.bbclass def check_create_long_filename(filepath, pathname): · line 84

Quoted 5 lines
meta/classes/sanity.bbclass +4 -0
+    test_uris= ["http://yoctoproject.org/about",
+                "https://eula-downloads.yoctoproject.org/crownbay/crownbay-bernard-5.0.0",
+                "git://git.yoctoproject.org/yocto-firewall-test;protocol=git;rev=HEAD"]
+    retval = ""

These should probably be set as setable from the meta data. It is a reasonable default, but hard coding it with out a way to change it is probably not what we want.

meta/classes/sanity.bbclass def check_create_long_filename(filepath, pathname): · line 92

Quoted 8 lines
meta/classes/sanity.bbclass +8 -0
+
+    # Only check connectivity if network and this check enabled
+    # Because it's a fairy heavy test allow disabling of just this sanity test
+    # by setting DISABLE_NETWORK_SANITY
+    data = bb.data.createCopy(d)
+    network_disabled = not bb.data.getVar('BB_NO_NETWORK', data, True)
+    check_disabled = bb.data.getVar('DISABLE_NETWORK_SANITY', data, True)
+    if check_disabled or network_disabled:

Completely minor gnit. The copy here isn't needed until you start setting the DL_DIR. Why not wait til after the check to see if we need to do it.

Otherwise seem like a solid idea.

Signature · 2 lines
Jeremy Puhlman
Montavista Sofware, LLC.
#4 lore raw

Re: [RFC PATCH 2/2] sanity: implement network connectivity test

Quoted 8 lines · Jeremy Puhlman

meta/classes/sanity.bbclass def check_create_long_filename(filepath, pathname): · line 84

Quoted 4 lines
meta/classes/sanity.bbclass +4 -0
+    test_uris= ["http://yoctoproject.org/about",
+                "https://eula-downloads.yoctoproject.org/crownbay/crownbay-bernard-5.0.0",
+                "git://git.yoctoproject.org/yocto-firewall-test;protocol=git;rev=HEAD"]
+    retval = ""

These should probably be set as setable from the meta data. It is a reasonable default, but hard coding it with out a way to change it is probably not what we want.

Agreed.

Quoted 10 lines

meta/classes/sanity.bbclass def check_create_long_filename(filepath, pathname): · line 92

Quoted 9 lines
meta/classes/sanity.bbclass +8 -0
+
+    # Only check connectivity if network and this check enabled
+    # Because it's a fairy heavy test allow disabling of just this sanity test
+    # by setting DISABLE_NETWORK_SANITY
+    data = bb.data.createCopy(d)
+    network_disabled = not bb.data.getVar('BB_NO_NETWORK', data, True)
+    check_disabled = bb.data.getVar('DISABLE_NETWORK_SANITY', data, True)
+    if check_disabled or network_disabled:
Quoted 3 lines

Completely minor gnit. The copy here isn't needed until you start setting the DL_DIR. Why not wait til after the check to see if we need to do it.

Good catch!

Quoted 3 lines

Otherwise seem like a solid idea.

Thanks for the review Jeremy, v2 on it's way later today.

Cheers,
Joshua

Signature · 3 lines
Joshua Lock
        Yocto Project Build Monkey
        Intel Open Source Technology Centre