Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Testsuite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Feneas
federation
Testsuite
Commits
07ed1e15
Commit
07ed1e15
authored
Dec 29, 2018
by
zauberstuhl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testproject fix count check
parent
11d70c64
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
18 deletions
+23
-18
test_helper.bash
test_helper.bash
+16
-9
testproject.bats
testproject.bats
+7
-9
No files found.
test_helper.bash
View file @
07ed1e15
...
...
@@ -76,9 +76,9 @@ function get() {
function
start_app
()
{
params
=
""
if
[
!
-z
${
PRSHA
}
]
;
then
echo
"
!!!!!!! Custom build active !!!!!!!"
echo
"
Using repository
$PRREPO
"
echo
"
With SHA
$PRSHA
"
echo
"
# +++ Custom build active +++"
>
&3
echo
"
# Project
$PROJECT
(
$PRREPO
)"
>
&3
echo
"
# With SHA
$PRSHA
"
>
&3
params
=
"-e PROJECT=
$PROJECT
-e PRSHA=
$PRSHA
-e PRREPO=
$PRREPO
"
fi
cid
=
$(
container_id
"
$1
"
)
...
...
@@ -141,8 +141,9 @@ function wait_for() {
TIMEOUT_PID
=
$!
while
true
;
do
$1
2>&1 |grep
-m
1
"
$2
"
>
/dev/null
if
[
"
$?
"
-eq
0
]
;
then
break
;
fi
res
=
$(
eval
$1
2>&1
)
;
code
=
$?
echo
"
$res
"
|grep
-m
1
"
$2
"
>
/dev/null
[
"
$?
"
-eq
0
]
&&
[
"
$code
"
-eq
0
]
&&
break
sleep
1
done
&
>
/dev/null 2>&1
CMD_PID
=
$!
...
...
@@ -176,14 +177,20 @@ function query() {
# init_database will be triggered on setup()
function
init_database
()
{
docker run
-d
--name
$(
container_id
"postgres"
)
postgres:latest
sleep
5
# timeout for container otherwise docker-logs fails
docker run
-d
--name
$(
container_id postgres
)
postgres:latest
cmd
=
"docker logs
$(
container_id postgres
)
"
text
=
"ready for start up"
code
=
$(
wait_for
"
$cmd
"
"
$text
"
)
[
"
$code
"
-eq
"0"
]
}
# init_redis will be triggered on setup()
function
init_redis
()
{
docker run
-d
--name
$(
container_id
"redis"
)
redis:latest
sleep
5
# timeout for container otherwise docker-logs fails
docker run
-d
--name
$(
container_id redis
)
redis:latest
cmd
=
"docker logs
$(
container_id redis
)
"
text
=
"Ready to accept connections"
code
=
$(
wait_for
"
$cmd
"
"
$text
"
)
[
"
$code
"
-eq
"0"
]
}
# create_database "g1"
...
...
testproject.bats
View file @
07ed1e15
...
...
@@ -32,7 +32,7 @@ load test_helper
@test
"
$btf
start testproject#2 server"
{
start_app tp2 3000 testproject
$(
latest_tag testproject
)
[
"
$?
"
-eq
0
]
cmd
=
"docker logs
$(
container_id tp
1
)
"
cmd
=
"docker logs
$(
container_id tp
2
)
"
text
=
"CREATE TABLE"
code
=
$(
wait_for
"
$cmd
"
"
$text
"
)
[
"
$code
"
-eq
"0"
]
...
...
@@ -54,17 +54,15 @@ load test_helper
}
@test
"
$btf
test count on tp1, it should be one"
{
get
"http://
$(
container_ip tp1
)
:3000"
echo
"expected 200, got
$HTTP_STATUS_CODE
"
[
"
$HTTP_STATUS_CODE
"
==
"200"
]
echo
"expected 1, got
$HTTP_BODY
"
[
"
$HTTP_BODY
"
==
"1"
]
cmd
=
'get "http://'
$(
container_ip tp1
)
':3000"'
code
=
$(
wait_for
"
$cmd
"
"1"
)
[
"
$code
"
-eq
"0"
]
}
@test
"
$btf
check the database on tp1 too"
{
result
=
$(
query tp1
"select count(*) from testtable;"
)
echo
"expected 1, got
$result
"
[
[
$result
=
~
"1"
]
]
cmd
=
'query tp1 "select count(*) from testtable;"'
code
=
$(
wait_for
"
$cmd
"
"1"
)
[
"
$code
"
-eq
"0"
]
}
@test
"
$btf
stop and delete the containers"
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment