@@ -17,7 +17,8 @@ open Bechamel
17
17
let () =
18
18
Suite_init. harness_init () ;
19
19
Printexc. record_backtrace true ;
20
- Debug. set_level Syslog. Emerg
20
+ Debug. set_level Syslog. Emerg ;
21
+ Xapi_event. register_hooks ()
21
22
22
23
let date = " 20250102T03:04:05Z"
23
24
@@ -36,11 +37,21 @@ let json_str =
36
37
37
38
let __context = Test_common. make_test_database ()
38
39
40
+ let host = Test_common. make_host ~__context ()
41
+
42
+ let pool = Test_common. make_pool ~__context ~master: host ()
43
+
39
44
let () =
40
- let host = Test_common. make_host ~__context () in
41
- let pool = Test_common. make_pool ~__context ~master: host () in
42
45
Db.Pool. set_license_server ~__context ~self: pool
43
- ~value: [(" jsontest" , json_str)]
46
+ ~value: [(" jsontest" , json_str)] ;
47
+ let open Xapi_database in
48
+ Db_ref. update_database
49
+ (Context. database_of __context)
50
+ (Db_cache_types.Database. register_callback " redo_log"
51
+ Redo_log. database_callback
52
+ )
53
+
54
+ let vm = Test_common. make_vm ~__context ~name_label: " test" ()
44
55
45
56
let get_all () : API.pool_t list =
46
57
Db.Pool. get_all_records ~__context |> List. map snd
@@ -95,6 +106,20 @@ let event =
95
106
96
107
let test_rpc_of_event () = Event_types. rpc_of_event event
97
108
109
+ let counter = Atomic. make 0
110
+
111
+ let test_set_vm_nvram () : unit =
112
+ let c = Atomic. fetch_and_add counter 1 mod 0x7F in
113
+ (* use different value each iteration, otherwise it becomes a noop *)
114
+ Db.VM. set_NVRAM ~__context ~self: vm
115
+ ~value: [(" test" , String. make 32768 (Char. chr @@ c))]
116
+
117
+ let test_db_pool_write () =
118
+ let c = Atomic. fetch_and_add counter 1 mod 0x7F in
119
+ Db.Pool. set_tags ~__context ~self: pool ~value: [String. make 16 (Char. chr @@ c)]
120
+
121
+ let test_db_pool_read () = Db.Pool. get_tags ~__context ~self: pool
122
+
98
123
let benchmarks =
99
124
[
100
125
Test. make ~name: " local_session_hook" (Staged. stage local_session_hook)
@@ -109,6 +134,9 @@ let benchmarks =
109
134
; Test. make ~name: " Db_lock.with_lock uncontended"
110
135
(Staged. stage db_lock_uncontended)
111
136
; Test. make ~name: " rpc_of_event" (Staged. stage test_rpc_of_event)
137
+ ; Test. make ~name: " Db.Pool.set_tags" (Staged. stage test_db_pool_write)
138
+ ; Test. make ~name: " Db.Pool.get_tags" (Staged. stage test_db_pool_read)
139
+ ; Test. make ~name: " Db.VM.set_NVRAM" (Staged. stage test_set_vm_nvram)
112
140
]
113
141
114
142
let () = Bechamel_simple_cli. cli benchmarks
0 commit comments