Skip to content

Commit 7a9af38

Browse files
authored
Add Cibir tests to Connection Pool tests (#4952)
1 parent 889aa6b commit 7a9af38

File tree

2 files changed

+17
-56
lines changed

2 files changed

+17
-56
lines changed

src/test/bin/quic_gtest.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -353,14 +353,15 @@ struct HandshakeArgs12 {
353353
::std::vector<HandshakeArgs12> list;
354354
for (int Family : { 4, 6 })
355355
for (uint16_t NumberOfConnections : { 1, 2, 4 })
356+
for (bool TestCibir : { false, true })
356357
for (bool XdpSupported : { false, true }) {
357358
#if !defined(_WIN32)
358359
if (XdpSupported) continue;
359360
#endif
360361
if (!UseDuoNic && XdpSupported) {
361362
continue;
362363
}
363-
list.push_back({ Family, NumberOfConnections, XdpSupported, false /*Don't test CIBIR*/ });
364+
list.push_back({ Family, NumberOfConnections, XdpSupported, TestCibir });
364365
}
365366
return list;
366367
}

src/test/lib/HandshakeTest.cpp

+15-55
Original file line numberDiff line numberDiff line change
@@ -4100,36 +4100,8 @@ QuicTestHandshakeSpecificLossPatterns(
41004100
}
41014101
}
41024102

