[PATCH 1/1] UBUNTU: SAUCE: replace cut&paste proxy setup code with autotest.client helper function

Paolo Pisati paolo.pisati at canonical.com
Tue Mar 3 11:22:26 UTC 2020


Signed-off-by: Paolo Pisati <paolo.pisati at canonical.com>
---
 ubuntu_futex/ubuntu_futex.py                  | 20 +++---------------
 .../ubuntu_kvm_unit_tests.py                  | 21 ++-----------------
 .../ubuntu_xfstests_btrfs.py                  | 18 ++--------------
 ubuntu_xfstests_ext4/ubuntu_xfstests_ext4.py  | 18 ++--------------
 ubuntu_xfstests_xfs/ubuntu_xfstests_xfs.py    | 18 ++--------------
 .../ubuntu_zfs_xfs_generic.py                 | 18 ++--------------
 xfstests/xfstests.py                          | 18 ++--------------
 7 files changed, 15 insertions(+), 116 deletions(-)

diff --git a/ubuntu_futex/ubuntu_futex.py b/ubuntu_futex/ubuntu_futex.py
index 57202996..dc385334 100644
--- a/ubuntu_futex/ubuntu_futex.py
+++ b/ubuntu_futex/ubuntu_futex.py
@@ -3,6 +3,7 @@
 import os
 import platform
 from autotest.client                        import test, utils
+from autotest.client                        import canonical
 
 class ubuntu_futex(test.test):
     version = 1
@@ -30,23 +31,8 @@ class ubuntu_futex(test.test):
     def setup(self):
         self.install_required_pkgs()
         self.job.require_gcc()
-        # Hacky way to use proxy settings, ideally this should be done on deployment stage
-        #
-        proxysets = [
-                {'addr': 'squid.internal', 'desc': 'Running in the Canonical CI environment'},
-                {'addr': '91.189.89.216',  'desc': 'Running in the Canonical enablement environment'},
-                {'addr': '10.245.64.1',    'desc': 'Running in the Canonical enablement environment'}
-            ]
-        for proxy in proxysets:
-            cmd = 'nc -w 2 ' + proxy['addr'] + ' 3128'
-            try:
-                utils.system_output(cmd, retain_output=False)
-                print proxy['desc']
-                os.environ['http_proxy'] = 'http://' + proxy['addr'] + ':3128'
-                os.environ['https_proxy'] = 'http://' + proxy['addr'] + ':3128'
-                break
-            except:
-                pass
+
+        canonical.setup_proxy()
 
         os.chdir(self.srcdir)
         cmd = 'git clone --depth=1 https://git.kernel.org/pub/scm/linux/kernel/git/dvhart/futextest.git'
diff --git a/ubuntu_kvm_unit_tests/ubuntu_kvm_unit_tests.py b/ubuntu_kvm_unit_tests/ubuntu_kvm_unit_tests.py
index f7e02a24..8d99f671 100644
--- a/ubuntu_kvm_unit_tests/ubuntu_kvm_unit_tests.py
+++ b/ubuntu_kvm_unit_tests/ubuntu_kvm_unit_tests.py
@@ -5,6 +5,7 @@ import re
 import platform
 from autotest.client            import test, utils, os_dep
 from autotest.client.shared     import error
+from autotest.client            import canonical
 
 class ubuntu_kvm_unit_tests(test.test):
     version = 1
@@ -26,25 +27,7 @@ class ubuntu_kvm_unit_tests(test.test):
         pass
 
     def setup(self):
-        # Hacky way to use proxy settings, ideally this should be done on deployment stage
-        #
-        self.install_required_pkgs()
-        self.job.require_gcc()
-        proxysets = [
-                {'addr': 'squid.internal', 'desc': 'Running in the Canonical CI environment'},
-                {'addr': '91.189.89.216',  'desc': 'Running in the Canonical enablement environment'},
-                {'addr': '10.245.64.1',    'desc': 'Running in the Canonical enablement environment'}
-            ]
-        for proxy in proxysets:
-            cmd = 'nc -w 2 ' + proxy['addr'] + ' 3128'
-            try:
-                utils.system_output(cmd, retain_output=False)
-                print proxy['desc']
-                os.environ['http_proxy'] = 'http://' + proxy['addr'] + ':3128'
-                os.environ['https_proxy'] = 'http://' + proxy['addr'] + ':3128'
-                break
-            except:
-                pass
+        canonical.setup_proxy()
 
         arch = platform.processor()
         opt = []
