@@ -36,8 +36,20 @@ let vgcreate =
3636 Lwt_main. run t
3737 )
3838
39+ let vgs_offline =
40+ " vgs <device>: check that we can read metadata without xenvmd." > ::
41+ (fun () ->
42+ with_temp_file (fun filename ->
43+ xenvm [ " vgcreate" ; vg; filename ] |> ignore_string;
44+ mkdir_rec " /etc/xenvm.d" 0o0644 ;
45+ xenvm [ " set-vg-info" ; " --pvpath" ; filename; " -S" ; " /tmp/xenvmd" ; vg; " --local-allocator-path" ; " /tmp/xenvm-local-allocator" ; " --uri" ; " file://local/services/xenvmd/" ^ vg ] |> ignore_string;
46+ xenvm [ " vgs" ; vg ] |> ignore_string
47+ )
48+ )
49+
3950let no_xenvmd_suite = " Commands which should work without xenvmd" > ::: [
4051 vgcreate;
52+ vgs_offline;
4153]
4254
4355let assert_lv_exists ?expected_size_in_extents name =
@@ -115,11 +127,31 @@ let lvchange_n =
115127 assert_equal ~printer: string_of_bool false (dm_exists name);
116128 xenvm [ " lvremove" ; vg ^ " /test" ] |> ignore_string
117129
130+ let parse_int x =
131+ int_of_string (String. trim x)
132+
133+ let vgs_online =
134+ " vgs <device>: check that we can read fresh metadata with xenvmd." > ::
135+ (fun () ->
136+ let metadata = Lwt_main. run (Client. get () ) in
137+ let count = xenvm [ " vgs" ; " /dev/" ^ vg; " --noheadings" ; " -o" ; " lv_count" ] |> parse_int in
138+ let expected = Lvm.Vg.LVs. cardinal metadata.Lvm.Vg. lvs in
139+ assert_equal ~printer: string_of_int expected count;
140+ (* The new LV will be cached: *)
141+ xenvm [ " lvcreate" ; " -n" ; " test" ; " -L" ; " 3" ; vg ] |> ignore_string;
142+ (* This should use the network, not the on-disk metadata: *)
143+ let count = xenvm [ " vgs" ; " /dev/" ^ vg; " --noheadings" ; " -o" ; " lv_count" ] |> parse_int in
144+ (* Did we see the new volume? *)
145+ assert_equal ~printer: string_of_int (expected+ 1 ) count;
146+ xenvm [ " lvremove" ; vg ^ " /test" ] |> ignore_string
147+ )
148+
118149let xenvmd_suite = " Commands which require xenvmd" > ::: [
119150 lvcreate_L;
120151 lvcreate_l;
121152 lvcreate_percent;
122153 lvchange_n;
154+ vgs_online;
123155]
124156
125157let _ =
0 commit comments