|
5 | 5 | #include <ydb/library/yql/providers/generic/connector/libcpp/ut_helpers/connector_client_mock.h>
|
6 | 6 | #include <ydb/library/yql/providers/generic/connector/libcpp/ut_helpers/database_resolver_mock.h>
|
7 | 7 | #include <ydb/library/yql/providers/s3/actors/yql_s3_actors_factory_impl.h>
|
| 8 | +#include <ydb/public/api/protos/ydb_query.pb.h> |
| 9 | +#include <ydb/public/api/grpc/ydb_query_v1.grpc.pb.h> |
| 10 | +#include <ydb/public/sdk/cpp/src/library/grpc/client/grpc_client_low.h> |
8 | 11 | #include <ydb-cpp-sdk/client/operation/operation.h>
|
9 | 12 | #include <ydb-cpp-sdk/client/query/query.h>
|
10 | 13 | #include <ydb-cpp-sdk/client/types/status_codes.h>
|
@@ -471,5 +474,39 @@ namespace NKikimr::NKqp {
|
471 | 474 | Y_UNIT_TEST(YdbFilterPushdown) {
|
472 | 475 | TestFilterPushdown(EProviderType::Ydb);
|
473 | 476 | }
|
| 477 | + |
| 478 | + void TestFailsOnIncorrectScriptExecutionOperation(const TString& operationId, const TString& fetchToken) { |
| 479 | + auto clientMock = std::make_shared<TConnectorClientMock>(); |
| 480 | + auto databaseAsyncResolverMock = MakeDatabaseAsyncResolver(EProviderType::Ydb); |
| 481 | + auto appConfig = CreateDefaultAppConfig(); |
| 482 | + auto s3ActorsFactory = NYql::NDq::CreateS3ActorsFactory(); |
| 483 | + auto kikimr = MakeKikimrRunner(false, clientMock, databaseAsyncResolverMock, appConfig, s3ActorsFactory); |
| 484 | + |
| 485 | + // Create trash query |
| 486 | + NYdbGrpc::TGRpcClientLow clientLow; |
| 487 | + |
| 488 | + std::shared_ptr<grpc::Channel> channel; |
| 489 | + channel = grpc::CreateChannel("localhost:" + ToString(kikimr->GetTestServer().GetGRpcServer().GetPort()), grpc::InsecureChannelCredentials()); |
| 490 | + { |
| 491 | + std::unique_ptr<Ydb::Query::V1::QueryService::Stub> stub; |
| 492 | + stub = Ydb::Query::V1::QueryService::NewStub(channel); |
| 493 | + grpc::ClientContext context; |
| 494 | + Ydb::Query::FetchScriptResultsRequest request; |
| 495 | + request.set_operation_id(operationId); |
| 496 | + request.set_fetch_token(fetchToken); |
| 497 | + Ydb::Query::FetchScriptResultsResponse response; |
| 498 | + grpc::Status st = stub->FetchScriptResults(&context, request, &response); |
| 499 | + UNIT_ASSERT(st.ok()); |
| 500 | + UNIT_ASSERT_EQUAL_C(response.status(), Ydb::StatusIds::BAD_REQUEST, response); |
| 501 | + } |
| 502 | + } |
| 503 | + |
| 504 | + Y_UNIT_TEST(TestFailsOnIncorrectScriptExecutionOperationId) { |
| 505 | + TestFailsOnIncorrectScriptExecutionOperation("trash", ""); |
| 506 | + } |
| 507 | + |
| 508 | + Y_UNIT_TEST(TestFailsOnIncorrectScriptExecutionFetchToken) { |
| 509 | + TestFailsOnIncorrectScriptExecutionOperation("", "trash"); |
| 510 | + } |
474 | 511 | }
|
475 | 512 | }
|
0 commit comments