|
4 | 4 | #include <ydb/library/actors/core/scheduler_basic.h>
|
5 | 5 | #include <ydb/library/actors/testlib/test_runtime.h>
|
6 | 6 | #include <util/system/tempfile.h>
|
| 7 | +#include <util/stream/null.h> |
7 | 8 | #include "meta_cache.h"
|
8 | 9 |
|
9 | 10 | #ifdef NDEBUG
|
@@ -152,24 +153,31 @@ Y_UNIT_TEST_SUITE(MetaCache) {
|
152 | 153 | NHttp::THttpOutgoingRequestPtr httpRequest = NHttp::THttpOutgoingRequest::CreateRequestGet(LocalEndpoint + ":" + ToString(port1) + "/server");
|
153 | 154 | actorSystem.Send(new NActors::IEventHandle(proxyIdC, clientId, new NHttp::TEvHttpProxy::TEvHttpOutgoingRequest(httpRequest)), 0, true);
|
154 | 155 |
|
155 |
| - // receiving response on server2 |
156 |
| - NHttp::TEvHttpProxy::TEvHttpIncomingRequest* request1 = actorSystem.GrabEdgeEvent<NHttp::TEvHttpProxy::TEvHttpIncomingRequest>(handle); |
157 |
| - UNIT_ASSERT_EQUAL(request1->Request->URL, "/server"); |
158 |
| - UNIT_ASSERT_EQUAL(request1->Request->Host, TStringBuilder() << LocalAddress << ":" << port2); |
159 |
| - |
160 |
| - // ignoring request |
161 |
| - |
162 |
| - // waiting for the timeout |
163 |
| - actorSystem.SimulateSleep(TDuration::Seconds(120)); |
164 |
| - |
165 |
| - // receiving retried response on server1 |
166 |
| - NHttp::TEvHttpProxy::TEvHttpIncomingRequest* request2 = actorSystem.GrabEdgeEvent<NHttp::TEvHttpProxy::TEvHttpIncomingRequest>(handle); |
167 |
| - UNIT_ASSERT_EQUAL(request2->Request->URL, "/server"); |
168 |
| - UNIT_ASSERT_EQUAL(request2->Request->Host, TStringBuilder() << LocalAddress << ":" << port1); |
169 |
| - |
| 156 | + NHttp::TEvHttpProxy::TEvHttpIncomingRequest* request1 = nullptr; |
| 157 | + TAutoPtr<NActors::IEventHandle> handle1; |
| 158 | + NHttp::TEvHttpProxy::TEvHttpIncomingRequest* request2 = nullptr; |
| 159 | + TAutoPtr<NActors::IEventHandle> handle2; |
| 160 | + |
| 161 | + while (!request1 || !request2) { |
| 162 | + // receiving response on server2 and server1 |
| 163 | + NHttp::TEvHttpProxy::TEvHttpIncomingRequest* request = actorSystem.GrabEdgeEvent<NHttp::TEvHttpProxy::TEvHttpIncomingRequest>(handle); |
| 164 | + if (request->Request->Host == TStringBuilder() << LocalAddress << ":" << port1) { |
| 165 | + request1 = request; |
| 166 | + handle1 = handle; |
| 167 | + } else if (request->Request->Host == TStringBuilder() << LocalAddress << ":" << port2) { |
| 168 | + request2 = request; |
| 169 | + handle2 = handle; |
| 170 | + } else { |
| 171 | + UNIT_ASSERT(false); |
| 172 | + } |
| 173 | + if (!request1 || !request2) { |
| 174 | + // waiting for the timeout - it seems that it doesn't actually work |
| 175 | + actorSystem.SimulateSleep(TDuration::Seconds(120)); |
| 176 | + } |
| 177 | + } |
170 | 178 | // constructing response
|
171 |
| - NHttp::THttpOutgoingResponsePtr httpResponse = request2->Request->CreateResponseString("HTTP/1.1 200 Found\r\nConnection: Close\r\nTransfer-Encoding: chunked\r\n\r\n6\r\npassed\r\n0\r\n\r\n"); |
172 |
| - actorSystem.Send(new NActors::IEventHandle(handle->Sender, serverId2, new NHttp::TEvHttpProxy::TEvHttpOutgoingResponse(httpResponse)), 0, true); |
| 179 | + NHttp::THttpOutgoingResponsePtr httpResponse = request1->Request->CreateResponseString("HTTP/1.1 200 Found\r\nConnection: Close\r\nTransfer-Encoding: chunked\r\n\r\n6\r\npassed\r\n0\r\n\r\n"); |
| 180 | + actorSystem.Send(new NActors::IEventHandle(handle1->Sender, serverId2, new NHttp::TEvHttpProxy::TEvHttpOutgoingResponse(httpResponse)), 0, true); |
173 | 181 |
|
174 | 182 | // receiving response on client
|
175 | 183 | NHttp::TEvHttpProxy::TEvHttpIncomingResponse* response = actorSystem.GrabEdgeEvent<NHttp::TEvHttpProxy::TEvHttpIncomingResponse>(handle);
|
|
0 commit comments