Skip to content

Commit e1062be

Browse files
committed
transfer tests, arrangement and shim to dynamic setting
1 parent 52db708 commit e1062be

16 files changed

+687
-111
lines changed
Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
1-
OCAMLBUILD = ocamlbuild -lib str -lib unix -I lib -I ocaml -cflag -g
2-
OCAMLBUILD_TEST = ocamlbuild -package oUnit -lib str -I ocaml -I test -cflag -g
1+
PYTHON=python2.7
2+
3+
OCAMLBUILD = ocamlbuild -package uuidm -lib str -lib unix -I ocaml -cflag -g
4+
OCAMLBUILD_TEST = ocamlbuild -package uuidm -package oUnit -lib str -I ocaml -I test -cflag -g
35

46
AGGREGATION = ocaml/TreeAggregation.ml ocaml/TreeAggregation.mli \
5-
ocaml/TreeAggregationArrangement.ml ocaml/TreeAggregationMain.ml ocaml/Serialization.ml
6-
AGGREGATION_TEST = test/SerializationTest.ml test/TreeAggregationTest.ml
7-
LIB = lib/OrderedMain.ml lib/OrderedShim.ml
7+
ocaml/TreeAggregationArrangement.ml ocaml/TreeAggregationMain.ml \
8+
ocaml/Serialization.ml ocaml/Opts.ml ocaml/OrderedShim.ml ocaml/Util.ml
9+
10+
AGGREGATION_TEST = test/SerializationTest.ml test/OptsTest.ml \
11+
test/TreeAggregationTest.ml test/TestCommon.ml
812

913
default: TreeAggregationMain.native
1014

11-
TreeAggregationMain.native: $(AGGREGATION) $(LIB)
15+
TreeAggregationMain.native: $(AGGREGATION)
1216
$(OCAMLBUILD) TreeAggregationMain.native
1317

1418
TreeAggregationTest.native: $(AGGREGATION) $(AGGREGATION_TEST)
1519
$(OCAMLBUILD_TEST) TreeAggregationTest.native
1620

17-
test: TreeAggregationTest.native
21+
test-units: TreeAggregationTest.native
1822
./TreeAggregationTest.native
1923

24+
test-integration: TreeAggregationMain.native test/integration.py
25+
$(PYTHON) test/integration.py
26+
27+
test: test-units test-integration
28+
2029
clean:
2130
$(OCAMLBUILD) TreeAggregationMain.native -clean
2231
$(OCAMLBUILD_TEST) TreeAggregationTest.native -clean
2332

24-
.PHONY: default clean test
33+
.PHONY: default clean test test-units test-integration
2534

2635
.NOTPARALLEL: TreeAggregationMain.native TreeAggregationTest.native
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
open List
2+
open Printf
3+
open Str
4+
5+
let cluster_default = []
6+
let me_default = -1
7+
let port_default = 8351
8+
let dbpath_default = "/var/lib/vard"
9+
let debug_default = false
10+
11+
let cluster = ref cluster_default
12+
let me = ref me_default
13+
let port = ref port_default
14+
let dbpath = ref dbpath_default
15+
let debug = ref debug_default
16+
17+
let node_spec arg nodes_ref doc =
18+
let parse opt =
19+
(* name,ip:port *)
20+
if string_match (regexp "\\([0-9]+\\),\\(.+\\):\\([0-9]+\\)") opt 0 then
21+
(int_of_string (matched_group 1 opt),
22+
(matched_group 2 opt, int_of_string (matched_group 3 opt)))
23+
else
24+
raise (Arg.Bad (sprintf "wrong argument: '%s'; option '%s' expects an address in the form 'name,host:port'" arg opt))
25+
in (arg, Arg.String (fun opt -> nodes_ref := !nodes_ref @ [parse opt]), doc)
26+
27+
let parse inp =
28+
let opts =
29+
[ node_spec "-node" cluster "{name,host:port} one node in the cluster"
30+
; ("-me", Arg.Set_int me, "{name} name for this node")
31+
; ("-port", Arg.Set_int port, "{port} port for client commands")
32+
; ("-dbpath", Arg.Set_string dbpath, "{path} directory for storing database files")
33+
; ("-debug", Arg.Set debug, "run in debug mode")
34+
] in
35+
Arg.parse_argv ?current:(Some (ref 0)) inp
36+
opts
37+
(fun x -> raise (Arg.Bad (sprintf "%s does not take position arguments" inp.(0))))
38+
"Try -help for help or one of the following."
39+
40+
let validate () =
41+
if length !cluster == 0 then begin
42+
raise (Arg.Bad "Please specify at least one -node")
43+
end;
44+
if !me == me_default then begin
45+
raise (Arg.Bad "Please specify the node name -me")
46+
end;
47+
if not (mem_assoc !me !cluster) then begin
48+
raise (Arg.Bad (sprintf "%d is not a member of this cluster" !me))
49+
end

0 commit comments

Comments
 (0)