Skip to content

Instantly share code, notes, and snippets.

@shvchk

shvchk/!README.md

Last active Nov 26, 2020
Embed
What would you like to do?
Patch to fix incorrect results of mirrors performance testing utility (python3-software-properties).

Patch to fix incorrect results of mirrors performance testing utility (python3-software-properties).

  • Install mirrors test utility:
    sudo apt install python3-software-properties --no-install-recommends

  • Download and apply patch:
    wget -qO- https://gist.githubusercontent.com/shvchk/b81e4579bff13486871f99404c497759/raw/MirrorTest.py.patch | sudo patch -d/ -p0

  • Use it:
    LC_ALL=C python3 /usr/lib/python3/dist-packages/softwareproperties/MirrorTest.py

Sample output:

> LC_ALL=C python3 /usr/lib/python3/dist-packages/softwareproperties/MirrorTest.py
Running ping tests
Running download tests
Testing mirror.wff-gaming.de
Testing ubuntu.melbourneitmirror.net
Testing linux.xjtuns.cn
Testing mirrors.avalonhosting.services
Testing mirrors.codec-cluster.org
Testing ftp.utexas.edu
Testing mirror.plustech.de
Testing mirror.ratiokontakt.de
Testing mirror2.tuxinator.org
Testing mirror.kumi.systems
Testing ubuntu.cybertips.info
Testing files.tux-users.net
Testing linux.darkpenguin.net
Testing mirrors.aliyun.com
Testing mirror.eu-fr.kamatera.com
Testing ny-mirrors.evowise.com
Testing la-mirrors.evowise.com
Testing mirror.de.leaseweb.net
Testing es-mirrors.evowise.com
Testing uk-mirrors.evowise.com
Testing mirrors.ukfast.co.uk
Testing mirrors.advancedhosters.com
mirror: uk-mirrors.evowise.com - time: 0.48804259300231934
mirror: es-mirrors.evowise.com - time: 0.5114705562591553
mirror: mirror.eu-fr.kamatera.com - time: 0.5532209873199463
mirror: ny-mirrors.evowise.com - time: 0.567798376083374
mirror: linux.darkpenguin.net - time: 0.6391427516937256
mirror: mirror.de.leaseweb.net - time: 0.7773537635803223
mirror: files.tux-users.net - time: 0.957298755645752
mirror: mirror2.tuxinator.org - time: 0.9695150852203369
mirror: la-mirrors.evowise.com - time: 1.1493926048278809
mirror: ubuntu.cybertips.info - time: 1.1670680046081543
mirror: mirrors.aliyun.com - time: 1.2511329650878906
mirror: mirror.ratiokontakt.de - time: 1.2832701206207275
mirror: mirrors.advancedhosters.com - time: 1.8812928199768066
mirror: mirrors.ukfast.co.uk - time: 2.537770986557007
mirror: mirror.plustech.de - time: 11.090754270553589
and the winner is: uk-mirrors.evowise.com
--- /usr/lib/python3/dist-packages/softwareproperties/MirrorTest.py 2020-11-26 19:06:50.529009943 +0000
+++ MirrorTest.py 2020-11-26 19:05:35.413352862 +0000
@@ -97,12 +97,14 @@
def run_full_test(self):
# Determinate the 5 top ping servers
- results_ping = self.run_ping_test(max=5, borders=(0, 0.5), mod=(0,7))
+ print("Running ping tests")
+ results_ping = self.run_ping_test(max=20, borders=(0, 0.5), mod=(0,7))
# Add two random mirrors to the download test
size = len(self.mirrors)
if size > 2:
results_ping.append([0, 0, self.mirrors[random.randint(1, size-1)]])
results_ping.append([0, 0, self.mirrors[random.randint(1, size-1)]])
+ print("Running download tests")
results = self.run_download_test([r[2] for r in results_ping],
borders=(0.5, 1),
mod=(MirrorTest.todo,
@@ -149,9 +151,10 @@
url = "%s/%s" % (mirror.get_repo_urls()[0],
self.test_file)
self.report_action("Downloading %s..." % url)
+ print("Testing %s" % mirror.hostname)
start = time.time()
try:
- urlopen(url, timeout=2).read(102400)
+ urlopen(url, timeout=2).read(30*1024**2)
return time.time() - start
except:
return 0
@@ -181,9 +184,8 @@
arch = pipe.read().strip()
running = threading.Event()
running.set()
- test_file = "dists/%s/%s/binary-%s/Packages.gz" % \
+ test_file = "dists/%s/Contents-%s.gz" % \
(distro.source_template.name,
- distro.source_template.components[0].name,
arch)
app = MirrorTest(list(distro.source_template.mirror_set.values()),
test_file, threading.Event(), running)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment