TEST_UNIX_FILE = TESTDATA_OBJDIR + '/ssessiontest.unix'
TEST_DATA = b'BIND10 test'
TEST_PORT = 53535
+TEST_PORT2 = 53536
+TEST_PORT3 = 53537
class TestForwarder(unittest.TestCase):
'''In general, this is a straightforward port of the C++ counterpart.
self.assertEqual(TEST_DATA, client_sock.recv(len(TEST_DATA)))
def test_push_and_pop(self):
- # This is a straightforward port of C++ pushAndPop test.
+ # This is a straightforward port of C++ pushAndPop test. See the
+ # C++ version why we use multiple ports for "local".
local6 = ('::1', TEST_PORT, 0, 0)
+ local6_alt = ('::1', TEST_PORT2, 0, 0)
+ local6_alt2 = ('::1', TEST_PORT3, 0, 0)
remote6 = ('2001:db8::1', 5300, 0, 0)
self.check_push_and_pop(AF_INET6, SOCK_DGRAM, IPPROTO_UDP,
local6, remote6, TEST_DATA, True)
local6, remote6, TEST_DATA, False)
local4 = ('127.0.0.1', TEST_PORT)
+ local4_alt = ('127.0.0.1', TEST_PORT2)
remote4 = ('192.0.2.2', 5300)
self.check_push_and_pop(AF_INET, SOCK_DGRAM, IPPROTO_UDP,
local4, remote4, TEST_DATA, False)
local4, remote4, TEST_DATA, False)
self.check_push_and_pop(AF_INET6, SOCK_DGRAM, IPPROTO_UDP,
- local6, remote6, self.large_text, False)
+ local6_alt, remote6, self.large_text, False)
self.check_push_and_pop(AF_INET6, SOCK_STREAM, IPPROTO_TCP,
local6, remote6, self.large_text, False)
self.check_push_and_pop(AF_INET, SOCK_DGRAM, IPPROTO_UDP,
- local4, remote4, self.large_text, False)
+ local4_alt, remote4, self.large_text, False)
self.check_push_and_pop(AF_INET, SOCK_STREAM, IPPROTO_TCP,
local4, remote4, self.large_text, False)
# scope (zone) ID
scope6 = ('fe80::1', TEST_PORT, 0, 1)
self.check_push_and_pop(AF_INET6, SOCK_DGRAM, IPPROTO_UDP,
- local6, scope6, TEST_DATA, False)
+ local6_alt2, scope6, TEST_DATA, False)
def test_push_too_fast(self):
# A straightforward port of C++ pushTooFast test.
const char* const TEST_UNIX_FILE = TEST_DATA_TOPBUILDDIR "/test.unix";
const char* const TEST_PORT = "53535";
+const char* const TEST_PORT2 = "53536"; // use this in case we need 2 ports
const char TEST_DATA[] = "BIND10 test";
// A simple helper structure to automatically close test sockets on return
}
TEST_F(ForwardTest, pushAndPop) {
- // Pass a UDP/IPv6 session.
+ // Pass a UDP/IPv6 session. We use different ports for different UDP
+ // tests because Solaris 11 seems to prohibit reusing the same port for
+ // some short period once the socket FD is forwarded, even if the sockets
+ // are closed. See Trac #2028.
const SockAddrInfo sai_local6(getSockAddr("::1", TEST_PORT));
+ const SockAddrInfo sai_local6_alt(getSockAddr("::1", TEST_PORT2));
const SockAddrInfo sai_remote6(getSockAddr("2001:db8::1", "5300"));
{
SCOPED_TRACE("Passing UDP/IPv6 session");
// receiver, which should be usable for multiple attempts of passing,
// regardless of family of the passed session
const SockAddrInfo sai_local4(getSockAddr("127.0.0.1", TEST_PORT));
+ const SockAddrInfo sai_local4_alt(getSockAddr("127.0.0.1", TEST_PORT2));
const SockAddrInfo sai_remote4(getSockAddr("192.0.2.2", "5300"));
{
SCOPED_TRACE("Passing UDP/IPv4 session");
// Also try large data
{
SCOPED_TRACE("Passing UDP/IPv6 session with large data");
- checkPushAndPop(AF_INET6, SOCK_DGRAM, IPPROTO_UDP, sai_local6,
+ checkPushAndPop(AF_INET6, SOCK_DGRAM, IPPROTO_UDP, sai_local6_alt,
sai_remote6, large_text_.c_str(), large_text_.length(),
false);
}
}
{
SCOPED_TRACE("Passing UDP/IPv4 session with large data");
- checkPushAndPop(AF_INET, SOCK_DGRAM, IPPROTO_UDP, sai_local4,
+ checkPushAndPop(AF_INET, SOCK_DGRAM, IPPROTO_UDP, sai_local4_alt,
sai_remote4, large_text_.c_str(), large_text_.length(),
false);
}