summaryrefslogtreecommitdiff
path: root/Makefile
blob: b63a11f7a4fe3de787ac6b5264282ae05b9d1371 (plain)
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
build all:
	erl -pa ../lager/ebin -make
clean:
	-rm ebin/*.beam
release: all
	test ! -f rel/db/treesize || \
		test $$(cat rel/db/treesize) = 0 && \
		rm -rf rel
	rm -rf rel
	mkdir rel
	./makerelease.erl
	(cd rel; \
		ln -s ../../plop/test .)
	cp httpd_props.conf rel
	cp catlfish.config rel
	cp storage_node.config rel
	cp storage_node_httpd.conf rel
	mkdir rel/catlfish
	mkdir rel/db
	mkdir rel/mergedb
	mkdir rel/mergedb/chains
	touch rel/mergedb/logorder
	printf "0" > rel/db/treesize
	cp -r webroot rel/catlfish
	test -d rel/catlfish/webroot/log || mkdir rel/catlfish/webroot/log

tests-prepare:
	rm -r rel/known_roots || true
	mkdir rel/known_roots
	cp tools/testcerts/roots/* rel/known_roots

	mkdir -p test/nodes/frontend-1/log
	mkdir -p test/nodes/storage-1/log
	mkdir -p test/nodes/storage-2/log
	cp test/config/frontend-1.config rel
	cp test/config/storage-1.config rel
	cp -r test/config/privatekeys rel
	cp -r test/config/publickeys rel
	rm -r rel/tests || true
	mkdir -p rel/tests/machine/machine-1/db
	printf "0" > rel/tests/machine/machine-1/db/treesize
	mkdir -p rel/tests/machine/machine-2/db
	printf "0" > rel/tests/machine/machine-2/db/treesize
	touch rel/tests/machine/machine-1/db/index
	touch rel/tests/machine/machine-1/db/newentries

tests-start:
	@for node in frontend-1 storage-1; do \
	  (cd rel ; bin/run_erl -daemon ../test/nodes/$$node/ ../test/nodes/$$node/log/ "exec bin/erl -config $$node") \
	done
	@for i in 1 2 3 4 5 6 7 8 9 10; do \
	  echo "waiting for system to start" ; \
	  sleep 0.5 ; \
	  allstarted=1 ; \
	  for testurl in https://127.0.0.1:8080/ https://127.0.0.1:8081/ https://127.0.0.1:8082/; do \
	    if curl -s -k $$testurl > /dev/null ; then : ; else allstarted=0 ; fi ; \
	    : ; \
	  done ; \
	  if [ $$allstarted == 1 ]; then break ; fi ; \
	done

tests-run:
	@(cd tools ; python testcase1.py ) || echo "Tests failed"
	@(cd tools ; python fetchallcerts.py https://127.0.0.1:8080/) || echo "Verification failed"

tests-stop:
	@for node in frontend-1 storage-1; do \
	  ./tools/halt.py ./rel/bin/to_erl test/nodes/$$node/ ; \
	done

tests-wait:
	sleep 5

tests: tests-prepare tests-start tests-run tests-wait tests-stop

# Unit testing.
check: all
	test/check.erl