@@ -1838,11 +1838,11 @@ Y_UNIT_TEST_SUITE(Viewer) {
1838
1838
1839
1839
TString PostExecuteScript (TKeepAliveHttpClient& httpClient, TString query) {
1840
1840
TStringStream requestBody;
1841
- requestBody
1842
- << " { \" database\ " : \ " /Root\" , "
1843
- << " \" script_content\ " : {"
1844
- << " \" text \" : \" " << query << " \" }, "
1845
- << " \" exec_mode \" : \" EXEC_MODE_EXECUTE \ " }" ;
1841
+ requestBody << R"json( {
1842
+ " database": "/Root",
1843
+ " script_content": { "text": " )json" << query << R"json( " },
1844
+ "exec_mode": "EXEC_MODE_EXECUTE",
1845
+ "stats_mode": "STATS_MODE_FULL " })json " ;
1846
1846
TStringStream responseStream;
1847
1847
TKeepAliveHttpClient::THeaders headers;
1848
1848
headers[" Content-Type" ] = " application/json" ;
@@ -1867,6 +1867,22 @@ Y_UNIT_TEST_SUITE(Viewer) {
1867
1867
<< " &database=%2FRoot" , &responseStream, headers);
1868
1868
const TString response = responseStream.ReadAll ();
1869
1869
UNIT_ASSERT_EQUAL_C (statusCode, HTTP_OK, statusCode << " : " << response);
1870
+
1871
+ return response;
1872
+ }
1873
+
1874
+ TString ListOperations (TKeepAliveHttpClient& httpClient) {
1875
+ TStringStream requestBody;
1876
+ TStringStream responseStream;
1877
+ TKeepAliveHttpClient::THeaders headers;
1878
+ headers[" Content-Type" ] = " application/json" ;
1879
+ headers[" Authorization" ] = " test_ydb_token" ;
1880
+ const TKeepAliveHttpClient::THttpCode statusCode = httpClient.DoGet (TStringBuilder ()
1881
+ << " /operation/list?timeout=600000&kind=scriptexec"
1882
+ << " &database=%2FRoot" , &responseStream, headers);
1883
+ const TString response = responseStream.ReadAll ();
1884
+ UNIT_ASSERT_EQUAL_C (statusCode, HTTP_OK, statusCode << " : " << response);
1885
+
1870
1886
return response;
1871
1887
}
1872
1888
@@ -1927,6 +1943,14 @@ Y_UNIT_TEST_SUITE(Viewer) {
1927
1943
response = GetOperation (httpClient, id);
1928
1944
NJson::ReadJsonTree (response, &jsonCfg, &json, /* throwOnError = */ true );
1929
1945
UNIT_ASSERT_EQUAL_C (json[" issues" ].GetArray ().size (), 0 , response);
1946
+ UNIT_ASSERT_C (json.GetMap ().contains (" metadata" ), response);
1947
+ UNIT_ASSERT_C (json[" metadata" ].GetMap ().contains (" exec_stats" ), response);
1948
+ UNIT_ASSERT_C (json[" metadata" ].GetMap ().at (" exec_stats" ).GetMap ().contains (" process_cpu_time_us" ), response);
1949
+
1950
+ response = ListOperations (httpClient);
1951
+ NJson::ReadJsonTree (response, &jsonCfg, &json, /* throwOnError = */ true );
1952
+ UNIT_ASSERT_EQUAL_C (json[" operations" ].GetArray ().size (), 1 , response);
1953
+ UNIT_ASSERT_EQUAL_C (json[" operations" ].GetArray ()[0 ][" id" ], id, response);
1930
1954
1931
1955
response = GetFetchScript (httpClient, id);
1932
1956
NJson::ReadJsonTree (response, &jsonCfg, &json, /* throwOnError = */ true );
0 commit comments