aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_vcl.py
blob: 8e8cc401888fc6d56b64fea14928ab62a21412da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * Copyright (c) 2015 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * config.h: feature configuration
 *
 * Copyright (c) 2008 Eliot Dresselhaus
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef included_vnet_config_h
#define included_vnet_config_h

#include <vlib/vlib.h>
#include <vppinfra/heap.h>

typedef struct
{
  /* Features are prioritized by index.  Smaller indices get
     performed first. */
  u32 feature_index;

  /* VLIB node which performs feature. */
  u32 node_index;

  /* Next index relative to previous node or main node. */
  u32 next_index;

  /* Opaque per feature configuration data. */
  u32 *feature_config;
} vnet_config_feature_t;

always_inline void
vnet_config_feature_free (vnet_config_feature_t * f)
{
  vec_free (f->feature_config);
}

typedef struct
{
  /* Sorted vector of features for this configuration. */
  vnet_config_feature_t *features;

  /* Config string as vector for hashing. */
  u32 *config_string_vector;

  /* Config string including all next indices and feature data as a vector. */
  u32 config_string_heap_index, config_string_heap_handle;

  /* Index in main pool. */
  u32 index;

  /* Number of interfaces/traffic classes that reference this config. */
  u32 reference_count;
} vnet_config_t;

typedef struct
{
  /* Pool of configs.  Index 0 is always null config and is never deleted. */
  vnet_config_t *config_pool;

  /* Hash table mapping vector config string to config pool index. */
  uword *config_string_hash;

  /* Global heap of configuration data. */
  u32 *config_string_heap;

  /* Node index which starts/ends feature processing. */
  u32 *start_node_indices, *end_node_indices_by_user_index,
    default_end_node_index;

  /* Interior feature processing nodes (not including start and end nodes). */
  u32 *node_index_by_feature_index;

  /* vnet_config pool index by user index */
  u32 *config_pool_index_by_user_index;

  /* Temporary vector for holding config strings.  Used to avoid continually
     allocating vectors. */
  u32 *config_string_temp;
} vnet_config_main_t;

always_inline void
vnet_config_free (vnet_config_main_t * cm, vnet_config_t * c)
{
  vnet_config_feature_t *f;
  vec_foreach (f, c->features) vnet_config_feature_free (f);
  vec_free (c->features);
  heap_dealloc (cm->config_string_heap, c->config_string_heap_handle);
  vec_free (c->config_string_vector);
}

always_inline void *
vnet_get_config_data (vnet_config_main_t * cm,
		      u32 * config_index, u32 * next_index, u32 n_data_bytes)
{
  u32 i, n, *d;

  i = *config_index;

  d = heap_elt_at_index (cm->config_string_heap, i);

  n = round_pow2 (n_data_bytes, sizeof (d[0])) / sizeof (d[0]);

  /* Last 32 bits are next index. */
  *next_index = d[n];

  /* Advance config index to next config. */
  *config_index = (i + n + 1);

  /* Return config data to user for this feature. */
  return (void *) d;
}

void vnet_config_init (vlib_main_t * vm,
		       vnet_config_main_t * cm,
		       char *start_node_names[],
		       int n_start_node_names,
		       char *feature_node_names[], int n_feature_node_names);

void vnet_config_del (vnet_config_main_t * cm, u32 config_id);

/* Calls to add/delete features from configurations. */
u32 vnet_config_add_feature (vlib_main_t * vm,
			     vnet_config_main_t * cm,
			     u32 config_id,
			     u32 feature_index,
			     void *feature_config,
			     u32 n_feature_config_bytes);

u32 vnet_config_del_feature (vlib_main_t * vm,
			     vnet_config_main_t * cm,
			     u32 config_id,
			     u32 feature_index,
			     void *feature_config,
			     u32 n_feature_config_bytes);

u32 vnet_config_modify_end_node (vlib_main_t * vm,
				 vnet_config_main_t * cm,
				 u32 config_string_heap_index,
				 u32 end_node_index);

u32 vnet_config_reset_end_node (vlib_main_t *vm, vnet_config_main_t *cm,
				u32 config_string_heap_index);

u32 vnet_config_get_end_node (vlib_main_t *vm, vnet_config_main_t *cm,
			      u32 config_string_heap_index);