diff --git a/ubuntu_xfstests_btrfs/ubuntu_xfstests_btrfs.py b/ubuntu_xfstests_btrfs/ubuntu_xfstests_btrfs.py
index ca72ddb3..2d3f99e2 100644
--- a/ubuntu_xfstests_btrfs/ubuntu_xfstests_btrfs.py
+++ b/ubuntu_xfstests_btrfs/ubuntu_xfstests_btrfs.py
@@ -3,6 +3,7 @@ import os, re, glob, logging
 import platform
 from autotest.client.shared import error
 from autotest.client import test, utils, os_dep
+from autotest.client import canonical
 
 class ubuntu_xfstests_btrfs(test.test):
 
@@ -163,22 +164,7 @@ class ubuntu_xfstests_btrfs(test.test):
 
         self.job.require_gcc()
 
-        # Hacky way to use proxy settings, ideally this should be done on deployment stage
-        #
-        print "Setup the http/https proxy"
-        proxysets = [{'addr': 'squid.internal', 'desc': 'Running in the Canonical CI environment'},
-                  {'addr': '91.189.89.216', 'desc': 'Running in the Canonical enablement environment'},
-                  {'addr': '10.245.64.1', 'desc': 'Running in the Canonical enablement environment'}]
-        for proxy in proxysets:
-            cmd = 'nc -w 2 ' + proxy['addr'] + ' 3128'
-            try:
-                utils.system_output(cmd, retain_output=False)
-                print proxy['desc']
-                os.environ['http_proxy'] = 'http://' + proxy['addr'] + ':3128'
-                os.environ['https_proxy'] = 'http://' + proxy['addr'] + ':3128'
-                break
-            except:
-                pass
+        canonical.setup_proxy()
 
         print "Fetching xfstests.."
         os.chdir(self.srcdir)
diff --git a/ubuntu_xfstests_ext4/ubuntu_xfstests_ext4.py b/ubuntu_xfstests_ext4/ubuntu_xfstests_ext4.py
index a8965604..92b79b7d 100644
--- a/ubuntu_xfstests_ext4/ubuntu_xfstests_ext4.py
+++ b/ubuntu_xfstests_ext4/ubuntu_xfstests_ext4.py
@@ -3,6 +3,7 @@ import os, re, glob, logging
 import platform
 from autotest.client.shared import error
 from autotest.client import test, utils, os_dep
+from autotest.client import canonical
 
 class ubuntu_xfstests_ext4(test.test):
 
@@ -165,22 +166,7 @@ class ubuntu_xfstests_ext4(test.test):
 
         self.job.require_gcc()
 
-        # Hacky way to use proxy settings, ideally this should be done on deployment stage
-        #
-        print "Setup the http/https proxy"
-        proxysets = [{'addr': 'squid.internal', 'desc': 'Running in the Canonical CI environment'},
-                  {'addr': '91.189.89.216', 'desc': 'Running in the Canonical enablement environment'},
-                  {'addr': '10.245.64.1', 'desc': 'Running in the Canonical enablement environment'}]
-        for proxy in proxysets:
-            cmd = 'nc -w 2 ' + proxy['addr'] + ' 3128'
-            try:
-                utils.system_output(cmd, retain_output=False)
-                print proxy['desc']
-                os.environ['http_proxy'] = 'http://' + proxy['addr'] + ':3128'
-                os.environ['https_proxy'] = 'http://' + proxy['addr'] + ':3128'
-                break
-            except:
-                pass
+        canonical.setup_proxy()
 
         print "Fetching xfstests.."
         os.chdir(self.srcdir)
diff --git a/ubuntu_xfstests_xfs/ubuntu_xfstests_xfs.py b/ubuntu_xfstests_xfs/ubuntu_xfstests_xfs.py
index 7344d450..c5ca83fb 100644
--- a/ubuntu_xfstests_xfs/ubuntu_xfstests_xfs.py
+++ b/ubuntu_xfstests_xfs/ubuntu_xfstests_xfs.py
@@ -3,6 +3,7 @@ import os, re, glob, logging
 import platform
 from autotest.client.shared import error
 from autotest.client import test, utils, os_dep
+from autotest.client import canonical
 
 class ubuntu_xfstests_xfs(test.test):
 
@@ -163,22 +164,7 @@ class ubuntu_xfstests_xfs(test.test):
 
         self.job.require_gcc()
 
