|
36 | 36 | #include <ydb/library/folder_service/folder_service.h>
|
37 | 37 | #include <ydb/core/ymq/actor/serviceid.h>
|
38 | 38 |
|
| 39 | +#include <thread> |
39 | 40 |
|
40 | 41 | using TJMap = NJson::TJsonValue::TMapType;
|
41 | 42 | using TJVector = NJson::TJsonValue::TArray;
|
@@ -335,6 +336,107 @@ class THttpProxyTestMock : public NUnitTest::TBaseFixture {
|
335 | 336 | return {httpCode, "", ""};
|
336 | 337 | }
|
337 | 338 |
|
| 339 | + NJson::TJsonMap CreateQueue(NJson::TJsonMap request, ui32 expectedHttpCode = 200) { |
| 340 | + auto res = SendHttpRequest("/Root", "AmazonSQS.CreateQueue", request, FormAuthorizationStr("ru-central1")); |
| 341 | + UNIT_ASSERT_VALUES_EQUAL(res.HttpCode, expectedHttpCode); |
| 342 | + NJson::TJsonMap json; |
| 343 | + UNIT_ASSERT(NJson::ReadJsonTree(res.Body, &json, true)); |
| 344 | + if (expectedHttpCode == 200) { |
| 345 | + UNIT_ASSERT(GetByPath<TString>(json, "QueueUrl").EndsWith(GetByPath<TString>(request, "QueueName"))); |
| 346 | + } |
| 347 | + return json; |
| 348 | + } |
| 349 | + |
| 350 | + NJson::TJsonMap DeleteQueue(NJson::TJsonMap request, ui32 expectedHttpCode = 200) { |
| 351 | + auto res = SendHttpRequest("/Root", "AmazonSQS.DeleteQueue", request, FormAuthorizationStr("ru-central1")); |
| 352 | + UNIT_ASSERT_VALUES_EQUAL(res.HttpCode, expectedHttpCode); |
| 353 | + NJson::TJsonMap json; |
| 354 | + UNIT_ASSERT(NJson::ReadJsonTree(res.Body, &json)); |
| 355 | + return json; |
| 356 | + } |
| 357 | + |
| 358 | + NJson::TJsonMap GetQueueAttributes(NJson::TJsonMap request, ui32 expectedHttpCode = 200) { |
| 359 | + auto res = SendHttpRequest("/Root", "AmazonSQS.GetQueueAttributes", request, FormAuthorizationStr("ru-central1")); |
| 360 | + UNIT_ASSERT_VALUES_EQUAL(res.HttpCode, expectedHttpCode); |
| 361 | + NJson::TJsonMap json; |
| 362 | + UNIT_ASSERT(NJson::ReadJsonTree(res.Body, &json)); |
| 363 | + return json; |
| 364 | + } |
| 365 | + |
| 366 | + NJson::TJsonMap SendMessage(NJson::TJsonMap request, ui32 expectedHttpCode = 200) { |
| 367 | + auto res = SendHttpRequest("/Root", "AmazonSQS.SendMessage", request, FormAuthorizationStr("ru-central1")); |
| 368 | + UNIT_ASSERT_VALUES_EQUAL(res.HttpCode, expectedHttpCode); |
| 369 | + NJson::TJsonMap json; |
| 370 | + UNIT_ASSERT(NJson::ReadJsonTree(res.Body, &json)); |
| 371 | + return json; |
| 372 | + } |
| 373 | + |
| 374 | + NJson::TJsonMap ReceiveMessage(NJson::TJsonMap request, ui32 expectedHttpCode = 200) { |
| 375 | + auto res = SendHttpRequest("/Root", "AmazonSQS.ReceiveMessage", request, FormAuthorizationStr("ru-central1")); |
| 376 | + UNIT_ASSERT_VALUES_EQUAL(res.HttpCode, expectedHttpCode); |
| 377 | + NJson::TJsonMap json; |
| 378 | + UNIT_ASSERT(NJson::ReadJsonTree(res.Body, &json)); |
| 379 | + return json; |
| 380 | + } |
| 381 | + |
| 382 | + NJson::TJsonMap DeleteMessage(NJson::TJsonMap request, ui32 expectedHttpCode = 200) { |
| 383 | + auto res = SendHttpRequest("/Root", "AmazonSQS.DeleteMessage", request, FormAuthorizationStr("ru-central1")); |
| 384 | + UNIT_ASSERT_VALUES_EQUAL(res.HttpCode, expectedHttpCode); |
| 385 | + NJson::TJsonMap json; |
| 386 | + UNIT_ASSERT(NJson::ReadJsonTree(res.Body, &json)); |
| 387 | + return json; |
| 388 | + } |
| 389 | + |
| 390 | + NJson::TJsonMap GetQueueUrl(NJson::TJsonMap request, ui32 expectedHttpCode = 200) { |
| 391 | + auto res = SendHttpRequest("/Root", "AmazonSQS.GetQueueUrl", request, FormAuthorizationStr("ru-central1")); |
| 392 | + UNIT_ASSERT_VALUES_EQUAL(res.HttpCode, expectedHttpCode); |
| 393 | + NJson::TJsonMap json; |
| 394 | + UNIT_ASSERT(NJson::ReadJsonTree(res.Body, &json)); |
| 395 | + return json; |
| 396 | + } |
| 397 | + |
| 398 | + NJson::TJsonMap ListQueues(NJson::TJsonMap request, ui32 expectedHttpCode = 200) { |
| 399 | + auto res = SendHttpRequest("/Root", "AmazonSQS.ListQueues", request, FormAuthorizationStr("ru-central1")); |
| 400 | + UNIT_ASSERT_VALUES_EQUAL(res.HttpCode, expectedHttpCode); |
| 401 | + NJson::TJsonMap json; |
| 402 | + UNIT_ASSERT(NJson::ReadJsonTree(res.Body, &json)); |
| 403 | + return json; |
| 404 | + } |
| 405 | + |
| 406 | + NJson::TJsonMap PurgeQueue(NJson::TJsonMap request, ui32 expectedHttpCode = 200) { |
| 407 | + auto res = SendHttpRequest("/Root", "AmazonSQS.PurgeQueue", request, FormAuthorizationStr("ru-central1")); |
| 408 | + UNIT_ASSERT_VALUES_EQUAL(res.HttpCode, expectedHttpCode); |
| 409 | + NJson::TJsonMap json; |
| 410 | + UNIT_ASSERT(NJson::ReadJsonTree(res.Body, &json)); |
| 411 | + return json; |
| 412 | + } |
| 413 | + |
| 414 | + NJson::TJsonMap SetQueueAttributes(NJson::TJsonMap request, ui32 expectedHttpCode = 200) { |
| 415 | + auto res = SendHttpRequest("/Root", "AmazonSQS.SetQueueAttributes", request, FormAuthorizationStr("ru-central1")); |
| 416 | + UNIT_ASSERT_VALUES_EQUAL(res.HttpCode, expectedHttpCode); |
| 417 | + NJson::TJsonMap json; |
| 418 | + UNIT_ASSERT(NJson::ReadJsonTree(res.Body, &json)); |
| 419 | + return json; |
| 420 | + } |
| 421 | + |
| 422 | + bool WaitQueueAttributes(TString queueUrl, size_t retries, std::function<bool (NJson::TJsonMap json)> predicate) { |
| 423 | + for (size_t i = 0; i < retries; ++i) { |
| 424 | + auto json = GetQueueAttributes({ |
| 425 | + {"QueueUrl", queueUrl}, |
| 426 | + {"AttributeNames", NJson::TJsonArray{"All"}} |
| 427 | + }); |
| 428 | + |
| 429 | + if (predicate(json)) { |
| 430 | + return true; |
| 431 | + } |
| 432 | + |
| 433 | + if (i + 1 < retries) { |
| 434 | + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); |
| 435 | + } |
| 436 | + } |
| 437 | + return false; |
| 438 | + } |
| 439 | + |
338 | 440 | private:
|
339 | 441 | TMaybe<NYdb::TResultSet> RunYqlDataQuery(TString query) {
|
340 | 442 | TString endpoint = TStringBuilder() << "localhost:" << KikimrGrpcPort;
|
@@ -476,7 +578,7 @@ class THttpProxyTestMock : public NUnitTest::TBaseFixture {
|
476 | 578 | );
|
477 | 579 |
|
478 | 580 | client.MkDir("/Root/SQS", ".FIFO");
|
479 |
| - client.CreateTable("/Root/SQS/.FIFO", |
| 581 | + client.CreateTable("/Root/SQS/.FIFO", |
480 | 582 | "Name: \"Messages\""
|
481 | 583 | "Columns { Name: \"QueueIdNumberHash\" Type: \"Uint64\"}"
|
482 | 584 | "Columns { Name: \"QueueIdNumber\" Type: \"Uint64\"}"
|
@@ -536,7 +638,7 @@ class THttpProxyTestMock : public NUnitTest::TBaseFixture {
|
536 | 638 | "KeyColumnNames: [\"Account\", \"QueueName\", \"EventType\"]"
|
537 | 639 | );
|
538 | 640 |
|
539 |
| - auto stateTableCommon = |
| 641 | + auto stateTableCommon = |
540 | 642 | "Name: \"State\""
|
541 | 643 | "Columns { Name: \"QueueIdNumberHash\" Type: \"Uint64\"}"
|
542 | 644 | "Columns { Name: \"QueueIdNumber\" Type: \"Uint64\"}"
|
@@ -580,7 +682,7 @@ class THttpProxyTestMock : public NUnitTest::TBaseFixture {
|
580 | 682 | "KeyColumnNames: [\"QueueIdNumberAndShardHash\", \"QueueIdNumber\", \"Shard\", \"Offset\"]"
|
581 | 683 | );
|
582 | 684 |
|
583 |
| - auto sentTimestampIdxCommonColumns= |
| 685 | + auto sentTimestampIdxCommonColumns= |
584 | 686 | "Columns { Name: \"QueueIdNumberAndShardHash\" Type: \"Uint64\"}"
|
585 | 687 | "Columns { Name: \"QueueIdNumber\" Type: \"Uint64\"}"
|
586 | 688 | "Columns { Name: \"Shard\" Type: \"Uint32\"}"
|
@@ -699,7 +801,7 @@ class THttpProxyTestMock : public NUnitTest::TBaseFixture {
|
699 | 801 | folderServiceConfig.SetEnable(false);
|
700 | 802 | actorId = as->Register(NKikimr::NFolderService::CreateFolderServiceActor(folderServiceConfig, "cloud4"));
|
701 | 803 | as->RegisterLocalService(NFolderService::FolderServiceActorId(), actorId);
|
702 |
| - |
| 804 | + |
703 | 805 | actorId = as->Register(NKikimr::NFolderService::CreateFolderServiceActor(folderServiceConfig, "cloud4"));
|
704 | 806 | as->RegisterLocalService(NSQS::MakeSqsFolderServiceID(), actorId);
|
705 | 807 |
|
|
0 commit comments