2022-02-22 15:19:20 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
""" Vpp HTTP tests """
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import http.client
|
2023-08-31 00:47:44 -04:00
|
|
|
from asfframework import VppAsfTestCase, VppTestRunner
|
2022-02-22 15:19:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
@unittest.skip("Requires root")
|
2023-08-31 00:47:44 -04:00
|
|
|
class TestHttpTps(VppAsfTestCase):
|
2022-04-26 19:02:15 +02:00
|
|
|
"""HTTP test class"""
|
2022-02-22 15:19:20 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
super(TestHttpTps, cls).setUpClass()
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
super(TestHttpTps, cls).tearDownClass()
|
|
|
|
|
|
|
|
def setUp(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
self.client_ip4 = "172.0.0.2"
|
|
|
|
self.server_ip4 = "172.0.0.1"
|
|
|
|
self.vapi.cli(f"create tap id 0 host-ip4-addr {self.client_ip4}/24")
|
|
|
|
self.vapi.cli(f"set int ip addr tap0 {self.server_ip4}/24")
|
|
|
|
self.vapi.cli("set int state tap0 up")
|
2022-02-22 15:19:20 +00:00
|
|
|
self.vapi.session_enable_disable(is_enable=1)
|
|
|
|
|
|
|
|
def test_http_tps(self):
|
2022-04-26 19:02:15 +02:00
|
|
|
fname = "test_file_1M"
|
|
|
|
self.vapi.cli("http tps uri tcp://0.0.0.0/8080")
|
2022-02-22 15:19:20 +00:00
|
|
|
con = http.client.HTTPConnection(f"{self.server_ip4}", 8080)
|
2022-04-26 19:02:15 +02:00
|
|
|
con.request("GET", f"/{fname}")
|
2022-02-22 15:19:20 +00:00
|
|
|
r = con.getresponse()
|
|
|
|
self.assertEqual(len(r.read()), 1 << 20)
|
|
|
|
|
|
|
|
|
2022-04-26 19:02:15 +02:00
|
|
|
if __name__ == "__main__":
|
2022-02-22 15:19:20 +00:00
|
|
|
unittest.main(testRunner=VppTestRunner)
|