Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit572cfa9

Browse files
author
Gauvain Pocentek
committed
Add a script to build a test env
functional_tests.sh has been split in 2 scripts to make easier the runof gitlab container.
1 parent03d8041 commit572cfa9

File tree

2 files changed

+82
-58
lines changed

2 files changed

+82
-58
lines changed

‎tools/build_test_env.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
# Copyright (C) 2016 Gauvain Pocentek <gauvain@pocentek.net>
3+
#
4+
# This program is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU Lesser General Public License as published by
6+
# the Free Software Foundation, either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# This program is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU Lesser General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU Lesser General Public License
15+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
PY_VER=2
18+
whilegetopts :p: opt"$@";do
19+
case$optin
20+
p)
21+
PY_VER=$OPTARG;;
22+
*)
23+
echo"Unknown option:$opt"
24+
exit 1;;
25+
esac
26+
done
27+
28+
case$PY_VERin
29+
2) VENV_CMD=virtualenv;;
30+
3) VENV_CMD=pyvenv;;
31+
*)
32+
echo"Wrong python version (2 or 3)"
33+
exit 1;;
34+
esac
35+
36+
docker run --name gitlab-test --detach --publish 8080:80 --publish 2222:22 genezys/gitlab:latest>/dev/null2>&1
37+
38+
LOGIN='root'
39+
PASSWORD='5iveL!fe'
40+
CONFIG=/tmp/python-gitlab.cfg
41+
GREEN='\033[0;32m'
42+
NC='\033[0m'
43+
OK="echo -e${GREEN}OK${NC}"
44+
45+
echo -n"Waiting for gitlab to come online..."
46+
I=0
47+
while:;do
48+
sleep 5
49+
curl -s http://localhost:8080/users/sign_in2>/dev/null| grep -q"GitLab Community Edition"&&break
50+
let I=I+5
51+
[$I-eq 120 ]&&exit 1
52+
done
53+
sleep 5
54+
$OK
55+
56+
# Get the token
57+
TOKEN=$(curl -s http://localhost:8080/api/v3/session \
58+
-X POST \
59+
--data"login=$LOGIN&password=$PASSWORD" \
60+
| python -c'import sys, json; print(json.load(sys.stdin)["private_token"])')
61+
62+
cat>$CONFIG<<EOF
63+
[global]
64+
default = local
65+
timeout = 2
66+
67+
[local]
68+
url = http://localhost:8080
69+
private_token =$TOKEN
70+
EOF
71+
72+
echo"Config file content ($CONFIG):"
73+
cat$CONFIG

‎tools/functional_tests.sh

Lines changed: 9 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -23,74 +23,25 @@ cleanup() {
2323
}
2424
trap cleanup EXIT
2525

26-
PY_VER=2
27-
whilegetopts :p: opt"$@";do
28-
case$optin
29-
p)
30-
PY_VER=$OPTARG;;
31-
*)
32-
echo"Unknown option:$opt"
33-
exit 1;;
34-
esac
35-
done
36-
37-
case$PY_VERin
38-
2) VENV_CMD=virtualenv;;
39-
3) VENV_CMD=pyvenv;;
40-
*)
41-
echo"Wrong python version (2 or 3)"
42-
exit 1;;
43-
esac
44-
45-
docker run --name gitlab-test --detach --publish 8080:80 --publish 2222:22 genezys/gitlab:latest>/dev/null2>&1
46-
47-
LOGIN='root'
48-
PASSWORD='5iveL!fe'
26+
setenv_script=$(dirname$0)/build_test_env.sh
27+
28+
.$setenv_script"$@"
29+
4930
CONFIG=/tmp/python-gitlab.cfg
5031
GITLAB="gitlab --config-file$CONFIG"
32+
GREEN='\033[0;32m'
33+
NC='\033[0m'
34+
OK="echo -e${GREEN}OK${NC}"
35+
5136
VENV=$(pwd)/.venv
5237

5338
$VENV_CMD$VENV
5439
.$VENV/bin/activate
5540
pip install -rrequirements.txt
5641
pip install -e.
5742

58-
GREEN='\033[0;32m'
59-
NC='\033[0m'
60-
OK="echo -e${GREEN}OK${NC}"
61-
62-
echo -n"Waiting for gitlab to come online..."
63-
I=0
64-
while:;do
65-
sleep 5
66-
curl -s http://localhost:8080/users/sign_in2>/dev/null| grep -q"GitLab Community Edition"&&break
67-
let I=I+5
68-
[$I-eq 120 ]&&exit 1
69-
done
70-
sleep 5
71-
$OK
72-
73-
# Get the token
74-
TOKEN=$(curl -s http://localhost:8080/api/v3/session \
75-
-X POST \
76-
--data"login=$LOGIN&password=$PASSWORD" \
77-
| python -c'import sys, json; print(json.load(sys.stdin)["private_token"])')
78-
79-
cat>$CONFIG<<EOF
80-
[global]
81-
default = local
82-
timeout = 2
83-
84-
[local]
85-
url = http://localhost:8080
86-
private_token =$TOKEN
87-
EOF
88-
89-
echo"Config file content ($CONFIG):"
90-
cat$CONFIG
91-
9243
# NOTE(gpocentek): the first call might fail without a little delay
93-
sleep10
44+
sleep5
9445

9546
set -e
9647

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp