(*) implements validate_ methods for all timestamp objects
[plcapi.git] / peers-test.mk
1 ### -*-Makefile-*-
2 CHROOT=/plc/root
3 PORT=5432
4 SITEDIR=/etc/planetlab/configs
5 SITE=site.xml
6 RPM=$(shell ls -rt /root/myplc*rpm | tail -1)
7 APIDIR=/usr/share/plc_api
8
9 PLC1=lurch.cs.princeton.edu
10 PLC2=planetlab-devbox.inria.fr
11
12 all:help
13
14 ####################
15 PUSH=pclean pplc2 papi2 pplc1 papi1
16
17 push:$(PUSH)
18
19 papi: pclean papi1 papi2
20 pplc: pclean pplc1 pplc2
21
22 pclean:
23         -find . '(' -name '*.pyc' -o -name '*~' ')' | xargs rm
24 papi1:
25         rsync -a -v -C ./ root@$(PLC1):new_plc_api/
26 pplc1:
27         rsync -a -v -C ./planetlab4.sql ./PLC root@$(PLC1):$(CHROOT)$(APIDIR)/
28 papi2:
29         rsync -a -v -C ./ root@$(PLC2):new_plc_api/
30 pplc2:
31         rsync -a -v -C ./planetlab4.sql ./PLC root@$(PLC2):$(CHROOT)$(APIDIR)/
32
33 ####################
34 DB=install-schema stop-clients clean-db restart-db
35 WEB=install-api restart
36
37 db: $(DB)
38         @date
39
40 db-dump:
41         chroot $(CHROOT) pg_dump -U pgsqluser planetlab4 > planetlab4.dump
42
43 web: $(WEB)
44
45 install-schema:
46         @echo 'installing schema'
47         @rsync -a -v planetlab4.sql $(CHROOT)$(APIDIR)/planetlab4.sql
48
49 install-api:
50         find . -name '*.py' | xargs tar cf - | ( cd $(CHROOT)$(APIDIR) ; tar xf -)
51         -find $(CHROOT)$(APIDIR) -name '*pyc' | xargs rm
52
53 stop-clients:
54         @echo 'pkilling psql'
55         @-pkill psql
56         @echo 'pkilling Shell.py'
57         @-pkill Shell.py
58         @echo stopping httpd
59         @chroot $(CHROOT) /etc/plc.d/httpd stop
60
61 clean-db:
62         @echo 'dropping db'
63         @chroot $(CHROOT) psql -U postgres --port $(PORT) template1 -c 'drop database planetlab4'
64
65 restart-db:
66         @echo 'restarting db'
67         @chroot $(CHROOT) service plc stop db postgresql httpd
68         @chroot $(CHROOT) service plc start httpd postgresql db
69
70 restart:
71         @echo 'Restarting PLC'
72         @chroot $(CHROOT) service plc restart
73
74 http:
75         @echo 'Restarting httpd'
76         @chroot $(CHROOT) /etc/plc.d/httpd stop ; chroot $(CHROOT) /etc/plc.d/httpd start
77
78 ####################
79 UPGRADE=down up reconfig restart
80
81 upgrade: $(UPGRADE)
82
83 rpm:
84         @echo latest rpm is $(RPM)
85
86 down:
87         cp $(SITEDIR)/$(SITE) .
88         rpm -e myplc
89 up:
90         rpm -i $(RPM)
91
92 reconfig:
93         service plc mount
94         mkdir -p $(SITEDIR)
95         cp $(SITE) $(SITEDIR)
96         (echo w; echo q) | chroot $(CHROOT) plc-config-tty
97
98 ####################
99 RUN=api sql log
100 api:
101         chroot $(CHROOT) /usr/share/plc_api/Shell.py
102
103 sql:
104         chroot $(CHROOT) psql -U pgsqluser planetlab4
105
106 log:
107         emacs /plc/data/var/log/httpd/error_log /plc/data/var/log/boot.log
108
109 ####################
110 # remove time/delay dependent output
111 normalize       = egrep -v "'expires':|^+++.*ellapsed"
112
113 TEST=run checkpoint diff
114 run: run-only normalize
115 run-only:
116         python -u ./TestPeers.py > TestPeers.out 2>&1
117
118 normalize: TestPeers.out.nor TestPeers.ref.nor
119 TestPeers.out.nor: TestPeers.out
120         $(normalize) TestPeers.out > TestPeers.out.nor
121 TestPeers.ref.nor: TestPeers.ref
122         $(normalize) TestPeers.ref > TestPeers.ref.nor
123
124 diff: normalize
125         @echo '<< REF OUT>>'
126         diff TestPeers.ref.nor TestPeers.out.nor
127
128 checkpoint:
129         @echo adopting latest run as reference
130         cp TestPeers.out TestPeers.ref
131         cp TestPeers.out.nor TestPeers.ref.nor
132
133 mrun:
134         python -u ./TestPeers.py -m > TestPeers.mout 2>&1
135 brun:
136         python -u ./TestPeers.py -b > TestPeers.bout 2>&1
137 prun:
138         python -u ./TestPeers.py -p > TestPeers.pout 2>&1
139 pbrun:
140         python -u ./TestPeers.py -p -b > TestPeers.pbout 2>&1
141 phrun:
142         python -u ./TestPeers.py -p -H > TestPeers.phout 2>&1
143
144 #######
145 HELP=rpm db-dump http
146
147 help:
148         @echo known targets:
149         @echo push: $(PUSH) 
150         @echo db: $(DB) 
151         @echo web: $(WEB) 
152         @echo upgrade: $(UPGRADE)
153         @echo test: $(TEST)
154         @echo run: $(RUN)
155         @echo OTHERS: $(HELP)
156