finally added notes on how to test mirroring and http mode!
Sitaram Chamarty
4 years ago
0 | # instructions for running the tests | |
0 | 1 | |
1 | ============================================ | |
2 | WARNING: THE TEST SUITE DELETES STUFF FIRST! | |
3 | ============================================ | |
2 | # Pre-requisites | |
3 | ||
4 | Install the following packages: | |
5 | ||
6 | * Manjaro (and probably Arch): | |
7 | ||
8 | pacman -S perl-json perl-json-xs apache | |
9 | ||
10 | * Fedora (and probably CentOS): | |
11 | ||
12 | dnf install -y perl-Test-Harness perl-JSON perl-JSON-XS httpd httpd-tools | |
13 | ||
14 | * others: | |
15 | ||
16 | (TBD) | |
17 | ||
18 | # RUNNING THE MAIN TEST SUITE | |
19 | ||
20 | ====================================== | |
21 | WARNING: THE TEST SUITE DELETES STUFF! | |
22 | ====================================== | |
4 | 23 | |
5 | 24 | Please run the tests ONLY on a userid where it's ok to LOSE DATA. |
6 | 25 | |
11 | 30 | http://gitolite.com/gitolite/testing.html has more details. Alternatively, |
12 | 31 | http://gitolite.com/gitolite/req.html#trying will help you try out gitolite if |
13 | 32 | you want to play with gitolite safely. |
33 | ||
34 | # RUNNING THE HTTP AND MIRROR TESTS | |
35 | ||
36 | ====================================== | |
37 | WARNING: THE TEST SUITE DELETES STUFF! | |
38 | ====================================== | |
39 | ||
40 | The http and mirror tests require a lot more preparation, including commands | |
41 | and/or scripts to be run as root, so they're not invoked when you simply run | |
42 | "prove" as above. | |
43 | ||
44 | ## Manjaro | |
45 | ||
46 | 1. Create 3 users: sam, frodo, and gollum (`useradd -m`). | |
47 | ||
48 | 2. Assuming you're running the tests using a local user called `g3`, run | |
49 | `visudo` and add the following line: | |
50 | ||
51 | g3 ALL = (sam,frodo,gollum) NOPASSWD: ALL | |
52 | ||
53 | Test this by running this command from within `g3` and making sure you get | |
54 | the correct results: | |
55 | ||
56 | sudo -u sam -i pwd | |
57 | # should print /home/sam | |
58 | # similarly make sure frodo and gollum also give correct results | |
59 | ||
60 | The mirror test will not run if this does not work. That does not mean | |
61 | *mirroring* will not work; only the test suite depends on this feature. | |
62 | ||
63 | 3. Manjaro does not, by default, add $HOME/bin to $PATH, so you will need the | |
64 | following on at least sam, frodo, and gollum: | |
65 | ||
66 | # copy-paste this into a root terminal | |
67 | for u in frodo sam gollum; do | |
68 | grep '$HOME/bin' /home/$u/.bash_profile || echo 'export PATH="$HOME/bin:$PATH"' >> /home/$u/.bash_profile | |
69 | done | |
70 | ||
71 | Again, test this by running: | |
72 | ||
73 | sudo -u sam -i echo '$PATH' | |
74 | ||
75 | and making sure the output starts with `/home/sam/bin:` (and similarly for | |
76 | frodo and gollum). | |
77 | ||
78 | 4. Take a look inside `t/manjaro-root-smart-http-test-setup` to make sure | |
79 | everything looks sane (because you have to run it as root!!), then run it | |
80 | as root. | |
81 | ||
82 | 5. Now you are ready to run the last two tests: | |
83 | ||
84 | GITOLITE_TEST=y prove t/smart-http | |
85 | GITOLITE_TEST=y prove t/mirror-test | |
86 | ||
87 | ## Fedora | |
88 | ||
89 | 1. Create 3 users: sam, frodo, and gollum (`useradd`). | |
90 | ||
91 | 2. Assuming you're running the tests using a local user called `g3`, run | |
92 | `visudo` and add the following line: | |
93 | ||
94 | g3 ALL = (sam,frodo,gollum) NOPASSWD: ALL | |
95 | ||
96 | Test this by running this command from within `g3` and making sure you get | |
97 | the correct results: | |
98 | ||
99 | sudo -u sam -i pwd | |
100 | # should print /home/sam | |
101 | # similarly make sure frodo and gollum also give correct results | |
102 | ||
103 | The mirror test will not run if this does not work. That does not mean | |
104 | *mirroring* will not work; only the test suite depends on this feature. | |
105 | ||
106 | 3. Take a look inside `t/fedora-root-smart-http-test-setup` to make sure | |
107 | everything looks sane (because you have to run it as root!!), then run it | |
108 | as root. | |
109 | ||
110 | 4. Now you are ready to run the last two tests: | |
111 | ||
112 | prove t/smart-http | |
113 | prove t/mirror-test | |
114 | ||
115 | vim: ft=markdown |
0 | #!/bin/bash | |
1 | ||
2 | # gitolite http mode TESTING setup for Fedora | |
3 | # - Probably works for CentOS also; if someone tests it let me know | |
4 | # - Use the comments to create a version for your distro if needed | |
5 | ||
6 | # CAUTION: This script needs to be run as root, so you best eyeball it at | |
7 | # least once to make sure you know what changes it is making. | |
8 | ||
9 | # WARNING: clobbers /usr/share/httpd/gitolite-home, and also creates 7 http | |
10 | # users with trivial passwords FOR TESTING. | |
11 | ||
12 | # HOWEVER: if you remove some of that, especially the part that creates test | |
13 | # users, this *should* work as a quick "setup gitolite http mode" script. | |
14 | ||
15 | # CAUTION: This script assumes the httpd.conf file is pretty much the default | |
16 | # "as shipped" version. If you fiddled with it, this script *may* break. | |
17 | # It's on you to determine if that is the case and manually simulate the | |
18 | # actions of this script. It's not that hard, and anyway it's just once (for | |
19 | # a given server) so it's not too bad. | |
20 | ||
21 | # ---------------------------------------------------------------------- | |
22 | ||
23 | cd ~apache | |
24 | # should be /usr/share/httpd; you may want to check just to be safe | |
25 | export GITOLITE_HTTP_HOME=$PWD/gitolite-home | |
26 | ||
27 | [[ -d gitolite-home ]] && { | |
28 | [[ $GITOLITE_TEST != y ]] && { | |
29 | echo "If you're OK with clobbering $GITOLITE_HTTP_HOME, please rerun with | |
30 | environment variable GITOLITE_TEST set to 'y'." | |
31 | exit 1; | |
32 | } | |
33 | } | |
34 | ||
35 | rm -rf gitolite-home | |
36 | mkdir gitolite-home | |
37 | ||
38 | # setup apache conf for gitolite | |
39 | cd /etc/httpd/conf.d | |
40 | [[ -f gitolite.conf ]] || { | |
41 | cat > gitolite.conf <<-EOF | |
42 | SetEnv GIT_PROJECT_ROOT $GITOLITE_HTTP_HOME/repositories | |
43 | ScriptAlias /git/ $GITOLITE_HTTP_HOME/gitolite-source/src/gitolite-shell/ | |
44 | ScriptAlias /gitmob/ $GITOLITE_HTTP_HOME/gitolite-source/src/gitolite-shell/ | |
45 | SetEnv GITOLITE_HTTP_HOME $GITOLITE_HTTP_HOME | |
46 | SetEnv GIT_HTTP_EXPORT_ALL | |
47 | ||
48 | <Location /git> | |
49 | AuthType Basic | |
50 | AuthName "Private Git Access" | |
51 | Require valid-user | |
52 | AuthUserFile $GITOLITE_HTTP_HOME/gitolite-http-authuserfile | |
53 | </Location> | |
54 | EOF | |
55 | } | |
56 | ||
57 | # get the gitolite sources | |
58 | cd $GITOLITE_HTTP_HOME | |
59 | ||
60 | if [[ -d /tmp/gitolite.git ]]; then | |
61 | git clone /tmp/gitolite.git gitolite-source | |
62 | # I do this because I have to test stuff *before* it gets to github, so I | |
63 | # can't simply clone what's on github. Instead, I use a local | |
64 | # world-readable bare repo cloned from my dev environment. | |
65 | else | |
66 | git clone 'https://github.com/sitaramc/gitolite' gitolite-source | |
67 | fi | |
68 | ||
69 | # make the bin directory, and add it to PATH | |
70 | cd gitolite-source | |
71 | mkdir $GITOLITE_HTTP_HOME/bin | |
72 | ./install -ln $GITOLITE_HTTP_HOME/bin | |
73 | export PATH=$PATH:$GITOLITE_HTTP_HOME/bin | |
74 | ||
75 | # come back to base, then run setup. Notice that you have to point HOME to | |
76 | # the right place, even if it is just for this command | |
77 | cd $GITOLITE_HTTP_HOME | |
78 | HOME=$GITOLITE_HTTP_HOME gitolite setup -a admin | |
79 | ||
80 | # insert some essential lines at the beginning of the rc file | |
81 | echo '$ENV{PATH} .= ":$ENV{GITOLITE_HTTP_HOME}/bin";' > 1 | |
82 | echo >> 1 | |
83 | cat .gitolite.rc >> 1 | |
84 | \mv 1 .gitolite.rc | |
85 | ||
86 | # create users "admin" and "u1" thru "u6" for testing | |
87 | htpasswd -bc $GITOLITE_HTTP_HOME/gitolite-http-authuserfile admin admin | |
88 | seq 6 | xargs -I % htpasswd -b $GITOLITE_HTTP_HOME/gitolite-http-authuserfile u% u% | |
89 | ||
90 | # fix up ownership | |
91 | chown -R apache:apache $GITOLITE_HTTP_HOME | |
92 | ||
93 | # restart httpd to make it pick up all the new stuff | |
94 | systemctl restart httpd |
0 | #!/bin/bash | |
1 | ||
2 | # gitolite http mode TESTING setup for Manjaro | |
3 | # - Probably works for Arch also; if someone tests it let me know | |
4 | # - Use the comments to create a version for your distro if needed | |
5 | ||
6 | # CAUTION: This script needs to be run as root, so you best eyeball it at | |
7 | # least once to make sure you know what changes it is making. | |
8 | ||
9 | # WARNING: clobbers /srv/http/gitolite-home, and also creates 7 http | |
10 | # users with trivial passwords FOR TESTING. | |
11 | ||
12 | # HOWEVER: if you remove some of that, especially the part that creates test | |
13 | # users, this *should* work as a quick "setup gitolite http mode" script. | |
14 | ||
15 | # CAUTION: This script assumes the httpd.conf file is pretty much the default | |
16 | # "as shipped" version. If you fiddled with it, this script *may* break. | |
17 | # It's on you to determine if that is the case and manually simulate the | |
18 | # actions of this script. It's not that hard, and anyway it's just once (for | |
19 | # a given server) so it's not too bad. | |
20 | ||
21 | # ---------------------------------------------------------------------- | |
22 | # BEGIN APACHE CONF CHANGES | |
23 | ||
24 | # Unlike Fedora, Manjaro's default httpd.conf does not contain a wildcard | |
25 | # include for stuff in conf.d; they're all explicitly included, so we need to | |
26 | # include gitolite.conf. | |
27 | cd /etc/httpd/conf | |
28 | grep ^Include.*gitolite.conf httpd.conf || | |
29 | printf "\n%s\n%s\n" '# gitolite http mode' 'Include conf/extra/gitolite.conf' >> httpd.conf | |
30 | ||
31 | # Again, unlike Fedora, Manjaro's default conf does not come with cgi enabled. | |
32 | # In fact, the directive is both commented out *and* inside an "IF" block for | |
33 | # some other module. Since I don't plan to be an expert on apache, I will | |
34 | # punt by including the required LoadModule line before the first LoadModule | |
35 | # line that is not in an "if" block (i.e., not indented). | |
36 | grep '^LoadModule cgi_module modules/mod_cgi.so' httpd.conf || | |
37 | perl -i -pE 'say "LoadModule cgi_module modules/mod_cgi.so" if /^LoadModule/ and not $flag++' httpd.conf | |
38 | ||
39 | # END APACHE CONF CHANGES | |
40 | # ---------------------------------------------------------------------- | |
41 | ||
42 | cd ~http | |
43 | # should be /srv/http; you may want to check just to be safe | |
44 | export GITOLITE_HTTP_HOME=$PWD/gitolite-home | |
45 | ||
46 | [[ -d gitolite-home ]] && { | |
47 | [[ $GITOLITE_TEST != y ]] && { | |
48 | echo "If you're OK with clobbering $GITOLITE_HTTP_HOME, please rerun with | |
49 | environment variable GITOLITE_TEST set to 'y'." | |
50 | exit 1; | |
51 | } | |
52 | } | |
53 | ||
54 | rm -rf gitolite-home | |
55 | mkdir gitolite-home | |
56 | ||
57 | # setup apache conf for gitolite | |
58 | cd /etc/httpd/conf/extra | |
59 | [[ -f gitolite.conf ]] || { | |
60 | cat > gitolite.conf <<-EOF | |
61 | SetEnv GIT_PROJECT_ROOT $GITOLITE_HTTP_HOME/repositories | |
62 | ScriptAlias /git/ $GITOLITE_HTTP_HOME/gitolite-source/src/gitolite-shell/ | |
63 | ScriptAlias /gitmob/ $GITOLITE_HTTP_HOME/gitolite-source/src/gitolite-shell/ | |
64 | SetEnv GITOLITE_HTTP_HOME $GITOLITE_HTTP_HOME | |
65 | SetEnv GIT_HTTP_EXPORT_ALL | |
66 | ||
67 | <Location /git> | |
68 | AuthType Basic | |
69 | AuthName "Private Git Access" | |
70 | Require valid-user | |
71 | AuthUserFile $GITOLITE_HTTP_HOME/gitolite-http-authuserfile | |
72 | </Location> | |
73 | EOF | |
74 | } | |
75 | ||
76 | # get the gitolite sources | |
77 | cd $GITOLITE_HTTP_HOME | |
78 | ||
79 | if [[ -d /tmp/gitolite.git ]]; then | |
80 | git clone /tmp/gitolite.git gitolite-source | |
81 | # I do this because I have to test stuff *before* it gets to github, so I | |
82 | # can't simply clone what's on github. Instead, I use a local | |
83 | # world-readable bare repo cloned from my dev environment. | |
84 | else | |
85 | git clone 'https://github.com/sitaramc/gitolite' gitolite-source | |
86 | fi | |
87 | ||
88 | # make the bin directory, and add it to PATH | |
89 | cd gitolite-source | |
90 | mkdir $GITOLITE_HTTP_HOME/bin | |
91 | ./install -ln $GITOLITE_HTTP_HOME/bin | |
92 | export PATH=$PATH:$GITOLITE_HTTP_HOME/bin | |
93 | ||
94 | # come back to base, then run setup. Notice that you have to point HOME to | |
95 | # the right place, even if it is just for this command | |
96 | cd $GITOLITE_HTTP_HOME | |
97 | HOME=$GITOLITE_HTTP_HOME gitolite setup -a admin | |
98 | ||
99 | # insert some essential lines at the beginning of the rc file | |
100 | echo '$ENV{PATH} .= ":$ENV{GITOLITE_HTTP_HOME}/bin";' > 1 | |
101 | echo >> 1 | |
102 | cat .gitolite.rc >> 1 | |
103 | \mv 1 .gitolite.rc | |
104 | ||
105 | # create users "admin" and "u1" thru "u6" for testing | |
106 | htpasswd -bc $GITOLITE_HTTP_HOME/gitolite-http-authuserfile admin admin | |
107 | seq 6 | xargs -I % htpasswd -b $GITOLITE_HTTP_HOME/gitolite-http-authuserfile u% u% | |
108 | ||
109 | # fix up ownership | |
110 | chown -R http:http $GITOLITE_HTTP_HOME | |
111 | ||
112 | # restart httpd to make it pick up all the new stuff | |
113 | systemctl restart httpd |