Merge ~jslarraz/qa-regression-testing:add_test_iperf3 into qa-regression-testing:master

Proposed by Jorge Sancho Larraz
Status: Merged
Merged at revision: 42d9f05032637862fc4d825fb6c07006665ef9ca
Proposed branch: ~jslarraz/qa-regression-testing:add_test_iperf3
Merge into: qa-regression-testing:master
Diff against target: 133 lines (+111/-0)
2 files modified
.launchpad.yaml (+14/-0)
scripts/test-iperf3.py (+97/-0)
Reviewer Review Type Date Requested Status
Steve Beattie Approve
Alex Murray Approve
Review via email: mp+453895@code.launchpad.net

Commit message

Add test-iperf3.py

Description of the change

Create new tests for iperf3 package

To post a comment you must log in.
Revision history for this message
Alex Murray (alexmurray) wrote :

LGTM but it would be good to add this to .launchpad.yaml so that it gets run by lpci automatically as well against each of the stable releases.

review: Approve
Revision history for this message
Steve Beattie (sbeattie) wrote :

This is great, thanks fo rgetting the infrastrucutre in place to make this test workable and preparing these test. It's fine to merge as is, but a couple of minor comments inline.

And adding it to the .launchpad.yaml would be appreciated, peek at the history for the file for examples, and https://git.launchpad.net/qa-regression-testing/tree/scripts/README.md#n144 also covers a bit of documentation as well as how to handle cases that can't be run in lpci. (That said, please help clarify the documentation.)

THanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/.launchpad.yaml b/.launchpad.yaml
index 7b32321..bd3e3a3 100644
--- a/.launchpad.yaml
+++ b/.launchpad.yaml
@@ -10,6 +10,7 @@ pipeline:
10 - busybox10 - busybox
11 - coreutils11 - coreutils
12 - util-linux12 - util-linux
13 - iperf3
1314
14jobs:15jobs:
15 imagemagick:16 imagemagick:
@@ -141,3 +142,16 @@ jobs:
141 - sudo142 - sudo
142 run: |143 run: |
143 ./lpcraft-runner util-linux144 ./lpcraft-runner util-linux
145
146 iperf3:
147 matrix:
148 - series: jammy
149 architectures: amd64
150 - series: focal
151 architectures: amd64
152 - series: bionic
153 architectures: amd64
154 packages:
155 - sudo
156 run: |
157 ./lpcraft-runner iperf3
diff --git a/scripts/test-iperf3.py b/scripts/test-iperf3.py
144new file mode 100755158new file mode 100755
index 0000000..a70c169
--- /dev/null
+++ b/scripts/test-iperf3.py
@@ -0,0 +1,97 @@
1#!/usr/bin/python3
2#
3# test-iperf3.py quality assurance test script for iperf3
4# Copyright (C) 2008-2023 Canonical Ltd.
5# Author: Jorge Sancho <jorge.sancho.larraz@canonical.com>
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 3,
9# as published by the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19# QRT-Packages: iperf3
20# QRT-Privilege: none
21# QRT-Conflicts: none
22
23'''
24 In general, this test should be run in a virtual machine (VM) or possibly
25 a chroot and not on a production machine. While efforts are made to make
26 these tests non-destructive, there is no guarantee this script will not
27 alter the machine. You have been warned.
28
29 How to run in a clean VM:
30 $ sudo apt-get -y install <QRT-Packages> && sudo ./test-iperf3.py -v'
31'''
32
33import unittest
34import time
35import subprocess
36import socket
37import testlib
38
39class iperfTest(testlib.TestlibCase):
40 '''Test iperf.'''
41
42 def setUp(self):
43 '''Set up prior to each test_* function'''
44 self.server = subprocess.Popen(["iperf3", "-s"])
45 time.sleep(1)
46
47 def tearDown(self):
48 '''Clean up after each test_* function'''
49 self.server.terminate()
50 self.server.wait()
51
52 def test_client(self):
53 # Check server can handle several consecutive requests
54 for i in range(5):
55 self.assertShellExitSuccess(["iperf3", "-c", "localhost"], timeout=90,
56 msg="The client process returned something other than 0. It may indicate "
57 "that something is not working properly..")
58
59 def test_CVE_2023_38403(self):
60 '''Test CVE-2023-38403'''
61
62 # Run PoC
63 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
64 sock.connect(("localhost", 5201))
65 sock.sendall(bytearray.fromhex('41'*37+'ff'*4+'41'*50))
66 sock.close()
67 time.sleep(1)
68
69 # Check server is alive
70 self.assertEqual(self.server.poll(), None, "Server is not running anymore. This behaviour is typically "
71 " observed after exploting CVE-2023-38403")
72
73 # Check client returned sucessfully
74 self.assertShellExitSuccess(["iperf3", "-c", "localhost"], timeout=90,
75 msg="The client process returned something other than 0. It may indicate "
76 "that something is not working properly..")
77
78 def test_LP_2038654(self):
79 '''Test LP-2038654'''
80
81 # Run PoC
82 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
83 sock.connect(("localhost", 5201))
84 sock.sendall(bytearray.fromhex('41'))
85 # We need to keep the connection alive, so that we don't want to call sock.close() yet
86 # sock.close()
87
88 # Wait for timeout to happen (timeout included in the patch)
89 time.sleep(11)
90
91 # Check client returned sucessfully
92 self.assertShellExitSuccess(["iperf3", "-c", "localhost"], timeout=90,
93 msg="The client process returned something other than 0. It may indicate "
94 "that something is not working properly..")
95
96if __name__ == '__main__':
97 unittest.main()
0\ No newline at end of file98\ No newline at end of file

Subscribers

People subscribed via source and target branches