Commit 73d31d69 authored by Lukas Matt's avatar Lukas Matt

Merge branch 'add_testproject' into 'master'

Add testproject

See merge request !7
parents e44464d9 9c7ea258
Pipeline #881 failed with stage
in 1 minute and 9 seconds
image: debian
stages: stages:
- build
- test - test
- deploy - deploy
.job_template: &job_definition .job_template: &job_definition
image: debian
stage: test stage: test
artifacts: artifacts:
reports: reports:
...@@ -20,6 +21,16 @@ stages: ...@@ -20,6 +21,16 @@ stages:
variables: variables:
- $CI_PIPELINE_TRIGGERED - $CI_PIPELINE_TRIGGERED
build docker images:
stage: build
before_script:
- apt-get update && apt-get install -y curl
- curl -L https://get.docker.com | bash -
script:
- bash scripts/build_docker_image.sh
only:
- tags
single project: single project:
<<: *job_definition <<: *job_definition
only: only:
...@@ -46,6 +57,12 @@ test socialhome: ...@@ -46,6 +57,12 @@ test socialhome:
variables: variables:
PROJECT: socialhome PROJECT: socialhome
test testproject:
<<: *job_definition
<<: *no_pipeline
variables:
PROJECT: testproject
pages: pages:
<<: *no_pipeline <<: *no_pipeline
image: ruby:2.3 image: ruby:2.3
...@@ -61,3 +78,5 @@ pages: ...@@ -61,3 +78,5 @@ pages:
artifacts: artifacts:
paths: paths:
- public - public
only:
- master
# Federation Tests # Federation Tests
You'll find the documentation here: [feneas.git.feneas.org/federation-testsuite](https://feneas.git.feneas.org/federation-testsuite/) You'll find the documentation here: [feneas.git.feneas.org/federation/testsuite](https://feneas.git.feneas.org/federation/testsuite/)
...@@ -13,7 +13,7 @@ load ganggo_helper ...@@ -13,7 +13,7 @@ load ganggo_helper
} }
@test "$btf start diaspora#1 server" { @test "$btf start diaspora#1 server" {
start_app "d1" "3000" "testing_diaspora"$(latest_tag "diaspora") start_app "d1" "3000" "diaspora"$(latest_tag "diaspora")
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
code=$(wait_for "docker logs $(container_id "d1")" "Starting Diaspora in production") code=$(wait_for "docker logs $(container_id "d1")" "Starting Diaspora in production")
echo "expected 0, got $code" echo "expected 0, got $code"
......
...@@ -2,21 +2,35 @@ nav: ...@@ -2,21 +2,35 @@ nav:
- page: Federation Tests - page: Federation Tests
permalink: "#federation-tests" permalink: "#federation-tests"
subnav: subnav:
- page: Projects - page: Vocabulary
permalink: "#projects" permalink: "#vocabulary"
- page: Add your project - page: Workflow
permalink: "#add-your-project" permalink: "#workflow"
- page: Development - page: Testsuite
permalink: "#development" permalink: "#testsuite"
subnav: subnav:
- page: Dependencies - page: Dependencies
permalink: "#dependencies" permalink: "#dependencies"
- page: Run tests - page: Docker Image
permalink: "#run-tests" permalink: "#docker-image"
- page: Run images subnav:
permalink: "#run-images" - page: Environment
permalink: "#environment"
- page: Dockerfile
permalink: "#dockerfile"
- page: "entrypoint.sh"
permalink: "#entrypointsh"
- page: Building
permalink: "#building"
- page: Testing
permalink: "#testing"
subnav:
- page: Run BATS
permalink: "#run-bats"
- page: Testsuite Server
permalink: "#testsuite-server"
baseurl: "/federation-testsuite" baseurl: "/federation/testsuite"
url: "https://feneas.git.feneas.org" url: "https://feneas.git.feneas.org"
markdown: kramdown markdown: kramdown
......
<div class="row alert alert-info">
<div class="eleven columns">
<p markdown="1">{{ include.text }}</p>
</div>
<div class="one columns">
<div data-icon="ei-exclamation" data-size="s"></div>
</div>
</div>
...@@ -12,6 +12,13 @@ ...@@ -12,6 +12,13 @@
<ol> <ol>
{% for s in n.subnav %} {% for s in n.subnav %}
<li><a href="{{ s.permalink }}">{{ s.page }}</a></li> <li><a href="{{ s.permalink }}">{{ s.page }}</a></li>
{% if s.subnav.size > 0 %}
<ol>
{% for ss in s.subnav %}
<li><a href="{{ ss.permalink }}">{{ ss.page }}</a></li>
{% endfor %}
</ol>
{% endif %}
{% endfor %} {% endfor %}
</ol> </ol>
{% endif %} {% endif %}
......
...@@ -60,6 +60,32 @@ $on-laptop: 780px; ...@@ -60,6 +60,32 @@ $on-laptop: 780px;
} }
.alert-info {
color: #0c5460;
background-color: #d1ecf1;
border-color: #bee5eb;
}
.alert p {
margin: 0;
}
.alert {
position: relative;
padding: .75rem 1.25rem;
margin-bottom: 1rem;
border: 1px solid transparent;
border-top-color: transparent;
border-right-color: transparent;
border-bottom-color: transparent;
border-left-color: transparent;
border-radius: .25rem;
}
*, ::after, ::before {
box-sizing: border-box;
}
@import @import
"normalize", "normalize",
"base", "base",
......
This diff is collapsed.
...@@ -16,7 +16,7 @@ load ganggo_helper ...@@ -16,7 +16,7 @@ load ganggo_helper
} }
@test "$btf start diaspora#1 server" { @test "$btf start diaspora#1 server" {
start_app "d1" "3000" "testing_diaspora"$(latest_tag "diaspora") start_app "d1" "3000" "diaspora"$(latest_tag "diaspora")
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
code=$(wait_for "docker logs $(container_id "d1")" "Starting Diaspora in production") code=$(wait_for "docker logs $(container_id "d1")" "Starting Diaspora in production")
echo "expected 0, got $code" echo "expected 0, got $code"
......
# ganggo_start_server "g1" "9000" # ganggo_start_server "g1" "9000"
function ganggo_start_server() { function ganggo_start_server() {
start_app "$1" "$2" "testing_ganggo"$(latest_tag "ganggo") start_app "$1" "$2" "ganggo"$(latest_tag "ganggo")
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
code=$(wait_for "docker logs $(container_id "$1")" "Listening on") code=$(wait_for "docker logs $(container_id "$1")" "Listening on")
echo "expected 0, got $code" echo "expected 0, got $code"
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
load test_helper load test_helper
@test "$btf start mastodon#1 server" { @test "$btf start mastodon#1 server" {
start_app "m1" "3000" "testing_mastodon"$(latest_tag "mastodon") start_app "m1" "3000" "mastodon"$(latest_tag "mastodon")
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
code=$(wait_for_mastodon "m1") code=$(wait_for_mastodon "m1")
echo "expected 0, got $code" echo "expected 0, got $code"
...@@ -11,7 +11,7 @@ load test_helper ...@@ -11,7 +11,7 @@ load test_helper
} }
@test "$btf start mastodon#2 server" { @test "$btf start mastodon#2 server" {
start_app "m2" "3001" "testing_mastodon"$(latest_tag "mastodon") start_app "m2" "3001" "mastodon"$(latest_tag "mastodon")
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
code=$(wait_for_mastodon "m2") code=$(wait_for_mastodon "m2")
echo "expected 0, got $code" echo "expected 0, got $code"
......
#!/bin/bash
project=$(echo $CI_COMMIT_TAG |cut -d- -f2)
# change into docker project
cd $CI_PROJECT_DIR/$project || exit 1
# authenticate with docker registry first
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD || exit 1
# build the image locally
docker build -t \
feneas/testsuite_${project}:$CI_COMMIT_TAG . || exit 1
# overwrite latest-tag with new image
docker tag feneas/testsuite_${project}:$CI_COMMIT_TAG \
feneas/testsuite_${project}:latest || exit 1
# upload the image and both tags
docker push feneas/testsuite_${project}:$CI_COMMIT_TAG || exit 1
docker push feneas/testsuite_${project}:latest || exit 1
# socialhome_start_server "s1" "9001" # socialhome_start_server "s1" "9001"
function socialhome_start_server() { function socialhome_start_server() {
start_app "$1" "$2" "testing_socialhome"$(latest_tag "socialhome") start_app "$1" "$2" "socialhome"$(latest_tag "socialhome")
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
code=$(wait_for "docker logs $(container_id "$1")" "Listening on endpoint tcp") code=$(wait_for "docker logs $(container_id "$1")" "Listening on endpoint tcp")
echo "expected 0, got $code" echo "expected 0, got $code"
......
...@@ -72,7 +72,7 @@ function get() { ...@@ -72,7 +72,7 @@ function get() {
fetch "GET" "" "url" "$1" fetch "GET" "" "url" "$1"
} }
# start_app "g1" "3000" "testing_diaspora:v1.0.1" # start_app "g1" "3000" "diaspora:v1.0.1"
function start_app() { function start_app() {
params="" params=""
if [ ! -z ${PRSHA} ]; then if [ ! -z ${PRSHA} ]; then
...@@ -82,11 +82,11 @@ function start_app() { ...@@ -82,11 +82,11 @@ function start_app() {
params="-e PROJECT=$PROJECT -e PRSHA=$PRSHA -e PRREPO=$PRREPO" params="-e PROJECT=$PROJECT -e PRSHA=$PRSHA -e PRREPO=$PRREPO"
fi fi
cid=$(container_id "$1") cid=$(container_id "$1")
echo "Starting docker container $cid (thefederation/$3) on port $2" echo "Starting docker container $cid (feneas/testsuite_$3) on port $2"
docker run --name=$cid $params \ docker run --name=$cid $params \
--link $(container_id "postgres"):postgreshost \ --link $(container_id "postgres"):postgreshost \
--link $(container_id "redis"):redishost \ --link $(container_id "redis"):redishost \
-e DATABASE=$1 -e PORT=$2 -d thefederation/$3 -e DATABASE=$1 -e PORT=$2 -d feneas/testsuite_$3
} }
# stop_app "g1" # stop_app "g1"
......
# vim:ft=sh
#
# this test file is related to https://feneas.git.feneas.org/federation/testsuite
load test_helper
@test "$btf create databases" {
for tp in tp1 tp2; do
create_database $tp
[ "$?" -eq 0 ]
done
}
@test "$btf start testproject#1 server" {
start_app tp1 3000 testproject$(latest_tag testproject)
[ "$?" -eq 0 ]
# NOTE You can also wait for certain log output!
# Incase your server is only operational after
# a special message then you can use the wait_for
# function from the test_helper file:
#
# wait_for <command> <search-text>
#
# for this project that could look something like this:
#
# cmd="docker logs $(container_id tp1)"
# text="CREATE TABLE"
# code=$(wait_for "$cmd" "$text")
# [ "$code" -eq "0" ]
}
@test "$btf start testproject#2 server" {
start_app tp2 3000 testproject$(latest_tag testproject)
[ "$?" -eq 0 ]
}
@test "$btf 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"
[ "$HTTP_STATUS_CODE" == "200" ]
echo "expected 0, got $HTTP_BODY"
[ "$HTTP_BODY" == "0" ]
done
}
@test "$btf 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" {
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" ]
}
@test "$btf check the database on tp1 too" {
result=$(query tp1 "select count(*) from testtable;")
echo "expected 1, got $result"
[[ $result =~ "1" ]]
}
@test "$btf stop and delete the containers" {
for tp in tp1 tp2; do
stop_app $tp
[ "$?" -eq 0 ]
remove_app $tp
[ "$?" -eq 0 ]
done
}
@test "$btf drop databases" {
for tp in tp1 tp2; do
drop_database $tp
[ "$?" -eq 0 ]
done
}
FROM debian:jessie
RUN apt-get update
RUN apt-get install -y \
git-core postgresql-client netcat curl
RUN git clone https://git.feneas.org/feneas/federation/testsuite-testproject.git
WORKDIR testsuite-testproject
ADD entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
#!/bin/bash
if [ "$PROJECT" == "testproject" ]; then
git checkout . \
&& git remote add custom $PRREPO \
&& git fetch custom \
&& git merge -m merge $PRSHA \
&& git log -1 || {
echo "Cannot pull from repo=$PRREPO sha=$PRSHA"
exit 1
}
fi
./testproject.sh $DATABASE postgreshost $PORT
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