5 # you need 3 disposable userids: sam, frodo, gollum. Then the test user (say
6 # "g3") needs to be able to sudo into them. Put this in /etc/sudoers:
8 # g3 ALL = (sam,frodo,gollum) NOPASSWD: ALL
10 $ENV{TSH_ERREXIT
} = 1;
12 # this is hardcoded; change it if needed
16 my $workdir = getcwd
();
18 my ($t, $t2); # temp vars
21 # ----------------------------------------------------------------------
24 ## try "DEF POK = !/DENIED/; !/failed to push/";
26 ## confreset;confadd '
30 ## try "ADMIN_PUSH set1; !/FATAL/" or die text();
32 # ----------------------------------------------------------------------
38 system("cp $h/.ssh/$k $h/.ssh/id_rsa");
39 system("cp $h/.ssh/$k.pub $h/.ssh/id_rsa.pub");
43 try
"F " . join(" ", @_);
44 try
"S " . join(" ", @_);
45 try
"G " . join(" ", @_);
49 DEF F = sudo -u frodo -i
50 DEF S = sudo -u sam -i
51 DEF G = sudo -u gollum -i
54 my $bd = `gitolite query-rc -n GL_BINDIR`;
57 $bd/../t/mirror-test-setup.sh; ok or die mirror setup shell script failed
58 /hello server-frodo, this is frodo/
59 /hello server-sam, this is frodo/
60 /hello server-gollum, this is frodo/
61 /hello server-frodo, this is sam/
62 /hello server-sam, this is sam/
63 /hello server-gollum, this is sam/
64 /hello server-frodo, this is gollum/
65 /hello server-sam, this is gollum/
66 /hello server-gollum, this is gollum/
67 /hello admin, this is frodo/
68 /Initialized empty .*/gitolite-admin.git/
69 /Initialized empty .*/r1.git/
70 /Initialized empty .*/r2.git/
71 /Initialized empty .*/testing.git/
72 /Initialized empty .*/gitolite-admin.git/
73 /Initialized empty .*/r1.git/
74 /Initialized empty .*/r2.git/
75 /Initialized empty .*/testing.git/
76 /Initialized empty .*/gitolite-admin.git/
77 /Initialized empty .*/r1.git/
78 /Initialized empty .*/r2.git/
79 /Initialized empty .*/testing.git/
82 # ----------------------------------------------------------------------
83 # SECTION 1: gitolite-admin shenanigans
85 # push to frodo and see sam and gollum change
87 git clone frodo\@localhost:gitolite-admin fga
88 ok; /Cloning into 'fga'.../
90 cp $h/.ssh/u?.pub keydir; ok
92 git commit -m 6keys; ok
94 /To localhost:gitolite-admin/
103 git ls-remote sam\@localhost:gitolite-admin
105 git ls-remote gollum\@localhost:gitolite-admin
114 # push to sam and see frodo and gollum change
116 git clone sam\@localhost:gitolite-admin sga
117 ok; /Cloning into 'sga'.../
121 /To localhost:gitolite-admin/
130 git ls-remote frodo\@localhost:gitolite-admin
132 git ls-remote gollum\@localhost:gitolite-admin
141 # push to gollum and fail at gollum
143 git clone gollum\@localhost:gitolite-admin gga
144 ok; /Cloning into 'gga'.../
148 !/To localhost:gitolite-admin/
150 /gollum: pushing 'gitolite-admin' to slave 'gollum' not allowed/
157 git ls-remote frodo\@localhost:gitolite-admin
159 git ls-remote sam\@localhost:gitolite-admin
161 git ls-remote gollum\@localhost:gitolite-admin
165 # fake out the gollum failure to continue the redirected push and fail at frodo
167 sudo -u gollum -i gitolite git-config -r gitolite-admin .
170 !/redirectOK.*gollum/
172 sudo -u gollum -i bash -c 'echo repo gitolite-admin > junk'
173 sudo -u gollum -i bash -c 'echo option mirror.redirectOK-1 = gollum >> junk'
174 sudo -u gollum -i bash -c 'cat junk >> .gitolite/conf/gitolite.conf'
175 sudo -u gollum -i gitolite compile
176 sudo -u gollum -i gitolite git-config -r gitolite-admin .
182 /frodo: redirection not allowed from 'gollum'/
183 !/To gollum\@localhost:gitolite-admin/
187 # reset gollum via frodo
191 git clone frodo\@localhost:gitolite-admin fga
192 ok; /Cloning into 'fga'.../
196 /To localhost:gitolite-admin/
200 sudo -u gollum -i gitolite git-config -r gitolite-admin .
203 !/redirectOK.*gollum/
211 git ls-remote sam\@localhost:gitolite-admin
213 git ls-remote gollum\@localhost:gitolite-admin
217 # ----------------------------------------------------------------------
218 # user repo shenanigans
220 # for a recap of the perms see t/mirror-test-setup.sh
225 /tmp/tsh_tempdir/ or die not in the right place
230 # u1 sam r1, R ok, W ok
234 git clone sam\@localhost:r1 sr1
235 /Cloning into 'sr1'.../
236 /warning: You appear to have cloned an empty repository/
239 git push origin master
240 /new branch/; /master -> master/
246 # u1 sam r1, W mirrors to frodo but not gollum
248 git ls-remote sam\@localhost:r1
250 git ls-remote frodo\@localhost:r1
252 git ls-remote gollum\@localhost:r1
253 /gollum: 'r1' is mirrored but not here/
263 # u2 sam r2 W ok, mirrors to all
265 git push sam\@localhost:r2 master
266 /new branch/; /master -> master/
269 git ls-remote frodo\@localhost:r2
272 git ls-remote gollum\@localhost:r2
279 # u1 gollum r1 -- "known unknown" :-)
280 # u1 frodo r1 R ok, W not ok
281 # u1 sam r1 R ok, W ok
286 git clone gollum\@localhost:r1 fr1
287 /gollum: 'r1' is mirrored but not here/
289 git clone frodo\@localhost:r1 fr1; ok
293 /frodo: pushing 'r1' to slave 'frodo' not allowed/
295 git clone sam\@localhost:r1 sr1; ok
305 # u1 sam r1 W mirrored to frodo but not gollum
307 git ls-remote sam\@localhost:r1
309 git ls-remote frodo\@localhost:r1
312 git ls-remote gollum\@localhost:r1
313 /gollum: 'r1' is mirrored but not here/
315 git reset --hard HEAD^; ok
322 /\\+ .......\\.\\.\\........ master -> master .forced update/
328 # u2 frodo r1 R ok, W not allowed (no redirectOK)
334 git clone frodo\@localhost:r1 fr1; ok
338 /frodo: pushing 'r1' to slave 'frodo' not allowed/
340 git clone frodo\@localhost:r2 fr2; ok
350 # u2 frodo r2 W mirrors to sam and gollum
352 git ls-remote sam\@localhost:r2
354 git ls-remote gollum\@localhost:r2
357 git reset --hard HEAD^; ok
364 /\\+ .......\\.\\.\\........ master -> master .forced update/
373 # u3 frodo r2 R ok W ok
375 git clone frodo\@localhost:r2 fr2; ok
385 # u3 frodo r2 W mirrors to sam and gollum
387 git ls-remote sam\@localhost:r2
389 git ls-remote gollum\@localhost:r2
392 git reset --hard HEAD^; ok
400 /\\+ refs/heads/master r2 u3 DENIED by fallthru/
405 # ----------------------------------------------------------------------
406 # all those vague edge cases where the two servers have totally wrong ideas
411 try
"sudo -u frodo -i ls .gitolite/logs";
413 my $lfn = ".gitolite/logs/$t";
416 ssh sam\@localhost mirror push frodo lfrodo; !ok
417 /FATAL: frodo: 'lfrodo' is local/
419 ssh sam\@localhost mirror push frodo mboth; !ok
420 /FATAL: frodo: 'mboth' is native/
422 ssh sam\@localhost mirror push frodo mnotsam; !ok
423 /FATAL: frodo: 'sam' is not the master for 'mnotsam'/
426 git clone sam\@localhost:lfrodo2 lfrodo2; ok
429 git push origin master; !ok
430 /FATAL: frodo: 'lfrodo2' is local/
433 git clone sam\@localhost:nnfrodo nnfrodo; ok
436 git push origin master; !ok
437 /FATAL: frodo: 'nnfrodo' is not native/
440 git clone sam\@localhost:nvsfrodo nvsfrodo; ok
443 git push origin master; !ok
444 /FATAL: frodo: 'sam' is not a valid slave for 'nvsfrodo'/