-
Notifications
You must be signed in to change notification settings - Fork 16
/
alternative.ml
104 lines (94 loc) · 2.81 KB
/
alternative.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
open Lwt
open Node_cfg
let mr_proper () =
Node.stop_all();
Node.clean_dirs();
Node.mkdirs()
let test_large_tlog_collection_restart () =
let fill client =
let rec loop i =
if i = 100000
then Lwt.return ()
else
begin
Lwt_io.printlf "%i" i >>= fun () ->
let key = Printf.sprintf "key%i" i in
let value = Printf.sprintf "value%i" i in
client # set key value >>= fun () ->
loop (i+1)
end
in
loop 0
in
let _ = mr_proper () in
Node.start_all();
Unix.sleep 1;
let _ = Client_main.with_master_client "cfg/arakoon.ini" fill in
Node.stop_all();
Node.start_all();
Unix.sleep 10;
(* iterate_n_times( 100, set_get_and_delete ) *)
Client_main.with_master_client "cfg/arakoon.ini"
(fun c -> c # set "XXX" "XXX");;
let test_lost_update () =
let _ = mr_proper () in
Node.start_all();
Unix.sleep 1;
let _ = Client_main.with_master_client "cfg/arakoon.ini"
(fun c -> c # set "xxx" "xxx")
in
let cfgs,_,_,_ = Node_cfg.read_config "cfg/arakoon.ini" in
let master = Lwt_main.run (Client_main.find_master cfgs) in
let others = List.filter (fun n -> n <> master) Node.names in
Node.stop_all();
List.iter (fun n -> ignore (Node.start n)) others;
Unix.sleep 1;
Client_main.with_master_client "cfg/arakoon.ini"
(fun c -> c # get "xxx" >>= fun v -> Lwt_io.printlf "value=%s" v);
Node.stop_all();;
open Arakoon_client
let test_sequence_is_transaction () =
let _ = mr_proper () in
Node.start_all () ;
Unix.sleep 1;
let _ = Client_main.with_master_client "cfg/arakoon.ini"
(fun c -> let seq = [Set ("key1","value1");
Delete ("key2");]
in
c # sequence seq
)
in ();;
let put_10e6 () =
let _ = mr_proper () in
Node.start_all();
Unix.sleep 1;
let (value:string) = String.make 202 '\x30' in
let _ = Client_main.with_master_client "cfg/arakoon.ini"
(fun c ->
let rec loop i =
if i = 0
then Lwt.return ()
else
let key = Printf.sprintf "put_X_%08i" i in
c # set key value >>= fun () ->
Lwt_io.printlf "%i" i >>= fun () ->
loop (i-1)
in
loop 10000000
)
in
();;
let put_50000 () =
let _ = Client_main.with_master_client "cfg/arakoon.ini"
(fun c ->
let rec loop n =
if n = 0 then Lwt.return ()
else
let key = Printf.sprintf "put_X_%06i" n in
c # set key key >>= fun () ->
Lwt_io.printlf "%i" n >>= fun () ->
loop (n-1)
in
loop (50 * 1000)
)
in ();;