u8 *vnet_config_format_features (vlib_main_t * vm,
				 vnet_config_main_t * cm,
				 u32 config_index, u8 * s);

#endif /* included_vnet_config_h */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
#!/usr/bin/env python
""" Vpp VCL tests """

import unittest
import os
import subprocess
import signal
from framework import VppTestCase, VppTestRunner, running_extended_tests, \
    Worker
from vpp_ip_route import VppIpTable, VppIpRoute, VppRoutePath, DpoProto


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

    def __init__(self, build_dir, appname, args, logger, env={}):
        vcl_lib_dir = "%s/vpp/lib" % build_dir
        if "iperf" in appname:
            app = appname
            env.update({'LD_PRELOAD':
                        "%s/libvcl_ldpreload.so" % vcl_lib_dir})
        elif "sock" in appname:
            app = "%s/vpp/bin/%s" % (build_dir, appname)
            env.update({'LD_PRELOAD':
                        "%s/libvcl_ldpreload.so" % vcl_lib_dir})
        else:
            app = "%s/vpp/bin/%s" % (build_dir, appname)
        self.args = [app] + args
        super(VCLAppWorker, self).__init__(self.args, logger, env)


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

    def __init__(self, methodName):
        var = "VPP_TEST_BUILD_DIR"
        self.build_dir = os.getenv(var, None)
        if self.build_dir is None:
            raise Exception("Environment variable `%s' not set" % var)
        self.vppDebug = 'vpp_debug' in self.build_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 = 10
        self.echo_phrase = "Hello, world! Jenny is a friend of mine."

        super(VCLTestCase, self).__init__(methodName)

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

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

    def cut_thru_test(self, server_app, server_args, client_app, client_args):
        self.env = {'VCL_API_PREFIX': self.shm_prefix,
                    'VCL_APP_SCOPE_LOCAL': "true"}

        worker_server = VCLAppWorker(self.build_dir, server_app, server_args,
                                     self.logger, self.env)
        worker_server.start()
        self.sleep(0.2)
        worker_client = VCLAppWorker(self.build_dir, client_app, client_args,
                                     self.logger, self.env)
        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)

    def thru_host_stack_setup(self):
        self.vapi.session_enable_disable(is_enabled=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(namespace_id="1", secret=1234,
                                    sw_if_index=self.loop0.sw_if_index)
        self.vapi.app_namespace_add(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):
        for i in self.lo_interfaces:
            i.unconfig_ip4()
            i.set_table_ip4(0)
            i.admin_down()

        self.vapi.session_enable_disable(is_enabled=0)

    def thru_host_stack_ipv6_setup(self):
        self.vapi.session_enable_disable(is_enabled=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(namespace_id="1", secret=1234,
                                    sw_if_index=self.loop0.sw_if_index)
        self.vapi.app_namespace_add(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,
                                          proto=DpoProto.DPO_PROTO_IP6)],
                            table_id=1, is_ip6=1)
        ip_t10 = VppIpRoute(self, self.loop0.local_ip6, 128,
                            [VppRoutePath("::0", 0xffffffff,
                                          nh_table_id=1,
                                          proto=DpoProto.DPO_PROTO_IP6)],
                            table_id=2, is_ip6=1)
        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):
        for i in self.lo_interfaces:
            i.unconfig_ip6()
            i.set_table_ip6(0)
            i.admin_down()

        self.vapi.session_enable_disable(is_enabled=0)

    def thru_host_stack_test(self, server_app, server_args,
                             client_app, client_args):
        self.env = {'VCL_API_PREFIX': self.shm_prefix,
                    'VCL_APP_SCOPE_GLOBAL': "true",
                    'VCL_APP_NAMESPACE_ID': "1",
                    'VCL_APP_NAMESPACE_SECRET': "1234"}

        worker_server = VCLAppWorker(self.build_dir, server_app, server_args,
                                     self.logger, self.env)
        worker_server.start()
        self.sleep(0.2)

        self.env.update({'VCL_APP_NAMESPACE_ID': "2",
                         'VCL_APP_NAMESPACE_SECRET': "5678"})
        worker_client = VCLAppWorker(self.build_dir, client_app, client_args,
                                     self.logger, self.env)
        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)

    def validateResults(self, worker_client, worker_server, timeout):
        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.SIGTERM)
                worker_client.join()
            except:
                self.logger.debug(
                    "Couldn't kill client worker process")
                raise
        if error:
            raise Exception(
                "Timeout! Client worker did not finish in %ss" % timeout)
        self.assert_equal(worker_client.result, 0, "Binary test return code")


