ATLAS Offline Software
crest_example.cxx
Go to the documentation of this file.
1 
10 #include <iostream>
11 #include <fstream>
12 #include <iomanip>
13 #include <nlohmann/json.hpp>
14 
15 #include <CrestApi/CrestApiExt.h>
16 #include <filesystem>
17 
18 #include <CrestApi/picosha2.h>
19 
20 
23 
24 using namespace Crest;
25 
26 using namespace std;
27 std::string SURL = "http://crest-01.cern.ch:8090";
28 
29 void print_path() {
30  std::cout << SURL << std::endl;
31 }
32 
33 bool createDirTree(const std::string& full_path) {
34  size_t pos = 0;
35  bool ret_val = true;
36 
37  while (ret_val == true && pos != std::string::npos) {
38  pos = full_path.find('/', pos + 1);
39  ret_val = std::filesystem::create_directory(full_path.substr(0, pos));
40  }
41 
42  return ret_val;
43 }
44 
45 //===================================================
46 // Tag Method Tests
47 //===================================================
48 
49 void testCreateTag(const std::string& tagname) {
50  std::cout << std::endl << "test: createTag" << std::endl;
51  CrestClient myCrestClient = CrestClient(SURL,false);
52 
53  nlohmann::json js =
54  {
55  {"description", "none"},
56  {"endOfValidity", 0},
57  {"insertionTime", "2018-12-06T11:18:35.641+0000"},
58  {"lastValidatedTime", 0},
59  {"modificationTime", "2018-12-06T11:18:35.641+0000"},
60  {"name", tagname},
61  {"payloadSpec", "stave: Int32, eta: Int32, mag: Float, base: Float, free: Float"},
62  {"synchronization", "none"},
63  {"timeType", "time"}
64  };
65 
66  try{
67  myCrestClient.createTag(js);
68  std::cout << std::endl << "test: createTag (success)" << std::endl;
69  }
70  catch (const std::exception& e) {
71  std::cout << std::endl << "test: createTag (failed)" << std::endl;
72  std::cout << e.what() << std::endl;
73  }
74 }
75 
77  std::cout << std::endl << "test: createTag2" << std::endl;
78  CrestClient myCrestClient = CrestClient(SURL,false);
79 
80  // real tag creation example:
81  // curl --header "Content-Type: application/json" --request POST --data
82  // '{"name":"CaloSwClusterCorrections.00-RUN2-02-11-clcon-dummy","description":"<timeStamp>run-lumi</timeStamp><addrHeader><address_header
83  // service_type=\"71\" clid=\"250904980\"
84  // /></addrHeader><typeName>CaloRec::ToolConstants</typeName><fullrep/>","timeType":"run-lumi","payloadSpec":"PoolRef:String4k"}'
85  // http://crest-01.cern.ch:8090/crestapi/tags
86 
87  nlohmann::json js =
88  {
89  {"name", "CaloSwClusterCorrections.00-RUN2-02-11-clcon-dummy"},
90  {"description",
91  "<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"250904980\" /></addrHeader><typeName>CaloRec::ToolConstants</typeName><fullrep/>"},
92  {"timeType", "run-lumi"},
93  {"payloadSpec", "PoolRef:String4k"}
94  };
95 
96  try{
97  myCrestClient.createTag(js);
98  std::cout << std::endl << "test: createTag2 (success)" << std::endl;
99  }
100  catch (const std::exception& e) {
101  std::cout << std::endl << "test: createTag2 (failed)" << std::endl;
102  std::cout << e.what() << std::endl;
103  }
104 }
105 
106 // Method to create a tag on the local storage (on disk).
107 
108 void testCreateTagF(const std::string& tagname) {
109  std::cout << std::endl << "test: createTagF" << std::endl;
110 
111  bool rewrite = true;
112  std::string path = "/tmp/cresttest/crest_dump";
114  std::filesystem::create_directories(path);
115  CrestClient myCrestClient = CrestClient(rewrite, path);
116 
117  nlohmann::json js =
118  {
119  {"description", "none"},
120  {"endOfValidity", 0},
121  {"insertionTime", "2018-12-06T11:18:35.641+0000"},
122  {"lastValidatedTime", 0},
123  {"modificationTime", "2018-12-06T11:18:35.641+0000"},
124  {"name", tagname},
125  {"payloadSpec", "stave: Int32, eta: Int32, mag: Float, base: Float, free: Float"},
126  {"synchronization", "none"},
127  {"timeType", "time"}
128  };
129 
130  try{
131  myCrestClient.createTag(js);
132  std::cout << std::endl << "test: createTagF (success)" << std::endl;
133  }
134  catch (const std::exception& e) {
135  std::cout << std::endl << "test: createTagF (failed)" << std::endl;
136  std::cout << e.what() << std::endl;
137  }
138 }
139 
140 void testListTags() {
141  std::cout << std::endl << "test: listTag" << std::endl;
142  CrestClient myCrestClient = CrestClient(SURL,false);
143 
144  try {
145  nlohmann::json tag_list = myCrestClient.listTags();
146  std::cout << std::endl << "test: listTags (result) =" << std::endl
147  << tag_list.dump(4) << std::endl;
148  }
149  catch (const std::exception& e) {
150  std::cout << std::endl << "test: listTags (failed)" << std::endl;
151  std::cout << e.what() << std::endl;
152  }
153 }
154 
156  std::cout << std::endl << "test: listTagsParams" << std::endl;
157  CrestClientExt myCrestClient = CrestClientExt(SURL);
158 
159  try{
160  // variants how to call this method:
161  // myCrestClient.listTagsParams();
162  // nlohmann::json res = myCrestClient.listTagsParams(100,200);
163 
164  nlohmann::json res = myCrestClient.listTagsParams(_page = 3, _size = 5);
165 
166  std::cout << std::endl << "test: listTagsParams (result) ="
167  << "result = " << res.dump(4) << std::endl;
168  }
169  catch (const std::exception& e) {
170  std::cout << std::endl << "test: listTagsParams (failed)" << std::endl;
171  std::cerr << e.what() << std::endl;
172  }
173 }
174 
175 void testListTagsParams(const std::string& name) {
176  std::cout << std::endl << "test: listTagsParams" << std::endl;
177  CrestClientExt myCrestClient = CrestClientExt(SURL);
178 
179  try{
180  // variants how to call this method:
181  // nlohmann::json res = myCrestClient.listTagsParams();
182  // nlohmann::json res = myCrestClient.listTagsParams("",100,200);
183 
184  nlohmann::json res1 = myCrestClient.listTagsParams(_page = 3, _size = 5);
185 
186  std::cout << "test: listTagsParams (A) = "
187  << std::endl << res1.dump(4) << std::endl;
188 
189  nlohmann::json res2 = myCrestClient.listTagsParams(_name = name, _page = 0, _size = 5);
190 
191  std::cout << "test: listTagsParams (B) = "
192  << std::endl << res2.dump(4) << std::endl;
193  }
194  catch (const std::exception& e) {
195  std::cout << std::endl << "test: listTagsParams (failed)" << std::endl;
196  std::cerr << e.what() << std::endl;
197  }
198 }
199 
200 void testFindTag(const std::string& tagname) {
201  std::cout << std::endl << "test: findTag" << std::endl;
202  CrestClient myCrestClient = CrestClient(SURL,false);
203 
204  try {
205  nlohmann::json tag_info = myCrestClient.findTag(tagname);
206  std::cout << std::endl << "test: findTag (result) =" << std::endl
207  << tag_info.dump(4) << std::endl;
208  }
209  catch (const std::exception& e) {
210  std::cout << std::endl << "test: findTag (failed)" << std::endl;
211  std::cout << e.what() << std::endl;
212  }
213 }
214 
215 void testRemoveTag(const std::string& tagname) {
216  std::cout << std::endl << "test: removeTag" << std::endl;
217  CrestClient myCrestClient = CrestClient(SURL,false);
218 
219  try {
220  myCrestClient.removeTag(tagname);
221  std::cout << std::endl << "test: removeTag (success)" << std::endl;
222  }
223  catch (const std::exception& e) {
224  std::cout << std::endl << "test: removeTag (failed)" << std::endl;
225  std::cout << e.what() << std::endl;
226  }
227 }
228 
229 void testUpdateTag(const std::string& tagname) {
230  std::cout << std::endl << "test: updateTag" << std::endl;
231  CrestClient myCrestClient = CrestClient(SURL,false);
232 
233  nlohmann::json js = {{"objectType", "json3"},
234  {"description", "test"}};
235 
236  try{
237  myCrestClient.updateTag(tagname, js);
238  std::cout << std::endl << "test: updateTag (success)" << std::endl;
239  }
240  catch (const std::exception& e) {
241  std::cout << std::endl << "test: updateTag (failed)" << std::endl;
242  std::cout << e.what() << std::endl;
243  }
244 }
245 
246 void testUpdateTagSpecification(const std::string& tagname) {
247  std::cout << std::endl << "test: updateTagSpecification" << std::endl;
248  CrestClient myCrestClient = CrestClient(SURL,false);
249 
250  std::string newObjectType = "json4";
251 
252  try{
253  myCrestClient.updateTagSpecification(tagname, newObjectType);
254  std::cout << std::endl << "test: updateTagSpecification (success)" << std::endl;
255  }
256  catch (const std::exception& e) {
257  std::cout << std::endl << "test: updateTagSpecification (failed)" << std::endl;
258  std::cout << e.what() << std::endl;
259  }
260 }
261 
262 //===================================================
263 // Global Tag Method Tests
264 //===================================================
265 
266 void testCreateGlobalTag(const std::string& tagname) {
267  std::cout << std::endl << "test: createGlobalTag" << std::endl;
268  CrestClient myCrestClient = CrestClient(SURL,false);
269 
270  nlohmann::json js =
271  {
272  {"name", tagname},
273  {"validity", 0},
274  {"description", "test"},
275  {"release", "1"},
276  {"insertionTime", "2018-12-18T11:32:58.081+0000"},
277  {"snapshotTime", "2018-12-18T11:32:57.952+0000"},
278  {"scenario", "test"},
279  {"workflow", "M"},
280  {"type", "t"},
281  {"snapshotTimeMilli", "null"},
282  {"insertionTimeMilli", "null"}
283  };
284 
285  try {
286  myCrestClient.createGlobalTag(js);
287  std::cout << std::endl << "test: createGlobalTag (success) " << std::endl;
288  }
289  catch (const std::exception& e) {
290  std::cout << std::endl << "test: createGlobalTag (failed)" << std::endl;
291  std::cout << e.what() << std::endl;
292  }
293 }
294 
295 void testFindGlobalTag(const std::string& tagname) {
296  std::cout << std::endl << "test: findGlobalTag" << std::endl;
297  CrestClient myCrestClient = CrestClient(SURL,false);
298 
299  try {
300  nlohmann::json tag_info = myCrestClient.findGlobalTag(tagname);
301  std::cout << std::endl << "test: findGlobalTag (result) = " << std::endl
302  << tag_info.dump(4) << std::endl;
303  }
304  catch (const std::exception& e) {
305  std::cout << std::endl << "test: findGlobalTag (failed)" << std::endl;
306  std::cout << e.what() << std::endl;
307  }
308 }
309 
311  std::cout << std::endl << "test: listGlobalTags" << std::endl;
312  CrestClient myCrestClient = CrestClient(SURL,false);
313 
314  try{
315  nlohmann::json tag_info9 = myCrestClient.listGlobalTags();
316  std::cout << std::endl << "test: listGlobalTags (result) = "
317  << tag_info9.dump(4) << std::endl;
318  }
319  catch (const std::exception& e) {
320  std::cout << std::endl << "test: listGlobalTags (failed)" << std::endl;
321  std::cout << e.what() << std::endl;
322  }
323 }
324 
326  std::cout << std::endl << "test: listGlobalTagsAsString" << std::endl;
327  CrestClient myCrestClient = CrestClient(SURL,false);
328 
329  try{
330  nlohmann::json tag_info9 = myCrestClient.listGlobalTagsAsString();
331  std::cout << std::endl << "test: listGlobalTagsAsString (result) = "
332  << tag_info9.dump(4) << std::endl;
333  }
334  catch (const std::exception& e) {
335  std::cout << std::endl << "test: listGlobalTagsAsString (failed)" << std::endl;
336  std::cout << e.what() << std::endl;
337  }
338 }
339 
340 void testListGlobalTagsParams(const std::string& name, int size, int page) {
341  std::cout << std::endl << "test: listGlobalTagsParams with additional parameters" << std::endl;
342  CrestClientExt myCrestClient = CrestClientExt(SURL);
343 
344  try{
345  nlohmann::json list_1 = myCrestClient.listGlobalTagsParams(name, size, page);
346  nlohmann::json list_2 = myCrestClient.listGlobalTagsParams(_name = name, _size = size, _page = page);
347  nlohmann::json list_3 = myCrestClient.listGlobalTagsParams(_name = "", _size = size, _page = page);
348 
349 
350  std::cout << std::endl << "test: listGlobalTagsParams (result A) =" << std::endl;
351  std::cout << list_1.dump(4) << std::endl;
352 
353 
354  std::cout << std::endl << "test: listGlobalTagsParams (result B) =" << std::endl;
355  std::cout << list_2.dump(4) << std::endl;
356 
357 
358  std::cout << std::endl << "test: listGlobalTagsParams (result C) =" << std::endl;
359  std::cout << list_3.dump(4) << std::endl;
360  }
361  catch (const std::exception& e) {
362  std::cout << std::endl << "test: listGlobalTagsParams with additional parameters (failed)" << std::endl;
363  std::cerr << e.what() << std::endl;
364  }
365 }
366 
367 void testRemoveGlobalTag(const std::string& tagname) {
368  std::cout << std::endl << "test: removeGlobalTag" << std::endl;
369  CrestClient myCrestClient = CrestClient(SURL,false);
370 
371  try{
372  myCrestClient.removeGlobalTag(tagname);
373  std::cout << std::endl << "test: removeGlobalTag (success)" << std::endl;
374  }
375  catch (const std::runtime_error& e) {
376  std::cout << std::endl << "test: removeGlobalTag (failed)" << std::endl;
377  }
378 }
379 
380 void testUpdateGlobalTag(const std::string& tagname) {
381  std::cout << std::endl << "test: updateGlobalTag" << std::endl;
382  CrestClient myCrestClient = CrestClient(SURL,false);
383 
384  nlohmann::json js =
385  {
386  {"name", tagname},
387  {"validity", 0},
388  {"description", "test"},
389  {"release", "1"},
390  {"insertionTime", "2018-12-18T11:32:58.081+0000"},
391  {"snapshotTime", "2018-12-18T11:32:57.952+0000"},
392  {"scenario", "test2"},
393  {"workflow", "M"},
394  {"type", "t"},
395  {"snapshotTimeMilli", "null"},
396  {"insertionTimeMilli", "null"}
397  };
398 
399  try {
400  myCrestClient.updateGlobalTag(tagname, js);
401  std::cout << std::endl << "test: updateGlobalTag (success) " << std::endl;
402  }
403  catch (const std::exception& e) {
404  std::cout << std::endl << "test: updateGlobalTag (failed)" << std::endl;
405  std::cout << e.what() << std::endl;
406  }
407 }
408 
409 void testFindGlobalTagAsString(const std::string& tagname) {
410  std::cout << std::endl << "test: findGlobalTagAsString" << std::endl;
411  CrestClient myCrestClient = CrestClient(SURL,false);
412 
413  try {
414  nlohmann::json tag_info = myCrestClient.findGlobalTagAsString(tagname);
415  std::cout << std::endl << "test: findGlobalTagAsString (result) = " << std::endl
416  << tag_info.dump(4) << std::endl;
417  }
418  catch (const std::exception& e) {
419  std::cout << std::endl << "test: findGlobalTagAsString (failed)" << std::endl;
420  std::cout << e.what() << std::endl;
421  }
422 }
423 
424 //===================================================
425 // RunLumiInfo Method Tests
426 //===================================================
427 
429  std::cout << std::endl << "test: createRunLumiInfo" << std::endl;
430  CrestClient myCrestClient = CrestClient(SURL,false);
431 
432  std::string str =
433  "{\"since\":\"10\",\"run\":\"7777771\",\"lb\":\"62\",\"starttime\":\"10\",\"endtime\":\"200\"}";
434  nlohmann::json js = myCrestClient.getJson(str);
435  std::cout << "run-lumi = " << std::endl
436  << js.dump(4) << std::endl;
437 
438  try{
439  myCrestClient.createRunLumiInfo(js);
440  std::cout << std::endl << "test: createRunLumiInfo (success) = " << std::endl;
441  }
442  catch (const std::exception& e) {
443  std::cout << std::endl << "test: createRunLumiInfo (failed)" << std::endl;
444  std::cout << e.what() << std::endl;
445  }
446 }
447 
449  std::cout << std::endl << "test: createRunLumiInfo2" << std::endl;
450  CrestClient myCrestClient = CrestClient(SURL,false);
451 
452  nlohmann::json jsRes =
453  {
454  {"since", 0},
455  {"runNumber", 0},
456  {"lb", 0},
457  {"starttime", 0},
458  {"endtime", 10}
459  };
460 
461  nlohmann::json jsFilter =
462  {
463  {"name", "test"},
464  {"additionalProp1", "test1"},
465  {"additionalProp2", "test2"},
466  {"additionalProp3", "test3"}
467  };
468 
469  nlohmann::json jsPage =
470  {
471  {"size", 10},
472  {"totalElements", 0},
473  {"totalPages", 0},
474  {"number", 0}
475  };
476 
478  jsRes
479  };
480 
481  nlohmann::json jsRM =
482  {
483  {"size", 1},
484  {"datatype", "string"},
485  {"format", "RunLumiSetDto"},
486  {"page", jsPage},
487  {"filter", jsFilter},
488  {"resources", res}
489  };
490 
491  std::cout << "run-lumi = " << std::endl
492  << jsRM.dump(4) << std::endl;
493 
494  try{
495  myCrestClient.createRunLumiInfo(jsRM);
496  std::cout << std::endl << "test: createRunLumiInfo (success)" << std::endl;
497  }
498  catch (const std::exception& e) {
499  std::cout << std::endl << "test: createRunLumiInfo (failed)" << std::endl;
500  std::cout << e.what() << std::endl;
501  }
502 }
503 
505  std::cout << std::endl << "test: listRunLumiInfo" << std::endl;
506  CrestClient myCrestClient = CrestClient(SURL,false);
507 
508  try{
509  nlohmann::json info16 = myCrestClient.listRunLumiInfo();
510  std::cout << std::endl << "test: listRunLumiInfo (success) = " << std::endl;
511  std::cout << info16.dump(4) << std::endl;
512  }
513  catch (const std::exception& e) {
514  std::cout << std::endl << "test: listRunLumiInfo (failed)" << std::endl;
515  std::cout << e.what() << std::endl;
516  }
517 }
518 
519 //===================================================
520 // Global Tag Map Method Tests
521 //===================================================
522 
523 void testFindGlobalTagMap(const std::string& mapname) {
524  std::cout << std::endl << "test: findGlobalTagMap" << std::endl;
525  CrestClient myCrestClient = CrestClient(SURL,false);
526 
527  try{
528  nlohmann::json tag_info = myCrestClient.findGlobalTagMap(mapname);
529  std::cout << std::endl << "test: findGlobalTagMap (result) = "
530  << tag_info.dump(4) << std::endl;
531  }
532  catch (const std::exception& e) {
533  std::cout << std::endl << "test: findGlobalTagMap (failed)" << std::endl;
534  std::cout << e.what() << std::endl;
535  }
536 }
537 
538 // global tag and tag have to exist
539 void testCreateGlobalTagMap(const std::string& globaltag, const std::string& tagname) {
540  std::cout << std::endl << "test: createGlobalTagMap" << std::endl;
541  CrestClient myCrestClient = CrestClient(SURL,false);
542 
543  nlohmann::json js =
544  {
545  {"globalTagName", globaltag},
546  {"record", "testing2"},
547  {"label", "test2"},
548  {"tagName", tagname}
549  };
550 
551  try{
552  myCrestClient.createGlobalTagMap(js);
553  std::cout << std::endl << "test: createGlobalTagMap (success) " << std::endl;
554  }
555  catch (const std::exception& e) {
556  std::cout << std::endl << "test: createGlobalTagMap (failed)" << std::endl;
557  std::cout << e.what() << std::endl;
558  }
559 }
560 
561 //===================================================
562 // Auxillary Method Tests
563 //===================================================
564 
565 void testGetJson() {
566  std::cout << std::endl << "test: getJson" << std::endl;
567  CrestClient myCrestClient = CrestClient(SURL,false);
568 
569  std::string stra =
570  "{\"tagName\":\"IndetBeampos-nominal\",\"since\":0,\"insertionTime\":\"2019-02-21T13:52:06.222+0000\",\"payloadHash\":\"de9afd9a5bb526d175265d1e66520ac1e7a81816cc3081925625759583e9107f\"}";
571  std::string strb = "test";
572 
573  try{
574  std::cout << myCrestClient.getJson(stra).dump(4) << std::endl;
575  }
576  catch (const std::exception& e) {
577  std::cout << std::endl << "test: getJson for string stra (failed)" << std::endl;
578  std::cout << e.what() << std::endl;
579  }
580 
581  try{
582  std::cout << myCrestClient.getJson(strb).dump(4) << std::endl;
583  }
584  catch (const std::exception& e) {
585  std::cout << std::endl << "test: getJson for string strb (failed)" << std::endl;
586  std::cout << e.what() << std::endl;
587  }
588 
589  std::cout << "getJson test ended" << std::endl;
590 }
591 
592 //===================================================
593 // Tag + Payloads Method Tests
594 //===================================================
595 
596 // Be carrful tag has to be creted before this test!
597 void testStorePayload(const std::string& tagname) {
598  std::cout << std::endl << "test: storePayload" << std::endl;
599  CrestClient myCrestClient = CrestClient(SURL,false);
600 
601  // payload + tag name (command line example):
602  // curl --form file=@./test.txt --form tag="SB_TAG-PYLD" --form since=0
603  // http://mvg-test-pc-03.cern.ch:8090/crestapi/payloads/store
604 
605  uint64_t since = 0;
606  std::string payload = "aaa";
607 
608 
609  try{
610  myCrestClient.storePayload(tagname, since, payload);
611  std::cout << std::endl << "test: storePayload (success)" << std::endl;
612  }
613  catch (const std::exception& e) {
614  std::cout << std::endl << "test: storePayload (failed)" << std::endl;
615  std::cout << e.what() << std::endl;
616  }
617 }
618 
619 // This test for the local file storage method storePayloadDump.
620 
621 void testStorePayloadDump(const std::string& tagname) {
622  std::cout << std::endl << "test: storePayloadDump" << std::endl;
623  bool rewrite = true;
624  std::string path = "/tmp/cresttest/crest_dump";
625  std::filesystem::create_directories(path);
626  CrestClient myCrestClient = CrestClient(rewrite, path);
627 
628  uint64_t since = 200;
629 
630 
631  std::string str =
632  "{\"niovs\": 2,\"format\":\"PYLD_JSON\",\"iovsList\":[{\"since\":800,\"payload\":\"vv1\"},{\"since\":900,\"payload\":\"ww1\"}]}";
633 
634  nlohmann::json js = myCrestClient.getJson(str);
635 
636  try {
637  myCrestClient.storePayloadDump(tagname, since, str);
638  std::cout << std::endl << "test: storePayloadDump (success) " << std::endl;
639  }
640  catch (const std::exception& e) {
641  std::cout << std::endl << "test: storePayloadDump (failed)" << std::endl;
642  std::cout << e.what() << std::endl;
643  }
644 }
645 
646 //===================================================
647 // IOV List Method Tests
648 //===================================================
649 
650 void testFindAllIovs(const std::string& tagname) {
651  std::cout << std::endl << "test: findAllIovs" << std::endl;
652  CrestClient myCrestClient = CrestClient(SURL,false);
653 
654  try{
655  nlohmann::json tag_info = myCrestClient.findAllIovs(tagname);
656  std::cout << std::endl << "test: findAllIovs (result) =" << std::endl;
657  std::cout << tag_info.dump(4) << std::endl;
658  }
659  catch (const std::exception& e) {
660  std::cout << std::endl << "test: findAllIovs (failed)" << std::endl;
661  std::cerr << e.what() << std::endl;
662  }
663 }
664 
665 void testFindAllIovsParams(const std::string& tagname, int size, int page) {
666  std::cout << std::endl << "test: findAllIovs with additional parameters" << std::endl;
667  CrestClientExt myCrestClient = CrestClientExt(SURL);
668 
669  try{
670  nlohmann::json iov_list_1 = myCrestClient.findAllIovsParams(tagname, size, page);
671  nlohmann::json iov_list_2 = myCrestClient.findAllIovsParams(tagname, _page = page, _size = size);
672 
673  std::cout << std::endl << "test: findAllIovs (result A) =" << std::endl;
674  std::cout << iov_list_1.dump(4) << std::endl;
675 
676  std::cout << std::endl << "test: findAllIovs (result B) =" << std::endl;
677  std::cout << iov_list_2.dump(4) << std::endl;
678  }
679  catch (const std::exception& e) {
680  std::cout << std::endl << "test: findAllIovs with additional parameters (failed)" << std::endl;
681  std::cerr << e.what() << std::endl;
682  }
683 }
684 
685 void testFindAllIovsFS(const std::string& tagname) {
686  std::cout << std::endl << "test: findAllIovsFS" << std::endl;
687 
688  CrestClient myCrestClient = CrestClient(true);
689 
690  try{
691  nlohmann::json tag_info = myCrestClient.findAllIovsFs(tagname);
692  std::cout << std::endl << "test: findAllIovsFS (result) =" << std::endl;
693  std::cout << tag_info.dump(4) << std::endl;
694  }
695  catch (const std::exception& e) {
696  std::cout << std::endl << "test: findAllIovsFS (failed)" << std::endl;
697  std::cerr << e.what() << std::endl;
698  }
699 }
700 
701 // test to check a method with additional parametrs:
702 
703 void testFindAllIovsFSPlus(const std::string& tagname, int size, int page) {
704  std::cout << std::endl << "test: findAllIovsFSPlus" << std::endl;
705  CrestClient myCrestClient = CrestClient(true);
706 
707  try{
708  nlohmann::json tag_info = myCrestClient.findAllIovsFs(tagname, size, page);
709  std::cout << std::endl << "test: findAllIovsFSPlus (result) =" << std::endl;
710  std::cout << tag_info.dump(4) << std::endl;
711  }
712  catch (const std::exception& e) {
713  std::cout << std::endl << "test: findAllIovsFSPlus (failed)" << std::endl;
714  std::cerr << e.what() << std::endl;
715  }
716 }
717 
718 void testSelectIovsParams(const std::string& tagname, long since, long until) {
719  std::cout << std::endl << "test: selectIovs with additional parameters" << std::endl;
720  CrestClientExt myCrestClient = CrestClientExt(SURL);
721 
722  try{
723  nlohmann::json iov_list_1 = myCrestClient.selectIovs(tagname, since, until);
724  nlohmann::json iov_list_2 = myCrestClient.selectIovs(tagname, since, -1);
725 
726  std::cout << std::endl << "test: selectIovs (result A) =" << std::endl;
727  std::cout << iov_list_1.dump(4) << std::endl;
728 
729  std::cout << std::endl << "test: selectIovs (result B) =" << std::endl;
730  std::cout << iov_list_2.dump(4) << std::endl;
731 
732  std::cout << "result A size = " << iov_list_1.size() << std::endl;
733  std::cout << "result B size = " << iov_list_2.size() << std::endl;
734  }
735  catch (const std::exception& e) {
736  std::cout << std::endl << "test: selectIovs with additional parameters (failed)" << std::endl;
737  std::cerr << e.what() << std::endl;
738  }
739 }
740 
741 void testSelectIovsFS(const std::string& tagname, long since, long until) {
742  std::cout << std::endl << "test: selectIovsFS with additional parameters" << std::endl;
743  CrestClient myCrestClient = CrestClient(true);
744 
745  try{
746  nlohmann::json iov_list = myCrestClient.selectIovsFS(tagname, since, until);
747 
748  std::cout << std::endl << "test: selectIovs =" << std::endl;
749  std::cout << iov_list.dump(4) << std::endl;
750 
751  std::cout << "result size = " << iov_list.size() << std::endl;
752  }
753  catch (const std::exception& e) {
754  std::cout << std::endl << "test: selectIovsFS with additional parameters (failed)" << std::endl;
755  std::cerr << e.what() << std::endl;
756  }
757 }
758 
759 void testSelectIovs(const std::string& tagname) {
760  std::cout << std::endl << "test: selectIovs" << std::endl;
761  CrestClient myCrestClient = CrestClient(SURL,false);
762 
763  try{
764  nlohmann::json tag_info = myCrestClient.selectIovs(tagname);
765  std::cout << std::endl << "test: selectIovs (result) =" << std::endl;
766  std::cout << tag_info.dump(4) << std::endl;
767  }
768  catch (const std::exception& e) {
769  std::cout << std::endl << "test: selectIovs (failed)" << std::endl;
770  std::cerr << e.what() << std::endl;
771  }
772 }
773 
774 void testSelectIovs(const std::string& tagname, long since, long until, long snapshot) {
775  std::cout << std::endl << "test: selectIovs, all paprams" << std::endl;
776  CrestClient myCrestClient = CrestClient(SURL,false);
777 
778  try{
779  nlohmann::json tag_info = myCrestClient.selectIovs(tagname, since, until, snapshot);
780  std::cout << std::endl << "test: selectIovs (result) =" << std::endl;
781  std::cout << tag_info.dump(4) << std::endl;
782  }
783  catch (const std::exception& e) {
784  std::cout << std::endl << "test: selectIovs (failed)" << std::endl;
785  std::cerr << e.what() << std::endl;
786  }
787 }
788 
789 void testSelectGroups(const std::string& tagname) {
790  std::cout << std::endl << "test: selectGroups" << std::endl;
791  CrestClient myCrestClient = CrestClient(SURL,false);
792 
793  try{
794  nlohmann::json tag_info = myCrestClient.selectGroups(tagname);
795  std::cout << std::endl << "test: selectGroups (result) =" << std::endl;
796  std::cout << tag_info.dump(4) << std::endl;
797  }
798  catch (const std::exception& e) {
799  std::cout << std::endl << "test: selectGroups (failed)" << std::endl;
800  std::cerr << e.what() << std::endl;
801  }
802 }
803 
804 // IOV List Methods (end)
805 
806 
807 //===================================================
808 // Tag Meta Info Method Tests
809 //===================================================
810 
811 void testCreateTagMetaInfo(const std::string& tagname) {
812  std::cout << std::endl << "test: createTagMetainfo" << std::endl;
813  CrestClient myCrestClient = CrestClient(SURL,false);
814 
815  nlohmann::json js =
816  {
817  {"tagName", tagname},
818  {"description", "desc-01"},
819  {"tagInfo", "taginf-01"},
820  {"chansize", 0},
821  {"colsize", 0}
822  };
823 
824  try{
825  myCrestClient.createTagMetaInfo(js);
826  std::cout << std::endl << "test: createTagMetaInfo (success)" << std::endl;
827  }
828  catch (const std::exception& e) {
829  std::cout << std::endl << "test: createTagMetaInfo (failed)" << std::endl;
830  std::cerr << e.what() << std::endl;
831  }
832 }
833 
834 // Test for the method with 2 arguments:
835 
836 void testCreateTagMetaInfo2Args(const std::string& tagname) {
837  std::cout << std::endl << "test: createTagMetainfo" << std::endl;
838  CrestClient myCrestClient = CrestClient(SURL,false);
839 
840  nlohmann::json js =
841  {
842  {"tagName", tagname},
843  {"description", "desc-01"},
844  {"tagInfo", "taginf-01"},
845  {"chansize", 0},
846  {"colsize", 0},
847  {"insertionTime", "2019-03-14T13:29:25.286Z"}
848  };
849 
850  try{
851  std::cout << "test A:" << std::endl;
852  myCrestClient.createTagMetaInfo(tagname, js);
853  std::cout << "test: createTagMetaInfo (success)" << std::endl;
854  }
855  catch (const std::exception& e) {
856  std::cout << std::endl << "test: createTagMetaInfo (failed)" << std::endl;
857  std::cerr << e.what() << std::endl;
858  }
859  try{
860  std::cout << "test B:" << std::endl;
861  myCrestClient.createTagMetaInfo("test", js);
862  std::cout << "test: createTagMetaInfo (success)" << std::endl;
863  }
864  catch (const std::exception& e) {
865  std::cout << std::endl << "test: createTagMetaInfo (failed)" << std::endl;
866  std::cerr << e.what() << std::endl;
867  }
868 }
869 
870 // analogue
871 void testCreateTagMetaInfo2(const std::string& tagname) {
872  std::cout << std::endl << "test: createTagMetainfo2" << std::endl;
873  CrestClient myCrestClient = CrestClient(SURL,false);
874 
875  nlohmann::json js =
876  {
877  {"chansize", 1},
878  {"colsize", 0},
879  {"description",
880  "<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type=\"71\" clid=\"1238547719\" /></addrHeader><typeName>CondAttrListCollection</typeName>"},
881  {"insertionTime", "Fri Nov 13 16:31:10 2020"},
882  {"tagName", tagname}
883  };
884 
885  try{
886  myCrestClient.createTagMetaInfo(js);
887  std::cout << std::endl << "test: createTagMetaInfo (success)" << std::endl;
888  }
889  catch (const std::exception& e) {
890  std::cout << std::endl << "test: createTagMetaInfo (failed)" << std::endl;
891  std::cerr << e.what() << std::endl;
892  }
893 }
894 
895 // Example with more detailed parametrs:
896 void testCreateTagMetaInfoDetailed(const std::string& tagname) {
897  std::cout << std::endl << "test: createTagMetainfoDetailed" << std::endl;
898  CrestClient myCrestClient = CrestClient(SURL,false);
899 
900  nlohmann::json channel = {{"0", "ATLAS_PREFERRED"}};
901 
902  std::cout << std::endl << "channel = " << std::endl
903  << channel.dump(4) << std::endl;
904 
906 
907  nlohmann::json tagInfo =
908  {
909  {"channel_list", chanList},
910  {"node_description", "description of the node"},
911  {"payload_spec", "payload specification"}
912  };
913 
914  std::cout << std::endl << "TagInfo = " << std::endl
915  << tagInfo.dump(4) << std::endl;
916 
917  std::cout << std::endl << "TagInfo = " << std::endl
918  << tagInfo.dump() << std::endl;
919 
920  nlohmann::json js =
921  {
922  {"tagName", tagname},
923  {"description", "none"},
924  {"chansize", 1},
925  {"colsize", 6},
926  {"tagInfo", tagInfo.dump()},
927  {"insertionTime", "2020-12-04"}
928  };
929 
930 
931  try{
932  myCrestClient.createTagMetaInfo(js);
933  std::cout << std::endl << "test: createTagMetaInfoDetailed (success)" << std::endl;
934  }
935  catch (const std::exception& e) {
936  std::cout << std::endl << "test: createTagMetaInfoDetailed (failed)" << std::endl;
937  std::cerr << e.what() << std::endl;
938  }
939 }
940 
941 void testGetTagMetaInfo(const std::string& tagname) {
942  std::cout << std::endl << "test: getTagMetaInfo" << std::endl;
943  CrestClient myCrestClient = CrestClient(SURL,false);
944 
945  try{
946  nlohmann::json js = myCrestClient.getTagMetaInfo(tagname);
947  std::cout << std::endl << "test: getTagMetaInfo (result) =" << std::endl
948  << js.dump(4) << std::endl;
949  }
950  catch (const std::exception& e) {
951  std::cout << std::endl << "test: getTagMetaInfo (failed)" << std::endl;
952  std::cerr << e.what() << std::endl;
953  }
954 }
955 
956 void testUpdateTagMetainfo(const std::string& tagname) {
957  std::cout << std::endl << "test: updateTagMetainfo" << std::endl;
958  CrestClient myCrestClient = CrestClient(SURL,false);
959 
960  nlohmann::json js =
961  {
962  {"tagName", tagname},
963  {"description", "desc-02"}
964  };
965 
966  try{
967  myCrestClient.updateTagMetaInfo(js);
968  std::cout << std::endl << "test: updateTagMetaInfo (success)" << std::endl;
969  }
970  catch (const std::exception& e) {
971  std::cout << std::endl << "test: updateTagMetainfo (failed)" << std::endl;
972  std::cerr << e.what() << std::endl;
973  }
974 }
975 
976 //===================================================
977 // Tag Meta Info Method Tests in IOVDbSvc format
978 //===================================================
979 
980 void testCreateTagMetaInfoIOVDbSvc(const std::string& tagname) {
981  std::cout << std::endl << "test: createTagMetainfoIOVDbSvc" << std::endl;
982  CrestClient myCrestClient = CrestClient(SURL,false);
983  std::string description = "meta tag description";
984 
985  nlohmann::json channel1 = {{"0", "ATLAS_PREFERRED0"}};
986  nlohmann::json channel2 = {{"1", "ATLAS_PREFERRED1"}};
987 
988  nlohmann::json chanList = nlohmann::json::array({channel1, channel2});
989 
990  nlohmann::json tagInfo =
991  {
992  {"channel_list", chanList},
993  {"node_description", "description of the node"},
994  {"payload_spec",
995  "AlgorithmID:UInt32,LBAvInstLumi:Float,LBAvEvtsPerBX:Float,LumiType:UInt32,Valid:UInt32,BunchInstLumi:Blob64k"}
996  };
997 
998  try{
999  myCrestClient.createTagMetaInfoIOVDbSvc(tagname, tagInfo, description);
1000  std::cout << std::endl << "test: createTagMetaInfoIOVDbSvc (success)" << std::endl;
1001  }
1002  catch (const std::exception& e) {
1003  std::cout << std::endl << "test: createTagMetaInfoIOVDbSvc (failed)" << std::endl;
1004  std::cerr << e.what() << std::endl;
1005  }
1006 }
1007 
1008 void testGetTagMetaInfoIOVDbSvc(const std::string& tagname) {
1009  std::cout << std::endl << "test: getTagMetaInfoIOVDbSvc" << std::endl;
1010  CrestClient myCrestClient = CrestClient(SURL,false);
1011 
1012  try{
1013  nlohmann::json js68 = myCrestClient.getTagMetaInfoIOVDbSvc(tagname);
1014  std::cout << std::endl << "test: getTagMetaInfoIOVDbSvc (result) = " << std::endl
1015  << js68.dump(4) << std::endl;
1016  }
1017  catch (const std::exception& e) {
1018  std::cout << std::endl << "test: getTagMetaInfoIOVDbSvc (failed)" << std::endl;
1019  std::cerr << e.what() << std::endl;
1020  }
1021 }
1022 
1024  std::cout << std::endl << "test: convertTagMetaInfo2CREST" << std::endl;
1025  CrestClient myCrestClient = CrestClient(SURL,false);
1026 
1027  std::string tagname = "test_MvG4";
1028 
1029  nlohmann::json channel1 = {{"0", "ATLAS_PREFERRED0"}};
1030  nlohmann::json channel2 = {{"1", "ATLAS_PREFERRED1"}};
1031 
1032  nlohmann::json chanList = nlohmann::json::array({channel1, channel2});
1033 
1034  nlohmann::json tagInfo =
1035  {
1036  {"channel_list", chanList},
1037  {"node_description", "description of the node"},
1038  {"payload_spec",
1039  "AlgorithmID:UInt32,LBAvInstLumi:Float,LBAvEvtsPerBX:Float,LumiType:UInt32,Valid:UInt32,BunchInstLumi:Blob64k"}
1040  };
1041 
1042  std::cout << std::endl << "tagInfo = " << std::endl
1043  << tagInfo.dump(4) << std::endl;
1044 
1045  try{
1046  nlohmann::json res = myCrestClient.convertTagMetaInfo2CREST(tagInfo);
1047  std::cout << std::endl
1048  << "Tag Meta Info in CREST format = " << res.dump(4) << std::endl;
1049  }
1050  catch (const std::exception& e) {
1051  std::cout << std::endl << "test: convertTagMetaInfo2CREST (failed)" << std::endl;
1052  std::cerr << e.what() << std::endl;
1053  }
1054 }
1055 
1056 //================================================
1057 // Monitoring Method Tests in IOVDbSvc format
1058 //================================================
1059 
1061  std::cout << std::endl << "test: listPayloadTagInfo" << std::endl;
1062  CrestClient myCrestClient = CrestClient(SURL,false);
1063 
1064  try {
1065  nlohmann::json tag_list = myCrestClient.listPayloadTagInfo();
1066  std::cout << std::endl << "test: listPayloadTagInfo (result) =" << std::endl
1067  << tag_list.dump(4) << std::endl;
1068  }
1069  catch (const std::exception& e) {
1070  std::cout << std::endl << "test: listPayloadTagInfo (failed)" << std::endl;
1071  std::cerr << e.what() << std::endl;
1072  }
1073 }
1074 
1075 void testListPayloadTagInfo(const std::string& tagname) {
1076  std::cout << std::endl << "test: listPayloadTagInfo with tag " << tagname << std::endl;
1077  CrestClient myCrestClient = CrestClient(SURL,false);
1078 
1079  try {
1081  std::cout << std::endl << "test: listPayloadTagInfo (result) =" << std::endl
1082  << tag_list.dump(4) << std::endl;
1083  }
1084  catch (const std::exception& e) {
1085  std::cout << std::endl << "test: listPayloadTagInfo (failed)" << std::endl;
1086  std::cerr << e.what() << std::endl;
1087  }
1088 }
1089 
1090 //================================================
1091 // Payload and Blob Method Tests
1092 //================================================
1093 
1094 
1095 void testGetBlobInStream(const std::string& hash) {
1096  std::cout << std::endl << "test: getBlobInStream" << std::endl;
1097  CrestClient myCrestClient = CrestClient(SURL,false);
1098 
1099  try{
1100  remove("data.txt");
1101 
1102  std::ofstream out8; // stream for writing
1103  out8.open("data.txt"); // open the file to write
1104  if (out8.is_open()) {
1105  myCrestClient.getBlobInStream(hash, out8);
1106  std::cout << std::endl << "test: getBlobInStream test finished." << std::endl;
1107  std::cout << std::endl << "The blob for hash \"" << hash
1108  << "\" was written in the file \"data.txt\"." << std::endl;
1109  }
1110  }
1111  catch (const std::exception& e) {
1112  std::cout << std::endl << "test: getBlobInStream (failed)" << std::endl;
1113  std::cerr << e.what() << std::endl;
1114  }
1115 }
1116 
1117 void testGetBlob(const std::string& hash) {
1118  std::cout << std::endl << "test: getBlob" << std::endl;
1119  CrestClient myCrestClient = CrestClient(SURL,false);
1120 
1121  try{
1122  string tag_info7 = myCrestClient.getBlob(hash);
1123  std::cout << std::endl << "test: getBlob (result) =" << std::endl;
1124  std::cout << tag_info7 << std::endl;
1125  std::cout << std::endl << "test: getBlob" << std::endl;
1126  }
1127  catch (const std::exception& e) {
1128  std::cout << std::endl << "test: getBlob (failed)" << std::endl;
1129  std::cerr << e.what() << std::endl;
1130  }
1131 }
1132 
1133 void testGetPayloadAsJson(const std::string& hash) {
1134  std::cout << std::endl << "test: getPayloadAsJson" << std::endl;
1135  CrestClient myCrestClient = CrestClient(SURL,false);
1136 
1137  try{
1138  nlohmann::json info26 = myCrestClient.getPayloadAsJson(hash);
1139  std::cout << std::endl << "test: getPayloadAsJson (result) =" << std::endl;
1140  std::cout << info26.dump(4) << std::endl;
1141  std::cout << std::endl << "test: getPayloadAsJson" << std::endl;
1142  }
1143  catch (const std::exception& e) {
1144  std::cout << std::endl << "test: getPayloadAsJson (failed)" << std::endl;
1145  std::cerr << e.what() << std::endl;
1146  }
1147 }
1148 
1149 void testGetPayloadAsString(const std::string& hash) {
1150  std::cout << std::endl << "test: getPayloadAsString" << std::endl;
1151  CrestClient myCrestClient = CrestClient(SURL,false);
1152 
1153  try{
1154  std::string info27 = myCrestClient.getPayloadAsString(hash);
1155  std::cout << std::endl << "test: getPayloadAsString (result) =" << std::endl;
1156  std::cout << info27 << std::endl;
1157  std::cout << std::endl << "test: getPayloadAsString" << std::endl;
1158  }
1159  catch (const std::exception& e) {
1160  std::cout << std::endl << "test: getPayloadAsString (failed)" << std::endl;
1161  std::cerr << e.what() << std::endl;
1162  }
1163 }
1164 
1165 void testGetPayloadMetaInfoAsString(const std::string& hash) {
1166  std::cout << std::endl << "test: getPayloadMetaInfoAsString" << std::endl;
1167  CrestClient myCrestClient = CrestClient(SURL,false);
1168 
1169  try{
1170  std::string info15 = myCrestClient.getPayloadMetaInfoAsString(hash);
1171  std::cout << std::endl << "test: getPayloadMetaInfoAsString (result) =" << std::endl;
1172  std::cout << info15 << std::endl;
1173  std::cout << std::endl << "test: getPayloadMetaInfoAsString" << std::endl;
1174  }
1175  catch (const std::exception& e) {
1176  std::cout << std::endl << "test: getPayloadMetaInfoAsString (failed)" << std::endl;
1177  std::cerr << e.what() << std::endl;
1178  }
1179 }
1180 
1181 void testGetPayloadMetaInfo(const std::string& hash) {
1182  std::cout << std::endl << "test: getPayloadMetaInfo" << std::endl;
1183  CrestClient myCrestClient = CrestClient(SURL,false);
1184 
1185  try{
1186  nlohmann::json info14 = myCrestClient.getPayloadMetaInfo(hash);
1187  std::cout << std::endl << "test: getPayloadMetaInfo (result) =" << std::endl;
1188  std::cout << info14.dump(4) << std::endl;
1189  std::cout << std::endl << "test: getPayloadMetaInfo" << std::endl;
1190  }
1191  catch (const std::exception& e) {
1192  std::cout << std::endl << "test: getPayloadMetaInfo (failed)" << std::endl;
1193  std::cerr << e.what() << std::endl;
1194  }
1195 }
1196 
1197 //===================================================
1198 // Tests for File Storage Methods
1199 //===================================================
1200 
1201 // Tag Meta Info:
1202 
1203 // Example with detailed parametrs:
1204 void testCreateTagMetaInfoDetailedFs(const std::string& tagname) {
1205  std::cout << std::endl << "test: createTagMetainfoDetailedFs" << std::endl;
1206 
1207  CrestClient myCrestClient = CrestClient(true);
1208 
1209  nlohmann::json channel = {{"0", "ATLAS_PREFERRED"}};
1210 
1211  std::cout << std::endl << "channel = " << std::endl
1212  << channel.dump(4) << std::endl;
1213 
1215 
1216  nlohmann::json tagInfo =
1217  {
1218  {"channel_list", chanList},
1219  {"node_description", "description of the node"},
1220  {"payload_spec", "payload specification"}
1221  };
1222 
1223  std::cout << std::endl << "TagInfo = " << std::endl
1224  << tagInfo.dump(4) << std::endl;
1225 
1226  std::cout << std::endl << "TagInfo = " << std::endl
1227  << tagInfo.dump() << std::endl;
1228 
1229  nlohmann::json js =
1230  {
1231  {"tagName", tagname},
1232  {"description", "none"},
1233  {"chansize", 1},
1234  {"colsize", 6},
1235  {"tagInfo", tagInfo.dump()},
1236  {"insertionTime", "2020-12-04"}
1237  };
1238 
1239 
1240  try{
1241  myCrestClient.createTagMetaInfo(js);
1242  std::cout << std::endl << "test: createTagMetaInfoDetailedFs (success)" << std::endl;
1243  }
1244  catch (const std::exception& e) {
1245  std::cout << std::endl << "test: createTagMetaInfoDetailedFs (failed)" << std::endl;
1246  std::cerr << e.what() << std::endl;
1247  }
1248 }
1249 
1250 void testGetTagMetaInfoFs(const std::string& tagname) {
1251  std::cout << std::endl << "test: getTagMetaInfoFs" << std::endl;
1252 
1253  CrestClient myCrestClient = CrestClient(true);
1254 
1255  try{
1256  nlohmann::json js = myCrestClient.getTagMetaInfo(tagname);
1257  std::cout << std::endl << "test: getTagMetaInfoFs (result) =" << std::endl
1258  << js.dump(4) << std::endl;
1259  }
1260  catch (const std::exception& e) {
1261  std::cout << std::endl << "test: getTagMetaInfoFs (failed)" << std::endl;
1262  std::cerr << e.what() << std::endl;
1263  }
1264 }
1265 
1266 void testUpdateTagMetaInfoFs(const std::string& tagname) {
1267  std::cout << std::endl << "test: updateTagMetainfoFs" << std::endl;
1268  CrestClient myCrestClient = CrestClient(true);
1269 
1270  nlohmann::json channel = {{"0", "ATLAS_PREFERRED"}};
1271 
1272  std::cout << std::endl << "channel = " << std::endl
1273  << channel.dump(4) << std::endl;
1274 
1276 
1277  nlohmann::json tagInfo =
1278  {
1279  {"channel_list", chanList},
1280  {"node_description", "description of the node"},
1281  {"payload_spec", "payload specification"}
1282  };
1283 
1284  std::cout << std::endl << "TagInfo = " << std::endl
1285  << tagInfo.dump(4) << std::endl;
1286 
1287  std::cout << std::endl << "TagInfo = " << std::endl
1288  << tagInfo.dump() << std::endl;
1289 
1290  nlohmann::json js =
1291  {
1292  {"tagName", tagname},
1293  {"description", "none"},
1294  {"chansize", 1},
1295  {"colsize", 6},
1296  {"tagInfo", tagInfo.dump()},
1297  {"insertionTime", "2020-12-04"}
1298  };
1299 
1300  try{
1301  // myCrestClient.updateTagMetaInfoFs(tagname+"a",js); // test for wrong tag name, uncomment it if you want test this
1302  // case.
1303  myCrestClient.updateTagMetaInfoFs(tagname, js);
1304  std::cout << std::endl << "test: updateTagMetaInfoFs (success)" << std::endl;
1305  }
1306  catch (const std::exception& e) {
1307  std::cout << std::endl << "test: updateTagMetaInfoFs (failed)" << std::endl;
1308  std::cerr << e.what() << std::endl;
1309  }
1310 }
1311 
1312 // Tag Methods:
1313 
1314 void testFindTagFs(const std::string& tagname) {
1315  std::cout << std::endl << "test: findTagFs" << std::endl;
1316  CrestClient myCrestClient = CrestClient(true);
1317 
1318  std::cout << std::endl << "test: findTagFs" << std::endl;
1319 
1320  try {
1321  nlohmann::json tag_info = myCrestClient.findTag(tagname);
1322  std::cout << std::endl << "test: findTagFs (result) =" << std::endl
1323  << tag_info.dump(4) << std::endl;
1324  }
1325  catch (const std::exception& e) {
1326  std::cout << std::endl << "test: findTagFs (failed)" << std::endl;
1327  std::cout << e.what() << std::endl;
1328  }
1329 }
1330 
1331 void testCreateTagFs(const std::string& tagname) {
1332  std::cout << std::endl << "test: createTagFs" << std::endl;
1333 
1334  bool rewrite = true;
1335  CrestClient myCrestClient = CrestClient(rewrite);
1336 
1337  nlohmann::json js =
1338  {
1339  {"description", "none"},
1340  {"endOfValidity", 0},
1341  {"insertionTime", "2018-12-06T11:18:35.641+0000"},
1342  {"lastValidatedTime", 0},
1343  {"modificationTime", "2018-12-06T11:18:35.641+0000"},
1344  {"name", tagname},
1345  {"payloadSpec", "stave: Int32, eta: Int32, mag: Float, base: Float, free: Float"},
1346  {"synchronization", "none"},
1347  {"timeType", "time"}
1348  };
1349 
1350  try{
1351  myCrestClient.createTag(js);
1352  std::cout << std::endl << "test: createTagFs (success)" << std::endl;
1353  }
1354  catch (const std::exception& e) {
1355  std::cout << std::endl << "test: createTagFs (failed)" << std::endl;
1356  std::cout << e.what() << std::endl;
1357  }
1358 }
1359 
1360 // Payloads methods:
1361 
1362 void testStoreBatchPayloadsFs(const std::string& tagname) {
1363  std::cout << std::endl << "test: storeBatchPayloads" << std::endl;
1364 
1365  bool rewrite = true;
1366  CrestClient myCrestClient = CrestClient(rewrite);
1367 
1368  uint64_t endtime = 200;
1369  std::string str = "[{\"data\":\"aaa\",\"since\":100},{\"data\":\"bbb\",\"since\":150}]";
1370  nlohmann::json js = myCrestClient.getJson(str);
1371 
1372  try {
1373  myCrestClient.storeBatchPayloads(tagname, endtime, js);
1374  std::cout << std::endl << "test: storeBatchPayloads (success) " << std::endl;
1375  }
1376  catch (const std::exception& e) {
1377  std::cout << std::endl << "test: storeBatchPayloads (failed)" << std::endl;
1378  std::cerr << e.what() << std::endl;
1379  }
1380 }
1381 
1382 // Global Tag Methods:
1383 
1384 void testCreateGlobalTagFs(const std::string& tagname) {
1385  std::cout << std::endl << "test: createGlobalTagFs" << std::endl;
1386 
1387  bool rewrite = true;
1388  CrestClient myCrestClient = CrestClient(rewrite);
1389 
1390  nlohmann::json js =
1391  {
1392  {"name", tagname},
1393  {"validity", 0},
1394  {"description", "test"},
1395  {"release", "1"},
1396  {"insertionTime", "2018-12-18T11:32:58.081+0000"},
1397  {"snapshotTime", "2018-12-18T11:32:57.952+0000"},
1398  {"scenario", "test"},
1399  {"workflow", "M"},
1400  {"type", "t"},
1401  {"snapshotTimeMilli", "null"},
1402  {"insertionTimeMilli", "null"}
1403  };
1404 
1405  try {
1406  myCrestClient.createGlobalTagFs(js);
1407  std::cout << std::endl << "test: createGlobalTagFs (success) " << std::endl;
1408  }
1409  catch (const std::exception& e) {
1410  std::cout << std::endl << "test: createGlobalTagFs (failed)" << std::endl;
1411  std::cout << e.what() << std::endl;
1412  }
1413 }
1414 
1415 void testFindGlobalTagFs(const std::string& tagname) {
1416  std::cout << std::endl << "test: findGlobalTagFs" << std::endl;
1417  bool rewrite = true;
1418  CrestClient myCrestClient = CrestClient(rewrite);
1419 
1420  try {
1421  nlohmann::json tag_info = myCrestClient.findGlobalTagFs(tagname);
1422  std::cout << std::endl << "test: findGlobalTagFs (result) = " << std::endl
1423  << tag_info.dump(4) << std::endl;
1424  }
1425  catch (const std::exception& e) {
1426  std::cout << std::endl << "test: findGlobalTagFs (failed)" << std::endl;
1427  std::cout << e.what() << std::endl;
1428  }
1429 }
1430 
1431 // Global Tag Map Methods:
1432 
1433 void testCreateGlobalTagMapFs(const std::string& globaltag, const std::string& tagname) {
1434  std::cout << std::endl << "test: createGlobalTagMapFs" << std::endl;
1435  bool rewrite = true;
1436  CrestClient myCrestClient = CrestClient(rewrite);
1437 
1438  nlohmann::json js =
1439  {
1440  {"globalTagName", globaltag},
1441  {"record", "testing2"},
1442  {"label", "test2"},
1443  {"tagName", tagname}
1444  };
1445 
1446  try{
1447  myCrestClient.createGlobalTagMapFs(js);
1448  std::cout << std::endl << "test: createGlobalTagMapFs (success) " << std::endl;
1449  }
1450  catch (const std::exception& e) {
1451  std::cout << std::endl << "test: createGlobalTagMapFs (failed)" << std::endl;
1452  std::cout << e.what() << std::endl;
1453  }
1454 }
1455 
1456 void testFindGlobalTagMapFs(const std::string& tagname) {
1457  std::cout << std::endl << "test: findGlobalTagMapFs" << std::endl;
1458  bool rewrite = true;
1459  CrestClient myCrestClient = CrestClient(rewrite);
1460 
1461  try {
1462  nlohmann::json tag_info = myCrestClient.findGlobalTagMapFs(tagname);
1463  std::cout << std::endl << "test: findGlobalTagMapFs (result) = " << std::endl
1464  << tag_info.dump(4) << std::endl;
1465  }
1466  catch (const std::exception& e) {
1467  std::cout << std::endl << "test: findGlobalTagMapFs (failed)" << std::endl;
1468  std::cout << e.what() << std::endl;
1469  }
1470 }
1471 
1472 // Hash calculation tests
1473 
1474 void testGetHash(const std::string& str) {
1475  std::cout << std::endl << "test: getHash" << std::endl;
1476  CrestClient myCrestClient = CrestClient(SURL,false);
1477 
1478  std::cout << myCrestClient.getHash(str) << std::endl;
1479 }
1480 
1481 void hashCalculationTest(const std::string& str) {
1482  std::cout << "Hash(" << str << ") = ";
1483  std::string hash_hex_str = picosha2::hash256_hex_string(str.begin(), str.end());
1484  std::cout << hash_hex_str << std::endl;
1485 }
1486 
1487 // Global Tag tests:
1488 
1489 void testCreateGlobalTag(const std::string& tagname, const std::string& description) {
1490  std::cout << std::endl << "test: createGlobalTag (2 parameters)" << std::endl;
1491  CrestClient myCrestClient = CrestClient(SURL,false);
1492 
1493  try {
1494  myCrestClient.createGlobalTag(tagname, description);
1495  std::cout << std::endl << "test: createGlobalTag (success) (2 parameters)" << std::endl;
1496  }
1497  catch (const std::exception& e) {
1498  std::cout << std::endl << "test: createGlobalTag (failed) (2 parameters)" << std::endl;
1499  std::cout << e.what() << std::endl;
1500  }
1501 }
1502 
1503 // global tag and tag have to exist
1504 void testCreateGlobalTagMap(const std::string& globaltag, const std::string& tagname,
1505  const std::string& record, const std::string& label) {
1506  std::cout << std::endl << "test: createGlobalTagMap (all parameters)" << std::endl;
1507  CrestClient myCrestClient = CrestClient(SURL,false);
1508 
1509  nlohmann::json js =
1510  {
1511  {"globalTagName", globaltag},
1512  {"record", record},
1513  {"label", label},
1514  {"tagName", tagname}
1515  };
1516 
1517  try{
1518  myCrestClient.createGlobalTagMap(js);
1519  std::cout << std::endl << "test: createGlobalTagMap (all parameters) (success) " << std::endl;
1520  }
1521  catch (const std::exception& e) {
1522  std::cout << std::endl << "test: createGlobalTagMap (all parameters) (failed)" << std::endl;
1523  std::cout << e.what() << std::endl;
1524  }
1525 }
1526 
1527 // current time & date test
1528 
1530  std::cout << std::endl << "test: getDateAndTime" << std::endl;
1531  CrestClient myCrestClient = CrestClient(SURL,false);
1532 
1533  try{
1534  std::string time = myCrestClient.getDateAndTime();
1535  std::cout << std::endl << "now = " << time << std::endl;
1536  }
1537  catch (const std::exception& e) {
1538  std::cout << std::endl << "test: getDateAndTime (failed)" << std::endl;
1539  std::cerr << e.what() << std::endl;
1540  }
1541 }
1542 
1543 // payload method tests for file starage
1544 
1545 void testGetPayloadAsStringFS(const std::string& hash) {
1546  std::cout << std::endl << "test: getPayloadAsStringFS" << std::endl;
1547  CrestClient myCrestClient = CrestClient(true);
1548 
1549  try {
1550  std::string info = myCrestClient.getPayloadAsStringFS(hash);
1551  std::cout << std::endl << "test: getPayloadAsStringFS (result) =" << std::endl
1552  << info << std::endl;
1553  }
1554  catch (const std::exception& e) {
1555  std::cout << std::endl << "test: getPayloadAsStringFS (failed)" << std::endl;
1556  std::cout << e.what() << std::endl;
1557  }
1558 }
1559 
1560 void testGetPayloadAsJsonFS(const std::string& hash) {
1561  std::cout << std::endl << "test: getPayloadAsJsonFS" << std::endl;
1562  CrestClient myCrestClient = CrestClient(true);
1563 
1564  try {
1565  nlohmann::json info = myCrestClient.getPayloadAsJsonFS(hash);
1566  std::cout << std::endl << "test: getPayloadAsJsonFS (result) =" << std::endl
1567  << info.dump(4) << std::endl;
1568  }
1569  catch (const std::exception& e) {
1570  std::cout << std::endl << "test: getPayloadAsJsonFS (failed)" << std::endl;
1571  std::cout << e.what() << std::endl;
1572  }
1573 }
1574 
1575 void testGetPayloadMetaInfoAsStringFS(const std::string& hash) {
1576  std::cout << std::endl << "test: getPayloadMetaInfoAsStringFS" << std::endl;
1577  CrestClient myCrestClient = CrestClient(true);
1578 
1579  try {
1580  std::string info = myCrestClient.getPayloadMetaInfoAsStringFS(hash);
1581  std::cout << std::endl << "test: getPayloadMetaInfoAsStringFS (result) =" << std::endl
1582  << info << std::endl;
1583  }
1584  catch (const std::exception& e) {
1585  std::cout << std::endl << "test: getPayloadMetaInfoAsStringFS (failed)" << std::endl;
1586  std::cout << e.what() << std::endl;
1587  }
1588 }
1589 
1590 void testGetPayloadMetaInfoAsJsonFS(const std::string& hash) {
1591  std::cout << std::endl << "test: getPayloadMetaInfoAsJsonFS" << std::endl;
1592  CrestClient myCrestClient = CrestClient(true);
1593 
1594  try {
1596  std::cout << std::endl << "test: getPayloadMetaInfoAsJsonFS (result) =" << std::endl
1597  << info.dump(4) << std::endl;
1598  }
1599  catch (const std::exception& e) {
1600  std::cout << std::endl << "test: getPayloadMetaInfoAsJsonFS (failed)" << std::endl;
1601  std::cout << e.what() << std::endl;
1602  }
1603 }
1604 
1605 void testGetBlobInStreamFS(const std::string& hash) {
1606  std::cout << std::endl << "test: getBlobInStreamFs" << std::endl;
1607  CrestClient myCrestClient = CrestClient(true);
1608 
1609  try{
1610  remove("data.txt");
1611 
1612  std::ofstream out8; // stream for writing
1613  out8.open("data.txt"); // open the file to write
1614  if (out8.is_open()) {
1615  string tag_info8 = myCrestClient.getBlobInStreamFs(hash, out8);
1616  std::cout << std::endl << "test: getBlobInStreamFs (result) =" << std::endl;
1617  std::cout << tag_info8 << std::endl;
1618  std::cout << "blob is in the file data.txt" << std::endl;
1619  std::cout << std::endl << "test: getBlobInStreamFs" << std::endl;
1620  }
1621  }
1622  catch (const std::exception& e) {
1623  std::cout << std::endl << "test: getBlobInStreamFs (failed)" << std::endl;
1624  std::cerr << e.what() << std::endl;
1625  }
1626 }
1627 
1628 void testGetBlobFS(const std::string& hash) {
1629  std::cout << std::endl << "test: getBlobFs" << std::endl;
1630  CrestClient myCrestClient = CrestClient(true);
1631 
1632  try {
1633  std::string info = myCrestClient.getBlobFs(hash);
1634  std::cout << std::endl << "test: getBlobFs (result) =" << std::endl
1635  << info << std::endl;
1636  }
1637  catch (const std::exception& e) {
1638  std::cout << std::endl << "test: getBlobFs (failed)" << std::endl;
1639  std::cout << e.what() << std::endl;
1640  }
1641 }
1642 
1644  std::cout << std::endl << "test: returnJArray" << std::endl;
1645  CrestClient myCrestClient = CrestClient(SURL,false);
1646 
1647  nlohmann::json js = {
1648  {"name", "test"}
1649  };
1650 
1651  try {
1652  nlohmann::json res = myCrestClient.returnJArray(js);
1653  std::cout << std::endl << "test: returnJArray (result) =" << std::endl
1654  << res.dump(4) << std::endl;
1655  }
1656  catch (const std::exception& e) {
1657  std::cout << std::endl << "test: returnJArray (failed)" << std::endl;
1658  std::cout << e.what() << std::endl;
1659  }
1660 }
1661 
1662 //=====================================================
1663 // Tests for storeBatchPayloads methods
1664 // (i.e. IOVs and payloads stored in batch mode)
1665 //=====================================================
1666 
1667 
1668 // Test for the storeBatchPayloads method. It has two payloads with the predefined payloadHash values ("aaa" and "bbb").
1669 
1670 void testStoreBatchPayloads(const std::string& tagname) {
1671  std::cout << std::endl << "test: storeBatchPayloads" << std::endl;
1672  CrestClient myCrestClient = CrestClient(SURL,false);
1673 
1674  uint64_t endtime = 200;
1675  std::string str = "[{\"data\":\"aaa\",\"since\":100},{\"data\":\"bbb\",\"since\":150}]";
1676  nlohmann::json js = myCrestClient.getJson(str);
1677 
1678  try {
1679  myCrestClient.storeBatchPayloads(tagname, endtime, js);
1680  std::cout << std::endl << "test: storeBatchPayloads (success) " << std::endl;
1681  }
1682  catch (const std::exception& e) {
1683  std::cout << std::endl << "test: storeBatchPayloads (failed)" << std::endl;
1684  std::cerr << e.what() << std::endl;
1685  }
1686 }
1687 
1688 // Test for the storeBatchPayloads method. The payloads are calculated each time.
1689 
1690 void testStoreBatchPayloadsB(const std::string& tagname) {
1691  std::cout << std::endl << "test: storeBatchPayloads2" << std::endl;
1692  CrestClient myCrestClient = CrestClient(SURL,false);
1693 
1694  uint64_t endtime = 200;
1695  std::string d1 = "\"" + myCrestClient.getDateAndTime() + "_A\"";
1696  std::string d2 = "\"" + myCrestClient.getDateAndTime() + "_B\"";
1697 
1698  std::string str = "[{\"data\":" + d1 + ",\"since\":100},{\"data\":" + d2 + ",\"since\":150}]";
1699  nlohmann::json js = myCrestClient.getJson(str);
1700 
1701  try {
1702  myCrestClient.storeBatchPayloads(tagname, endtime, js);
1703  std::cout << std::endl << "test: storeBatchPayloads2 (success) " << std::endl;
1704  }
1705  catch (const std::exception& e) {
1706  std::cout << std::endl << "test: storeBatchPayloads2 (failed)" << std::endl;
1707  std::cerr << e.what() << std::endl;
1708  }
1709 }
1710 
1711 // This test creates n IOVs/payloads for the tag with name tagname
1712 
1713 void testTagAndStoreBatchFsNItems(const std::string& tagname, int n) {
1714  std::cout << std::endl << "test: createTagFs" << std::endl;
1715 
1716  bool rewrite = true;
1717  CrestClient myCrestClient = CrestClient(rewrite);
1718 
1719  nlohmann::json js =
1720  {
1721  {"description", "none"},
1722  {"endOfValidity", 0},
1723  {"insertionTime", "2018-12-06T11:18:35.641+0000"},
1724  {"lastValidatedTime", 0},
1725  {"modificationTime", "2018-12-06T11:18:35.641+0000"},
1726  {"name", tagname},
1727  {"payloadSpec", "stave: Int32, eta: Int32, mag: Float, base: Float, free: Float"},
1728  {"synchronization", "none"},
1729  {"timeType", "time"}
1730  };
1731 
1732  try{
1733  myCrestClient.createTag(js);
1734  std::cout << std::endl << "test: storeBatchPayloads for N items (a tag created)" << std::endl;
1735  }
1736  catch (const std::exception& e) {
1737  std::cout << std::endl << "test: storeBatchPayloads for N items (tag creation failed)" << std::endl;
1738  std::cout << e.what() << std::endl;
1739  }
1740 
1741  int step = 10;
1742  uint64_t endtime = (n + 1) * step;
1743 
1745 
1746  for (int i = 1; i <= n; i++) {
1747  int since = i * step;
1748  std::string d = myCrestClient.getDateAndTime() + "_" + std::to_string(i);
1749 
1750  nlohmann::json itemD =
1751  {
1752  {"data", d},
1753  {"since", since}
1754  };
1755 
1756  data.push_back(itemD);
1757  } // end i
1758 
1759  try {
1760  myCrestClient.storeBatchPayloads(tagname, endtime, data);
1761  std::cout << std::endl << "test: storeBatchPayloads for N items (success) " << std::endl;
1762  }
1763  catch (const std::exception& e) {
1764  std::cout << std::endl << "test: storeBatchPayloads for N items (failed)" << std::endl;
1765  std::cerr << e.what() << std::endl;
1766  }
1767 }
1768 
1769 // The test to create a tag with the iovs/payloads together.
1770 
1771 void testTagAndStoreBatchFs(const std::string& tagname) {
1772  std::cout << std::endl << "test: createTagFs" << std::endl;
1773 
1774  bool rewrite = true;
1775  CrestClient myCrestClient = CrestClient(rewrite);
1776 
1777  nlohmann::json js =
1778  {
1779  {"description", "none"},
1780  {"endOfValidity", 0},
1781  {"insertionTime", "2018-12-06T11:18:35.641+0000"},
1782  {"lastValidatedTime", 0},
1783  {"modificationTime", "2018-12-06T11:18:35.641+0000"},
1784  {"name", tagname},
1785  {"payloadSpec", "stave: Int32, eta: Int32, mag: Float, base: Float, free: Float"},
1786  {"synchronization", "none"},
1787  {"timeType", "time"}
1788  };
1789 
1790  try{
1791  myCrestClient.createTag(js);
1792  std::cout << std::endl << "test: createTagFs (success)" << std::endl;
1793  }
1794  catch (const std::exception& e) {
1795  std::cout << std::endl << "test: createTagFs (failed)" << std::endl;
1796  std::cout << e.what() << std::endl;
1797  }
1798 
1799  uint64_t endtime = 200;
1800  std::string str = "[{\"data\":\"aaa\",\"since\":100},{\"data\":\"bbb\",\"since\":150}]";
1801  nlohmann::json js2 = myCrestClient.getJson(str);
1802 
1803  try {
1804  myCrestClient.storeBatchPayloads(tagname, endtime, js2);
1805  std::cout << std::endl << "test: storeBatchPayloads (success) " << std::endl;
1806  }
1807  catch (const std::exception& e) {
1808  std::cout << std::endl << "test: storeBatchPayloads (failed)" << std::endl;
1809  std::cerr << e.what() << std::endl;
1810  }
1811 }
1812 
1813 void testTagAndStoreBatchFsB(const std::string& tagname) {
1814  std::cout << std::endl << "test: createTagFs" << std::endl;
1815 
1816  bool rewrite = true;
1817  CrestClient myCrestClient = CrestClient(rewrite);
1818 
1819  nlohmann::json js =
1820  {
1821  {"description", "none"},
1822  {"endOfValidity", 0},
1823  {"insertionTime", "2018-12-06T11:18:35.641+0000"},
1824  {"lastValidatedTime", 0},
1825  {"modificationTime", "2018-12-06T11:18:35.641+0000"},
1826  {"name", tagname},
1827  {"payloadSpec", "stave: Int32, eta: Int32, mag: Float, base: Float, free: Float"},
1828  {"synchronization", "none"},
1829  {"timeType", "time"}
1830  };
1831 
1832  try{
1833  myCrestClient.createTag(js);
1834  std::cout << std::endl << "test: createTagFs (success)" << std::endl;
1835  }
1836  catch (const std::exception& e) {
1837  std::cout << std::endl << "test: createTagFs (failed)" << std::endl;
1838  std::cout << e.what() << std::endl;
1839  }
1840 
1841  uint64_t endtime = 200;
1842  std::string d1 = "\"" + myCrestClient.getDateAndTime() + "_A\"";
1843  std::string d2 = "\"" + myCrestClient.getDateAndTime() + "_B\"";
1844 
1845  std::string str = "[{\"payloadHash\":" + d1 + ",\"since\":100},{\"payloadHash\":" + d2 + ",\"since\":150}]";
1846  nlohmann::json js2 = myCrestClient.getJson(str);
1847 
1848  try {
1849  myCrestClient.storeBatchPayloads(tagname, endtime, js2);
1850  std::cout << std::endl << "test: storeBatchPayloads A (success) " << std::endl;
1851  }
1852  catch (const std::exception& e) {
1853  std::cout << std::endl << "test: storeBatchPayloads A (failed)" << std::endl;
1854  std::cerr << e.what() << std::endl;
1855  }
1856 
1857  d1 = "\"" + myCrestClient.getDateAndTime() + "_C\"";
1858  d2 = "\"" + myCrestClient.getDateAndTime() + "_D\"";
1859 
1860  str = "[{\"data\":" + d1 + ",\"since\":200},{\"data\":" + d2 + ",\"since\":250}]";
1861  js2 = myCrestClient.getJson(str);
1862 
1863  try {
1864  myCrestClient.storeBatchPayloads(tagname, endtime, js2);
1865  std::cout << std::endl << "test: storeBatchPayloads B (success) " << std::endl;
1866  }
1867  catch (const std::exception& e) {
1868  std::cout << std::endl << "test: storeBatchPayloads B (failed)" << std::endl;
1869  std::cerr << e.what() << std::endl;
1870  }
1871 }
1872 
1873 // IOV Number Methods:
1874 
1875 void testGetSize(const std::string& tagname) {
1876  std::cout << std::endl << "test: getSize" << std::endl;
1877  CrestClient myCrestClient = CrestClient(SURL,false);
1878 
1879  try {
1880  int info = myCrestClient.getSize(tagname);
1881  std::cout << std::endl << "test: getSize (result) = "
1882  << info << std::endl;
1883  }
1884  catch (const std::exception& e) {
1885  std::cout << std::endl << "test: getSize (failed)" << std::endl;
1886  std::cout << e.what() << std::endl;
1887  }
1888 }
1889 
1890 void testGetSizeFS(const std::string& tagname) {
1891  std::cout << std::endl << "test: getSizeFS" << std::endl;
1892 
1893  bool rewrite = true;
1894  CrestClient myCrestClient = CrestClient(rewrite);
1895 
1896  try {
1897  int info = myCrestClient.getSizeFS(tagname);
1898  std::cout << std::endl << "test: getSizeFS (result) = "
1899  << info << std::endl;
1900  }
1901  catch (const std::exception& e) {
1902  std::cout << std::endl << "test: getSizeFS (failed)" << std::endl;
1903  std::cout << e.what() << std::endl;
1904  }
1905 }
1906 
1907 // Auxillary tests
1908 
1909 void test01() {
1910  map<std::string, std::string> m;
1911  m["key1"] = "val1";
1912 
1913  map <std::string, std::string> :: iterator it = m.begin();
1914  cout << "Map Listing 1: " << endl;
1915  for (int i = 0; it != m.end(); ++it, ++i) { // Output
1916  cout << i << ") key: " << it->first << ", value: " << it->second << endl;
1917  }
1918 
1919  bool rewrite = true;
1920  CrestClient myCrestClient = CrestClient(rewrite);
1921  nlohmann::json iovs = myCrestClient.findAllIovsFs("MvG_01");
1922  std::cout << "IOV List = " << std::endl << iovs.dump(4) << std::endl;
1923 
1924  int length = iovs.size();
1925  std::cout << "IOV number = " << length << std::endl;
1926  for (int i = 0; i < length; i++) {
1927  std::cout << "item (" << i << ") = " << std::endl << iovs[i].dump(4) << std::endl;
1928 
1929  auto r = iovs[i].find("payloadHash");
1930  if (r != iovs[i].end()) {
1931  std::string hash = iovs[i].value("payloadHash", "NONE");
1932  std::cout << "hash = " << hash << std::endl;
1933  std::cout << "iov = " << iovs[i].dump() << std::endl;
1934  m[hash] = iovs[i].dump();
1935  }
1936  }
1937 
1938  it = m.begin();
1939  cout << "Map Listing 2: " << endl;
1940  for (int i = 0; it != m.end(); ++it, ++i) { // Output
1941  cout << i << ") key: " << it->first << ", value: " << it->second << endl;
1942  }
1943 }
1944 
1945 // Tag statistics method test:
1946 
1947 void testGetTagDataInfo(const std::string& tagname) {
1948  bool rewrite = true;
1949  CrestClient myCrestClient = CrestClient(rewrite);
1950 
1951  try{
1952  myCrestClient.getTagDataInfo(tagname);
1953  }
1954  catch (const std::exception& e) {
1955  std::cout << std::endl << "test: testGetTagDataInfo (failed)" << std::endl;
1956  std::cout << e.what() << std::endl;
1957  }
1958 }
1959 
1960 void testGetFirstLetters(const std::string& str) {
1961  std::cout << std::endl << "test: getFirstLetters" << std::endl;
1962  CrestClient myCrestClient = CrestClient(SURL,false);
1963 
1964  std::cout << "string to test = " << str << std::endl;
1965 
1966  try{
1967  std::string str2 = myCrestClient.getFirstLetters(str);
1968  std::cout << std::endl << "test: getFirstLetters (result) = " << str2 << std::endl;
1969  }
1970  catch (const std::exception& e) {
1971  std::cout << std::endl << "test: getFirstLetters (failed)" << std::endl;
1972  std::cerr << e.what() << std::endl;
1973  }
1974 }
1975 
1976 
1977 void testCreateIOV(const std::string& tagname1, const std::string& tagname2) {
1978  std::cout << std::endl << "test: createIOV" << std::endl;
1979 
1980  CrestClient myCrestClient = CrestClient(SURL,false);
1981 
1982  nlohmann::json js =
1983  {
1984  {"description", "none"},
1985  {"endOfValidity", 0},
1986  {"insertionTime", "2018-12-06T11:18:35.641+0000"},
1987  {"lastValidatedTime", 0},
1988  {"modificationTime", "2018-12-06T11:18:35.641+0000"},
1989  {"name", tagname1},
1990  {"payloadSpec", "stave: Int32, eta: Int32, mag: Float, base: Float, free: Float"},
1991  {"synchronization", "none"},
1992  {"timeType", "time"}
1993  };
1994 
1995  std::cout << "tag 1 = " << std::endl << js.dump(4) << std::endl;
1996 
1997  try{
1998  myCrestClient.createTag(js);
1999  std::cout << std::endl << "Tag " << tagname1 << " created" << std::endl;
2000  }
2001  catch (const std::exception& e) {
2002  std::cout << std::endl << "ERROR: tag " << tagname1 << " creation failed" << std::endl;
2003  std::cout << e.what() << std::endl;
2004  exit(0);
2005  }
2006 
2007  js["name"] = tagname2;
2008 
2009  std::cout << "tag 2 = " << std::endl << js.dump(4) << std::endl;
2010 
2011  try{
2012  myCrestClient.createTag(js);
2013  std::cout << std::endl << "Tag " << tagname2 << " created" << std::endl;
2014  }
2015  catch (const std::exception& e) {
2016  std::cout << std::endl << "ERROR: tag " << tagname2 << " creation failed" << std::endl;
2017  std::cout << e.what() << std::endl;
2018  exit(0);
2019  }
2020 
2021  // payloads and IOVs:
2022 
2023  uint64_t endtime = 200;
2024  std::string d1 = "\"" + myCrestClient.getDateAndTime() + "_A\"";
2025  std::string d2 = "\"" + myCrestClient.getDateAndTime() + "_B\"";
2026 
2027  std::string str = "[{\"data\":" + d1 + ",\"since\":100},{\"data\":" + d2 + ",\"since\":150}]";
2028  nlohmann::json js2 = myCrestClient.getJson(str);
2029 
2030  try {
2031  myCrestClient.storeBatchPayloads(tagname1, endtime, js2);
2032  std::cout << std::endl << "2 IOVs created in tag " << tagname1 << std::endl;
2033  }
2034  catch (const std::exception& e) {
2035  std::cout << std::endl << "ERROR: payloads and IOVs were not created." << std::endl;
2036  std::cerr << e.what() << std::endl;
2037  exit(0);
2038  }
2039 
2040  // copy the data to tag 2:
2041 
2042  try{
2043  nlohmann::json iovList = myCrestClient.findAllIovs(tagname1);
2044  std::cout << std::endl << "IOV list for tag " << tagname1 << " =" << std::endl;
2045  std::cout << iovList.dump(4) << std::endl;
2046 
2047  int listSize = iovList.size();
2048 
2049  for (int j = 0; j < listSize; j++) {
2050 
2051  nlohmann::json iov = iovList[j];
2052  nlohmann::json newIov = iov;
2053 
2054  newIov["tagName"] = tagname2;
2055 
2056  try{
2057  myCrestClient.createIov(newIov);
2058  }
2059  catch (const std::exception& e) {
2060  std::cout << "ERROR: Cannot write the IOV for the tag \"" << tagname2 << "\"" << std::endl;
2061  std::cerr << e.what() << std::endl;
2062  exit(0);
2063  }
2064 
2065  } // j
2066  }
2067  catch (const std::exception& e) {
2068  std::cout << std::endl << "ERROR: cannot get IOV list for tag " << tagname1 << std::endl;
2069  std::cerr << e.what() << std::endl;
2070  exit(0);
2071  }
2072 
2073  try{
2074  nlohmann::json iovList = myCrestClient.findAllIovs(tagname2);
2075  std::cout << std::endl << "IOV list for tag " << tagname2 << " =" << std::endl;
2076  std::cout << iovList.dump(4) << std::endl;
2077  }
2078  catch (const std::exception& e) {
2079  std::cout << std::endl << "ERROR: cannot get IOV list for tag " << tagname2 << std::endl;
2080  std::cerr << e.what() << std::endl;
2081  exit(0);
2082  }
2083 
2084 }
2085 
2086 void testStoreBatchIOVs(const std::string& tagname1, const std::string& tagname2) {
2087  std::cout << std::endl << "test: storeBatchIOVs" << std::endl;
2088  CrestClient myCrestClient = CrestClient(SURL,false);
2089 
2090  nlohmann::json js =
2091  {
2092  {"description", "none"},
2093  {"endOfValidity", 0},
2094  {"insertionTime", "2018-12-06T11:18:35.641+0000"},
2095  {"lastValidatedTime", 0},
2096  {"modificationTime", "2018-12-06T11:18:35.641+0000"},
2097  {"name", tagname1},
2098  {"payloadSpec", "stave: Int32, eta: Int32, mag: Float, base: Float, free: Float"},
2099  {"synchronization", "none"},
2100  {"timeType", "time"}
2101  };
2102 
2103  std::cout << "tag 1 = " << std::endl << js.dump(4) << std::endl;
2104 
2105  try{
2106  myCrestClient.createTag(js);
2107  std::cout << std::endl << "Tag " << tagname1 << " created" << std::endl;
2108  }
2109  catch (const std::exception& e) {
2110  std::cout << std::endl << "ERROR: tag " << tagname1 << " creation failed" << std::endl;
2111  std::cout << e.what() << std::endl;
2112  exit(0);
2113  }
2114 
2115  js["name"] = tagname2;
2116 
2117  std::cout << "tag 2 = " << std::endl << js.dump(4) << std::endl;
2118 
2119  try{
2120  myCrestClient.createTag(js);
2121  std::cout << std::endl << "Tag " << tagname2 << " created" << std::endl;
2122  }
2123  catch (const std::exception& e) {
2124  std::cout << std::endl << "ERROR: tag " << tagname2 << " creation failed" << std::endl;
2125  std::cout << e.what() << std::endl;
2126  exit(0);
2127  }
2128 
2129  // payloads and IOVs:
2130 
2131  uint64_t endtime = 200;
2132  std::string d1 = "\"" + myCrestClient.getDateAndTime() + "_A\"";
2133  std::string d2 = "\"" + myCrestClient.getDateAndTime() + "_B\"";
2134 
2135  std::string str = "[{\"data\":" + d1 + ",\"since\":100},{\"data\":" + d2 + ",\"since\":150}]";
2136  nlohmann::json js2 = myCrestClient.getJson(str);
2137 
2138  try {
2139  myCrestClient.storeBatchPayloads(tagname1, endtime, js2);
2140  std::cout << std::endl << "2 IOVs created in tag " << tagname1 << std::endl;
2141  }
2142  catch (const std::exception& e) {
2143  std::cout << std::endl << "ERROR: payloads and IOVs were not created." << std::endl;
2144  std::cerr << e.what() << std::endl;
2145  exit(0);
2146  }
2147 
2148  // copy the data to tag 2:
2149 
2150  try{
2151  nlohmann::json iovList = myCrestClient.findAllIovs(tagname1);
2152  std::cout << std::endl << "IOV list for tag " << tagname1 << " =" << std::endl;
2153  std::cout << iovList.dump(4) << std::endl;
2154 
2155  int listSize = iovList.size();
2156  nlohmann::json newIovList = nlohmann::json::array();
2157 
2158  for (int j = 0; j < listSize; j++) {
2159 
2160  nlohmann::json iov = iovList[j];
2161  nlohmann::json newIov = iov;
2162 
2163  newIov["tagName"] = tagname2;
2164  newIovList.push_back(newIov);
2165 
2166  } // j
2167 
2168 
2169  try{
2170  myCrestClient.storeBatchIOVs(newIovList);
2171  }
2172  catch (const std::exception& e) {
2173  std::cout << "ERROR: Cannot write the IOVs for the tag \"" << tagname2 << "\"" << std::endl;
2174  std::cerr << e.what() << std::endl;
2175  exit(0);
2176  }
2177 
2178  }
2179  catch (const std::exception& e) {
2180  std::cout << std::endl << "ERROR: cannot get IOV list for tag " << tagname1 << std::endl;
2181  std::cerr << e.what() << std::endl;
2182  exit(0);
2183  }
2184 
2185  try{
2186  nlohmann::json iovList = myCrestClient.findAllIovs(tagname2);
2187  std::cout << std::endl << "IOV list for tag " << tagname2 << " =" << std::endl;
2188  std::cout << iovList.dump(4) << std::endl;
2189  }
2190  catch (const std::exception& e) {
2191  std::cout << std::endl << "ERROR: cannot get IOV list for tag " << tagname2 << std::endl;
2192  std::cerr << e.what() << std::endl;
2193  exit(0);
2194  }
2195 
2196 }
2197 
2198 
2200  std::cout << std::endl << "test: getMgmtInfo" << std::endl;
2201  CrestClient myCrestClient = CrestClient(SURL,false);
2202 
2203  try {
2204  nlohmann::json tag_info = myCrestClient.getMgmtInfo();
2205  std::cout << std::endl << "test: getMgmtInfo (result) =" << std::endl
2206  << tag_info.dump(4) << std::endl;
2207  }
2208  catch (const std::exception& e) {
2209  std::cout << std::endl << "test: getMgmtInfo (failed)" << std::endl;
2210  std::cout << e.what() << std::endl;
2211  }
2212 }
2213 
2215  std::cout << std::endl << "test: getCrestVersion" << std::endl;
2216  CrestClient myCrestClient = CrestClient(SURL,false);
2217 
2218  try {
2219  std::string version = myCrestClient.getCrestVersion();
2220  std::cout << std::endl << "test: CREST server version = "
2221  << version << std::endl;
2222  }
2223  catch (const std::exception& e) {
2224  std::cout << std::endl << "test: getCrestVersion (failed)" << std::endl;
2225  std::cout << e.what() << std::endl;
2226  }
2227 }
2228 
2230  std::cout << std::endl << "test: getClientVersion" << std::endl;
2231  CrestClient myCrestClient = CrestClient(SURL,false);
2232 
2233  try {
2234  std::string version = myCrestClient.getClientVersion();
2235  std::cout << std::endl << "test: CrestApi version = "
2236  << version << std::endl;
2237  }
2238  catch (const std::exception& e) {
2239  std::cout << std::endl << "test: getClientVersion (failed)" << std::endl;
2240  std::cout << e.what() << std::endl;
2241  }
2242 }
2243 
2245  std::cout << std::endl << "test: getMajorVersion" << std::endl;
2246  CrestClient myCrestClient = CrestClient(SURL,false);
2247 
2248  std::string A = "4.1"; // good version
2249  std::string B = "abracadabra"; // wrong version
2250  std::string C = ".2"; // wrong version
2251  std::string D = "aaa.2"; // wrong version
2252 
2253  try {
2254  int versionA = myCrestClient.getMajorVersion(A);
2255  std::cout << std::endl << "test: major version (" << A << ") = "
2256  << versionA << std::endl;
2257  }
2258  catch (const std::exception& e) {
2259  std::cout << std::endl << "test: getMajorVersion (failed)" << std::endl;
2260  std::cout << e.what() << std::endl;
2261  }
2262 
2263  try {
2264  int versionB = myCrestClient.getMajorVersion(B);
2265  std::cout << std::endl << "test: major version (" << B << ") = "
2266  << versionB << std::endl;
2267  }
2268  catch (const std::exception& e) {
2269  std::cout << std::endl << "test: getMajorVersion (failed)" << std::endl;
2270  std::cout << e.what() << std::endl;
2271  }
2272 
2273  try {
2274  int versionC = myCrestClient.getMajorVersion(C);
2275  std::cout << std::endl << "test: major version (" << C << ") = "
2276  << versionC << std::endl;
2277  }
2278  catch (const std::exception& e) {
2279  std::cout << std::endl << "test: getMajorVersion (failed)" << std::endl;
2280  std::cout << e.what() << std::endl;
2281  }
2282 
2283  try {
2284  int versionD = myCrestClient.getMajorVersion(D);
2285  std::cout << std::endl << "test: major version (" << D << ") = "
2286  << versionD << std::endl;
2287  }
2288  catch (const std::exception& e) {
2289  std::cout << std::endl << "test: getMajorVersion (failed)" << std::endl;
2290  std::cout << e.what() << std::endl;
2291  }
2292 }
2293 
2294 
2296  std::cout << std::endl << "test: checkCrestVersion" << std::endl;
2297  CrestClient myCrestClient = CrestClient(SURL,false);
2298 
2299  try {
2300  myCrestClient.checkCrestVersion();
2301  std::cout << "test is OK." << std::endl;
2302  }
2303  catch (const std::exception& e) {
2304  std::cout << std::endl << "test: checkCrestVersion (failed)" << std::endl;
2305  std::cout << e.what() << std::endl;
2306  }
2307 }
2308 
2309 // V4 tests:
2310 
2312  std::cout << std::endl << "test: getCrestVersion2" << std::endl;
2313  CrestClient myCrestClient = CrestClient(SURL,false);
2314 
2315  try {
2316  std::string version = myCrestClient.getCrestVersion2();
2317  std::cout << std::endl << "test: CREST server version = "
2318  << version << std::endl;
2319  }
2320  catch (const std::exception& e) {
2321  std::cout << std::endl << "test: getCrestVersion2 (failed)" << std::endl;
2322  std::cout << e.what() << std::endl;
2323  }
2324 }
2325 
2327  std::cout << std::endl << "test: checkCrestVersion2" << std::endl;
2328  CrestClient myCrestClient = CrestClient(SURL,false);
2329 
2330  try {
2331  myCrestClient.checkCrestVersion2();
2332  std::cout << "test is OK." << std::endl;
2333  }
2334  catch (const std::exception& e) {
2335  std::cout << std::endl << "test: checkCrestVersion2 (failed)" << std::endl;
2336  std::cout << e.what() << std::endl;
2337  }
2338 }
2339 
2341  std::cout << std::endl << "test: testConstructor" << std::endl;
2342  CrestClient myCrestClient = CrestClient(SURL,false);
2343 
2344 }
2345 
2346 
2347 void testRemoveTagFromGlobalTagMap(const std::string& global_tag){
2348  std::cout << std::endl << "test: removeTagFromGlobalTagMap" << std::endl;
2349  CrestClient myCrestClient = CrestClient(SURL,false);
2350 
2351  try{
2352  nlohmann::json tagMap = myCrestClient.findGlobalTagMap(global_tag);
2353  std::cout << std::endl << "test: GlobalTagMap (initial) = "
2354  << tagMap.dump(4) << std::endl;
2355 
2356  int n = tagMap.size();
2357  std::cout << n << " tags will be deleted:\n";
2358 
2359 
2360  for (int i = 0; i < n; i++){
2361  nlohmann::json j = tagMap[i];
2362 
2363  std::string tag = "";
2364  std::string label = "";
2365 
2366  auto subjectIdIter1 = j.find("tagName");
2367  if (subjectIdIter1 != j.end()){
2368  std::string tag = j["tagName"];
2369  std::cout << "tag name = " << tag << std::endl;
2370  }
2371 
2372  auto subjectIdIter2 = j.find("label");
2373  if (subjectIdIter2 != j.end()){
2374  label = j["label"];
2375  std::cout << "label = " << label << std::endl;
2376  }
2377 
2378  try{
2379  myCrestClient.removeTagFromGlobalTagMap(global_tag,tag,label);
2380  std::cout << tag << " removed.\n";
2381  }
2382  catch (const std::exception& e) {
2383  std::cout << std::endl << "Cannot remove tag " << tag << std::endl;
2384  std::cout << e.what() << std::endl;
2385  } // try
2386  } // for
2387 
2388  }
2389  catch (const std::exception& e) {
2390  std::cout << std::endl << "test: findGlobalTagMap (failed)" << std::endl;
2391  std::cout << e.what() << std::endl;
2392  }
2393 
2394  // Result:
2395  try{
2396  nlohmann::json tagMap = myCrestClient.findGlobalTagMap(global_tag);
2397  std::cout << std::endl << "test: GlobalTagMap (result) = "
2398  << tagMap.dump(4) << std::endl;
2399  }
2400  catch (const std::exception& e) {
2401  std::cout << std::endl << "test: tRemoveTagFromGlobalTagMap (failed)" << std::endl;
2402  std::cout << e.what() << std::endl;
2403  }
2404 
2405 }
2406 
2407 void testStoreBatchPayloadsFiles(const std::string& tagname) {
2408  std::cout << std::endl << "test: storeBatchPayloadsFiles" << std::endl;
2409  CrestClient myCrestClient = CrestClient(SURL,false);
2410 
2411  uint64_t endtime = 200;
2412  std::string d1 = "\"" + myCrestClient.getDateAndTime() + "_A\"";
2413  std::string d2 = "\"" + myCrestClient.getDateAndTime() + "_B\"";
2414 
2415  std::string file1 = "/tmp/mvg01.txt";
2416  std::string file2 = "/tmp/mvg02.txt";
2417 
2418  std::ofstream out1;
2419  out1.open(file1);
2420  if (out1.is_open()){
2421  out1 << d1;
2422  }
2423  out1.close();
2424 
2425  std::ofstream out2;
2426  out2.open(file2);
2427  if (out2.is_open()){
2428  out2 << d2;
2429  }
2430  out2.close();
2431 
2432  d1 = "file://" + file1;
2433  d2 = "file://" + file2;
2434 
2435  std::string str = "[{\"data\":\"" + d1 + "\",\"since\":100},{\"data\":\"" + d2 + "\",\"since\":150}]";
2436  nlohmann::json js = myCrestClient.getJson(str);
2437 
2438  std::cout << "json = " << js.dump(4) << std::endl;
2439 
2440  try {
2441  myCrestClient.storeBatchPayloadsFiles(tagname, endtime, js);
2442  std::cout << std::endl << "test: storeBatchPayloadsFiles (success) " << std::endl;
2443  }
2444  catch (const std::exception& e) {
2445  std::cout << std::endl << "test: storeBatchPayloadsFiles (failed)" << std::endl;
2446  std::cerr << e.what() << std::endl;
2447  }
2448 }
2449 
2450 
2451 void testStoreData(const std::string& tagname) {
2452  std::cout << std::endl << "test: storeData" << std::endl;
2453  CrestClient myCrestClient = CrestClient(SURL,false);
2454 
2455  uint64_t endtime = 200;
2456  uint64_t since = 100;
2457  std::string d1 = "\"" + myCrestClient.getDateAndTime() + "_A\"";
2458 
2459  std::string file = "/tmp/mvg01.txt";
2460 
2461  std::ofstream out1;
2462  out1.open(file);
2463  if (out1.is_open()){
2464  out1 << d1;
2465  }
2466  out1.close();
2467 
2468  try {
2469  myCrestClient.storeData(tagname, endtime, since, file);
2470  std::cout << std::endl << "test: storeData (success) " << std::endl;
2471  }
2472  catch (const std::exception& e) {
2473  std::cout << std::endl << "test: storeData (failed)" << std::endl;
2474  std::cerr << e.what() << std::endl;
2475  }
2476 }
2477 
2478 void testStoreDataArray(const std::string& tagname) {
2479  std::cout << std::endl << "test: storeDataArray" << std::endl;
2480  CrestClient myCrestClient = CrestClient(SURL,false);
2481 
2482  uint64_t endtime = 200;
2483  uint64_t since1 = 100;
2484  uint64_t since2 = 150;
2485  std::string d1 = "\"" + myCrestClient.getDateAndTime() + "_A\"";
2486  std::string d2 = "\"" + myCrestClient.getDateAndTime() + "_B\"";
2487 
2488  std::string file1 = "/tmp/mvg01.txt";
2489  std::string file2 = "/tmp/mvg02.txt";
2490 
2491  std::map<uint64_t, std::string> data;
2492 
2493  std::ofstream out1;
2494  out1.open(file1);
2495  if (out1.is_open()){
2496  out1 << d1;
2497  }
2498  out1.close();
2499 
2500  std::ofstream out2;
2501  out2.open(file2);
2502  if (out2.is_open()){
2503  out2 << d2;
2504  }
2505  out2.close();
2506 
2507  data[since1] = file1;
2508  data[since2] = file2;
2509 
2510  try {
2511  myCrestClient.storeDataArray(tagname, endtime, data);
2512  std::cout << std::endl << "test: storeDataArray (success) " << std::endl;
2513  }
2514  catch (const std::exception& e) {
2515  std::cout << std::endl << "test: storeDataArray (failed)" << std::endl;
2516  std::cerr << e.what() << std::endl;
2517  }
2518 }
2519 
2520 
2521 void testCreateGlobalTagMap2(const std::string& globaltag, const std::string& tagname) {
2522  std::cout << std::endl << "test: createGlobalTagMap" << std::endl;
2523  CrestClient myCrestClient = CrestClient(SURL,false);
2524 
2525  nlohmann::json js =
2526  {
2527  {"globalTagName", globaltag},
2528  {"record", "testing3"},
2529  {"label", "test3"},
2530  {"tagName", tagname}
2531  };
2532 
2533  try{
2534  myCrestClient.createGlobalTagMap(js);
2535  std::cout << std::endl << "test: createGlobalTagMap (success) " << std::endl;
2536  }
2537  catch (const std::exception& e) {
2538  std::cout << std::endl << "test: createGlobalTagMap (failed)" << std::endl;
2539  std::cout << e.what() << std::endl;
2540  }
2541 }
2542 
2543 void testSelectGroups2(const std::string& tagname, int groupsize) {
2544  std::cout << std::endl << "test: selectGroups2" << std::endl;
2545  CrestClient myCrestClient = CrestClient(SURL,false);
2546 
2547  try{
2548  nlohmann::json tag_info = myCrestClient.selectGroups(tagname, groupsize);
2549  std::cout << std::endl << "test: selectGroups2 (result) =" << std::endl;
2550  std::cout << tag_info.dump(4) << std::endl;
2551  }
2552  catch (const std::exception& e) {
2553  std::cout << std::endl << "test: selectGroups2 (failed)" << std::endl;
2554  std::cerr << e.what() << std::endl;
2555  }
2556 }
2557 
2558 
2559 int main(int argc, char* argv[]) {
2560  if (argc == 2) {
2561 
2562  SURL = argv[1];
2563  print_path();
2564 
2565  // TO RUN TEST UNCOMMENT IT!
2566  // (and check parameters!)
2567 
2568  std::string tagname = "test_tag_01"; // write your tag name
2569 
2570  // Test: tag crestion, tag reading and removing.
2571 
2572  // testRemoveTag(tagname); // remove tag if it exist
2576 
2577  // Test: tag creation, IOVs and payloads storing.
2578  /*
2579  testRemoveTag(tagname);
2580  testCreateTag(tagname);
2581  testFindAllIovs(tagname);
2582  testStoreBatchPayloadsB(tagname); // new test
2583  // testStoreBatchPayloads(tagname); // old test
2584  testFindTag(tagname);
2585  testFindAllIovs(tagname);
2586  testRemoveTag(tagname);
2587  */
2588 
2589 
2590  // Test: tag and global tag creation.
2591  /*
2592  testRemoveTag(tagname);
2593  testCreateTag(tagname);
2594  testCreateGlobalTag("MvG_TEST_01");
2595  testFindGlobalTag("MvG_TEST_01");
2596  testCreateGlobalTagMap("MvG_TEST_01",tagname);
2597  testFindGlobalTagMap("MvG_TEST_01");
2598 
2599  testRemoveGlobalTag("MvG_TEST_01");
2600  testFindGlobalTag("MvG_TEST_01");
2601  testFindGlobalTagMap("MvG_TEST_01");
2602  */
2603 
2604 
2605  // Test: tag meta info creation.
2606  /*
2607  testRemoveTag(tagname);
2608  testCreateTag(tagname);
2609  testCreateTagMetaInfo(tagname);
2610  // testCreateTagMetaInfo2(tagname); // variant 2
2611  testGetTagMetaInfo(tagname);
2612  testUpdateTagMetainfo(tagname);
2613  testGetTagMetaInfo(tagname);
2614  testRemoveTag(tagname);
2615  */
2616 
2617 
2618  } else {
2619  std::cout << "CREST Server path not found" << std::endl;
2620  std::cout << "Please, run this program with a server path:" << std::endl;
2621  std::cout << "crest_example http://crest-undertow-api.web.cern.ch" << std::endl;
2622  }
2623  std::cout << "Test ended" << std::endl;
2624  return 0;
2625 }
grepfile.info
info
Definition: grepfile.py:38
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Crest::CrestClient::getPayloadAsJsonFS
nlohmann::json getPayloadAsJsonFS(const std::string &hash)
This auxillary method finds a payload resource associated to the hash in the local file storage.
Definition: CrestApi.cxx:2566
testGetPayloadMetaInfoAsStringFS
void testGetPayloadMetaInfoAsStringFS(const std::string &hash)
Definition: crest_example.cxx:1575
beamspotman.r
def r
Definition: beamspotman.py:676
Crest::CrestClient::getBlob
std::string getBlob(const std::string &hash)
This method finds payload data by hash; the payload object contains the real BLOB.
Definition: CrestApi.cxx:915
Crest::CrestClient::getBlobInStreamFs
std::string getBlobInStreamFs(const std::string &hash, std::ofstream &out)
This method finds payload data by hash; the payload object contains the real BLOB.
Definition: CrestApi.cxx:2610
testCreateIOV
void testCreateIOV(const std::string &tagname1, const std::string &tagname2)
Definition: crest_example.cxx:1977
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
testCreateTagF
void testCreateTagF(const std::string &tagname)
Definition: crest_example.cxx:108
Crest::CrestClient::selectIovs
nlohmann::json selectIovs(const std::string &tagname)
Select iovs for a given tagname.
Definition: CrestApi.cxx:493
testConvertTagMetaInfo2CREST
void testConvertTagMetaInfo2CREST()
Definition: crest_example.cxx:1023
testCreateTag
void testCreateTag(const std::string &tagname)
Definition: crest_example.cxx:49
testGetBlobInStream
void testGetBlobInStream(const std::string &hash)
Definition: crest_example.cxx:1095
Crest::CrestClient::findGlobalTagMapFs
nlohmann::json findGlobalTagMapFs(const std::string &name)
The auxillary method to find a global tag by name for the file storage.
Definition: CrestApi.cxx:2412
Crest::CrestClient::findAllIovs
nlohmann::json findAllIovs(const std::string &tagname)
This method finds all iovs for a given tag name.
Definition: CrestApi.cxx:390
testGetSizeFS
void testGetSizeFS(const std::string &tagname)
Definition: crest_example.cxx:1890
dqt_zlumi_alleff_HIST.iov
iov
Definition: dqt_zlumi_alleff_HIST.py:119
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
Crest::CrestClient::getTagDataInfo
void getTagDataInfo(const std::string &tagname)
This is an auxillary method for checking how many unique IOVs(hashcodes) are in an IOV list.
Definition: CrestApi.cxx:2712
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
testCreateGlobalTagMapFs
void testCreateGlobalTagMapFs(const std::string &globaltag, const std::string &tagname)
Definition: crest_example.cxx:1433
CrestApiExt.h
Header file for CREST C++ Client Library (CrestClientExt)
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
Crest::CrestClient::getDateAndTime
std::string getDateAndTime()
The auxillary method to get a current data and time.
Definition: CrestApi.cxx:2534
Crest::CrestClient::createTagMetaInfoIOVDbSvc
void createTagMetaInfoIOVDbSvc(const std::string &tagname, nlohmann::json &js)
This method creates a tag meta info in the CREST database.
Definition: CrestApi.cxx:2134
testCreateTagMetaInfoDetailedFs
void testCreateTagMetaInfoDetailedFs(const std::string &tagname)
Definition: crest_example.cxx:1204
testRemoveGlobalTag
void testRemoveGlobalTag(const std::string &tagname)
Definition: crest_example.cxx:367
testStoreDataArray
void testStoreDataArray(const std::string &tagname)
Definition: crest_example.cxx:2478
testUpdateTagSpecification
void testUpdateTagSpecification(const std::string &tagname)
Definition: crest_example.cxx:246
Crest::CrestClient::getPayloadMetaInfoAsJsonFS
nlohmann::json getPayloadMetaInfoAsJsonFS(const std::string &hash)
This auxillary method finds a payload resource associated to the hash in the local file storage.
Definition: CrestApi.cxx:2594
Crest::CrestClient::getJson
nlohmann::json getJson(const std::string &str)
Auxillary method to convert string in to JSON object.
Definition: CrestApi.cxx:1650
json
nlohmann::json json
Definition: HistogramDef.cxx:9
testCreateGlobalTagFs
void testCreateGlobalTagFs(const std::string &tagname)
Definition: crest_example.cxx:1384
testSelectIovsParams
void testSelectIovsParams(const std::string &tagname, long since, long until)
Definition: crest_example.cxx:718
Crest::CrestClient::createTag
void createTag(nlohmann::json &js)
This method creates a tag in the CREST database.
Definition: CrestApi.cxx:262
find_tgc_unfilled_channelids.iovs
iovs
Definition: find_tgc_unfilled_channelids.py:12
Crest::CrestClient::getBlobInStream
std::string getBlobInStream(const std::string &hash, std::ofstream &out)
This method finds payload data by hash; the payload object contains the real BLOB.
Definition: CrestApi.cxx:936
hist_file_dump.d
d
Definition: hist_file_dump.py:137
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
testFindAllIovsFSPlus
void testFindAllIovsFSPlus(const std::string &tagname, int size, int page)
Definition: crest_example.cxx:703
testGetMgmtInfo
void testGetMgmtInfo()
Definition: crest_example.cxx:2199
Crest::CrestClient::getTagMetaInfo
nlohmann::json getTagMetaInfo(const std::string &tagname)
This method gets a tag meta info from the CREST database.
Definition: CrestApi.cxx:2037
Crest::CrestClient::findGlobalTagMap
nlohmann::json findGlobalTagMap(const std::string &name)
This method search for mappings using the global tag name.
Definition: CrestApi.cxx:849
testFindGlobalTagFs
void testFindGlobalTagFs(const std::string &tagname)
Definition: crest_example.cxx:1415
Crest::CrestClient::createGlobalTag
void createGlobalTag(nlohmann::json &js)
Create a global tag in the database.
Definition: CrestApi.cxx:688
picosha2::hash256_hex_string
void hash256_hex_string(InIter first, InIter last, std::string &hex_str)
Definition: picosha2.h:353
testSelectIovs
void testSelectIovs(const std::string &tagname)
Definition: crest_example.cxx:759
skel.it
it
Definition: skel.GENtoEVGEN.py:423
Crest::CrestClient::selectIovsFS
nlohmann::json selectIovsFS(const std::string &tagname, long since, long until)
This method selects all iovs for a given tag name and for the selected time interval (since-until).
Definition: CrestApi.cxx:2689
Crest::CrestClient::storeData
void storeData(const std::string &tag, uint64_t endtime, uint64_t since, const std::string &file)
This method stores a payload from a file in the database, associated to a given IOV since and tag nam...
Definition: CrestApi.cxx:3119
testCreateRunLumiInfo
void testCreateRunLumiInfo()
Definition: crest_example.cxx:428
testStoreBatchIOVs
void testStoreBatchIOVs(const std::string &tagname1, const std::string &tagname2)
Definition: crest_example.cxx:2086
testGetPayloadMetaInfoAsString
void testGetPayloadMetaInfoAsString(const std::string &hash)
Definition: crest_example.cxx:1165
hashCalculationTest
void hashCalculationTest(const std::string &str)
Definition: crest_example.cxx:1481
testGetPayloadMetaInfoAsJsonFS
void testGetPayloadMetaInfoAsJsonFS(const std::string &hash)
Definition: crest_example.cxx:1590
Crest::CrestClient::getSize
int getSize(const std::string &tagname)
This metghod gets the number of iovs for the given tag.
Definition: CrestApi.cxx:454
dq_defect_virtual_defect_validation.d1
d1
Definition: dq_defect_virtual_defect_validation.py:79
testUpdateTagMetaInfoFs
void testUpdateTagMetaInfoFs(const std::string &tagname)
Definition: crest_example.cxx:1266
Crest::CrestClient::findGlobalTag
nlohmann::json findGlobalTag(const std::string &name)
Finds a global tag by name.
Definition: CrestApi.cxx:745
WriteCaloSwCorrections.tag_list
tag_list
Definition: WriteCaloSwCorrections.py:28
Crest::CrestClient::getHash
std::string getHash(std::string_view str)
The auxillary method to calculate a hash code for a given string.
Definition: CrestApi.cxx:2441
Crest::CrestClient::listGlobalTags
nlohmann::json listGlobalTags()
This method finds a global tag lists.
Definition: CrestApi.cxx:773
testCreateTagMetaInfo2
void testCreateTagMetaInfo2(const std::string &tagname)
Definition: crest_example.cxx:871
testStoreData
void testStoreData(const std::string &tagname)
Definition: crest_example.cxx:2451
Crest::CrestClient::updateGlobalTag
void updateGlobalTag(const std::string &name, nlohmann::json body)
This method allows to update a GlobalTag.Arguments: the name has to uniquely identify a global tag.
Definition: CrestApi.cxx:672
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
testFindTag
void testFindTag(const std::string &tagname)
Definition: crest_example.cxx:200
testGetBlobFS
void testGetBlobFS(const std::string &hash)
Definition: crest_example.cxx:1628
testGetFirstLetters
void testGetFirstLetters(const std::string &str)
Definition: crest_example.cxx:1960
Crest::CrestClient::checkCrestVersion2
void checkCrestVersion2()
This method is a CREST version test.
Definition: CrestApi.cxx:2889
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
ATLAS_NO_CHECK_FILE_THREAD_SAFETY
Definition: crest_example.cxx:22
Crest::CrestClient::getPayloadMetaInfo
nlohmann::json getPayloadMetaInfo(const std::string &hash)
This method finds a payload resource associated to the hash.
Definition: CrestApi.cxx:956
Crest::CrestClient::storeDataArray
void storeDataArray(const std::string &tag, uint64_t endtime, std::map< uint64_t, std::string > m)
This method stores several payloads from files in batch mode.
Definition: CrestApi.cxx:3130
Crest
Definition: CrestApi.h:29
testGetTagDataInfo
void testGetTagDataInfo(const std::string &tagname)
Definition: crest_example.cxx:1947
Crest::CrestClient::updateTagMetaInfoFs
void updateTagMetaInfoFs(const std::string &tagname, nlohmann::json &js)
This auxillary method updates a tag meta info in local file storage.
Definition: CrestApi.cxx:2224
Crest::CrestClient::getPayloadAsStringFS
std::string getPayloadAsStringFS(const std::string &hash)
This auxillary method finds a payload resource associated to the hash in the local file storage.
Definition: CrestApi.cxx:2547
testCreateGlobalTag
void testCreateGlobalTag(const std::string &tagname)
Definition: crest_example.cxx:266
testListGlobalTagsAsString
void testListGlobalTagsAsString()
Definition: crest_example.cxx:325
Crest::CrestClient::removeTagFromGlobalTagMap
void removeTagFromGlobalTagMap(const std::string &global_tag, const std::string &tag, const std::string &label)
This method removes a tag with the name tag and the label from the global tag map with name global_ta...
Definition: CrestApi.cxx:2902
testListPayloadTagInfo
void testListPayloadTagInfo()
Definition: crest_example.cxx:1060
Crest::CrestClient::getBlobFs
std::string getBlobFs(const std::string &hash)
This method finds payload data by hash in the file storage; the payload object contains the real BLOB...
Definition: CrestApi.cxx:2600
testTagAndStoreBatchFsNItems
void testTagAndStoreBatchFsNItems(const std::string &tagname, int n)
Definition: crest_example.cxx:1713
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
testFindAllIovs
void testFindAllIovs(const std::string &tagname)
Definition: crest_example.cxx:650
testGetMajorVersion
void testGetMajorVersion()
Definition: crest_example.cxx:2244
dq_defect_copy_defect_database.since
def since
Definition: dq_defect_copy_defect_database.py:54
dq_defect_copy_defect_database.until
def until
Definition: dq_defect_copy_defect_database.py:55
testGetPayloadAsString
void testGetPayloadAsString(const std::string &hash)
Definition: crest_example.cxx:1149
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
testStoreBatchPayloadsFs
void testStoreBatchPayloadsFs(const std::string &tagname)
Definition: crest_example.cxx:1362
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
main
int main(int argc, char *argv[])
Definition: crest_example.cxx:2559
testFindGlobalTagMap
void testFindGlobalTagMap(const std::string &mapname)
Definition: crest_example.cxx:523
Crest::CrestClient::convertTagMetaInfo2CREST
nlohmann::json convertTagMetaInfo2CREST(nlohmann::json &js)
Auxillary method to convert a Tag Meta Info from the JSON IOVDbSvc format in CREST Server format.
Definition: CrestApi.cxx:1955
Crest::CrestClient::storeBatchPayloadsFiles
void storeBatchPayloadsFiles(const std::string &tag_name, uint64_t endtime, nlohmann::json &js)
This method stores several payloads from files in batch mode.
Definition: CrestApi.cxx:2925
testGetHash
void testGetHash(const std::string &str)
Definition: crest_example.cxx:1474
testGetTagMetaInfoFs
void testGetTagMetaInfoFs(const std::string &tagname)
Definition: crest_example.cxx:1250
testListTags
void testListTags()
Definition: crest_example.cxx:140
Crest::CrestClient::listTags
nlohmann::json listTags(void)
This method returns the tag list.
Definition: CrestApi.cxx:103
testStoreBatchPayloads
void testStoreBatchPayloads(const std::string &tagname)
Definition: crest_example.cxx:1670
Crest::CrestClient::updateTag
void updateTag(const std::string &tagname, nlohmann::json body)
This method allows to update tag record in the CREST DB.
Definition: CrestApi.cxx:278
Crest::CrestClient::storeBatchPayloads
void storeBatchPayloads(const std::string &tag_name, uint64_t endtime, const std::string &iovsetupload)
This method stores several payloads in batch mode.
Definition: CrestApi.cxx:1102
Crest::CrestClient::getPayloadAsString
std::string getPayloadAsString(const std::string &hash)
This method finds a payload resource associated to the hash.
Definition: CrestApi.cxx:1066
testCreateTagFs
void testCreateTagFs(const std::string &tagname)
Definition: crest_example.cxx:1331
lumiFormat.i
int i
Definition: lumiFormat.py:92
testCreateTagMetaInfo2Args
void testCreateTagMetaInfo2Args(const std::string &tagname)
Definition: crest_example.cxx:836
testStorePayload
void testStorePayload(const std::string &tagname)
Definition: crest_example.cxx:597
Crest::CrestClient::getCrestVersion
std::string getCrestVersion()
This method returns the full CREST Server version.
Definition: CrestApi.cxx:2783
beamspotman.n
n
Definition: beamspotman.py:731
Crest::CrestClient::createGlobalTagMapFs
void createGlobalTagMapFs(nlohmann::json &js)
The auxillary method to create a global tag map in file storage.
Definition: CrestApi.cxx:2329
Crest::CrestClient::returnJArray
nlohmann::json returnJArray(nlohmann::json js)
This auxillary method creates a JSON array from a JSON object.
Definition: CrestApi.cxx:2639
testTagAndStoreBatchFsB
void testTagAndStoreBatchFsB(const std::string &tagname)
Definition: crest_example.cxx:1813
testUpdateGlobalTag
void testUpdateGlobalTag(const std::string &tagname)
Definition: crest_example.cxx:380
testGetTagMetaInfoIOVDbSvc
void testGetTagMetaInfoIOVDbSvc(const std::string &tagname)
Definition: crest_example.cxx:1008
calibdata.exception
exception
Definition: calibdata.py:496
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
print_path
void print_path()
Definition: crest_example.cxx:29
file
TFile * file
Definition: tile_monitor.h:29
testGetPayloadAsJson
void testGetPayloadAsJson(const std::string &hash)
Definition: crest_example.cxx:1133
testFindAllIovsParams
void testFindAllIovsParams(const std::string &tagname, int size, int page)
Definition: crest_example.cxx:665
Crest::CrestClient::getSizeFS
int getSizeFS(const std::string &tagname)
This metghod gets the number of iovs for the given tag.
Definition: CrestApi.cxx:2645
testStoreBatchPayloadsB
void testStoreBatchPayloadsB(const std::string &tagname)
Definition: crest_example.cxx:1690
testConstructor
void testConstructor()
Definition: crest_example.cxx:2340
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
Crest::CrestClient::findTag
nlohmann::json findTag(const std::string &name)
This method finds a tag by the name.
Definition: CrestApi.cxx:226
testGetSize
void testGetSize(const std::string &tagname)
Definition: crest_example.cxx:1875
Crest::data
Definition: CrestApi.cxx:1269
testUpdateTag
void testUpdateTag(const std::string &tagname)
Definition: crest_example.cxx:229
testListGlobalTags
void testListGlobalTags()
Definition: crest_example.cxx:310
Crest::CrestClient::createGlobalTagMap
void createGlobalTagMap(nlohmann::json &gt)
Method to create a global tag map.
Definition: CrestApi.cxx:872
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
Crest::CrestClient::getPayloadMetaInfoAsStringFS
std::string getPayloadMetaInfoAsStringFS(const std::string &hash)
This auxillary method finds a payload resource associated to the hash in the local file storage.
Definition: CrestApi.cxx:2572
Crest::CrestClientExt
Definition: CrestApiExt.h:30
Crest::CrestClient::getCrestVersion2
std::string getCrestVersion2()
This method returns the full CREST Server version.
Definition: CrestApi.cxx:2863
calibdata.exit
exit
Definition: calibdata.py:236
testSelectGroups2
void testSelectGroups2(const std::string &tagname, int groupsize)
Definition: crest_example.cxx:2543
testCreateTagMetaInfoIOVDbSvc
void testCreateTagMetaInfoIOVDbSvc(const std::string &tagname)
Definition: crest_example.cxx:980
testCreateGlobalTagMap2
void testCreateGlobalTagMap2(const std::string &globaltag, const std::string &tagname)
Definition: crest_example.cxx:2521
testGetDateAndTime
void testGetDateAndTime()
Definition: crest_example.cxx:1529
beamspotman.dir
string dir
Definition: beamspotman.py:623
CheckTagAssociation.globaltag
globaltag
Definition: CheckTagAssociation.py:18
testGetBlobInStreamFS
void testGetBlobInStreamFS(const std::string &hash)
Definition: crest_example.cxx:1605
testSelectGroups
void testSelectGroups(const std::string &tagname)
Definition: crest_example.cxx:789
Crest::CrestClient::storePayloadDump
void storePayloadDump(const std::string &tag, uint64_t since, const std::string &js)
Method to store a payload in the local file system.
Definition: CrestApi.cxx:2446
lumiFormat.array
array
Definition: lumiFormat.py:98
Crest::CrestClient::listPayloadTagInfo
nlohmann::json listPayloadTagInfo()
This method retrieves monitoring information on all payloads as a list of payload tag information.
Definition: CrestApi.cxx:1023
Crest::CrestClient::getFirstLetters
std::string getFirstLetters(const std::string &str)
This is an auxillary method extract first letters from the string (hash).
Definition: CrestApi.cxx:2762
testTagAndStoreBatchFs
void testTagAndStoreBatchFs(const std::string &tagname)
Definition: crest_example.cxx:1771
testGetPayloadMetaInfo
void testGetPayloadMetaInfo(const std::string &hash)
Definition: crest_example.cxx:1181
Crest::CrestClient::getClientVersion
std::string getClientVersion()
This method returns the full CrestApi version.
Definition: CrestApi.cxx:2809
testListGlobalTagsParams
void testListGlobalTagsParams(const std::string &name, int size, int page)
Definition: crest_example.cxx:340
testCheckCrestVersion2
void testCheckCrestVersion2()
Definition: crest_example.cxx:2326
Crest::CrestClient::updateTagMetaInfo
void updateTagMetaInfo(nlohmann::json &js)
This method updates a tag meta info in the CREST database.
Definition: CrestApi.cxx:2060
testStorePayloadDump
void testStorePayloadDump(const std::string &tagname)
Definition: crest_example.cxx:621
Crest::CrestClient::storePayload
void storePayload(const std::string &tag, uint64_t since, const std::string &js)
Create a payload in the database, associated to a given iov since and tag name.
Definition: CrestApi.cxx:1252
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
testFindGlobalTagMapFs
void testFindGlobalTagMapFs(const std::string &tagname)
Definition: crest_example.cxx:1456
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
Crest::CrestClient::updateTagSpecification
void updateTagSpecification(const std::string &tagname, const std::string &objectType)
This method cahnges object type specification.
Definition: CrestApi.cxx:293
testGetPayloadAsStringFS
void testGetPayloadAsStringFS(const std::string &hash)
Definition: crest_example.cxx:1545
testGetTagMetaInfo
void testGetTagMetaInfo(const std::string &tagname)
Definition: crest_example.cxx:941
testGetCrestVersion2
void testGetCrestVersion2()
Definition: crest_example.cxx:2311
Crest::CrestClient::checkCrestVersion
void checkCrestVersion()
This method is a CREST version test.
Definition: CrestApi.cxx:2833
testListRunLumiInfo
void testListRunLumiInfo()
Definition: crest_example.cxx:504
Crest::CrestClient::getMgmtInfo
nlohmann::json getMgmtInfo()
This is an auxillary method to read the CREST Server properties.
Definition: CrestApi.cxx:2767
test01
void test01()
Definition: crest_example.cxx:1909
testFindGlobalTagAsString
void testFindGlobalTagAsString(const std::string &tagname)
Definition: crest_example.cxx:409
testCreateTag2
void testCreateTag2()
Definition: crest_example.cxx:76
testGetBlob
void testGetBlob(const std::string &hash)
Definition: crest_example.cxx:1117
Crest::CrestClient::findGlobalTagAsString
std::string findGlobalTagAsString(const std::string &name)
Finds a global tag by name.
Definition: CrestApi.cxx:724
Crest::CrestClient::storeBatchIOVs
void storeBatchIOVs(nlohmann::json &js)
This method stores an IOV set on the CREST server.
Definition: CrestApi.cxx:630
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
MyPlots.page
page
Definition: MyPlots.py:234
get_generator_info.version
version
Definition: get_generator_info.py:33
SURL
std::string SURL
Definition: crest_example.cxx:27
testRemoveTag
void testRemoveTag(const std::string &tagname)
Definition: crest_example.cxx:215
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
Crest::CrestClient::createIov
void createIov(nlohmann::json &iov)
This method creates an iov for a given tag in the CREST DB for the created payload.
Definition: CrestApi.cxx:370
Crest::CrestClient::selectGroups
nlohmann::json selectGroups(const std::string &tagname)
Select groups for a given tagname.
Definition: CrestApi.cxx:579
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
testReturnJArray
void testReturnJArray()
Definition: crest_example.cxx:1643
testCreateTagMetaInfoDetailed
void testCreateTagMetaInfoDetailed(const std::string &tagname)
Definition: crest_example.cxx:896
testUpdateTagMetainfo
void testUpdateTagMetainfo(const std::string &tagname)
Definition: crest_example.cxx:956
testCheckCrestVersion
void testCheckCrestVersion()
Definition: crest_example.cxx:2295
dq_defect_virtual_defect_validation.d2
d2
Definition: dq_defect_virtual_defect_validation.py:81
Crest::CrestClient::createTagMetaInfo
void createTagMetaInfo(nlohmann::json &js)
This method creates a tag meta info in the CREST database.
Definition: CrestApi.cxx:1998
testFindGlobalTag
void testFindGlobalTag(const std::string &tagname)
Definition: crest_example.cxx:295
Crest::CrestClient
Definition: CrestApi.h:62
Crest::CrestClient::getMajorVersion
int getMajorVersion(std::string &str)
This is an auxillary method to extract a major version number from full version string.
Definition: CrestApi.cxx:2813
testCreateTagMetaInfo
void testCreateTagMetaInfo(const std::string &tagname)
Definition: crest_example.cxx:811
picosha2.h
Crest::CrestClient::removeTag
void removeTag(const std::string &tagName)
This method allows to remove a Tag.
Definition: CrestApi.cxx:209
testRemoveTagFromGlobalTagMap
void testRemoveTagFromGlobalTagMap(const std::string &global_tag)
Definition: crest_example.cxx:2347
tagname
Definition: tagname.h:29
LArCellBinning.step
step
Definition: LArCellBinning.py:158
testCreateRunLumiInfo2
void testCreateRunLumiInfo2()
Definition: crest_example.cxx:448
PlotCalibFromCool.iovList
iovList
Definition: PlotCalibFromCool.py:351
createDirTree
bool createDirTree(const std::string &full_path)
Definition: crest_example.cxx:33
testSelectIovsFS
void testSelectIovsFS(const std::string &tagname, long since, long until)
Definition: crest_example.cxx:741
str
Definition: BTagTrackIpAccessor.cxx:11
Crest::CrestClient::listRunLumiInfo
nlohmann::json listRunLumiInfo()
This method gets full list of run/lumi information data.
Definition: CrestApi.cxx:1198
testListTagsParams
void testListTagsParams()
Definition: crest_example.cxx:155
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
Crest::CrestClient::getPayloadAsJson
nlohmann::json getPayloadAsJson(const std::string &hash)
This method finds a payload resource associated to the hash.
Definition: CrestApi.cxx:1042
Crest::CrestClient::getTagMetaInfoIOVDbSvc
nlohmann::json getTagMetaInfoIOVDbSvc(const std::string &tagname)
This method gets a tag meta info from the CREST database in IOVDbSvc format.
Definition: CrestApi.cxx:2120
Crest::CrestClient::getPayloadMetaInfoAsString
std::string getPayloadMetaInfoAsString(const std::string &hash)
This method finds a payload resource associated to the hash.
Definition: CrestApi.cxx:980
testFindAllIovsFS
void testFindAllIovsFS(const std::string &tagname)
Definition: crest_example.cxx:685
checker_macros.h
Define macros for attributes used to control the static checker.
testGetPayloadAsJsonFS
void testGetPayloadAsJsonFS(const std::string &hash)
Definition: crest_example.cxx:1560
testGetCrestVersion
void testGetCrestVersion()
Definition: crest_example.cxx:2214
Crest::CrestClient::createRunLumiInfo
void createRunLumiInfo(nlohmann::json &body)
This method creates an entry for run information.
Definition: CrestApi.cxx:1216
Crest::CrestClient::findGlobalTagFs
nlohmann::json findGlobalTagFs(const std::string &name)
The auxillary method to find a global tag by name stored in file storage.
Definition: CrestApi.cxx:2307
testGetJson
void testGetJson()
Definition: crest_example.cxx:565
testCreateGlobalTagMap
void testCreateGlobalTagMap(const std::string &globaltag, const std::string &tagname)
Definition: crest_example.cxx:539
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
testFindTagFs
void testFindTagFs(const std::string &tagname)
Definition: crest_example.cxx:1314
Crest::CrestClient::createGlobalTagFs
void createGlobalTagFs(nlohmann::json &js)
The auxillary method to create a global tag in file storage.
Definition: CrestApi.cxx:2266
Crest::CrestClient::removeGlobalTag
void removeGlobalTag(const std::string &name)
This method allows to remove a Global Tag form CREST DB.
Definition: CrestApi.cxx:758
Crest::CrestClient::findAllIovsFs
nlohmann::json findAllIovsFs(const std::string &tagname)
This method finds all iovs by the tag name in the file storage.
Definition: CrestApi.cxx:1781
testGetClientVersion
void testGetClientVersion()
Definition: crest_example.cxx:2229
Crest::CrestClient::listGlobalTagsAsString
std::string listGlobalTagsAsString()
This method finds a global tag lists.
Definition: CrestApi.cxx:788
description
std::string description
glabal timer - how long have I taken so far?
Definition: hcg.cxx:88
testStoreBatchPayloadsFiles
void testStoreBatchPayloadsFiles(const std::string &tagname)
Definition: crest_example.cxx:2407