4103-
struct ServerMultiAcceptContext {
4104-
uint32_t StartedConnectionCount;
4105-
uint32_t MaxConnections;
4106-
CxPlatEvent StartedEvent;
4107-
UniquePtr<TestConnection>* Connections;
4108-
4109-
_Function_class_(NEW_CONNECTION_CALLBACK)
4110-
static
4111-
bool
4112-
ListenerMultiAcceptConnection(
4113-
_In_ TestListener* Listener,
4114-
_In_ HQUIC ConnectionHandle
4115-
)
4116-
{
4117-
auto* This = (ServerMultiAcceptContext*)Listener->Context;
4118-
uint32_t NewCount = (uint32_t)InterlockedIncrement((long*)&This->StartedConnectionCount);
4119-
if (NewCount > This->MaxConnections) {
4120-
TEST_FAILURE("Too many connections started!");
4121-
return false;
4122-
}
4123-
This->Connections[NewCount - 1] =
4124-
UniquePtr<TestConnection>(new(std::nothrow) TestConnection(ConnectionHandle, nullptr));
4125-
if (This->StartedConnectionCount == This->MaxConnections) {
4126-
This->StartedEvent.Set();
4127-
}
4128-
return true;
4129-
}
4130-
};
4131-
41324103
struct ConnectionPoolConnectionContext {
4104+
CxPlatEvent ConnectedEvent;
41334105
uint16_t IdealProcessor;
41344106
uint16_t PartitionIndex;
41354107
bool Connected;
@@ -4139,6 +4111,7 @@ struct ConnectionPoolConnectionContext {
41394111
switch (Event->Type) {
41404112
case QUIC_CONNECTION_EVENT_CONNECTED:
41414113
This->Connected = true;
4114+
This->ConnectedEvent.Set();
41424115
break;
41434116
case QUIC_CONNECTION_EVENT_IDEAL_PROCESSOR_CHANGED:
41444117
This->IdealProcessor = Event->IDEAL_PROCESSOR_CHANGED.IdealProcessor;
@@ -4169,7 +4142,7 @@ QuicTestConnectionPoolCreate(
41694142
MsQuicAlpn Alpn("MsQuicTest");
41704143

41714144
MsQuicSettings Settings;
4172-
Settings.SetIdleTimeoutMs(1000);
4145+
Settings.SetIdleTimeoutMs(TestWaitTimeout);
41734146
Settings.SetPeerBidiStreamCount(1);
41744147

41754148
MsQuicConfiguration ServerConfiguration(Registration, Alpn, Settings, ServerSelfSignedCredConfig);
@@ -4181,16 +4154,9 @@ QuicTestConnectionPoolCreate(
41814154
QuicAddr ServerAddr(QuicAddrFamily);
41824155
if (XdpSupported) {
41834156
QuicAddrSetToDuoNic(&ServerAddr.SockAddr);
4184-
} else {
4185-
QuicAddrSetToLoopback(&ServerAddr.SockAddr);
41864157
}
4187-
const uint16_t ServerPort = 4433;
4188-
ServerAddr.SetPort(ServerPort);
41894158

41904159
{
4191-
UniquePtrArray<UniquePtr<TestConnection>> ServerConnections(new(std::nothrow) UniquePtr<TestConnection>[NumberOfConnections]);
4192-
TEST_NOT_EQUAL(nullptr, ServerConnections);
4193-
41944160
UniquePtrArray<ConnectionScope> Connections(new(std::nothrow) ConnectionScope[NumberOfConnections]);
41954161
TEST_NOT_EQUAL(nullptr, Connections);
41964162

@@ -4207,14 +4173,15 @@ QuicTestConnectionPoolCreate(
42074173
Contexts[i].PartitionIndex = 0;
42084174
}
42094175

4210-
ServerMultiAcceptContext ServerAcceptContext {};
4211-
ServerAcceptContext.MaxConnections = NumberOfConnections;
4212-
ServerAcceptContext.Connections = ServerConnections.get();
4213-
ServerAcceptContext.StartedConnectionCount = 0;
4214-
TestListener Listener(Registration, ServerMultiAcceptContext::ListenerMultiAcceptConnection, ServerConfiguration);
4215-
TEST_TRUE(Listener.IsValid());
4216-
Listener.Context = &ServerAcceptContext;
4217-
TEST_QUIC_SUCCEEDED(Listener.Start(Alpn, &ServerAddr.SockAddr));
4176+
MsQuicAutoAcceptListener Listener(Registration, ServerConfiguration, MsQuicConnection::NoOpCallback);
4177+
TEST_QUIC_SUCCEEDED(Listener.GetInitStatus());
4178+
4179+
if (TestCibirSupport) {
4180+
TEST_QUIC_SUCCEEDED(Listener.SetCibirId(CibirId, CibirIdLength));
4181+
}
4182+
4183+
TEST_QUIC_SUCCEEDED(Listener.Start(Alpn, ServerAddr));
4184+
TEST_QUIC_SUCCEEDED(Listener.GetLocalAddr(ServerAddr));
42184185

42194186
{
42204187
UniquePtrArray<uint8_t*> CibirIdPtrs(new(std::nothrow) uint8_t*[NumberOfConnections]);
@@ -4229,7 +4196,7 @@ QuicTestConnectionPoolCreate(
42294196
if (XdpSupported) {
42304197
PoolConfig.ServerAddress = &ServerAddr.SockAddr;
42314198
}
4232-
PoolConfig.ServerPort = ServerPort;
4199+
PoolConfig.ServerPort = ServerAddr.GetPort();
42334200
PoolConfig.Context = (void**)ContextPtrs.get();
42344201
PoolConfig.Family = QuicAddrFamily;
42354202
PoolConfig.NumberOfConnections = NumberOfConnections;
@@ -4238,7 +4205,6 @@ QuicTestConnectionPoolCreate(
42384205
if (TestCibirSupport) {
42394206
for (uint32_t i = 0; i < NumberOfConnections; i++) {
42404207
CxPlatCopyMemory(&(CibirIdBuffer[i * CibirIdLength]), CibirId, CibirIdLength);
4241-
CibirIdBuffer[(i * CibirIdLength) + (CibirIdLength - 1)] += (uint8_t)i;
42424208
CibirIdPtrs[i] = &CibirIdBuffer[i * CibirIdLength];
42434209
}
42444210
PoolConfig.CibirIds = CibirIdPtrs.get();
@@ -4248,22 +4214,16 @@ QuicTestConnectionPoolCreate(
42484214
QUIC_STATUS Status = MsQuic->ConnectionPoolCreate(&PoolConfig, &(Connections.get()->Handle));
42494215
if (XdpSupported) {
42504216
TEST_QUIC_SUCCEEDED(Status);
4251-
ServerAcceptContext.StartedEvent.WaitForever();
42524217
for (uint32_t i = 0; i < NumberOfConnections; i++) {
4253-
//
4254-
// Verify the server connections are connected. The client connections should also be connected too.
4255-
//
4256-
ServerConnections[i]->WaitForConnectionComplete();
4257-
if (!ServerConnections[i]->GetIsConnected()) {
4258-
TEST_FAILURE("Server connection %u failed to connect", i);
4259-
}
42604218
//
42614219
// Verify the client connection is connected.
42624220
//
4221+
Contexts[i].ConnectedEvent.WaitTimeout(TestWaitTimeout);
42634222
if (!Contexts[i].Connected) {
42644223
TEST_FAILURE("Client connection %u failed to connect", i);
42654224
}
42664225
}
4226+
TEST_EQUAL(NumberOfConnections, Listener.AcceptedConnectionCount);
42674227
} else {
42684228
//
42694229
// When testing no XDP support, the loopback address is used,

0 commit comments

Comments
 (0)