class VCLCutThruTestCase(VCLTestCase):
    """ VCL Cut Thru Tests """

    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_iperf3_timeout = 20
        self.client_iperf3_args = ["-V4d", "-t 5", "-c", self.server_addr]
        self.server_iperf3_args = ["-V4d", "-s"]
        self.client_uni_dir_nsock_timeout = 60
        self.client_uni_dir_nsock_test_args = ["-I", "5", "-U", "-X",
                                               self.server_addr,
                                               self.server_port]
        self.client_bi_dir_nsock_timeout = 120
        self.client_bi_dir_nsock_test_args = ["-I", "2", "-B", "-X",
                                              self.server_addr,
                                              self.server_port]

    def tearDown(self):
        self.cut_thru_tear_down()

        super(VCLCutThruTestCase, self).tearDown()

    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 """

        try:
            subprocess.check_output(['iperf3', '-v'])
        except:
            self.logger.error("WARNING: 'iperf3' is not installed,")
            self.logger.error("         'test_ldp_cut_thru_iperf3' not run!")
            return

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

    @unittest.skipUnless(running_extended_tests(), "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(running_extended_tests(), "part of extended tests")
    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)

    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)

    @unittest.skipUnless(running_extended_tests(), "part of extended tests")
    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)

    @unittest.skipUnless(running_extended_tests(), "part of extended tests")
    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)


class VCLThruHostStackTestCase(VCLTestCase):
    """ VCL Thru Host Stack Tests """

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

        self.thru_host_stack_setup()
        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(VCLThruHostStackTestCase, self).tearDown()

    def test_ldp_thru_host_stack_echo(self):
        """ run LDP thru host stack echo test """

        self.thru_host_stack_test("sock_test_server", self.server_args,
                                  "sock_test_client",
                                  self.client_echo_test_args)
        # TBD: Remove these when VPP thru host teardown config bug is fixed.
        self.thru_host_stack_test("vcl_test_server", self.server_args,
                                  "vcl_test_client",
                                  self.client_echo_test_args)

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

        # TBD: Enable this when VPP  thru host teardown config bug is fixed.
        # self.thru_host_stack_test("vcl_test_server", self.server_args,
        #                           "vcl_test_client",
        #                           self.client_echo_test_args)

    # TBD: Remove VCLThruHostStackExtended*TestCase classes and move
    #      tests here when VPP  thru host teardown/setup config bug
    #      is fixed.


class VCLThruHostStackNSessionBidirTestCase(VCLTestCase):
    """ VCL Thru Host Stack NSession Bidir Tests """

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

        self.thru_host_stack_setup()
        if self.vppDebug:
            self.client_bi_dir_nsock_timeout = 120
            self.client_bi_dir_nsock_test_args = ["-B", "-X", "-N 10000",
                                                  self.loop0.local_ip4,
                                                  self.server_port]
        else:
            self.client_bi_dir_nsock_timeout = 90
            self.client_bi_dir_nsock_test_args = ["-I", "2", "-B", "-X",
                                                  "-N 1000",
                                                  self.loop0.local_ip4,
                                                  self.server_port]

    def tearDown(self):
        self.thru_host_stack_tear_down()

        super(VCLThruHostStackNSessionBidirTestCase, self).tearDown()

    @unittest.skipUnless(running_extended_tests(), "part of extended tests")
    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)


class VCLThruHostStackExtendedBTestCase(VCLTestCase):
    """ VCL Thru Host Stack Extended B Tests """

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

        self.thru_host_stack_setup()
        if self.vppDebug:
            self.client_bi_dir_nsock_timeout = 120
            self.client_bi_dir_nsock_test_args = ["-B", "-X", "-N 1000",
                                                  self.loop0.local_ip4,
                                                  self.server_port]
        else:
            self.client_bi_dir_nsock_timeout = 60
            self.client_bi_dir_nsock_test_args = ["-I", "2", "-B", "-X",
                                                  "-N 1000",
                                                  self.loop0.local_ip4,
                                                  self.server_port]

    def tearDown(self):
        self.thru_host_stack_tear_down()

        super(VCLThruHostStackExtendedBTestCase, self).tearDown()

    @unittest.skipUnless(running_extended_tests(), "part of extended tests")
    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)


class VCLThruHostStackExtendedCTestCase(VCLTestCase):
    """ VCL Thru Host Stack Extended C Tests """

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

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

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

    def tearDown(self):
        self.thru_host_stack_tear_down()

        super(VCLThruHostStackExtendedCTestCase, self).tearDown()

    @unittest.skipUnless(running_extended_tests(), "part of extended tests")
    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)


class VCLThruHostStackExtendedDTestCase(VCLTestCase):
    """ VCL Thru Host Stack Extended D Tests """

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

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

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

    def tearDown(self):
        self.thru_host_stack_tear_down()

        super(VCLThruHostStackExtendedDTestCase, self).tearDown()

    @unittest.skipUnless(running_extended_tests(), "part of extended tests")
    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)


class VCLThruHostStackIperfTestCase(VCLTestCase):
    """ VCL Thru Host Stack Iperf Tests """

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

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

    def tearDown(self):
        self.thru_host_stack_tear_down()

        super(VCLThruHostStackIperfTestCase, self).tearDown()

    def test_ldp_thru_host_stack_iperf3(self):
        """ run LDP thru host stack iperf3 test """

        try:
            subprocess.check_output(['iperf3', '-v'])
        except:
            self.logger.error("WARNING: 'iperf3' is not installed,")
            self.logger.error(
                "         'test_ldp_thru_host_stack_iperf3' not run!")
            return

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


class VCLIpv6CutThruTestCase(VCLTestCase):
    """ VCL IPv6 Cut Thru Tests """

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

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

    def tearDown(self):
        self.cut_thru_tear_down()

        super(VCLIpv6CutThruTestCase, self).tearDown()

    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)

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

        try:
            subprocess.check_output(['iperf3', '-v'])
        except:
            self.logger.error("WARNING: 'iperf3' is not installed,")
            self.logger.error(
                "         'test_ldp_ipv6_cut_thru_iperf3' not run!")
            return

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

    @unittest.skipUnless(running_extended_tests(), "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(running_extended_tests(), "part of extended tests")
    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)

    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(running_extended_tests(), "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(running_extended_tests(), "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)


class VCLIpv6ThruHostStackTestCase(VCLTestCase):
    """ VCL IPv6 Thru Host Stack Tests """

    def setUp(self):
        super(VCLIpv6ThruHostStackTestCase, 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(VCLIpv6ThruHostStackTestCase, self).tearDown()

    def test_ldp_ipv6_thru_host_stack_echo(self):
        """ run LDP IPv6 thru host stack echo test """

        self.thru_host_stack_test("sock_test_server",
                                  self.server_ipv6_args,
                                  "sock_test_client",
                                  self.client_ipv6_echo_test_args)
        # TBD: Remove these when VPP thru host teardown config bug is fixed.
        self.thru_host_stack_test("vcl_test_server",
                                  self.server_ipv6_args,
                                  "vcl_test_client",
                                  self.client_ipv6_echo_test_args)

    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)

    # TBD: Remove VCLIpv6ThruHostStackExtended*TestCase classes and move
    #      tests here when VPP  thru host teardown/setup config bug
    #      is fixed.


class VCLIpv6ThruHostStackExtendedATestCase(VCLTestCase):
    """ VCL IPv6 Thru Host Stack Extended A Tests """

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

        self.thru_host_stack_ipv6_setup()
        if self.vppDebug:
            self.client_bi_dir_nsock_timeout = 120
            self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-B", "-X",
                                                       self.loop0.local_ip6,
                                                       self.server_port]
        else:
            self.client_bi_dir_nsock_timeout = 90
            self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-I",
                                                       "2", "-B", "-X",
                                                       self.loop0.local_ip6,
                                                       self.server_port]

    def tearDown(self):
        self.thru_host_stack_ipv6_tear_down()

        super(VCLIpv6ThruHostStackExtendedATestCase, self).tearDown()

    @unittest.skipUnless(running_extended_tests(), "part of extended tests")
    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_ipv6_args,
                                  "vcl_test_client",
                                  self.client_ipv6_bi_dir_nsock_test_args)


class VCLIpv6ThruHostStackExtendedBTestCase(VCLTestCase):
    """ VCL IPv6 Thru Host Stack Extended B Tests """

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

        self.thru_host_stack_ipv6_setup()
        if self.vppDebug:
            self.client_bi_dir_nsock_timeout = 120
            self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-B", "-X",
                                                       self.loop0.local_ip6,
                                                       self.server_port]
        else:
            self.client_bi_dir_nsock_timeout = 60
            self.client_ipv6_bi_dir_nsock_test_args = ["-6", "-I", "2",
                                                       "-B", "-X",
                                                       self.loop0.local_ip6,
                                                       self.server_port]

    def tearDown(self):
        self.thru_host_stack_ipv6_tear_down()

        super(VCLIpv6ThruHostStackExtendedBTestCase, self).tearDown()

    @unittest.skipUnless(running_extended_tests(), "part of extended tests")
    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_ipv6_args,
                                  "sock_test_client",
                                  self.client_ipv6_bi_dir_nsock_test_args)


class VCLIpv6ThruHostStackExtendedCTestCase(VCLTestCase):
    """ VCL IPv6 Thru Host Stack Extended C Tests """

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

        self.thru_host_stack_ipv6_setup()
        if self.vppDebug:
            self.client_uni_dir_nsock_timeout = 120
            self.numSockets = "2"
        else:
            self.client_uni_dir_nsock_timeout = 120
            self.numSockets = "5"

        self.client_ipv6_uni_dir_nsock_test_args = ["-6",
                                                    "-I", self.numSockets,
                                                    "-U", "-X",
                                                    self.loop0.local_ip6,
                                                    self.server_port]

    def tearDown(self):
        self.thru_host_stack_ipv6_tear_down()

        super(VCLIpv6ThruHostStackExtendedCTestCase, self).tearDown()

    @unittest.skipUnless(running_extended_tests(), "part of extended tests")
    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_ipv6_args,
                                  "sock_test_client",
                                  self.client_ipv6_uni_dir_nsock_test_args)


class VCLIpv6ThruHostStackExtendedDTestCase(VCLTestCase):
    """ VCL IPv6 Thru Host Stack Extended D Tests """

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

        self.thru_host_stack_ipv6_setup()
        if self.vppDebug:
            self.client_uni_dir_nsock_timeout = 120
            self.numSockets = "2"
        else:
            self.client_uni_dir_nsock_timeout = 120
            self.numSockets = "5"

        self.client_ipv6_uni_dir_nsock_test_args = ["-6",
                                                    "-I", self.numSockets,
                                                    "-U", "-X",
                                                    self.loop0.local_ip6,
                                                    self.server_port]

    def tearDown(self):
        self.thru_host_stack_ipv6_tear_down()

        super(VCLIpv6ThruHostStackExtendedDTestCase, self).tearDown()

    @unittest.skipUnless(running_extended_tests(), "part of extended tests")
    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_ipv6_args,
                                  "vcl_test_client",
                                  self.client_ipv6_uni_dir_nsock_test_args)


class VCLIpv6ThruHostStackIperfTestCase(VCLTestCase):
    """ VCL IPv6 Thru Host Stack Iperf Tests """

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

        self.thru_host_stack_ipv6_setup()
        self.client_iperf3_timeout = 20
        self.client_ipv6_iperf3_args = ["-V6d", "-t 5", "-c",
                                        self.loop0.local_ip6]
        self.server_ipv6_iperf3_args = ["-V6d", "-s"]

    def tearDown(self):
        self.thru_host_stack_ipv6_tear_down()

        super(VCLIpv6ThruHostStackIperfTestCase, self).tearDown()

    @unittest.skipUnless(running_extended_tests(), "part of extended tests")
    def test_ldp_thru_host_stack_iperf3(self):
        """ run LDP thru host stack iperf3 test """

        try:
            subprocess.check_output(['iperf3', '-v'])
        except:
            self.logger.error("WARNING: 'iperf3' is not installed,")
            self.logger.error(
                "         'test_ldp_thru_host_stack_iperf3' not run!")
            return

        self.timeout = self.client_iperf3_timeout
        self.thru_host_stack_test("iperf3", self.server_ipv6_iperf3_args,
                                  "iperf3", self.client_ipv6_iperf3_args)


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