-        # Hacky way to use proxy settings, ideally this should be done on deployment stage
-        #
-        print "Setup the http/https proxy"
-        proxysets = [{'addr': 'squid.internal', 'desc': 'Running in the Canonical CI environment'},
-                  {'addr': '91.189.89.216', 'desc': 'Running in the Canonical enablement environment'},
-                  {'addr': '10.245.64.1', 'desc': 'Running in the Canonical enablement environment'}]
-        for proxy in proxysets:
-            cmd = 'nc -w 2 ' + proxy['addr'] + ' 3128'
-            try:
-                utils.system_output(cmd, retain_output=False)
-                print proxy['desc']
-                os.environ['http_proxy'] = 'http://' + proxy['addr'] + ':3128'
-                os.environ['https_proxy'] = 'http://' + proxy['addr'] + ':3128'
-                break
-            except:
-                pass
+        canonical.setup_proxy()
 
         print "Fetching xfstests.."
         os.chdir(self.srcdir)
diff --git a/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py b/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py
index a99c7678..f7c6c18b 100644
--- a/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py
+++ b/ubuntu_zfs_xfs_generic/ubuntu_zfs_xfs_generic.py
@@ -4,6 +4,7 @@ import os
 import platform
 from autotest.client                        import test, utils
 import platform
+from autotest.client                        import canonical
 
 class ubuntu_zfs_xfs_generic(test.test):
     version = 5
@@ -68,22 +69,7 @@ class ubuntu_zfs_xfs_generic(test.test):
         utils.system_output('useradd fsgqa || true', retain_output=True)
         utils.system_output('grep -q fsgqa /etc/sudoers || echo \"fsgqa    ALL=(ALL)NOPASSWD: ALL\" >> /etc/sudoers', retain_output=True)
 
-        # Hacky way to use proxy settings, ideally this should be done on deployment stage
-        #
-        print "Setup the http/https proxy"
-        proxysets = [{'addr': 'squid.internal', 'desc': 'Running in the Canonical CI environment'},
-                  {'addr': '91.189.89.216', 'desc': 'Running in the Canonical enablement environment'},
-                  {'addr': '10.245.64.1', 'desc': 'Running in the Canonical enablement environment'}]
-        for proxy in proxysets:
-            cmd = 'nc -w 2 ' + proxy['addr'] + ' 3128'
-            try:
-                utils.system_output(cmd, retain_output=False)
-                print proxy['desc']
-                os.environ['http_proxy'] = 'http://' + proxy['addr'] + ':3128'
-                os.environ['https_proxy'] = 'http://' + proxy['addr'] + ':3128'
-                break
-            except:
-                pass
+        canonical.setup_proxy()
 
         print "Fetching xfstests.."
         os.chdir(self.srcdir)
diff --git a/xfstests/xfstests.py b/xfstests/xfstests.py
index 4a786103..91845d5e 100644
--- a/xfstests/xfstests.py
+++ b/xfstests/xfstests.py
@@ -3,6 +3,7 @@ import os, re, glob, logging
 import platform
 from autotest.client.shared import error
 from autotest.client import test, utils, os_dep
+from autotest.client import canonical
 
 class xfstests(test.test):
 
@@ -159,22 +160,7 @@ class xfstests(test.test):
 
         self.job.require_gcc()
 
-        # Hacky way to use proxy settings, ideally this should be done on deployment stage
-        #
-        print "Setup the http/https proxy"
-        proxysets = [{'addr': 'squid.internal', 'desc': 'Running in the Canonical CI environment'},
-                  {'addr': '91.189.89.216', 'desc': 'Running in the Canonical enablement environment'},
-                  {'addr': '10.245.64.1', 'desc': 'Running in the Canonical enablement environment'}]
-        for proxy in proxysets:
-            cmd = 'nc -w 2 ' + proxy['addr'] + ' 3128'
-            try:
-                utils.system_output(cmd, retain_output=False)
-                print proxy['desc']
-                os.environ['http_proxy'] = 'http://' + proxy['addr'] + ':3128'
-                os.environ['https_proxy'] = 'http://' + proxy['addr'] + ':3128'
-                break
-            except:
-                pass
+        canonical.setup_proxy()
 
         print "Fetching xfstests.."
         os.chdir(self.srcdir)
-- 
2.25.1




More information about the kernel-team mailing list