Project

General

Profile

Bug #11301 » 0001-Add-test-case-for-clean-client-server-shutdown.patch

Bruce Toll, 02/01/2023 10:51 PM

View differences:

test/http/HttpClientServerTest.C
Exception,
};
constexpr auto SimulatedWorkTime = std::chrono::milliseconds{500};
class TestResource : public WResource
{
public:
......
: delaySendingBody_(false),
haveEverMoreData_(false),
haveRandomMoreData_(false),
simulateWork_(false),
aborted_(0)
{ }
......
return aborted_;
}
void simulateWork() {
simulateWork_ = true;
}
virtual void handleRequest(const Http::Request& request,
Http::Response& response) override
{
if (simulateWork_)
std::this_thread::sleep_for(SimulatedWorkTime);
switch (type_) {
case TestType::Simple:
return handleSimple(request, response);
......
bool delaySendingBody_;
bool haveEverMoreData_;
bool haveRandomMoreData_;
bool simulateWork_;
int aborted_;
TestType type_ = TestType::Simple;
......
}
}
BOOST_AUTO_TEST_CASE( http_client_server_clean_shutdown )
{
Server server;
server.resource().setType(TestType::Continuation);
server.resource().simulateWork();
if (server.start()) {
Client client;
client.get("http://" + server.address() + "/test");
std::this_thread::sleep_for(SimulatedWorkTime / 2);
client.abort();
client.waitDone();
}
}
#endif // WT_THREADED
(1-1/4)