Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] sanity.class: Add possibility to configure networking check
@ 2022-02-11  8:44 Pavel Zhukov
  2022-02-11 11:18 ` [OE-core] " Ross Burton
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Zhukov @ 2022-02-11  8:44 UTC (permalink / raw)
  To: openembedded-core; +Cc: pavel, Pavel Zhukov

Previously sanity checker required all uri listed in
CONNECTIVITY_CHECK_URIS to be available for networking check. It caused
selftests failures due to temprorary example.com unavailability.
Add CONNECTIVITY_CHECK_ALL variable to change this behaviour and check
for any host from the list to be available it allows to specify
"failover" uri and/or speed checker up if few uris have been specified.

Default value is set to "1" for backward compatibility.

Signed-off-by: Pavel Zhukov <pavel.zhukov@huawei.com>
---
 meta/classes/sanity.bbclass                   | 44 ++++++++++++-------
 .../distro/include/default-distrovars.inc     |  5 ++-
 2 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/meta/classes/sanity.bbclass b/meta/classes/sanity.bbclass
index f288b4c84c..695776bba3 100644
--- a/meta/classes/sanity.bbclass
+++ b/meta/classes/sanity.bbclass
@@ -326,6 +326,7 @@ def check_connectivity(d):
     # using the same syntax as for SRC_URI. If the variable is not set
     # the check is skipped
     test_uris = (d.getVar('CONNECTIVITY_CHECK_URIS') or "").split()
+    check_all = (d.getVar('CONNECTIVITY_CHECK_ALL') or "1") == "1"
     retval = ""
 
     bbn = d.getVar('BB_NO_NETWORK')
@@ -341,22 +342,33 @@ def check_connectivity(d):
         data = bb.data.createCopy(d)
         data.delVar('PREMIRRORS')
         data.delVar('MIRRORS')
-        try:
-            fetcher = bb.fetch2.Fetch(test_uris, data)
-            fetcher.checkstatus()
-        except Exception as err:
-            # Allow the message to be configured so that users can be
-            # pointed to a support mechanism.
-            msg = data.getVar('CONNECTIVITY_CHECK_MSG') or ""
-            if len(msg) == 0:
-                msg = "%s.\n" % err
-                msg += "    Please ensure your host's network is configured correctly.\n"
-                msg += "    If your ISP or network is blocking the above URL,\n"
-                msg += "    try with another domain name, for example by setting:\n"
-                msg += "    CONNECTIVITY_CHECK_URIS = \"https://www.yoctoproject.org/\""
-                msg += "    You could also set BB_NO_NETWORK = \"1\" to disable network\n"
-                msg += "    access if all required sources are on local disk.\n"
-            retval = msg
+        err = None
+        for uri in test_uris:
+            try:
+                if check_all:
+                    fetcher = bb.fetch2.Fetch(test_uris, data)
+                else:
+                    fetcher = bb.fetch2.Fetch([uri], data)
+                fetcher.checkstatus()
+                return retval
+            except Exception as e:
+                err = "{} \n {}".format(err, e)
+                if check_all:
+                    break
+
+
+        # Allow the message to be configured so that users can be
+        # pointed to a support mechanism.
+        msg = data.getVar('CONNECTIVITY_CHECK_MSG') or ""
+        if len(msg) == 0:
+            msg = "%s.\n" % err
+            msg += "    Please ensure your host's network is configured correctly.\n"
+            msg += "    If your ISP or network is blocking the above URL,\n"
+            msg += "    try with another domain name, for example by setting:\n"
+            msg += "    CONNECTIVITY_CHECK_URIS = \"https://www.yoctoproject.org/\""
+            msg += "    You could also set BB_NO_NETWORK = \"1\" to disable network\n"
+            msg += "    access if all required sources are on local disk.\n"
+        retval = msg
 
     return retval
 
diff --git a/meta/conf/distro/include/default-distrovars.inc b/meta/conf/distro/include/default-distrovars.inc
index fb0f1097da..867d694146 100644
--- a/meta/conf/distro/include/default-distrovars.inc
+++ b/meta/conf/distro/include/default-distrovars.inc
@@ -54,4 +54,7 @@ KERNEL_IMAGETYPES ??= "${KERNEL_IMAGETYPE}"
 # fetch from the network (and warn you if not). To disable the test set
 # the variable to be empty.
 # Git example url: git://git.yoctoproject.org/yocto-firewall-test;protocol=git;rev=master;branch=master
-CONNECTIVITY_CHECK_URIS ?= "https://www.example.com/"
+CONNECTIVITY_CHECK_URIS ?= "https://www.example.com/ https://www.yoctoproject.org"
+# Define is all CONNECTIVITY_CHECK_URIS are required to be available or it's enough to have some
+# of them reachable for networking check
+CONNECTIVITY_CHECK_ALL ?= "0"
-- 
2.34.1



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

end of thread, other threads:[~2022-02-11 13:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-11  8:44 [PATCH] sanity.class: Add possibility to configure networking check Pavel Zhukov
2022-02-11 11:18 ` [OE-core] " Ross Burton
2022-02-11 11:23   ` Jacob Kroon
2022-02-11 11:39     ` Ross Burton
2022-02-11 12:08       ` Jacob Kroon
2022-02-11 13:13         ` Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox