summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2021-03-03 10:40:05 +0100
committerDamjan Marion <dmarion@me.com>2021-03-15 17:23:53 +0000
commit4376ab2a926b36c1131588069a8a9cdd2520073d (patch)
treec7315eeed5c134abef38a25d52ba0fb158a14f86 /src
parent387a08a8be413379618a633b140c58c35a1f6640 (diff)
tests: use socket transport instead of shared memory
Type: improvement Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I9e65c94a5a05047a5104e9361ea36eac77b40442 Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/linux-cp/lcp.api4
-rw-r--r--src/plugins/map/test/test_map.py9
-rw-r--r--src/vlib/test/test_cli.py7
-rw-r--r--src/vnet/bfd/bfd.api21
-rw-r--r--src/vnet/bfd/bfd_api.c44
-rw-r--r--src/vnet/bfd/test/test_bfd.py30
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_papi.py5
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_transport_socket.py4
8 files changed, 91 insertions, 33 deletions
diff --git a/src/plugins/linux-cp/lcp.api b/src/plugins/linux-cp/lcp.api
index 49fdeddf886..5bde88082df 100644
--- a/src/plugins/linux-cp/lcp.api
+++ b/src/plugins/linux-cp/lcp.api
@@ -85,13 +85,13 @@ autoreply autoendian define lcp_itf_pair_add_del
@param context - sender context, to match reply w/ request
@param sw_if_index - interface to use as filter (~0 == "all")
*/
-autoendian define lcp_itf_pair_get
+define lcp_itf_pair_get
{
u32 client_index;
u32 context;
u32 cursor;
};
-autoendian define lcp_itf_pair_get_reply
+define lcp_itf_pair_get_reply
{
u32 context;
i32 retval;
diff --git a/src/plugins/map/test/test_map.py b/src/plugins/map/test/test_map.py
index 93ea3f06976..746f0aff2de 100644
--- a/src/plugins/map/test/test_map.py
+++ b/src/plugins/map/test/test_map.py
@@ -114,15 +114,16 @@ class TestMAP(VppTestCase):
def test_api_map_domains_get(self):
# Create a bunch of domains
- domains = self.create_domains('130.67.0.0/24', '2001::/32',
+ no_domains = 4096 # This must be large enough to ensure VPP suspends
+ domains = self.create_domains('130.67.0.0/20', '2001::/32',
'2001::1/128')
- self.assertEqual(len(domains), 256)
+ self.assertEqual(len(domains), no_domains)
d = []
cursor = 0
# Invalid cursor
- rv, details = self.vapi.map_domains_get(cursor=1234)
+ rv, details = self.vapi.map_domains_get(cursor=no_domains+10)
self.assertEqual(rv.retval, -7)
# Delete a domain in the middle of walk
@@ -136,7 +137,7 @@ class TestMAP(VppTestCase):
self.assertEqual(rv.retval, -165)
d = list(self.vapi.vpp.details_iter(self.vapi.map_domains_get))
- self.assertEqual(len(d), 255)
+ self.assertEqual(len(d), no_domains - 1)
# Clean up
for i in domains:
diff --git a/src/vlib/test/test_cli.py b/src/vlib/test/test_cli.py
index a1ffbac81d8..5005bf4c43a 100644
--- a/src/vlib/test/test_cli.py
+++ b/src/vlib/test/test_cli.py
@@ -5,7 +5,7 @@ import datetime
import time
import unittest
-from vpp_papi import vpp_transport_shmem
+from vpp_papi import VPPIOError
from framework import VppTestCase, VppTestRunner
@@ -39,9 +39,8 @@ class TestCLI(VppTestCase):
self.assertEqual(rv.retval, 0)
def test_long_cli_delay(self):
- """ Test that VppApiClient raises VppTransportShmemIOError if timeout.""" # noqa
- with self.assertRaises(
- vpp_transport_shmem.VppTransportShmemIOError) as ctx:
+ """ Test that VppApiClient raises VppIOError if timeout.""" # noqa
+ with self.assertRaises(VPPIOError) as ctx:
rv = self.vapi.papi.cli_inband(cmd='wait 10')
def test_long_cli_delay_override(self):
diff --git a/src/vnet/bfd/bfd.api b/src/vnet/bfd/bfd.api
index 9fdd5b728d4..f53cc7630fd 100644
--- a/src/vnet/bfd/bfd.api
+++ b/src/vnet/bfd/bfd.api
@@ -206,6 +206,11 @@ autoreply define bfd_udp_session_set_flags
vl_api_if_status_flags_t flags;
};
+service {
+ rpc want_bfd_events returns want_bfd_events_reply
+ events bfd_udp_session_event;
+};
+
/** \brief Register for BFD events
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@@ -220,6 +225,22 @@ autoreply define want_bfd_events
u32 pid;
};
+define bfd_udp_session_event
+{
+ u32 client_index;
+ u32 pid;
+ vl_api_interface_index_t sw_if_index;
+ vl_api_address_t local_addr;
+ vl_api_address_t peer_addr;
+ vl_api_bfd_state_t state;
+ bool is_authenticated;
+ u8 bfd_key_id;
+ u32 conf_key_id;
+ u32 required_min_rx;
+ u32 desired_min_tx;
+ u8 detect_mult;
+};
+
/** \brief BFD UDP - add/replace key to configuration
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
diff --git a/src/vnet/bfd/bfd_api.c b/src/vnet/bfd/bfd_api.c
index ba7783fd54f..4760df2ac1b 100644
--- a/src/vnet/bfd/bfd_api.c
+++ b/src/vnet/bfd/bfd_api.c
@@ -175,6 +175,48 @@ send_bfd_udp_session_details (vl_api_registration_t * reg, u32 context,
}
void
+send_bfd_udp_session_event (vl_api_registration_t *reg, u32 pid,
+ bfd_session_t *bs)
+{
+ if (bs->transport != BFD_TRANSPORT_UDP4 &&
+ bs->transport != BFD_TRANSPORT_UDP6)
+ {
+ return;
+ }
+
+ vl_api_bfd_udp_session_event_t *mp = vl_msg_api_alloc (sizeof (*mp));
+ clib_memset (mp, 0, sizeof (*mp));
+ mp->_vl_msg_id = ntohs (VL_API_BFD_UDP_SESSION_EVENT);
+ mp->pid = pid;
+ mp->state = clib_host_to_net_u32 (bs->local_state);
+ bfd_udp_session_t *bus = &bs->udp;
+ bfd_udp_key_t *key = &bus->key;
+ mp->sw_if_index = clib_host_to_net_u32 (key->sw_if_index);
+ if ((!bs->auth.is_delayed && bs->auth.curr_key) ||
+ (bs->auth.is_delayed && bs->auth.next_key))
+ {
+ mp->is_authenticated = true;
+ }
+ if (bs->auth.is_delayed && bs->auth.next_key)
+ {
+ mp->bfd_key_id = bs->auth.next_bfd_key_id;
+ mp->conf_key_id = clib_host_to_net_u32 (bs->auth.next_key->conf_key_id);
+ }
+ else if (!bs->auth.is_delayed && bs->auth.curr_key)
+ {
+ mp->bfd_key_id = bs->auth.curr_bfd_key_id;
+ mp->conf_key_id = clib_host_to_net_u32 (bs->auth.curr_key->conf_key_id);
+ }
+ ip_address_encode (&key->local_addr, IP46_TYPE_ANY, &mp->local_addr);
+ ip_address_encode (&key->peer_addr, IP46_TYPE_ANY, &mp->peer_addr);
+
+ mp->required_min_rx = clib_host_to_net_u32 (bs->config_required_min_rx_usec);
+ mp->desired_min_tx = clib_host_to_net_u32 (bs->config_desired_min_tx_usec);
+ mp->detect_mult = bs->local_detect_mult;
+ vl_api_send_msg (reg, (u8 *) mp);
+}
+
+void
bfd_event (bfd_main_t * bm, bfd_session_t * bs)
{
vpe_api_main_t *vam = &vpe_api_main;
@@ -190,7 +232,7 @@ bfd_event (bfd_main_t * bm, bfd_session_t * bs)
case BFD_TRANSPORT_UDP4:
/* fallthrough */
case BFD_TRANSPORT_UDP6:
- send_bfd_udp_session_details (vl_reg, 0, bs);
+ send_bfd_udp_session_event (vl_reg, 0, bs);
}
}
}
diff --git a/src/vnet/bfd/test/test_bfd.py b/src/vnet/bfd/test/test_bfd.py
index 3e6453ccbc9..01b468c8e27 100644
--- a/src/vnet/bfd/test/test_bfd.py
+++ b/src/vnet/bfd/test/test_bfd.py
@@ -549,7 +549,7 @@ def bfd_session_up(test):
test.test_session.inc_seq_num()
test.test_session.send_packet()
test.logger.info("BFD: Waiting for event")
- e = test.vapi.wait_for_event(1, "bfd_udp_session_details")
+ e = test.vapi.wait_for_event(1, "bfd_udp_session_event")
verify_event(test, e, expected_state=BFDState.up)
test.logger.info("BFD: Session is Up")
test.test_session.update(state=BFDState.up)
@@ -569,7 +569,7 @@ def bfd_session_down(test):
test.test_session.inc_seq_num()
test.test_session.send_packet()
test.logger.info("BFD: Waiting for event")
- e = test.vapi.wait_for_event(1, "bfd_udp_session_details")
+ e = test.vapi.wait_for_event(1, "bfd_udp_session_event")
verify_event(test, e, expected_state=BFDState.down)
test.logger.info("BFD: Session is Down")
test.assert_equal(test.vpp_session.state, BFDState.down, BFDState)
@@ -750,12 +750,12 @@ class BFD4TestCase(VppTestCase):
self.test_session.update(your_discriminator=p[BFD].my_discriminator,
state=BFDState.up)
self.logger.info("BFD: Waiting for event")
- e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
+ e = self.vapi.wait_for_event(1, "bfd_udp_session_event")
verify_event(self, e, expected_state=BFDState.init)
self.logger.info("BFD: Sending Up")
self.test_session.send_packet()
self.logger.info("BFD: Waiting for event")
- e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
+ e = self.vapi.wait_for_event(1, "bfd_udp_session_event")
verify_event(self, e, expected_state=BFDState.up)
self.logger.info("BFD: Session is Up")
self.test_session.update(state=BFDState.up)
@@ -820,7 +820,7 @@ class BFD4TestCase(VppTestCase):
detection_time = self.test_session.detect_mult *\
self.vpp_session.required_min_rx / USEC_IN_SEC
self.sleep(detection_time, "waiting for BFD session time-out")
- e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
+ e = self.vapi.wait_for_event(1, "bfd_udp_session_event")
verify_event(self, e, expected_state=BFDState.down)
def test_peer_discr_reset_sess_down(self):
@@ -917,7 +917,7 @@ class BFD4TestCase(VppTestCase):
self.vpp_session.required_min_rx) / USEC_IN_SEC
self.test_session.send_packet(final)
time_mark = time.time()
- e = self.vapi.wait_for_event(2 * timeout, "bfd_udp_session_details")
+ e = self.vapi.wait_for_event(2 * timeout, "bfd_udp_session_event")
verify_event(self, e, expected_state=BFDState.down)
time_to_event = time.time() - time_mark
self.assert_in_range(time_to_event, .9 * timeout,
@@ -957,7 +957,7 @@ class BFD4TestCase(VppTestCase):
self.vpp_session.required_min_rx / USEC_IN_SEC
before = time.time()
e = self.vapi.wait_for_event(
- 2 * detection_time, "bfd_udp_session_details")
+ 2 * detection_time, "bfd_udp_session_event")
after = time.time()
self.assert_in_range(after - before,
0.9 * detection_time,
@@ -1404,7 +1404,7 @@ class BFD4TestCase(VppTestCase):
bfd_session_up(self)
self.vpp_session.admin_down()
self.pg0.enable_capture()
- e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
+ e = self.vapi.wait_for_event(1, "bfd_udp_session_event")
verify_event(self, e, expected_state=BFDState.admin_down)
for dummy in range(2):
p = wait_for_bfd_packet(self)
@@ -1417,7 +1417,7 @@ class BFD4TestCase(VppTestCase):
self.assert_equal(p[BFD].state, BFDState.admin_down, BFDState)
self.vpp_session.admin_up()
self.test_session.update(state=BFDState.down)
- e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
+ e = self.vapi.wait_for_event(1, "bfd_udp_session_event")
verify_event(self, e, expected_state=BFDState.down)
p = wait_for_bfd_packet(
self, pcap_time_min=time.time() - self.vpp_clock_offset)
@@ -1426,14 +1426,14 @@ class BFD4TestCase(VppTestCase):
p = wait_for_bfd_packet(
self, pcap_time_min=time.time() - self.vpp_clock_offset)
self.assert_equal(p[BFD].state, BFDState.init, BFDState)
- e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
+ e = self.vapi.wait_for_event(1, "bfd_udp_session_event")
verify_event(self, e, expected_state=BFDState.init)
self.test_session.update(state=BFDState.up)
self.test_session.send_packet()
p = wait_for_bfd_packet(
self, pcap_time_min=time.time() - self.vpp_clock_offset)
self.assert_equal(p[BFD].state, BFDState.up, BFDState)
- e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
+ e = self.vapi.wait_for_event(1, "bfd_udp_session_event")
verify_event(self, e, expected_state=BFDState.up)
def test_config_change_remote_demand(self):
@@ -1483,7 +1483,7 @@ class BFD4TestCase(VppTestCase):
vpp_session.add_vpp_config()
vpp_session.admin_up()
intf.remove_vpp_config()
- e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
+ e = self.vapi.wait_for_event(1, "bfd_udp_session_event")
self.assert_equal(e.sw_if_index, sw_if_index, "sw_if_index")
self.assertFalse(vpp_session.query_vpp_config())
@@ -1562,12 +1562,12 @@ class BFD6TestCase(VppTestCase):
self.test_session.update(your_discriminator=p[BFD].my_discriminator,
state=BFDState.up)
self.logger.info("BFD: Waiting for event")
- e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
+ e = self.vapi.wait_for_event(1, "bfd_udp_session_event")
verify_event(self, e, expected_state=BFDState.init)
self.logger.info("BFD: Sending Up")
self.test_session.send_packet()
self.logger.info("BFD: Waiting for event")
- e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
+ e = self.vapi.wait_for_event(1, "bfd_udp_session_event")
verify_event(self, e, expected_state=BFDState.up)
self.logger.info("BFD: Session is Up")
self.test_session.update(state=BFDState.up)
@@ -1698,7 +1698,7 @@ class BFD6TestCase(VppTestCase):
vpp_session.add_vpp_config()
vpp_session.admin_up()
intf.remove_vpp_config()
- e = self.vapi.wait_for_event(1, "bfd_udp_session_details")
+ e = self.vapi.wait_for_event(1, "bfd_udp_session_event")
self.assert_equal(e.sw_if_index, sw_if_index, "sw_if_index")
self.assertFalse(vpp_session.query_vpp_config())
diff --git a/src/vpp-api/python/vpp_papi/vpp_papi.py b/src/vpp-api/python/vpp_papi/vpp_papi.py
index 86bf7cbee30..851c214cad4 100644
--- a/src/vpp-api/python/vpp_papi/vpp_papi.py
+++ b/src/vpp-api/python/vpp_papi/vpp_papi.py
@@ -917,13 +917,8 @@ class VPPApiClient:
while True:
kwargs['cursor'] = cursor
rv, details = f(**kwargs)
- #
- # Convert to yield from details when we only support python 3
- #
for d in details:
yield d
if rv.retval == 0 or rv.retval != -165:
break
cursor = rv.cursor
-
-# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
diff --git a/src/vpp-api/python/vpp_papi/vpp_transport_socket.py b/src/vpp-api/python/vpp_papi/vpp_transport_socket.py
index 4af2d934ae8..b0861057e72 100644
--- a/src/vpp-api/python/vpp_papi/vpp_transport_socket.py
+++ b/src/vpp-api/python/vpp_papi/vpp_transport_socket.py
@@ -90,8 +90,8 @@ class VppTransport:
try:
self.socket.connect(self.server_address)
except socket.error as msg:
- logging.error("{} on socket {}".format(msg, self.server_address))
- raise
+ # logging.error("{} on socket {}".format(msg, self.server_address))
+ raise msg
self.connected = True