Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
springboot-maven3-centos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Thomas MENARD
springboot-maven3-centos
Commits
5f477fe4
Commit
5f477fe4
authored
8 years ago
by
Luis Fernando Gomes
Browse files
Options
Downloads
Patches
Plain Diff
Fix tests for Mac
parent
ae85157b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/run
+27
-8
27 additions, 8 deletions
test/run
with
27 additions
and
8 deletions
test/run
+
27
−
8
View file @
5f477fe4
...
@@ -12,15 +12,23 @@ if [ $# -eq 0 ]; then
...
@@ -12,15 +12,23 @@ if [ $# -eq 0 ]; then
echo
"ERROR: No test project name has been passed."
echo
"ERROR: No test project name has been passed."
exit
1
exit
1
fi
fi
# Determining system utility executables (darwin compatibility check)
READLINK_EXEC
=
"readlink"
MKTEMP_EXEC
=
"mktemp"
if
(
echo
"
$OSTYPE
"
| egrep
-qs
'darwin'
)
;
then
!
type
-a
"greadlink"
&>
"/dev/null"
||
READLINK_EXEC
=
"greadlink"
!
type
-a
"gmktemp"
&>
"/dev/null"
||
MKTEMP_EXEC
=
"gmktemp"
fi
test_project
=
${
1
}
test_project
=
${
1
}
test_dir
=
"
$(
readlink
-zf
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
))
"
test_dir
=
"
$(
$READLINK_EXEC
-zf
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
))
"
image_dir
=
$(
readlink
-zf
${
test_dir
}
/..
)
image_dir
=
$(
$READLINK_EXEC
-zf
${
test_dir
}
/..
)
scripts_url
=
"file://
${
image_dir
}
/.sti/bin"
scripts_url
=
"file://
${
image_dir
}
/.sti/bin"
cid_file
=
$(
mktemp
-u
--suffix
=
.cid
)
cid_file
=
$(
$MKTEMP_EXEC
-u
--suffix
=
.cid
)
# Since we built the candidate image locally, we don't want S2I attempt to pull
# Since we built the candidate image locally, we don't want S2I
to
attempt to pull
# it from Docker hub
# it from Docker hub
s2i_args
=
"--force-pull=false"
s2i_args
=
"--force-pull=false
--loglevel=2
"
# Read exposed port from image meta data
# Read exposed port from image meta data
test_port
=
"
$(
docker inspect
--format
=
'{{range $key, $value := .ContainerConfig.ExposedPorts }}{{$key}}{{end}}'
${
IMAGE_NAME
}
|
sed
's/\/.*//'
)
"
test_port
=
"
$(
docker inspect
--format
=
'{{range $key, $value := .ContainerConfig.ExposedPorts }}{{$key}}{{end}}'
${
IMAGE_NAME
}
|
sed
's/\/.*//'
)
"
...
@@ -38,11 +46,15 @@ container_exists() {
...
@@ -38,11 +46,15 @@ container_exists() {
}
}
container_ip
()
{
container_ip
()
{
docker inspect
--format
=
"{{ .NetworkSettings.IPAddress }}"
$(
cat
$cid_file
)
if
(
echo
"
$OSTYPE
"
| egrep
-qs
'darwin'
)
;
then
docker-machine ip
else
docker inspect
--format
=
"{{ .NetworkSettings.IPAddress }}"
$(
cat
$cid_file
)
fi
}
}
run_s2i_build
()
{
run_s2i_build
()
{
s2i build
${
sti_args
}
file://
${
test_dir
}
/
${
test_project
}
${
IMAGE_NAME
}
${
IMAGE_NAME
}
-
${
test_project
}
s2i build
--incremental
=
true
${
sti_args
}
file://
${
test_dir
}
/
${
test_project
}
${
IMAGE_NAME
}
${
IMAGE_NAME
}
-
${
test_project
}
}
}
prepare
()
{
prepare
()
{
...
@@ -58,6 +70,7 @@ prepare() {
...
@@ -58,6 +70,7 @@ prepare() {
git config user.email
"build@localhost"
&&
git config user.name
"builder"
git config user.email
"build@localhost"
&&
git config user.name
"builder"
git add
-A
&&
git commit
-m
"Sample commit"
git add
-A
&&
git commit
-m
"Sample commit"
popd
>
/dev/null
popd
>
/dev/null
run_s2i_build
}
}
run_test_application
()
{
run_test_application
()
{
...
@@ -80,7 +93,7 @@ cleanup() {
...
@@ -80,7 +93,7 @@ cleanup() {
check_result
()
{
check_result
()
{
local
result
=
"
$1
"
local
result
=
"
$1
"
if
[[
"
$result
"
!=
"0"
]]
;
then
if
[[
"
$result
"
!=
"0"
]]
;
then
info
"TEST FAILED for
${
test_project
}
(
${
result
}
)"
info
"TEST FAILED for
${
test_project
}
(
exit code:
${
result
}
)"
cleanup
cleanup
exit
$result
exit
$result
fi
fi
...
@@ -116,6 +129,12 @@ test_connection() {
...
@@ -116,6 +129,12 @@ test_connection() {
local
attempt
=
1
local
attempt
=
1
local
result
=
1
local
result
=
1
while
[
$attempt
-le
$max_attempts
]
;
do
while
[
$attempt
-le
$max_attempts
]
;
do
echo
"Sending GET request to http://
$(
container_ip
)
:
${
test_port
}
/"
if
(
echo
"
$OSTYPE
"
| egrep
-qs
'darwin'
)
;
then
echo
"Warning for OSX users: if you can't access the container's IP
${
container_ip
}
directly (because you use boot2docker for example)"
echo
"you should run the curl command in a container, for example using:"
echo
"docker run --rm -it sequenceiq/alpine-curl curl -s -w %{http_code} -o /dev/null http://
$(
container_ip
)
:
${
test_port
}
/"
fi
response_code
=
$(
curl
-s
-w
%
{
http_code
}
-o
/dev/null http://
$(
container_ip
)
:
${
test_port
}
/
)
response_code
=
$(
curl
-s
-w
%
{
http_code
}
-o
/dev/null http://
$(
container_ip
)
:
${
test_port
}
/
)
status
=
$?
status
=
$?
if
[
$status
-eq
0
]
;
then
if
[
$status
-eq
0
]
;
then
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment