@@ -15,7 +15,22 @@ namespace {
15
15
using namespace NKikimr ;
16
16
using namespace NFq ;
17
17
18
- TString NoPermissionStr = " You have no permission to resolve database id into database endpoint. " ;
18
+ TString MakeErrorPrefix (
19
+ const TString& host,
20
+ const TString& url,
21
+ const TString& databaseId,
22
+ const NYql::EDatabaseType& databaseType) {
23
+ TStringBuilder ss;
24
+
25
+ return TStringBuilder ()
26
+ << " Error while trying to resolve managed " << ToString (databaseType)
27
+ << " database with id " << databaseId << " via HTTP request to"
28
+ << " : endpoint '" << host << " '"
29
+ << " , url '" << url << " '"
30
+ << " : " ;
31
+ }
32
+
33
+ TString NoPermissionStr = " you have no permission to resolve database id into database endpoint." ;
19
34
20
35
struct TTestBootstrap : public TTestActorRuntime {
21
36
NConfig::TCheckpointCoordinatorConfig Settings;
@@ -114,7 +129,9 @@ Y_UNIT_TEST_SUITE(TDatabaseResolverTests) {
114
129
const TString& status,
115
130
const TString& responseBody,
116
131
const NYql::TDatabaseResolverResponse::TDatabaseDescription& description,
117
- const NYql::TIssues& issues)
132
+ const NYql::TIssues& issues,
133
+ const TString& error = " "
134
+ )
118
135
{
119
136
TTestBootstrap bootstrap;
120
137
@@ -132,7 +149,7 @@ Y_UNIT_TEST_SUITE(TDatabaseResolverTests) {
132
149
NYql::IDatabaseAsyncResolver::TDatabaseAuthMap (
133
150
{std::make_pair (requestIdAndDatabaseType, databaseAuth)}),
134
151
TString (" https://ydbc.ydb.cloud.yandex.net:8789/ydbc/cloud-prod" ),
135
- TString (" mdbGateway " ),
152
+ TString (" https://mdb.api.cloud.yandex.net:443 " ),
136
153
TString (" traceId" ),
137
154
NFq::MakeMdbEndpointGeneratorGeneric (true ))));
138
155
@@ -145,14 +162,17 @@ Y_UNIT_TEST_SUITE(TDatabaseResolverTests) {
145
162
146
163
bootstrap.WaitForBootstrap ();
147
164
148
- auto response = std::make_unique<NHttp::THttpIncomingResponse>(nullptr );
149
- response->Status = status;
150
- response->Body = responseBody;
165
+ std::unique_ptr<NHttp::THttpIncomingResponse> httpIncomingResponse;
166
+ if (!error) {
167
+ httpIncomingResponse = std::make_unique<NHttp::THttpIncomingResponse>(nullptr );
168
+ httpIncomingResponse->Status = status;
169
+ httpIncomingResponse->Body = responseBody;
170
+ }
151
171
152
172
bootstrap.Send (new IEventHandle (
153
173
processorActorId,
154
174
bootstrap.HttpProxy ,
155
- new NHttp::TEvHttpProxy::TEvHttpIncomingResponse (httpOutgoingRequest->Request , response .release (), " " )));
175
+ new NHttp::TEvHttpProxy::TEvHttpIncomingResponse (httpOutgoingRequest->Request , httpIncomingResponse .release (), error )));
156
176
157
177
NYql::TDatabaseResolverResponse::TDatabaseDescriptionMap result;
158
178
if (status == " 200" ) {
@@ -184,6 +204,36 @@ Y_UNIT_TEST_SUITE(TDatabaseResolverTests) {
184
204
);
185
205
}
186
206
207
+ Y_UNIT_TEST (Ydb_Serverless_Timeout) {
208
+ NYql::TIssues issues{
209
+ NYql::TIssue (
210
+ TStringBuilder{} << MakeErrorPrefix (
211
+ " ydbc.ydb.cloud.yandex.net:8789" ,
212
+ " /ydbc/cloud-prod/database?databaseId=etn021us5r9rhld1vgbh" ,
213
+ " etn021us5r9rhld1vgbh" ,
214
+ NYql::EDatabaseType::Ydb
215
+ ) << " Connection timeout"
216
+ )
217
+ };
218
+
219
+ Test (
220
+ NYql::EDatabaseType::Ydb,
221
+ NYql::NConnector::NApi::EProtocol::PROTOCOL_UNSPECIFIED,
222
+ " https://ydbc.ydb.cloud.yandex.net:8789/ydbc/cloud-prod/database?databaseId=etn021us5r9rhld1vgbh" ,
223
+ " " ,
224
+ " " ,
225
+ NYql::TDatabaseResolverResponse::TDatabaseDescription{
226
+ TString{" ydb.serverless.yandexcloud.net:2135" },
227
+ TString{" ydb.serverless.yandexcloud.net" },
228
+ 2135 ,
229
+ TString (" /ru-central1/b1g7jdjqd07qg43c4fmp/etn021us5r9rhld1vgbh" ),
230
+ true
231
+ },
232
+ issues,
233
+ " Connection timeout"
234
+ );
235
+ }
236
+
187
237
Y_UNIT_TEST (DataStreams_Serverless) {
188
238
Test (
189
239
NYql::EDatabaseType::DataStreams,
@@ -298,7 +348,12 @@ Y_UNIT_TEST_SUITE(TDatabaseResolverTests) {
298
348
Y_UNIT_TEST (ClickHouse_PermissionDenied) {
299
349
NYql::TIssues issues{
300
350
NYql::TIssue (
301
- TStringBuilder{} << NoPermissionStr << " Please check that your service account has role `managed-clickhouse.viewer`."
351
+ TStringBuilder{} << MakeErrorPrefix (
352
+ " mdb.api.cloud.yandex.net:443" ,
353
+ " /managed-clickhouse/v1/clusters/etn021us5r9rhld1vgbh/hosts" ,
354
+ " etn021us5r9rhld1vgbh" ,
355
+ NYql::EDatabaseType::ClickHouse
356
+ ) << NoPermissionStr << " Please check that your service account has role `managed-clickhouse.viewer`."
302
357
)
303
358
};
304
359
@@ -366,7 +421,12 @@ Y_UNIT_TEST_SUITE(TDatabaseResolverTests) {
366
421
Y_UNIT_TEST (PostgreSQL_PermissionDenied) {
367
422
NYql::TIssues issues{
368
423
NYql::TIssue (
369
- TStringBuilder{} << NoPermissionStr << " Please check that your service account has role `managed-postgresql.viewer`."
424
+ TStringBuilder{} << MakeErrorPrefix (
425
+ " mdb.api.cloud.yandex.net:443" ,
426
+ " /managed-postgresql/v1/clusters/etn021us5r9rhld1vgbh/hosts" ,
427
+ " etn021us5r9rhld1vgbh" ,
428
+ NYql::EDatabaseType::PostgreSQL
429
+ ) << NoPermissionStr << " Please check that your service account has role `managed-postgresql.viewer`."
370
430
)
371
431
};
372
432
@@ -396,7 +456,12 @@ Y_UNIT_TEST_SUITE(TDatabaseResolverTests) {
396
456
Y_UNIT_TEST (DataStreams_PermissionDenied) {
397
457
NYql::TIssues issues{
398
458
NYql::TIssue (
399
- NoPermissionStr
459
+ TStringBuilder{} << MakeErrorPrefix (
460
+ " ydbc.ydb.cloud.yandex.net:8789" ,
461
+ " /ydbc/cloud-prod/database?databaseId=etn021us5r9rhld1vgbh" ,
462
+ " etn021us5r9rhld1vgbh" ,
463
+ NYql::EDatabaseType::DataStreams
464
+ ) << NoPermissionStr
400
465
)
401
466
};
402
467
Test (
@@ -434,7 +499,7 @@ Y_UNIT_TEST_SUITE(TDatabaseResolverTests) {
434
499
std::make_pair (requestIdAndDatabaseType1, databaseAuth),
435
500
std::make_pair (requestIdAndDatabaseType2, databaseAuth)}),
436
501
TString (" https://ydbc.ydb.cloud.yandex.net:8789/ydbc/cloud-prod" ),
437
- TString (" mdbGateway " ),
502
+ TString (" https://mdb.api.cloud.yandex.net:443 " ),
438
503
TString (" traceId" ),
439
504
NFq::MakeMdbEndpointGeneratorGeneric (true ))));
440
505
@@ -481,7 +546,11 @@ Y_UNIT_TEST_SUITE(TDatabaseResolverTests) {
481
546
482
547
NYql::TIssues issues{
483
548
NYql::TIssue (
484
- TStringBuilder{} << " Cannot resolve database id (status = 404). Response body from /ydbc/cloud-prod/database?databaseId=etn021us5r9rhld1vgb1: {\" message\" :\" Database not found\" }"
549
+ TStringBuilder () << MakeErrorPrefix (
550
+ " ydbc.ydb.cloud.yandex.net:8789" ,
551
+ " /ydbc/cloud-prod/database?databaseId=etn021us5r9rhld1vgb1" ,
552
+ " etn021us5r9rhld1vgb1" ,
553
+ NYql::EDatabaseType::DataStreams)<< " \n Status: 404\n Response body: {\" message\" :\" Database not found\" }"
485
554
)
486
555
};
487
556
0 commit comments