Commit c005dd3c authored by zauberstuhl's avatar zauberstuhl
Browse files

Rename global vars

parent cfa553b4
Pipeline #2336 failed with stage
in 10 minutes and 37 seconds
......@@ -189,7 +189,7 @@ load test_helper
Since we need two instances of our `testproject` we have to create two postgresql databases first:
```
@test "$btf create databases" {
@test "$PREFIX create databases" {
for tp in tp1 tp2; do
create_database $tp
[ "$?" -eq 0 ]
......@@ -200,12 +200,12 @@ Since we need two instances of our `testproject` we have to create two postgresq
and start-up the mentioned servers:
```
@test "$btf start testproject#1 server" {
@test "$PREFIX start testproject#1 server" {
start_app tp1 3000 testproject$(latest_tag testproject)
[ "$?" -eq 0 ]
}
@test "$btf start testproject#2 server" {
@test "$PREFIX start testproject#2 server" {
start_app tp2 3000 testproject$(latest_tag testproject)
[ "$?" -eq 0 ]
}
......@@ -221,12 +221,12 @@ To prove this we send two requests:
2. to tp1 ensuring the message was received
```
@test "$btf increase count on tp1 via tp2" {
@test "$PREFIX increase count on tp1 via tp2" {
get "http://$(container_ip tp2):3000/add@$(container_ip tp1):3000"
[ "$HTTP_STATUS_CODE" == "200" ]
}
@test "$btf test count on tp1, it should be one" {
@test "$PREFIX 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" ]
......@@ -238,7 +238,7 @@ To prove this we send two requests:
Last but not least we do some cleaning and we are done with our first unit test for the federated web `\m/`
```
@test "$btf stop and delete the containers" {
@test "$PREFIX stop and delete the containers" {
for tp in tp1 tp2; do
stop_app $tp
[ "$?" -eq 0 ]
......@@ -247,7 +247,7 @@ Last but not least we do some cleaning and we are done with our first unit test
done
}
@test "$btf drop databases" {
@test "$PREFIX drop databases" {
for tp in tp1 tp2; do
drop_database $tp
[ "$?" -eq 0 ]
......
......@@ -24,7 +24,7 @@ function ganggo_fetch_token() {
echo "body = $HTTP_BODY"
echo "token = $token"
[ "$token" != "null" ]
echo "-H access_token:$token" > $curl_params
echo "-H access_token:$token" > $CURL_PARAMS
}
# ganggo_start_sharing "g2@localhost:9001" "http://localhost:9000"
......
......@@ -27,7 +27,7 @@ function socialhome_fetch_token() {
echo "body = $HTTP_BODY"
echo "token = $token"
[ "$token" != "null" ]
echo "-H 'Authorization: Token $token'" > $curl_params
echo "-H 'Authorization: Token $token'" > $CURL_PARAMS
}
# socialhome_start_sharing "g1@localhost:9000" "http://localhost:9001"
......
export btf=$(basename $BATS_TEST_FILENAME)
export curl_params="/tmp/.bats-curl_params"
export test_id="/tmp/.bats-test_id"
export PREFIX=$(basename $BATS_TEST_FILENAME)
export CURL_PARAMS="$BATS_TMPDIR/curl-params"
export TEST_ID="$BATS_TMPDIR/test-id$CI_JOB_ID"
export CI_REGISTRY_IMAGE="registry.git.feneas.org/feneas/federation/testsuite"
unset HTTP_STATUS_CODE
......@@ -38,7 +38,7 @@ function fetch() {
unset params
unset field_params
[ -f "$curl_params" ] && params=$(cat $curl_params)
[ -f "$CURL_PARAMS" ] && params=$(cat $CURL_PARAMS)
if [[ "$3" == "url" ]]; then field_params="-d '$2'"
else
IFS='&' read -ra reqparams <<< "$2"
......@@ -103,10 +103,10 @@ function remove_app() {
# container_id "g1"
function container_id() {
# set a gloabl test ID for multiple project testing
if [ ! -f "$test_id" ]; then
shuf -i 10000-90000 -n 1 > $test_id
if [ ! -f "$TEST_ID" ]; then
shuf -i 10000-90000 -n 1 > $TEST_ID
fi
echo "$(cat $test_id)-$1"
echo "$(cat $TEST_ID)-$1"
}
# container_ip "g1"
......
......@@ -3,16 +3,16 @@
load '../test_helper'
load '../projects/ganggo/ganggo_helper'
@test "$btf create database" {
@test "$PREFIX create database" {
create_database "g1"
[ "$?" -eq 0 ]
}
@test "$btf start ganggo#1 server" {
@test "$PREFIX start ganggo#1 server" {
ganggo_start_server g1 "9000"
}
@test "$btf start diaspora#1 server" {
@test "$PREFIX start diaspora#1 server" {
start_app "d1" "3000" "diaspora"$(latest_tag "diaspora")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs $(container_id "d1")" "Starting Diaspora in production")
......@@ -22,17 +22,17 @@ load '../projects/ganggo/ganggo_helper'
sleep 15
}
@test "$btf create ganggo user" {
@test "$PREFIX create ganggo user" {
ganggo_create_user g1 "http://$(container_ip "g1"):9000"
}
@test "$btf create diaspora user" {
@test "$PREFIX create diaspora user" {
rails_runner d1 "User.build(
username: 'd1', email: 'd1@d1.de', password: 'pppppp').save!"
[ "$?" -eq 0 ]
}
@test "$btf setup user relations" {
@test "$PREFIX setup user relations" {
rails_runner "d1" "user = User.find_by(username: 'd1')
person = Person.find_or_fetch_by_identifier('g1@$(container_ip "g1"):9000')
aspect = Aspect.new(name: 'test', user_id: user.id)
......@@ -101,15 +101,15 @@ function send_type() {
[ "$code" -eq "0" ]
}
@test "$btf create public entities and check federation" {
@test "$PREFIX create public entities and check federation" {
send_type public
}
@test "$btf create private entities and check federation" {
@test "$PREFIX create private entities and check federation" {
send_type private
}
@test "$btf stop and delete containers" {
@test "$PREFIX stop and delete containers" {
for app in g1 d1; do
stop_app $app
[ "$?" -eq 0 ]
......@@ -118,7 +118,7 @@ function send_type() {
done
}
@test "$btf drop databases" {
@test "$PREFIX drop databases" {
drop_database "g1"
[ "$?" -eq 0 ]
drop_database "d1"
......
......@@ -6,16 +6,16 @@
load '../test_helper'
load '../projects/ganggo/ganggo_helper'
@test "$btf create database" {
@test "$PREFIX create database" {
create_database "g1"
[ "$?" -eq 0 ]
}
@test "$btf start ganggo#1 server" {
@test "$PREFIX start ganggo#1 server" {
ganggo_start_server g1 "9000"
}
@test "$btf start diaspora#1 server" {
@test "$PREFIX start diaspora#1 server" {
start_app "d1" "3000" "diaspora"$(latest_tag "diaspora")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs $(container_id "d1")" "Starting Diaspora in production")
......@@ -25,21 +25,21 @@ load '../projects/ganggo/ganggo_helper'
sleep 15
}
@test "$btf create user" {
@test "$PREFIX create user" {
ganggo_create_user g1 "http://$(container_ip "g1"):9000"
}
@test "$btf create diaspora user" {
@test "$PREFIX create diaspora user" {
rails_runner d1 "User.build(
username: 'd1', email: 'd1@d1.de', password: 'pppppp').save!"
[ "$?" -eq 0 ]
}
@test "$btf fetch user token" {
@test "$PREFIX fetch user token" {
ganggo_fetch_token g1 "http://$(container_ip "g1"):9000"
}
@test "$btf setup user relations" {
@test "$PREFIX setup user relations" {
ganggo_start_sharing \
"d1@$(container_ip "d1"):3000" "http://$(container_ip "g1"):9000"
}
......@@ -109,15 +109,15 @@ function send_type() {
#[ "$code" -eq "0" ]
}
@test "$btf create public entities and check federation" {
@test "$PREFIX create public entities and check federation" {
send_type public
}
@test "$btf create private entities and check federation" {
@test "$PREFIX create private entities and check federation" {
send_type private
}
@test "$btf stop and delete containers" {
@test "$PREFIX stop and delete containers" {
for app in g1 d1; do
stop_app $app
[ "$?" -eq 0 ]
......@@ -126,7 +126,7 @@ function send_type() {
done
}
@test "$btf drop databases" {
@test "$PREFIX drop databases" {
drop_database "g1"
[ "$?" -eq 0 ]
drop_database "d1"
......
......@@ -6,34 +6,34 @@
load '../test_helper'
load '../projects/ganggo/ganggo_helper'
@test "$btf create databases" {
@test "$PREFIX create databases" {
create_database "g1"
[ "$?" -eq 0 ]
create_database "g2"
[ "$?" -eq 0 ]
}
@test "$btf start ganggo#1 server" {
@test "$PREFIX start ganggo#1 server" {
ganggo_start_server g1 "9000"
}
@test "$btf start ganggo#2 server" {
@test "$PREFIX start ganggo#2 server" {
ganggo_start_server g2 "9001"
}
@test "$btf create user#1" {
@test "$PREFIX create user#1" {
ganggo_create_user g1 "http://$(container_ip "g1"):9000"
}
@test "$btf create user#2" {
@test "$PREFIX create user#2" {
ganggo_create_user g2 "http://$(container_ip "g2"):9001"
}
@test "$btf fetch user#1 token" {
@test "$PREFIX fetch user#1 token" {
ganggo_fetch_token g1 "http://$(container_ip "g1"):9000"
}
@test "$btf setup user relations" {
@test "$PREFIX setup user relations" {
ganggo_start_sharing \
"g2@$(container_ip "g2"):9001" "http://$(container_ip "g1"):9000"
}
......@@ -104,15 +104,15 @@ function send_type() {
#[ "$code" -eq "0" ]
}
@test "$btf create public entities and check federation" {
@test "$PREFIX create public entities and check federation" {
send_type public
}
@test "$btf create private entities and check federation" {
@test "$PREFIX create private entities and check federation" {
send_type private
}
@test "$btf stop and delete containers" {
@test "$PREFIX stop and delete containers" {
for app in g1 g2; do
stop_app $app
[ "$?" -eq 0 ]
......@@ -121,7 +121,7 @@ function send_type() {
done
}
@test "$btf drop databases" {
@test "$PREFIX drop databases" {
drop_database "g1"
[ "$?" -eq 0 ]
drop_database "g2"
......
......@@ -2,7 +2,7 @@
load '../test_helper'
@test "$btf start mastodon#1 server" {
@test "$PREFIX start mastodon#1 server" {
start_app "m1" "3000" "mastodon"$(latest_tag "mastodon")
[ "$?" -eq 0 ]
code=$(wait_for_mastodon "m1")
......@@ -10,7 +10,7 @@ load '../test_helper'
[ "$code" -eq "0" ]
}
@test "$btf start mastodon#2 server" {
@test "$PREFIX start mastodon#2 server" {
start_app "m2" "3001" "mastodon"$(latest_tag "mastodon")
[ "$?" -eq 0 ]
code=$(wait_for_mastodon "m2")
......@@ -19,7 +19,7 @@ load '../test_helper'
}
# see https://github.com/tootsuite/documentation/blob/master/Using-the-API/Testing-with-cURL.md
@test "$btf create oauth application" {
@test "$PREFIX create oauth application" {
post
"client_name=bats&redirect_uris=urn:ietf:wg:oauth:2.0:oob&scopes=read%20write%20follow" \
"http://$(container_ip "m1"):3000/api/v1/apps"
......@@ -37,10 +37,10 @@ load '../test_helper'
token=$(json_value "access_token")
echo "token = $token"
[ "$token" != "" ]
echo "-H 'Authorization: Bearer $token'" > $curl_params
echo "-H 'Authorization: Bearer $token'" > $CURL_PARAMS
}
@test "$btf follow admin@m2:3001" {
@test "$PREFIX follow admin@m2:3001" {
post "uri=admin@$(container_ip "m2"):3001" \
"http://$(container_ip "m1"):3000/api/v1/follows"
post "uri=admin@$(container_ip "m2"):3001" \
......@@ -52,7 +52,7 @@ load '../test_helper'
[ "$username" == "admin" ]
}
@test "$btf search for admin@m2:3001" {
@test "$PREFIX search for admin@m2:3001" {
get "http://$(container_ip "m1"):3000/api/v1/search?q=admin@$(container_ip "m2"):3001"
echo "HTTP_STATUS_CODE = $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
......@@ -62,13 +62,13 @@ load '../test_helper'
[ "$acct" == "admin@$(container_ip "m2"):3001" ]
}
@test "$btf clean-up containers, databases and temp files" {
@test "$PREFIX clean-up containers, databases and temp files" {
stop_app "m1 m2"
[ "$?" -eq 0 ]
remove_app "m1 m2"
[ "$?" -eq 0 ]
drop_database "m1"
[ "$?" -eq 0 ]
rm -v $curl_params
rm -v $CURL_PARAMS
[ "$?" -eq 0 ]
}
......@@ -7,57 +7,57 @@ load '../test_helper'
load '../projects/ganggo/ganggo_helper'
load '../projects/socialhome/socialhome_helper'
@test "$btf create databases" {
@test "$PREFIX create databases" {
create_database "g1"
[ "$?" -eq 0 ]
create_database "s1"
[ "$?" -eq 0 ]
}
@test "$btf start ganggo#1 server" {
@test "$PREFIX start ganggo#1 server" {
ganggo_start_server g1 "9000"
}
@test "$btf start socialhome#1 server" {
@test "$PREFIX start socialhome#1 server" {
socialhome_start_server s1 "9001"
}
@test "$btf create ganggo#1 user" {
@test "$PREFIX create ganggo#1 user" {
ganggo_create_user g1 "http://$(container_ip "g1"):9000"
}
@test "$btf create socialhome#1 user" {
@test "$PREFIX create socialhome#1 user" {
socialhome_create_user s1
}
# since socialhome only delivers to subscriped servers
# the ganggo user has to follow the socialhome user
@test "$btf fetch ganggo#1 token" {
@test "$PREFIX fetch ganggo#1 token" {
ganggo_fetch_token g1 "http://$(container_ip "g1"):9000"
}
@test "$btf setup user relations" {
@test "$PREFIX setup user relations" {
ganggo_start_sharing \
"s1@$(container_ip "s1"):9001" "http://$(container_ip "g1"):9000"
}
# otherwise the socialhome token request will fail
@test "$btf clean-up ganggo#1 files" {
rm -v $curl_params
@test "$PREFIX clean-up ganggo#1 files" {
rm -v $CURL_PARAMS
[ "$?" -eq 0 ]
}
# according to http://socialhome.readthedocs.io/en/latest/api.html#authenticating
@test "$btf fetch socialhome#1 token" {
@test "$PREFIX fetch socialhome#1 token" {
socialhome_fetch_token s1 "http://$(container_ip "s1"):9001"
}
@test "$btf start sharing" {
@test "$PREFIX start sharing" {
socialhome_start_sharing \
"g1@$(container_ip "g1"):9000" "http://$(container_ip "s1"):9001"
}
@test "$btf create public entities and check federation" {
@test "$PREFIX create public entities and check federation" {
post "text=foobar&visibility=public" \
"http://$(container_ip "s1"):9001/api/content/"
[ "$?" -eq 0 ]
......@@ -74,7 +74,7 @@ load '../projects/socialhome/socialhome_helper'
[ "$code" -eq "0" ]
}
@test "$btf clean-up files, containers and database" {
@test "$PREFIX clean-up files, containers and database" {
for app in g1 s1; do
stop_app $app
[ "$?" -eq 0 ]
......@@ -83,6 +83,6 @@ load '../projects/socialhome/socialhome_helper'
drop_database $app
[ "$?" -eq 0 ]
done
rm -v $curl_params
rm -v $CURL_PARAMS
[ "$?" -eq 0 ]
}
......@@ -4,14 +4,14 @@
load '../test_helper'
@test "$btf create databases" {
@test "$PREFIX create databases" {
for tp in tp1 tp2; do
create_database $tp
[ "$?" -eq 0 ]
done
}
@test "$btf start testproject#1 server" {
@test "$PREFIX start testproject#1 server" {
start_app tp1 3000 testproject$(latest_tag testproject)
[ "$?" -eq 0 ]
# NOTE You can also wait for certain log output!
......@@ -29,7 +29,7 @@ load '../test_helper'
[ "$code" -eq "0" ]
}
@test "$btf start testproject#2 server" {
@test "$PREFIX start testproject#2 server" {
start_app tp2 3000 testproject$(latest_tag testproject)
[ "$?" -eq 0 ]
cmd="docker logs $(container_id tp2)"
......@@ -38,7 +38,7 @@ load '../test_helper'
[ "$code" -eq "0" ]
}
@test "$btf test initial count, it should be zero" {
@test "$PREFIX test initial count, it should be zero" {
for tp in tp1 tp2; do
get "http://$(container_ip $tp):3000"
echo "expected 200, got $HTTP_STATUS_CODE"
......@@ -48,24 +48,24 @@ load '../test_helper'
done
}
@test "$btf increase count on tp1 via tp2" {
@test "$PREFIX increase count on tp1 via tp2" {
get "http://$(container_ip tp2):3000/add@$(container_ip tp1):3000"
[ "$HTTP_STATUS_CODE" == "200" ]
}
@test "$btf test count on tp1, it should be one" {
@test "$PREFIX test count on tp1, it should be one" {
cmd='get "http://'$(container_ip tp1)':3000"'
code=$(wait_for "$cmd" "1")
[ "$code" -eq "0" ]
}
@test "$btf check the database on tp1 too" {
@test "$PREFIX check the database on tp1 too" {
cmd='query tp1 "select count(*) from testtable;"'
code=$(wait_for "$cmd" "1")
[ "$code" -eq "0" ]
}
@test "$btf stop and delete the containers" {
@test "$PREFIX stop and delete the containers" {
for tp in tp1 tp2; do
stop_app $tp
[ "$?" -eq 0 ]
......@@ -74,7 +74,7 @@ load '../test_helper'
done
}
@test "$btf drop databases" {
@test "$PREFIX drop databases" {
for tp in tp1 tp2; do
drop_database $tp
[ "$?" -eq 0 ]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment