#!/usr/bin/env python3
""" Vpp VCL tests """

import unittest
import os
import subprocess
import signal
import glob
from config import config
from asfframework import VppAsfTestCase, VppTestRunner, Worker, tag_fixme_ubuntu2404
from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath

iperf3 = "/usr/bin/iperf3"


def have_app(app):
    try:
        subprocess.check_output([app, "-v"])
    except (subprocess.CalledProcessError, OSError):
        return False
    return True


_have_iperf3 = have_app(iperf3)


class VCLAppWorker(Worker):
    """VCL Test Application Worker"""

    libname = "libvcl_ldpreload.so"

    class LibraryNotFound(Exception):
        pass

    def __init__(
        self, appname, executable_args, logger, env=None, role=None, *args, **kwargs
    ):
        self.role = role
        vcl_ldpreload_glob = f"{config.vpp_install_dir}/**/{self.libname}"
        vcl_ldpreload_so = glob.glob(vcl_ldpreload_glob, recursive=True)

        if len(vcl_ldpreload_so) < 1:
            raise LibraryNotFound("cannot locate library: {}".format(self.libname))

        vcl_ldpreload_so = vcl_ldpreload_so[0]

        if env is None:
            env = {}
        if "iperf" in appname:
            app = appname
            env.update({"LD_PRELOAD": vcl_ldpreload_so})
        elif "sock" in appname:
            app = f"{config.vpp_build_dir}/vpp/bin/{appname}"
            env.update({"LD_PRELOAD": vcl_ldpreload_so})
        else:
            app = f"{config.vpp_build_dir}/vpp/bin/{appname}"
        self.args = [app] + executable_args
        super(VCLAppWorker, self).__init__(self.args, logger, env, *args, **kwargs)


class VCLTestCase(VppAsfTestCase):
    """VCL Test Class"""

    session_startup = ["poll-main"]

    @classmethod
    def setUpClass(cls):
        if cls.session_startup:
            conf = "session {" + " ".join(cls.session_startup) + "}"
            cls.extra_vpp_config = [conf]
        super(VCLTestCase, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(VCLTestCase, cls).tearDownClass()

    def setUp(self):
        self.vppDebug = "vpp_debug" in config.vpp_install_dir
        self.server_addr = "127.0.0.1"
        self.server_port = "22000"
        self.server_args = [self.server_port]
        self.server_ipv6_addr = "::1"
        self.server_ipv6_args = ["-6", self.server_port]
        self.timeout = 20
        self.echo_phrase = "Hello, world! Jenny is a friend of mine."
        self.pre_test_sleep = 0.3
        self.post_test_sleep = 1
        self.sapi_client_sock = ""
        self.sapi_server_sock = ""

        if os.path.isfile("/tmp/ldp_server_af_unix_socket"):
            os.remove("/tmp/ldp_server_af_unix_socket")

        super(VCLTestCase, self).setUp()

    def update_vcl_app_env(self, ns_id, ns_secret, attach_sock):
        if not ns_id:
            if "VCL_APP_NAMESPACE_ID" in self.vcl_app_env:
                del self.vcl_app_env["VCL_APP_NAMESPACE_ID"]
        else:
            self.vcl_app_env["VCL_APP_NAMESPACE_ID"] = ns_id

        if not ns_secret:
            if "VCL_APP_NAMESPACE_SECRET" in self.vcl_app_env:
                del self.vcl_app_env["VCL_APP_NAMESPACE_SECRET"]
        else:
            self.vcl_app_env["VCL_APP_NAMESPACE_SECRET"] = ns_secret

        if not attach_sock:
            self.vcl_app_env["VCL_VPP_API_SOCKET"] = self.get_api_sock_path()
            if "VCL_VPP_SAPI_SOCKET" in self.vcl_app_env:
                del self.vcl_app_env["VCL_VPP_SAPI_SOCKET"]
        else:
            sapi_sock = "%s/app_ns_sockets/%s" % (self.tempdir, attach_sock)
            self.vcl_app_env["VCL_VPP_SAPI_SOCKET"] = sapi_sock
            if "VCL_VPP_API_SOCKET" in self.vcl_app_env:
                del self.vcl_app_env["VCL_VPP_API_SOCKET"]

    def cut_thru_setup(self):
        self.vapi.session_enable_disable(is_enable=1)

    def cut_thru_tear_down(self):
        self.vapi.session_enable_disable(is_enable=0)

    def cut_thru_test(self, server_app, server_args, client_app, client_args):
        self.vcl_app_env = {"VCL_APP_SCOPE_LOCAL": "true"}

        self.update_vcl_app_env("", "", self.sapi_server_sock)
        worker_server = VCLAppWorker(
            server_app, server_args, self.logger, self.vcl_app_env, "server"
        )
        worker_server.start()
        self.sleep(self.pre_test_sleep)

        self.update_vcl_app_env("", "", self.sapi_client_sock)
        worker_client = VCLAppWorker(
            client_app, client_args, self.logger, self.vcl_app_env, "client"
        )
        worker_client.start()
        worker_client.join(self.timeout)
        try:
            self.validateResults(worker_client, worker_server, self.timeout)
        except Exception as error:
            self.fail("Failed with %s" % error)
        self.sleep(self.post_test_sleep)

    def thru_host_stack_setup(self):
        self.vapi.session_enable_disable(is_enable=1)
        self.create_loopback_interfaces(2)

        table_id = 1

        for i in self.lo_interfaces:
            i.admin_up()

            if table_id != 0:
                tbl = VppIpTable(self, table_id)
                tbl.add_vpp_config()

            i.set_table_ip4(table_id)
            i.config_ip4()
            table_id += 1

        # Configure namespaces
        self.vapi.app_namespace_add_del_v4(
            namespace_id="1", secret=1234, sw_if_index=self.loop0.sw_if_index
        )
        self.vapi.app_namespace_add_del_v4(
            namespace_id="2", secret=5678, sw_if_index=self.loop1.sw_if_index
        )

        # Add inter-table routes
        ip_t01 = VppIpRoute(
            self,
            self.loop1.local_ip4,
            32,
            [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=2)],
            table_id=1,
        )
        ip_t10 = VppIpRoute(
            self,
            self.loop0.local_ip4,
            32,
            [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=1)],
            table_id=2,
        )
        ip_t01.add_vpp_config()
        ip_t10.add_vpp_config()
        self.logger.debug(self.vapi.cli("show ip fib"))

    def thru_host_stack_tear_down(self):
        self.vapi.app_namespace_add_del_v4(
            is_add=0, namespace_id="1", secret=1234, sw_if_index=self.loop0.sw_if_index
        )
        self.vapi.app_namespace_add_del_v4(
            is_add=0, namespace_id="2", secret=5678, sw_if_index=self.loop1.sw_if_index
        )
        for i in self.lo_interfaces:
            i.unconfig_ip4()
            i.set_table_ip4(0)
            i.admin_down()
            i.remove_vpp_config()

    def thru_host_stack_ipv6_setup(self):
        self.vapi.session_enable_disable(is_enable=1)
        self.create_loopback_interfaces(2)

        table_id = 1

        for i in self.lo_interfaces:
            i.admin_up()

            tbl = VppIpTable(self, table_id, is_ip6=1)
            tbl.add_vpp_config()

            i.set_table_ip6(table_id)
            i.config_ip6()
            table_id += 1

        # Configure namespaces
        self.vapi.app_namespace_add_del_v4(
            namespace_id="1", secret=1234, sw_if_index=self.loop0.sw_if_index
        )
        self.vapi.app_namespace_add_del_v4(
            namespace_id="2", secret=5678, sw_if_index=self.loop1.sw_if_index
        )

        # Add inter-table routes
        ip_t01 = VppIpRoute(
            self,
            self.loop1.local_ip6,
            128,
            [VppRoutePath("::0", 0xFFFFFFFF, nh_table_id=2)],
            table_id=1,
        )
        ip_t10 = VppIpRoute(
            self,
            self.loop0.local_ip6,
            128,
            [VppRoutePath("::0", 0xFFFFFFFF, nh_table_id=1)],
            table_id=2,
        )
        ip_t01.add_vpp_config()
        ip_t10.add_vpp_config()
        self.logger.debug(self.vapi.cli("show interface addr"))
        self.logger.debug(self.vapi.cli("show ip6 fib"))

    def thru_host_stack_ipv6_tear_down(self):
        self.vapi.app_namespace_add_del_v4(
            is_add=0, namespace_id="1", secret=1234, sw_if_index=self.loop0.sw_if_index
        )
        self.vapi.app_namespace_add_del_v4(
            is_add=0, namespace_id="2", secret=5678, sw_if_index=self.loop1.sw_if_index
        )
        for i in self.lo_interfaces:
            i.unconfig_ip6()
            i.set_table_ip6(0)
            i.admin_down()

        self.vapi.session_enable_disable(is_enable=0)

    @unittest.skipUnless(_have_iperf3, "'%s' not found, Skipping.")
    def thru_host_stack_test(self, server_app, server_args, client_app, client_args):
        self.vcl_app_env = {"VCL_APP_SCOPE_GLOBAL": "true"}

        self.update_vcl_app_env("1", "1234", self.sapi_server_sock)
        worker_server = VCLAppWorker(
            server_app, server_args, self.logger, self.vcl_app_env, "server"
        )
        worker_server.start()
        self.sleep(self.pre_test_sleep)

        self.update_vcl_app_env("2", "5678", self.sapi_client_sock)
        worker_client = VCLAppWorker(
            client_app, client_args, self.logger, self.vcl_app_env, "client"
        )
        worker_client.start()
        worker_client.join(self.timeout)

        try:
            self.validateResults(worker_client, worker_server, self.timeout)
        except Exception as error:
            self.fail("Failed with %s" % error)
        self.sleep(self.post_test_sleep)

    def validateResults(self, worker_client, worker_server, timeout):
        if worker_server.process is None:
            raise RuntimeError("worker_server is not running.")
        if os.path.isdir("/proc/{}".format(worker_server.process.pid)):
            self.logger.info(
                "Killing server worker process (pid %d)" % worker_server.process.pid
            )
            os.killpg(os.getpgid(worker_server.process.pid), signal.SIGTERM)
            worker_server.join()
        self.logger.info("Client worker result is `%s'" % worker_client.result)
        error = False
        if worker_client.result is None:
            try:
                error = True
                self.logger.error(
                    "Timeout: %ss! Killing client worker process (pid %d)"
                    % (timeout, worker_client.process.pid)
                )
                os.killpg(os.getpgid(worker_client.process.pid), signal.SIGKILL)
                worker_client.join()
            except OSError:
                self.logger.debug("Couldn't kill client worker process")
                raise
        if error:
            raise RuntimeError("Timeout! Client worker did not finish in %ss" % timeout)
        self.assert_equal(worker_client.result, 0, "Binary test return code")


@tag_fixme_ubuntu2404
class LDPCutThruTestCase(VCLTestCase):
    """LDP Cut Thru Tests"""

    @classmethod
    def setUpClass(cls):
        cls.session_startup = ["poll-main", "use-app-socket-api"]
        super(LDPCutThruTestCase, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(LDPCutThruTestCase, cls).tearDownClass()

    def setUp(self):
        super(LDPCutThruTestCase, self).setUp()

        self.cut_thru_setup()
        self.client_echo_test_args = [
            "-E",
            self.echo_phrase,
            "-X",
            self.server_addr,
            self.server_port,
        ]
        self.client_iperf3_timeout = 20
        self.client_iperf3_args = ["-4", "-t 2", "-c", self.server_addr]
        self.server_iperf3_args = ["-4", "-s"]
        self.client_uni_dir_nsock_timeout = 20
        self.client_uni_dir_nsock_test_args = [
            "-N",
            "1000",
            "-U",
            "-X",
            "-I",
            "2",
            self.server_addr,
            self.server_port,
        ]
        self.client_bi_dir_nsock_timeout = 20
        self.client_bi_dir_nsock_test_args = [
            "-N",
            "1000",
            "-B",
            "-X",
            "-I",
            "2",
            self.server_addr,
            self.server_port,
        ]
        self.sapi_client_sock = "default"
        self.sapi_server_sock = "default"

    def tearDown(self):
        super(LDPCutThruTestCase, self).tearDown()
        self.cut_thru_tear_down()

    def show_commands_at_teardown(self):
        self.logger.debug(self.vapi.cli("show session verbose 2"))
        self.logger.debug(self.vapi.cli("show app mq"))

    @unittest.skipUnless(config.extended, "part of extended tests")
    def test_ldp_cut_thru_echo(self):
        """run LDP cut thru echo test"""

        self.cut_thru_test(
            "sock_test_server",
            self.server_args,
            "sock_test_client",
            self.client_echo_test_args,
        )

    def test_ldp_cut_thru_iperf3(self):
        """run LDP cut thru iperf3 test"""

        self.timeout = self.client_iperf3_timeout
        self.cut_thru_test(
            iperf3, self.server_iperf3_args, iperf3, self.client_iperf3_args
        )

    @unittest.skipUnless(config.extended, "part of extended tests")
    def test_ldp_cut_thru_uni_dir_nsock(self):
        """run LDP cut thru uni-directional (multiple sockets) test"""

        self.timeout = self.client_uni_dir_nsock_timeout
        self.cut_thru_test(
            "sock_test_server",
            self.server_args,
            "sock_test_client",
            self.client_uni_dir_nsock_test_args,
        )

    @unittest.skipUnless(config.extended, "part of extended tests")
    @unittest.skip("sock test apps need to be improved")
    def test_ldp_cut_thru_bi_dir_nsock(self):
        """run LDP cut thru bi-directional (multiple sockets) test"""

        self.timeout = self.client_bi_dir_nsock_timeout
        self.cut_thru_test(
            "sock_test_server",
            self.server_args,
            "sock_test_client",
            self.client_bi_dir_nsock_test_args,
        )


@unittest.skipIf(
    "hs_apps" in config.excluded_plugins, "Exclude tests requiring hs_apps plugin"
)
class VCLCutThruTestCase(VCLTestCase):
    """VCL Cut Thru Tests"""

    @classmethod
    def setUpClass(cls):
        super(VCLCutThruTestCase, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(VCLCutThruTestCase, cls).tearDownClass()

    def setUp(self):
        super(VCLCutThruTestCase, self).setUp()

        self.cut_thru_setup()
        self.client_echo_test_args = [
            "-E",
            self.echo_phrase,
            "-X",
            self.server_addr,
            self.server_port,
        ]

        self.client_uni_dir_nsock_timeout = 20
        self.client_uni_dir_nsock_test_args = [
            "-N",
            "1000",
            "-U",
            "-X",
            "-I",
            "2",
            self.server_addr,
            self.server_port,
        ]
        self.client_bi_dir_nsock_timeout = 20
        self.client_bi_dir_nsock_test_args = [
            "-N",
            "1000",
            "-B",
            "-X",
            "-I",
            "2",
            self.server_addr,
            self.server_port,
        ]

    def tearDown(self):
        super(VCLCutThruTestCase, self).tearDown()

    def show_commands_at_teardown(self):
        self.logger.debug(self.vapi.cli("show session verbose 2"))
        self.logger.debug(self.vapi.cli("show app mq"))

    def test_vcl_cut_thru_echo(self):
        """run VCL cut thru echo test"""

        self.cut_thru_test(
            "vcl_test_server",
            self.server_args,
            "vcl_test_client",
            self.client_echo_test_args,
        )

    def test_vcl_cut_thru_uni_dir_nsock(self):
        """run VCL cut thru uni-directional (multiple sockets) test"""

        self.timeout = self.client_uni_dir_nsock_timeout
        self.cut_thru_test(
            "vcl_test_server",
            self.server_args,
            "vcl_test_client",
            self.client_uni_dir_nsock_test_args,
        )

    def test_vcl_cut_thru_bi_dir_nsock(self):
        """run VCL cut thru bi-directional (multiple sockets) test"""

        self.timeout = self.client_bi_dir_nsock_timeout
        self.cut_thru_test(
            "vcl_test_server",
            self.server_args,
            "vcl_test_client",
            self.client_bi_dir_nsock_test_args,
        )


@unittest.skipIf(
    "hs_apps" in config.excluded_plugins, "Exclude tests requiring hs_apps plugin"
)
class VCLThruHostStackEcho(VCLTestCase):
    """VCL Thru Host Stack Echo"""

    @classmethod
    def setUpClass(cls):
        super(VCLThruHostStackEcho, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(VCLThruHostStackEcho, cls).tearDownClass()

    def setUp(self):
        super(VCLThruHostStackEcho, self).setUp()

        self.thru_host_stack_setup()
        self.client_bi_dir_nsock_timeout = 20
        self.client_bi_dir_nsock_test_args = [
            "-N",
            "1000",
            "-B",
            "-X",
            "-I",
            "2",
            self.loop0.local_ip4,
            self.server_port,
        ]
        self.client_echo_test_args = [
            "-E",
            self.echo_phrase,
            "-X",
            self.loop0.local_ip4,
            self.server_port,
        ]

    def tearDown(self):
        self.thru_host_stack_tear_down()
        super(VCLThruHostStackEcho, self).tearDown()

    def test_vcl_thru_host_stack_echo(self):
        """run VCL IPv4 thru host stack echo test"""

        self.thru_host_stack_test(
            "vcl_test_server",
            self.server_args,
            "vcl_test_client",
            self.client_echo_test_args,
        )

    def show_commands_at_teardown(self):
        self.logger.debug(self.vapi.cli("show app server"))
        self.logger.debug(self.vapi.cli("show session verbose"))
        self.logger.debug(self.vapi.cli("show app mq"))


@unittest.skipIf(
    "hs_apps" in config.excluded_plugins, "Exclude tests requiring hs_apps plugin"
)
class VCLThruHostStackTLS(VCLTestCase):
    """VCL Thru Host Stack TLS"""

    @classmethod
    def setUpClass(cls):
        cls.session_startup = ["poll-main", "use-app-socket-api"]
        super(VCLThruHostStackTLS, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(VCLThruHostStackTLS, cls).tearDownClass()

    def setUp(self):
        super(VCLThruHostStackTLS, self).setUp()

        self.thru_host_stack_setup()
        self.client_uni_dir_tls_timeout = 20
        self.server_tls_args = ["-L", self.server_port]
        self.client_uni_dir_tls_test_args = [
            "-N",
            "1000",
            "-U",
            "-X",
            "-L",
            self.loop0.local_ip4,
            self.server_port,
        ]
        self.sapi_server_sock = "1"
        self.sapi_client_sock = "2"

    def test_vcl_thru_host_stack_tls_uni_dir(self):
        """run VCL thru host stack uni-directional TLS test"""

        self.timeout = self.client_uni_dir_tls_timeout
        self.thru_host_stack_test(
            "vcl_test_server",
            self.server_tls_args,
            "vcl_test_client",
            self.client_uni_dir_tls_test_args,
        )

    def tearDown(self):
        self.thru_host_stack_tear_down()
        super(VCLThruHostStackTLS, self).tearDown()

    def show_commands_at_teardown(self):
        self.logger.debug(self.vapi.cli("show app server"))
        self.logger.debug(self.vapi.cli("show session verbose 2"))
        self.logger.debug(self.vapi.cli("show app mq"))


@unittest.skipIf(
    "hs_apps" in config.excluded_plugins, "Exclude tests requiring hs_apps plugin"
)
class VCLThruHostStackEchoInterruptMode(VCLThruHostStackEcho):
    """VCL Thru Host Stack Echo interrupt mode"""

    @classmethod
    def setUpClass(cls):
        cls.session_startup = ["use-private-rx-mqs", "use-app-socket-api"]
        super(VCLThruHostStackEcho, cls).setUpClass()

    def test_vcl_thru_host_stack_echo(self):
        """run VCL IPv4 thru host stack echo test interrupt mode"""

        self.sapi_server_sock = "1"
        self.sapi_client_sock = "2"

        self.thru_host_stack_test(
            "vcl_test_server",
            self.server_args,
            "vcl_test_client",
            self.client_echo_test_args,
        )


class VCLThruHostStackTLSInterruptMode(VCLThruHostStackTLS):
    """VCL Thru Host Stack TLS interrupt mode"""

    @classmethod
    def setUpClass(cls):
        cls.session_startup = ["poll-main", "use-app-socket-api", "use-private-rx-mqs"]
        super(VCLThruHostStackTLS, cls).setUpClass()


@unittest.skipIf(
    "hs_apps" in config.excluded_plugins, "Exclude tests requiring hs_apps plugin"
)
class VCLThruHostStackDTLS(VCLTestCase):
    """VCL Thru Host Stack DTLS"""

    @classmethod
    def setUpClass(cls):
        super(VCLThruHostStackDTLS, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(VCLThruHostStackDTLS, cls).tearDownClass()

    def setUp(self):
        super(VCLThruHostStackDTLS, self).setUp()

        self.thru_host_stack_setup()
        self.client_uni_dir_dtls_timeout = 20
        self.server_dtls_args = ["-p", "dtls", self.server_port]
        self.client_uni_dir_dtls_test_args = [
            "-N",
            "1000",
            "-U",
            "-X",
            "-p",
            "dtls",
            "-T 1400",
            self.loop0.local_ip4,
            self.server_port,
        ]

    def test_vcl_thru_host_stack_dtls_uni_dir(self):
        """run VCL thru host stack uni-directional DTLS test"""

        self.timeout = self.client_uni_dir_dtls_timeout
        self.thru_host_stack_test(
            "vcl_test_server",
            self.server_dtls_args,
            "vcl_test_client",
            self.client_uni_dir_dtls_test_args,
        )

    def tearDown(self):
        self.thru_host_stack_tear_down()
        super(VCLThruHostStackDTLS, self).tearDown()

    def show_commands_at_teardown(self):
        self.logger.debug(self.vapi.cli("show app server"))
        self.logger.debug(self.vapi.cli("show session verbose 2"))
        self.logger.debug(self.vapi.cli("show app mq"))


@unittest.skipIf(
    "hs_apps" in config.excluded_plugins, "Exclude tests requiring hs_apps plugin"
)
class VCLThruHostStackQUIC(VCLTestCase):
    """VCL Thru Host Stack QUIC"""

    @classmethod
    def setUpClass(cls):
        cls.extra_vpp_plugin_config.append("plugin quic_plugin.so { enable }")
        super(VCLThruHostStackQUIC, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(VCLThruHostStackQUIC, cls).tearDownClass()

    def setUp(self):
        super(VCLThruHostStackQUIC, self).setUp()

        self.thru_host_stack_setup()
        self.client_uni_dir_quic_timeout = 20
        self.server_quic_args = ["-p", "quic", self.server_port]
        self.client_uni_dir_quic_test_args = [
            "-N",
            "1000",
            "-U",
            "-X",
            "-p",
            "quic",
            self.loop0.local_ip4,
            self.server_port,
        ]

    @unittest.skipUnless(config.extended, "part of extended tests")
    def test_vcl_thru_host_stack_quic_uni_dir(self):
        """run VCL thru host stack uni-directional QUIC test"""

        self.timeout = self.client_uni_dir_quic_timeout
        self.thru_host_stack_test(
            "vcl_test_server",
            self.server_quic_args,
            "vcl_test_client",
            self.client_uni_dir_quic_test_args,
        )

    def tearDown(self):
        self.thru_host_stack_tear_down()
        super(VCLThruHostStackQUIC, self).tearDown()

    def show_commands_at_teardown(self):
        self.logger.debug(self.vapi.cli("show app server"))
        self.logger.debug(self.vapi.cli("show session verbose 2"))
        self.logger.debug(self.vapi.cli("show app mq"))


@unittest.skipIf(
    "hs_apps" in config.excluded_plugins, "Exclude tests requiring hs_apps plugin"
)
class VCLThruHostStackBidirNsock(VCLTestCase):
    """VCL Thru Host Stack Bidir Nsock"""

    @classmethod
    def setUpClass(cls):
        super(VCLThruHostStackBidirNsock, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(VCLThruHostStackBidirNsock, cls).tearDownClass()

    def setUp(self):
        super(VCLThruHostStackBidirNsock, self).setUp()

        self.thru_host_stack_setup()
        self.client_bi_dir_nsock_timeout = 20
        self.client_bi_dir_nsock_test_args = [
            "-N",
            "1000",
            "-B",
            "-X",
            "-I",
            "2",
            self.loop0.local_ip4,
            self.server_port,
        ]
        self.client_echo_test_args = [
            "-E",
            self.echo_phrase,
            "-X",
            self.loop0.local_ip4,
            self.server_port,
        ]

    def tearDown(self):
        self.thru_host_stack_tear_down()
        super(VCLThruHostStackBidirNsock, self).tearDown()

    def show_commands_at_teardown(self):
        self.logger.debug(self.vapi.cli("show session verbose 2"))
        self.logger.debug(self.vapi.cli("show app mq"))

    def test_vcl_thru_host_stack_bi_dir_nsock(self):
        """run VCL thru host stack bi-directional (multiple sockets) test"""

        self.timeout = self.client_bi_dir_nsock_timeout
        self.thru_host_stack_test(
            "vcl_test_server",
            self.server_args,
            "vcl_test_client",
            self.client_bi_dir_nsock_test_args,
        )


@unittest.skipIf(
    "hs_apps" in config.excluded_plugins, "Exclude tests requiring hs_apps plugin"
)
class LDPThruHostStackBidirNsock(VCLTestCase):
    """LDP Thru Host Stack Bidir Nsock"""

    @classmethod
    def setUpClass(cls):
        super(LDPThruHostStackBidirNsock, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(LDPThruHostStackBidirNsock, cls).tearDownClass()

    def setUp(self):
        super(LDPThruHostStackBidirNsock, self).setUp()

        self.thru_host_stack_setup()
        self.client_bi_dir_nsock_timeout = 20
        self.client_bi_dir_nsock_test_args = [
            "-N",
            "1000",
            "-B",
            "-X",
            # OUCH! Host Stack Bug?
            # Only fails when running
            # 'make test TEST_JOBS=auto'
            # or TEST_JOBS > 1
            # "-I", "2",
            self.loop0.local_ip4,
            self.server_port,
        ]

    def tearDown(self):
        self.thru_host_stack_tear_down()
        super(LDPThruHostStackBidirNsock, self).tearDown()

    def show_commands_at_teardown(self):
        self.logger.debug(self.vapi.cli("show session verbose 2"))
        self.logger.debug(self.vapi.cli("show app mq"))

    def test_ldp_thru_host_stack_bi_dir_nsock(self):
        """run LDP thru host stack bi-directional (multiple sockets) test"""

        self.timeout = self.client_bi_dir_nsock_timeout
        self.thru_host_stack_test(
            "sock_test_server",
            self.server_args,
            "sock_test_client",
            self.client_bi_dir_nsock_test_args,
        )


@unittest.skipIf(
    "hs_apps" in config.excluded_plugins, "Exclude tests requiring hs_apps plugin"
)
class LDPThruHostStackNsock(VCLTestCase):
    """LDP Thru Host Stack Nsock"""

    @classmethod
    def setUpClass(cls):
        super(LDPThruHostStackNsock, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(LDPThruHostStackNsock, cls).tearDownClass()

    def setUp(self):
        super(LDPThruHostStackNsock, self).setUp()

        self.thru_host_stack_setup()
        if self.vppDebug:
            self.client_uni_dir_nsock_timeout = 20
            self.numSockets = "2"
        else:
            self.client_uni_dir_nsock_timeout = 20
            self.numSockets = "5"

        self.client_uni_dir_nsock_test_args = [
            "-N",
            "1000",
            "-U",
            "-X",
            "-I",
            self.numSockets,
            self.loop0.local_ip4,
            self.server_port,
        ]

    def tearDown(self):
        self.thru_host_stack_tear_down()
        super(LDPThruHostStackNsock, self).tearDown()

    def test_ldp_thru_host_stack_uni_dir_nsock(self):
        """run LDP thru host stack uni-directional (multiple sockets) test"""

        self.timeout = self.client_uni_dir_nsock_timeout
        self.thru_host_stack_test(
            "sock_test_server",
            self.server_args,
            "sock_test_client",
            self.client_uni_dir_nsock_test_args,
        )


@unittest.skipIf(
    "hs_apps" in config.excluded_plugins, "Exclude tests requiring hs_apps plugin"
)
class VCLThruHostStackNsock(VCLTestCase):
    """VCL Thru Host Stack Nsock"""

    @classmethod
    def setUpClass(cls):
        super(VCLThruHostStackNsock, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(VCLThruHostStackNsock, cls).tearDownClass()

    def setUp(self):
        super(VCLThruHostStackNsock, self).setUp()

        self.thru_host_stack_setup()
        if self.vppDebug:
            self.client_uni_dir_nsock_timeout = 20
            self.numSockets = "2"
        else:
            self.client_uni_dir_nsock_timeout = 20
            self.numSockets = "5"

        self.client_uni_dir_nsock_test_args = [
            "-N",
            "1000",
            "-U",
            "-X",
            "-I",
            self.numSockets,
            self.loop0.local_ip4,
            self.server_port,
        ]

    def tearDown(self):
        self.thru_host_stack_tear_down()
        super(VCLThruHostStackNsock, self).tearDown()

    def test_vcl_thru_host_stack_uni_dir_nsock(self):
        """run VCL thru host stack uni-directional (multiple sockets) test"""

        self.timeout = self.client_uni_dir_nsock_timeout
        self.thru_host_stack_test(
            "vcl_test_server",
            self.server_args,
            "vcl_test_client",
            self.client_uni_dir_nsock_test_args,
        )


@tag_fixme_ubuntu2404
class LDPThruHostStackIperf(VCLTestCase):
    """LDP Thru Host Stack Iperf"""

    @classmethod
    def setUpClass(cls):
        super(LDPThruHostStackIperf, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(LDPThruHostStackIperf, cls).tearDownClass()

    def setUp(self):
        super(LDPThruHostStackIperf, self).setUp()

        self.thru_host_stack_setup()
        self.client_iperf3_timeout = 20
        self.client_iperf3_args = ["-4", "-t 2", "-c", self.loop0.local_ip4]
        self.server_iperf3_args = ["-4", "-s"]

    def tearDown(self):
        self.thru_host_stack_tear_down()
        super(LDPThruHostStackIperf, self).tearDown()

    def show_commands_at_teardown(self):
        self.logger.debug(self.vapi.cli("show session verbose 2"))
        self.logger.debug(self.vapi.cli("show app mq"))

    @unittest.skipUnless(_have_iperf3, "'%s' not found, Skipping.")
    def test_ldp_thru_host_stack_iperf3(self):
        """run LDP thru host stack iperf3 test"""

        self.timeout = self.client_iperf3_timeout
        self.thru_host_stack_test(
            iperf3, self.server_iperf3_args, iperf3, self.client_iperf3_args
        )

    @unittest.skipUnless(_have_iperf3, "'%s' not found, Skipping.")
    def test_ldp_thru_host_stack_iperf3_mss(self):
        """run LDP thru host stack iperf3 test with mss option"""

        self.timeout = self.client_iperf3_timeout
        self.client_iperf3_args.append("-M 1000")
        self.thru_host_stack_test(
            iperf3, self.server_iperf3_args, iperf3, self.client_iperf3_args
        )


@tag_fixme_ubuntu2404
class LDPThruHostStackIperfUdp(VCLTestCase):
    """LDP Thru Host Stack Iperf UDP"""

    @classmethod
    def setUpClass(cls):
        super(LDPThruHostStackIperfUdp, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(LDPThruHostStackIperfUdp, cls).tearDownClass()

    def setUp(self):
        super(LDPThruHostStackIperfUdp, self).setUp()

        self.thru_host_stack_setup()
        self.client_iperf3_timeout = 20
        self.client_iperf3_args = [
            "-4",
            "-t 2",
            "-u",
            "-l 1400",
            "-P 2",
            "-c",
            self.loop0.local_ip4,
        ]
        self.server_iperf3_args = ["-4", "-s"]

    def tearDown(self):
        self.thru_host_stack_tear_down()
        super(LDPThruHostStackIperfUdp, self).tearDown()

    def show_commands_at_teardown(self):
        self.logger.debug(self.vapi.cli("show session verbose 2"))
        self.logger.debug(self.vapi.cli("show app mq"))

    @unittest.skipUnless(_have_iperf3, "'%s' not found, Skipping.")
    def test_ldp_thru_host_stack_iperf3_udp(self):
        """run LDP thru host stack iperf3 UDP test"""

        self.timeout = self.client_iperf3_timeout
        self.thru_host_stack_test(
            iperf3, self.server_iperf3_args, iperf3, self.client_iperf3_args
        )


@tag_fixme_ubuntu2404
class LDPIpv6CutThruTestCase(VCLTestCase):
    """LDP IPv6 Cut Thru Tests"""

    @classmethod
    def setUpClass(cls):
        super(LDPIpv6CutThruTestCase, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(LDPIpv6CutThruTestCase, cls).tearDownClass()

    def show_commands_at_teardown(self):
        self.logger.debug(self.vapi.cli("show session verbose 2"))
        self.logger.debug(self.vapi.cli("show app mq"))

    def setUp(self):
        super(LDPIpv6CutThruTestCase, self).setUp()

        self.cut_thru_setup()
        self.client_iperf3_timeout = 20
        self.client_uni_dir_nsock_timeout = 20
        self.client_bi_dir_nsock_timeout = 20
        self.client_ipv6_echo_test_args = [
            "-6",
            "-E",
            self.echo_phrase,
            "-X",
            self.server_ipv6_addr,
            self.server_port,
        ]
        self.client_ipv6_iperf3_args = ["-6", "-t 2", "-c", self.server_ipv6_addr]
        self.server_ipv6_iperf3_args = ["-6", "-s"]
        self.client_ipv6_uni_dir_nsock_test_args = [
            "-N",
            "1000",
            "-U",
            "-X",
            "-6",
            "-I",
            "2",
            self.server_ipv6_addr,
            self.server_port,
        ]
        self.client_ipv6_bi_dir_nsock_test_args = [
            "-N",
            "1000",
            "-B",
            "-X",
            "-6",
            "-I",
            "2",
            self.server_ipv6_addr,
            self.server_port,
        ]

    def tearDown(self):
        super(LDPIpv6CutThruTestCase, self).tearDown()
        self.cut_thru_tear_down()

    @unittest.skipUnless(config.extended, "part of extended tests")
    def test_ldp_ipv6_cut_thru_echo(self):
        """run LDP IPv6 cut thru echo test"""

        self.cut_thru_test(
            "sock_test_server",
            self.server_ipv6_args,
            "sock_test_client",
            self.client_ipv6_echo_test_args,
        )

    @unittest.skipUnless(_have_iperf3, "'%s' not found, Skipping.")
    def test_ldp_ipv6_cut_thru_iperf3(self):
        """run LDP IPv6 cut thru iperf3 test"""

        self.timeout = self.client_iperf3_timeout
        self.cut_thru_test(
            iperf3, self.server_ipv6_iperf3_args, iperf3, self.client_ipv6_iperf3_args
        )

    @unittest.skipUnless(config.extended, "part of extended tests")
    def test_ldp_ipv6_cut_thru_uni_dir_nsock(self):
        """run LDP IPv6 cut thru uni-directional (multiple sockets) test"""

        self.timeout = self.client_uni_dir_nsock_timeout
        self.cut_thru_test(
            "sock_test_server",
            self.server_ipv6_args,
            "sock_test_client",
            self.client_ipv6_uni_dir_nsock_test_args,
        )

    @unittest.skipUnless(config.extended, "part of extended tests")
    @unittest.skip("sock test apps need to be improved")
    def test_ldp_ipv6_cut_thru_bi_dir_nsock(self):
        """run LDP IPv6 cut thru bi-directional (multiple sockets) test"""

        self.timeout = self.client_bi_dir_nsock_timeout
        self.cut_thru_test(
            "sock_test_server",
            self.server_ipv6_args,
            "sock_test_client",
            self.client_ipv6_bi_dir_nsock_test_args,
        )


@unittest.skipIf(
    "hs_apps" in config.excluded_plugins, "Exclude tests requiring hs_apps plugin"
)
class VCLIpv6CutThruTestCase(VCLTestCase):
    """VCL IPv6 Cut Thru Tests"""

    @classmethod
    def setUpClass(cls):
        super(VCLIpv6CutThruTestCase, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(VCLIpv6CutThruTestCase, cls).tearDownClass()

    def show_commands_at_teardown(self):
        self.logger.debug(self.vapi.cli("show session verbose 2"))
        self.logger.debug(self.vapi.cli("show app mq"))

    def setUp(self):
        super(VCLIpv6CutThruTestCase, self).setUp()

        self.cut_thru_setup()
        self.client_uni_dir_nsock_timeout = 20
        self.client_bi_dir_nsock_timeout = 20
        self.client_ipv6_echo_test_args = [
            "-6",
            "-E",
            self.echo_phrase,
            "-X",
            self.server_ipv6_addr,
            self.server_port,
        ]
        self.client_ipv6_uni_dir_nsock_test_args = [
            "-N",
            "1000",
            "-U",
            "-X",
            "-6",
            "-I",
            "2",
            self.server_ipv6_addr,
            self.server_port,
        ]
        self.client_ipv6_bi_dir_nsock_test_args = [
            "-N",
            "1000",
            "-B",
            "-X",
            "-6",
            "-I",
            "2",
            self.server_ipv6_addr,
            self.server_port,
        ]

    def tearDown(self):
        super(VCLIpv6CutThruTestCase, self).tearDown()
        self.cut_thru_tear_down()

    def show_commands_at_teardown(self):
        self.logger.debug(self.vapi.cli("show session verbose 2"))
        self.logger.debug(self.vapi.cli("show app mq"))

    def test_vcl_ipv6_cut_thru_echo(self):
        """run VCL IPv6 cut thru echo test"""

        self.cut_thru_test(
            "vcl_test_server",
            self.server_ipv6_args,
            "vcl_test_client",
            self.client_ipv6_echo_test_args,
        )

    @unittest.skipUnless(config.extended, "part of extended tests")
    def test_vcl_ipv6_cut_thru_uni_dir_nsock(self):
        """run VCL IPv6 cut thru uni-directional (multiple sockets) test"""

        self.timeout = self.client_uni_dir_nsock_timeout
        self.cut_thru_test(
            "vcl_test_server",
            self.server_ipv6_args,
            "vcl_test_client",
            self.client_ipv6_uni_dir_nsock_test_args,
        )

    @unittest.skipUnless(config.extended, "part of extended tests")
    def test_vcl_ipv6_cut_thru_bi_dir_nsock(self):
        """run VCL IPv6 cut thru bi-directional (multiple sockets) test"""

        self.timeout = self.client_bi_dir_nsock_timeout
        self.cut_thru_test(
            "vcl_test_server",
            self.server_ipv6_args,
            "vcl_test_client",
            self.client_ipv6_bi_dir_nsock_test_args,
        )


@unittest.skipIf(
    "hs_apps" in config.excluded_plugins, "Exclude tests requiring hs_apps plugin"
)
class VCLIpv6ThruHostStackEcho(VCLTestCase):
    """VCL IPv6 Thru Host Stack Echo"""

    @classmethod
    def setUpClass(cls):
        super(VCLIpv6ThruHostStackEcho, cls).setUpClass()

    @classmethod
    def tearDownClass(cls):
        super(VCLIpv6ThruHostStackEcho, cls).tearDownClass()

    def setUp(self):
        super(VCLIpv6ThruHostStackEcho, self).setUp()

        self.thru_host_stack_ipv6_setup()
        self.client_ipv6_echo_test_args = [
            "-6",
            "-E",
            self.echo_phrase,
            "-X",
            self.loop0.local_ip6,
            self.server_port,
        ]

    def tearDown(self):
        self.thru_host_stack_ipv6_tear_down()
        super(VCLIpv6ThruHostStackEcho, self).tearDown()

    def test_vcl_ipv6_thru_host_stack_echo(self):
        """run VCL IPv6 thru host stack echo test"""

        self.thru_host_stack_test(
            "vcl_test_server",
            self.server_ipv6_args,
            "vcl_test_client",
            self.client_ipv6_echo_test_args,
        )


if __name__ == "__main__":
    unittest.main(testRunner=VppTestRunner)
