]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/multi_stress_watch.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 #include "include/rados/librados.h"
3 #include "include/rados/librados.hpp"
4 #include "test/librados/test.h"
15 using namespace librados
;
17 using std :: ostringstream
;
22 class WatchNotifyTestCtx
: public WatchCtx
25 void notify ( uint8_t opcode
, uint64_t ver
, bufferlist
& bl
) override
31 #pragma GCC diagnostic ignored "-Wpragmas"
32 #pragma GCC diagnostic push
33 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
36 test_loop ( Rados
& cluster
, std :: string pool_name
, std :: string obj_name
)
40 ret
= cluster
. ioctx_create ( pool_name
. c_str (), ioctx
);
42 std :: cerr
<< "ioctx_create " << pool_name
<< " failed with " << ret
<< std :: endl
;
46 ret
= ioctx
. create ( obj_name
, false );
48 std :: cerr
<< "create failed with " << ret
<< std :: endl
;
52 for ( int i
= 0 ; i
< 10000 ; ++ i
) {
53 std :: cerr
<< "Iteration " << i
<< std :: endl
;
55 WatchNotifyTestCtx ctx
;
56 ret
= ioctx
. watch ( obj_name
, 0 , & handle
, & ctx
);
59 ret
= ioctx
. notify ( obj_name
, 0 , bl2
);
63 ioctx
. unwatch ( obj_name
, handle
);
69 #pragma GCC diagnostic pop
70 #pragma GCC diagnostic warning "-Wpragmas"
73 test_replicated ( Rados
& cluster
, std :: string pool_name
, std :: string obj_name
)
76 cluster
. pool_create ( pool_name
. c_str ());
78 test_loop ( cluster
, pool_name
, obj_name
);
82 test_erasure ( Rados
& cluster
, std :: string pool_name
, std :: string obj_name
)
87 ret
= cluster
. mon_command (
88 "{ \" prefix \" : \" osd erasure-code-profile set \" , \" name \" : \" testprofile \" , \" profile \" : [ \" k=2 \" , \" m=1 \" , \" crush-failure-domain=osd \" ]}" ,
91 std :: cerr
<< "mon_command erasure-code-profile set failed with " << ret
<< std :: endl
;
94 //std::cout << outs << std::endl;
97 ret
= cluster
. mon_command (
98 "{ \" prefix \" : \" osd pool create \" , \" pool \" : \" " + pool_name
+ " \" , \" pool_type \" : \" erasure \" , \" pg_num \" :12, \" pgp_num \" :12, \" erasure_code_profile \" : \" testprofile \" }" ,
101 std :: cerr
<< outs
<< std :: endl
;
102 std :: cerr
<< "mon_command create pool failed with " << ret
<< std :: endl
;
105 //std::cout << outs << std::endl;
107 cluster
. wait_for_latest_osdmap ();
108 test_loop ( cluster
, pool_name
, obj_name
);
112 int main ( int args
, char ** argv
)
114 if ( args
!= 3 && args
!= 4 ) {
115 std :: cerr
<< "Error: " << argv
[ 0 ] << " [ec|rep] pool_name obj_name" << std :: endl
;
119 std :: string pool_name
, obj_name
, type
;
120 // For backward compatibility with unmodified teuthology version
130 std :: cerr
<< "Test type " << type
<< std :: endl
;
131 std :: cerr
<< "pool_name, obj_name are " << pool_name
<< ", " << obj_name
<< std :: endl
;
133 if ( type
!= "ec" && type
!= "rep" ) {
134 std :: cerr
<< "Error: " << argv
[ 0 ] << " Invalid arg must be 'ec' or 'rep' saw " << type
<< std :: endl
;
138 char * id
= getenv ( "CEPH_CLIENT_ID" );
139 if ( id
) std :: cerr
<< "Client id is: " << id
<< std :: endl
;
142 ret
= cluster
. init ( id
);
144 std :: cerr
<< "Error " << ret
<< " in cluster.init" << std :: endl
;
147 ret
= cluster
. conf_read_file ( NULL
);
149 std :: cerr
<< "Error " << ret
<< " in cluster.conf_read_file" << std :: endl
;
152 ret
= cluster
. conf_parse_env ( NULL
);
154 std :: cerr
<< "Error " << ret
<< " in cluster.conf_read_env" << std :: endl
;
157 ret
= cluster
. connect ();
159 std :: cerr
<< "Error " << ret
<< " in cluster.connect" << std :: endl
;
163 test_replicated ( cluster
, pool_name
, obj_name
);
164 else if ( type
== "ec" )
165 test_erasure ( cluster
, pool_name
, obj_name
);