Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / cls / replica_log / cls_replica_log_ops.cc
1 /*
2  * Ceph - scalable distributed file system
3  *
4  * This is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License version 2.1, as published by the Free Software 
7  * Foundation.  See file COPYING.
8  * 
9  */
10
11 #include "cls_replica_log_ops.h"
12 #include "common/Formatter.h"
13 #include "common/ceph_json.h"
14
15 void cls_replica_log_delete_marker_op::dump(Formatter *f) const
16 {
17   f->dump_string("entity_id", entity_id);
18 }
19
20 void cls_replica_log_delete_marker_op::
21 generate_test_instances(std::list<cls_replica_log_delete_marker_op*>& ls)
22 {
23   ls.push_back(new cls_replica_log_delete_marker_op);
24   ls.push_back(new cls_replica_log_delete_marker_op);
25   ls.back()->entity_id = "test_entity_1";
26 }
27
28 void cls_replica_log_set_marker_op::dump(Formatter *f) const
29 {
30   encode_json("marker", marker, f);
31 }
32
33 void cls_replica_log_set_marker_op::
34 generate_test_instances(std::list<cls_replica_log_set_marker_op*>& ls)
35 {
36   std::list<cls_replica_log_progress_marker*> samples;
37   cls_replica_log_progress_marker::generate_test_instances(samples);
38   std::list<cls_replica_log_progress_marker*>::iterator i;
39   for (i = samples.begin(); i != samples.end(); ++i) {
40     ls.push_back(new cls_replica_log_set_marker_op(*(*i)));
41   }
42 }
43
44 void cls_replica_log_get_bounds_op::dump(Formatter *f) const
45 {
46   f->dump_string("contents", "empty");
47 }
48
49 void cls_replica_log_get_bounds_op::
50 generate_test_instances(std::list<cls_replica_log_get_bounds_op*>& ls)
51 {
52   ls.push_back(new cls_replica_log_get_bounds_op);
53 }
54
55 void cls_replica_log_get_bounds_ret::dump(Formatter *f) const
56 {
57   f->dump_string("position_marker", position_marker);
58   oldest_time.gmtime(f->dump_stream("oldest_time"));
59   encode_json("entity_markers", markers, f);
60 }
61
62 void cls_replica_log_get_bounds_ret::
63 generate_test_instances(std::list<cls_replica_log_get_bounds_ret*>& ls)
64 {
65   std::list<cls_replica_log_progress_marker*> samples;
66   cls_replica_log_progress_marker::generate_test_instances(samples);
67   std::list<cls_replica_log_progress_marker> samples_whole;
68   std::list<cls_replica_log_progress_marker*>::iterator i;
69   int count = 0;
70   for (i = samples.begin(); i != samples.end(); ++i) {
71     ls.push_back(new cls_replica_log_get_bounds_ret());
72     ls.back()->markers.push_back(*(*i));
73     ls.back()->oldest_time.set_from_double(1000*count);
74     ls.back()->position_marker = ls.back()->markers.front().position_marker;
75     samples_whole.push_back(*(*i));
76   }
77   ls.push_back(new cls_replica_log_get_bounds_ret());
78   ls.back()->markers = samples_whole;
79   ls.back()->oldest_time = samples_whole.back().position_time;
80   ls.back()->position_marker = samples_whole.back().position_marker;
81 }