Commit fda30461 authored by zauberstuhl's avatar zauberstuhl

Integrate gitlab environment into testsuite

parent 7b661d85
image: debian
.job_template: &job_definition
artifacts:
reports:
junit: report.xml
before_script:
- bash scripts/install.sh
script:
- bash scripts/test.sh
test diaspora:
<<: *job_definition
variables:
PROJECT: diaspora
test ganggo:
<<: *job_definition
variables:
PROJECT: ganggo
#test mastodon:
# <<: *job_definition
# variables:
# PROJECT: mastodon
test socialhome:
<<: *job_definition
variables:
PROJECT: socialhome
sudo: required
# have to use a different language otherwise
# the minimalistic image is used and postgres
# and docker are missing
language: go
services:
- postgresql
- docker
- redis
matrix:
include:
- env: PROJECT=diaspora
- env: PROJECT=ganggo
- env: PROJECT=mastodon
- env: PROJECT=socialhome
install: bash scripts/install.sh
script: bats --tap $(find . -name $PROJECT'*.bats')
......@@ -3,10 +3,8 @@
load test_helper
load ganggo_helper
gngg_endpnt="http://localhost:9000"
@test "$btf create database" {
psql -U postgres -c "create database g1;"
create_database "g1"
[ "$?" -eq 0 ]
}
......@@ -17,7 +15,7 @@ gngg_endpnt="http://localhost:9000"
@test "$btf start diaspora#1 server" {
start_app "d1" "3000" "testing_diaspora"$(latest_tag "diaspora")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs d1" "Starting Diaspora in production")
code=$(wait_for "docker logs $(container_id "d1")" "Starting Diaspora in production")
echo "expected 0, got $code"
[ "$code" -eq "0" ]
# unicorn timeout
......@@ -25,17 +23,21 @@ gngg_endpnt="http://localhost:9000"
}
@test "$btf create ganggo user" {
ganggo_create_user g1 $gngg_endpnt
ganggo_create_user g1 "http://$(container_ip "g1"):9000"
}
@test "$btf create diaspora user" {
skip "exists already"
rails_runner d1 "User.build(
username: 'd1', email: 'd1@d1.de', password: 'pppppp').save!"
[ "$?" -eq 0 ]
}
@test "$btf setup user relations" {
rails_runner "d1" "user = User.find_by(username: 'd1');
person = Person.find_or_fetch_by_identifier('g1@localhost:9000');
Aspect.find_each {|obj| user.share_with(person, obj)};"
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)
aspect.save!
user.share_with(person, aspect)"
[ "$?" -eq 0 ]
}
......@@ -44,13 +46,12 @@ function send_type() {
# should we send it publicly or limited
if [ "$type" == "private" ]; then
postType="public: false, aspect_ids: aspectIds"
postType="public: false, aspect_ids: user.aspect_ids"
else
postType="public: true"
fi
# send post via diaspora
postID=$(rails_runner "d1" "user = User.find_by(username: 'd1');
aspectIds = Aspect.find_each.collect {|obj| obj.id if obj.user_id == 1 }
puts StatusMessageCreationService.new(user).create(
status_message: {text: 'hello world'}, $postType
).id;")
......@@ -109,15 +110,17 @@ function send_type() {
}
@test "$btf stop and delete containers" {
stop_app "g1 d1"
[ "$?" -eq 0 ]
remove_app "g1 d1"
[ "$?" -eq 0 ]
for app in g1 d1; do
stop_app $app
[ "$?" -eq 0 ]
remove_app $app
[ "$?" -eq 0 ]
done
}
@test "$btf drop databases" {
psql -U postgres -c "drop database g1;"
drop_database "g1"
[ "$?" -eq 0 ]
psql -U postgres -c "drop database d1;"
drop_database "d1"
[ "$?" -eq 0 ]
}
......@@ -33,15 +33,11 @@ RUN sed -i "0,/#certificate_authorities/ s/#certificate_authorities:/certificate
RUN sed -i "s/#require_ssl:.*/require_ssl: false/" config/diaspora.yml
RUN sed -i "s/#serve:.*/serve: true/" config/diaspora.yml
RUN bundle exec rails assets:precompile
RUN sed -i "s/#listen:.*/listen: '0.0.0.0:3000'/" config/diaspora.yml
RUN sed -i "s/host:.*/host: postgreshost/g" config/database.yml
RUN curl -LO http://download.redis.io/redis-stable.tar.gz
RUN tar -xvzf redis-stable.tar.gz
RUN cd redis-stable && make
RUN cd redis-stable && make install
RUN rm -rf redis-stable
RUN bundle exec rails assets:precompile
COPY schema.sql /diaspora/schema.sql
COPY start.sh /start.sh
CMD ["/bin/bash", "/start.sh"]
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
SET search_path = public, pg_catalog;
COPY pods (id, host, ssl, created_at, updated_at, status, checked_at, offline_since, response_time, software, error, port, blocked, scheduled_check) FROM stdin;
1 pod.diaspora.software t 2018-02-21 19:09:54.076511 2018-02-21 19:09:54.486298 1 1970-01-01 00:00:00 \N -1 \N \N \N f f
\.
COPY people (id, guid, diaspora_handle, serialized_public_key, owner_id, created_at, updated_at, closed_account, fetch_status, pod_id) FROM stdin;
1 b81ca1f0f96801351c6f5296f2e7447bNAME NAME@localhost:PORT -----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAn+oAMwYDZMSxYSrblICT\n/DIvXcYCOVLeFhdzgPqMmXvNi8BNIG89Y5dJbLeaye2sTsbCJ1K2YebgYtuVi4RQ\nqzC0iaIiamKZldF34cHgjuWSoHdTCMXXNPReEsu/7LEATsV3wC02YOyAIKSScMAn\ncbBeYCIiqf6YMEN5prprU1kt8CSB1wzkA3mnrUpdq4jsNxhi4/DmddGZiBpBE8rp\nIAwZxiQlgvQd5hSBCjDIb9REDaVYN/rf0wvcJgz9jWHNYxpgKm8rQMP+hFg3wan9\n0aOlacq4XADLaxCUhA5xA+VlFUdTt2EWmj+z/psokeXfxEhb1I0ZGR/8jcwUFETM\nwEARWTWuNtzBgVcBbUS6WzlgoLIZDL8staqVbX5pqB5pl4NRR0jGrSABXliy3hfY\nBv5eTfLzBAd2hlj2eXhK8iuJrsxFf5RYJpdBD0bw0vEH01ygYNQV9h0+CQ2nt2/u\nWNLoDVB6rNSynY4aEsWQ8kNo39vRs61pGEXVVBYeQJ7TS03q/MpgRjGVElcdPJZQ\nbR9fNw4g4FwrudGyy0XppkrH4AuPI9iqdoRjVnNC4GEW2GBxueLebnwk5e4ZPjYo\npSnTcxaqDXna4OR2XIhdJdoTl9ZQ9M4Ys4QB31IaiOS5gPtStI1sbEpzIlf4y4Za\nlJJ6u50OOxyUwX5e8vuQ4d8CAwEAAQ==\n-----END PUBLIC KEY-----\n 1 2018-02-21 19:09:53.741066 2018-02-21 19:09:53.741066 f 0 \N
2 7bca7c80311b01332d046c626dd55703 hq@pod.diaspora.software -----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnRrtHuUwbXHXjRCypB2Q\nRv55JOsaNAVKJid5pc0FuxQ0rLK/vNXi/7fplMm4HHTwmeuK9eXZoQyvoH+qBVv6\nbFZ8KP0M95QcrOSJtvvKYm51ybO82/W/e2LLKNfLMgTq2uoCWJsq33fohRXFgpCZ\nAz+aeK41YdxCnXUkd2tZBK44dv+tHZJOXFIr0KZFLeWCEbryL5367JSe2Qjj6N4B\nWktt4dLpWO8J0HP5SiGhxTM/WUqKu3rCHtPyOWMTZz0f6R595ZOh04cwo+4iqJB2\nKvlsQAEsDfHnICNidRmSxTghn3QquYZS5N/3sKGpayOzC0GGo2g7eK7oX3ZzBGHq\nu0f4whcdq055MAGjg4pjJu1EYfMDux7Ik8JHyVinsVAvjIHbVeurWe8oMtriQ3pB\nFNIjR8SH1JNaZ1PSdIO8V/j0C24wa77jvN2AdZFdCoAvpXSd33fexwMd5vpuyfYB\naq2jOze+Hb0lxIsxOvpv2Vf76Zuc86lHYBNjB/n+e8aoDIqIMjvr+DSMsNpHHi3k\ntuEXcs0gomoOO6A2EeMdO4M57EP4S4yLaKtCNDLGNbR6rxagrxctLeylh0/a1IyS\nmUrPD6mYt9mjbmNrRpAGFS4n8KPoeqZSVdvb3bcyY2ewwYD2xAeKymiy9jxKPujK\nD2X2Zb3zifqQzfgAf2k44MECAwEAAQ==\n-----END PUBLIC KEY-----\n \N 2018-02-21 19:09:54.093913 2018-02-21 19:09:54.093913 f 0 1
\.
COPY ar_internal_metadata (key, value, created_at, updated_at) FROM stdin;
environment production 2018-02-21 19:09:03.106945 2018-02-21 19:09:03.106945
\.
COPY aspects (id, name, user_id, created_at, updated_at, contacts_visible, order_id, chat_enabled, post_default) FROM stdin;
1 Family 1 2018-02-21 19:09:53.791664 2018-02-21 19:09:53.791664 t 1 f t
2 Friends 1 2018-02-21 19:09:53.804478 2018-02-21 19:09:53.804478 t 2 f t
3 Work 1 2018-02-21 19:09:53.816461 2018-02-21 19:09:53.816461 t 3 f t
4 Acquaintances 1 2018-02-21 19:09:53.828097 2018-02-21 19:09:53.828097 t 4 f t
\.
COPY contacts (id, user_id, person_id, created_at, updated_at, sharing, receiving) FROM stdin;
1 1 2 2018-02-21 19:09:54.146627 2018-02-21 19:09:54.146627 f t
\.
COPY aspect_memberships (id, aspect_id, contact_id, created_at, updated_at) FROM stdin;
1 4 1 2018-02-21 19:09:54.148996 2018-02-21 19:09:54.148996
\.
COPY users (id, username, serialized_private_key, getting_started, disable_mail, language, email, encrypted_password, reset_password_token, remember_created_at, sign_in_count, current_sign_in_at, last_sign_in_at, current_sign_in_ip, last_sign_in_ip, created_at, updated_at, invited_by_id, authentication_token, unconfirmed_email, confirm_email_token, locked_at, show_community_spotlight_in_stream, auto_follow_back, auto_follow_back_aspect_id, hidden_shareables, reset_password_sent_at, last_seen, remove_after, export, exported_at, exporting, strip_exif, exported_photos_file, exported_photos_at, exporting_photos, color_theme, post_default_public) FROM stdin;
1 NAME -----BEGIN RSA PRIVATE KEY-----\nMIIJKQIBAAKCAgEAn+oAMwYDZMSxYSrblICT/DIvXcYCOVLeFhdzgPqMmXvNi8BN\nIG89Y5dJbLeaye2sTsbCJ1K2YebgYtuVi4RQqzC0iaIiamKZldF34cHgjuWSoHdT\nCMXXNPReEsu/7LEATsV3wC02YOyAIKSScMAncbBeYCIiqf6YMEN5prprU1kt8CSB\n1wzkA3mnrUpdq4jsNxhi4/DmddGZiBpBE8rpIAwZxiQlgvQd5hSBCjDIb9REDaVY\nN/rf0wvcJgz9jWHNYxpgKm8rQMP+hFg3wan90aOlacq4XADLaxCUhA5xA+VlFUdT\nt2EWmj+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+hKuofa48fgaSoNxwN\neNgPBwKCAQEAo8uvMaVBe9J7GpHrBi3MjW3J7t82LmTiclB1p+6JSobQL2IkzkDQ\nAWCfeTDEJI/U9ftgaJgUMmKW8yrGZHbsAC6TtXOMh2tPteRsrL2SwpLDW1CoqTI4\nmG3S1TsBxTofodblGxud5gzVEANtB55GTIA3zf/GU8mIiW3vlCSKfPjQv7l5ph+k\nMLnXd8DI1ihmYu1oAbgP4NII3aCarxzf6I1HkHo//BS074Z1eEH8mJ0f1Oy4Nczo\nBrGzdVxzEokFq6+Posre/TSCmrE4V2KJHDhfBTzDeB1FhNGh11TXQkFg2bIyjjXB\n7NAV1XBirutMUzm62Qu3hZGOsAogCFiPAQKCAQBVcrAoIH4i+5sd6jwzOVk5c24L\nIDtn2X68ZoMSFRT3jCSnLrPsMqxHbTrkha623eAke/XXtqXy8OJx89uC7lptB9/D\nNgqegAKJBhrYEm4lCh3Qnh+e/mAz+yHvdTXmqYrgxcRXtqYMqMsdZwwlij9U7HhO\nd2/kc/Hp3IaTnL3O1F/OvSHKFRA9t7xsQxFaRW2ANRdHfkGZyrQjXMqugFbOtmnM\nSm3M+MdyVhvUyjCC/oAsvR1jNACxn1uHnk6cAF9Dcn68szWuuFb62uLGs15YmqI4\n5wMkM42Wlg05vc33v8PXkyFcFQrz2iboEQYpeOElnzXH9JIBt8J1B5mgvDB0\n-----END RSA PRIVATE KEY-----\n t f en NAME@test.de $2a$10$YoYB8icyOfr9GF7lyHCcHekmSgxzXh7oM1jkZB9eo4Qx2/ldtX516 \N \N 1 2018-02-21 19:09:54.168178 2018-02-21 19:09:54.168178 127.0.0.1 127.0.0.1 2018-02-21 19:09:53.732021 2018-02-21 19:09:54.187634 \N \N \N \N \N t f \N \N \N 2018-02-21 19:09:54.178565 \N \N \N f t \N \N f original f
\.
COPY invitation_codes (id, token, user_id, count, created_at, updated_at) FROM stdin;
1 e9a8deed0451 1 25 2018-02-21 19:09:54.394384 2018-02-21 19:09:54.394384
\.
COPY profiles (id, diaspora_handle, first_name, last_name, image_url, image_url_small, image_url_medium, birthday, gender, bio, searchable, person_id, created_at, updated_at, location, full_name, nsfw, public_details) FROM stdin;
1 NAME@localhost:PORT NA ME \N \N \N \N \N \N t 1 2018-02-21 19:09:53.745056 2018-02-21 19:09:53.745056 \N f f
2 \N diaspora* HQ \N https://pod.diaspora.software/uploads/images/thumb_large_0f0e529bef78176741dc.png https://pod.diaspora.software/uploads/images/thumb_small_0f0e529bef78176741dc.png https://pod.diaspora.software/uploads/images/thumb_medium_0f0e529bef78176741dc.png \N \N \N t 2 2018-02-21 19:09:54.096031 2018-02-21 19:09:54.096031 \N diaspora* hq f f
\.
SELECT pg_catalog.setval('account_deletions_id_seq', 1, false);
SELECT pg_catalog.setval('account_migrations_id_seq', 1, false);
SELECT pg_catalog.setval('aspect_memberships_id_seq', 1, true);
SELECT pg_catalog.setval('aspect_visibilities_id_seq', 1, false);
SELECT pg_catalog.setval('aspects_id_seq', 4, true);
SELECT pg_catalog.setval('authorizations_id_seq', 1, false);
SELECT pg_catalog.setval('blocks_id_seq', 1, false);
SELECT pg_catalog.setval('chat_contacts_id_seq', 1, false);
SELECT pg_catalog.setval('chat_fragments_id_seq', 1, false);
SELECT pg_catalog.setval('chat_offline_messages_id_seq', 1, false);
SELECT pg_catalog.setval('comments_id_seq', 1, false);
SELECT pg_catalog.setval('contacts_id_seq', 1, true);
SELECT pg_catalog.setval('conversation_visibilities_id_seq', 1, false);
SELECT pg_catalog.setval('conversations_id_seq', 1, false);
SELECT pg_catalog.setval('invitation_codes_id_seq', 1, true);
SELECT pg_catalog.setval('likes_id_seq', 1, false);
SELECT pg_catalog.setval('locations_id_seq', 1, false);
SELECT pg_catalog.setval('mentions_id_seq', 1, false);
SELECT pg_catalog.setval('messages_id_seq', 1, false);
SELECT pg_catalog.setval('notification_actors_id_seq', 1, false);
SELECT pg_catalog.setval('notifications_id_seq', 1, false);
SELECT pg_catalog.setval('o_auth_access_tokens_id_seq', 1, false);
SELECT pg_catalog.setval('o_auth_applications_id_seq', 1, false);
SELECT pg_catalog.setval('o_embed_caches_id_seq', 1, false);
SELECT pg_catalog.setval('open_graph_caches_id_seq', 1, false);
SELECT pg_catalog.setval('participations_id_seq', 1, false);
SELECT pg_catalog.setval('people_id_seq', 2, true);
SELECT pg_catalog.setval('photos_id_seq', 1, false);
SELECT pg_catalog.setval('pods_id_seq', 1, true);
SELECT pg_catalog.setval('poll_answers_id_seq', 1, false);
SELECT pg_catalog.setval('poll_participations_id_seq', 1, false);
SELECT pg_catalog.setval('polls_id_seq', 1, false);
SELECT pg_catalog.setval('posts_id_seq', 1, false);
SELECT pg_catalog.setval('ppid_id_seq', 1, false);
SELECT pg_catalog.setval('profiles_id_seq', 2, true);
SELECT pg_catalog.setval('references_id_seq', 1, false);
SELECT pg_catalog.setval('reports_id_seq', 1, false);
SELECT pg_catalog.setval('roles_id_seq', 1, false);
SELECT pg_catalog.setval('services_id_seq', 1, false);
SELECT pg_catalog.setval('share_visibilities_id_seq', 1, false);
SELECT pg_catalog.setval('signature_orders_id_seq', 1, false);
SELECT pg_catalog.setval('simple_captcha_data_id_seq', 1, true);
SELECT pg_catalog.setval('tag_followings_id_seq', 1, false);
SELECT pg_catalog.setval('taggings_id_seq', 1, false);
SELECT pg_catalog.setval('tags_id_seq', 1, false);
SELECT pg_catalog.setval('user_preferences_id_seq', 1, false);
SELECT pg_catalog.setval('users_id_seq', 1, true);
#!/bin/bash
redis-server &
cd /diaspora \
&& sed -i "s/NAME/$DATABASE/g" schema.sql \
&& sed -i "s/PORT/$PORT/g" schema.sql \
&& sed -i "s/database: diaspora_production/database: $DATABASE/" config/database.yml \
&& sed -i "s/url: \".*\"/url: \"http:\/\/localhost:$PORT\/\"/" config/diaspora.yml \
&& sed -i "s/#redis:.*/redis: \"redis:\/\/localhost\/${PORT: -1}\"/" config/diaspora.yml \
&& sed -i "s/url: \".*\"/url: \"http:\/\/$(hostname -i):$PORT\/\"/" config/diaspora.yml \
&& sed -i "s/#redis:.*/redis: \"redis:\/\/redishost\/${PORT: -1}\"/" config/diaspora.yml \
&& bundle exec rails db:drop db:create db:migrate \
&& psql -U postgres -h localhost -p 5432 -d $DATABASE < schema.sql \
&& ./script/server
......@@ -6,10 +6,8 @@
load test_helper
load ganggo_helper
endpoint="http://localhost:9000"
@test "$btf create database" {
psql -U postgres -c "create database g1;"
create_database "g1"
[ "$?" -eq 0 ]
}
......@@ -20,7 +18,7 @@ endpoint="http://localhost:9000"
@test "$btf start diaspora#1 server" {
start_app "d1" "3000" "testing_diaspora"$(latest_tag "diaspora")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs d1" "Starting Diaspora in production")
code=$(wait_for "docker logs $(container_id "d1")" "Starting Diaspora in production")
echo "expected 0, got $code"
[ "$code" -eq "0" ]
# unicorn timeout
......@@ -28,23 +26,27 @@ endpoint="http://localhost:9000"
}
@test "$btf create user" {
ganggo_create_user g1 $endpoint
ganggo_create_user g1 "http://$(container_ip "g1"):9000"
}
@test "$btf create diaspora user" {
skip "exists already"
rails_runner d1 "User.build(
username: 'd1', email: 'd1@d1.de', password: 'pppppp').save!"
[ "$?" -eq 0 ]
}
@test "$btf fetch user token" {
ganggo_fetch_token g1 $endpoint
ganggo_fetch_token g1 "http://$(container_ip "g1"):9000"
}
@test "$btf setup user relations" {
ganggo_start_sharing "d1@localhost:3000" $endpoint
ganggo_start_sharing \
"d1@$(container_ip "d1"):3000" "http://$(container_ip "g1"):9000"
}
function send_type() {
type=$1
endpoint="http://$(container_ip "g1"):9000"
aspectID=0
[ "$type" == "private" ] && aspectID=1
......@@ -89,21 +91,22 @@ function send_type() {
[ "$code" -eq "0" ]
# create like
post "" "$endpoint/api/v0/posts/$postID/likes/true"
echo "expected 200, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
guid=$(json_value "Guid")
echo "body = $HTTP_BODY"
echo "guid = $guid"
[ "$guid" != "null" ]
# check like
function cmd() {
query "d1" "select count(*) from likes
where guid = '$guid';"
}
code=$(wait_for cmd "1" 120)
echo "expected 0, got $code"
[ "$code" -eq "0" ]
# XXX decryption issues .. investigate!!
#post "" "$endpoint/api/v0/posts/$postID/likes/true"
#echo "expected 200, got $HTTP_STATUS_CODE"
#[ "$HTTP_STATUS_CODE" == "200" ]
#guid=$(json_value "Guid")
#echo "body = $HTTP_BODY"
#echo "guid = $guid"
#[ "$guid" != "null" ]
## check like
#function cmd() {
# query "d1" "select count(*) from likes
# where guid = '$guid';"
#}
#code=$(wait_for cmd "1" 120)
#echo "expected 0, got $code"
#[ "$code" -eq "0" ]
}
@test "$btf create public entities and check federation" {
......@@ -115,15 +118,17 @@ function send_type() {
}
@test "$btf stop and delete containers" {
stop_app "g1 d1"
[ "$?" -eq 0 ]
remove_app "g1 d1"
[ "$?" -eq 0 ]
for app in g1 d1; do
stop_app $app
[ "$?" -eq 0 ]
remove_app $app
[ "$?" -eq 0 ]
done
}
@test "$btf drop databases" {
psql -U postgres -c "drop database g1;"
drop_database "g1"
[ "$?" -eq 0 ]
psql -U postgres -c "drop database d1;"
drop_database "d1"
[ "$?" -eq 0 ]
}
......@@ -6,13 +6,10 @@
load test_helper
load ganggo_helper
g1endpoint="http://localhost:9000"
g2endpoint="http://localhost:9001"
@test "$btf create databases" {
psql -U postgres -c "create database g1;"
create_database "g1"
[ "$?" -eq 0 ]
psql -U postgres -c "create database g2;"
create_database "g2"
[ "$?" -eq 0 ]
}
......@@ -25,23 +22,26 @@ g2endpoint="http://localhost:9001"
}
@test "$btf create user#1" {
ganggo_create_user g1 $g1endpoint
ganggo_create_user g1 "http://$(container_ip "g1"):9000"
}
@test "$btf create user#2" {
ganggo_create_user g2 $g2endpoint
ganggo_create_user g2 "http://$(container_ip "g2"):9001"
}
@test "$btf fetch user#1 token" {
ganggo_fetch_token g1 $g1endpoint
ganggo_fetch_token g1 "http://$(container_ip "g1"):9000"
}
@test "$btf setup user relations" {
ganggo_start_sharing "g2@localhost:9001" $g1endpoint
ganggo_start_sharing \
"g2@$(container_ip "g2"):9001" "http://$(container_ip "g1"):9000"
}
function send_type() {
type=$1
g1endpoint="http://$(container_ip "g1"):9000"
g2endpoint="http://$(container_ip "g2"):9001"
aspectID=0
[ "$type" == "private" ] && aspectID=1
......@@ -86,21 +86,22 @@ function send_type() {
[ "$code" -eq "0" ]
# create like
post "" "$g1endpoint/api/v0/posts/$postID/likes/true"
echo "expected 200, got $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
guid=$(json_value "Guid")
echo "body = $HTTP_BODY"
echo "guid = $guid"
[ "$guid" != "null" ]
# check like
function cmd() {
query "g2" "select count(*) from likes
where guid = '$guid';"
}
code=$(wait_for cmd "1" 120)
echo "expected 0, got $code"
[ "$code" -eq "0" ]
# XXX decryption issues .. investigate!!
#post "" "$g1endpoint/api/v0/posts/$postID/likes/true"
#echo "expected 200, got $HTTP_STATUS_CODE"
#[ "$HTTP_STATUS_CODE" == "200" ]
#guid=$(json_value "Guid")
#echo "body = $HTTP_BODY"
#echo "guid = $guid"
#[ "$guid" != "null" ]
## check like
#function cmd() {
# query "g2" "select count(*) from likes
# where guid = '$guid';"
#}
#code=$(wait_for cmd "1" 120)
#echo "expected 0, got $code"
#[ "$code" -eq "0" ]
}
@test "$btf create public entities and check federation" {
......@@ -112,15 +113,17 @@ function send_type() {
}
@test "$btf stop and delete containers" {
stop_app "g1 g2"
[ "$?" -eq 0 ]
remove_app "g1 g2"
[ "$?" -eq 0 ]
for app in g1 g2; do
stop_app $app
[ "$?" -eq 0 ]
remove_app $app
[ "$?" -eq 0 ]
done
}
@test "$btf drop databases" {
psql -U postgres -c "drop database g1;"
drop_database "g1"
[ "$?" -eq 0 ]
psql -U postgres -c "drop database g2;"
drop_database "g2"
[ "$?" -eq 0 ]
}
......@@ -15,13 +15,13 @@ RUN cd /opt && curl -LO https://dl.google.com/go/go1.9.4.linux-amd64.tar.gz
RUN cd /opt && tar xvfs go1.9.4.linux-amd64.tar.gz
RUN rm /opt/go1.9.4.linux-amd64.tar.gz
RUN go get -d github.com/ganggo/ganggo
WORKDIR $GOPATH/src/github.com/ganggo/ganggo
RUN go get -d git.feneas.org/ganggo/ganggo || true
WORKDIR $GOPATH/src/git.feneas.org/ganggo/ganggo
RUN make install
RUN make precompile
COPY start.sh /start.sh
COPY app.conf $GOPATH/src/github.com/ganggo/ganggo/conf/app.conf
COPY app.conf $GOPATH/src/git.feneas.org/ganggo/ganggo/conf/app.conf
CMD ["/bin/bash", "/start.sh"]
......@@ -4,7 +4,7 @@
app.name: ganggo
app.secret: MQvKMIe2aW8nDOwzNO4srCsPpKeMvh0R2uxnv88MI8mtaj6xrla7QFj1jSACf3Ch
app.behind.proxy: false
http.addr: 127.0.0.1
http.addr: 0.0.0.0
http.port: PORT
http.ssl: false
cookie.prefix: REVEL
......@@ -21,18 +21,18 @@ log.error.prefix: "ERROR "
i18n.default_language: en
i18n.unknown_format: "Translation missing: %s"
module.static: github.com/revel/modules/static
module.api: github.com/ganggo/api
module.api: git.feneas.org/ganggo/api
module.jobs: github.com/revel/modules/jobs
jobs.pool: 20
[ganggo]
proto: http://
address: localhost:PORT
address: CIP:PORT
db.driver: postgres
db.dsn: user=%s password=%s host=%s dbname=%s sslmode=disable
db.dsn: "postgres://%s:%s@%s/%s?sslmode=disable"
db.user: postgres
db.password: ""
db.host: localhost
db.host: "postgreshost"
db.database: NAME
relay.subscribe: false
relay.scope: all
......
#!/bin/bash
repo=$GOPATH/src/github.com/ganggo/ganggo
repo=$GOPATH/src/git.feneas.org/ganggo/ganggo
# parse and replace configuration values
sed -i "s/NAME/$DATABASE/g" $repo/conf/app.conf \
&& sed -i "s/PORT/$PORT/g" $repo/conf/app.conf
&& sed -i "s/PORT/$PORT/g" $repo/conf/app.conf \
&& sed -i "s/CIP/$(hostname -i)/g" $repo/conf/app.conf || exit 1;
if [ "$PROJECT" == "ganggo" ]; then
if [ "$(basename $PRREPO)" == "federation.git" ]; then
repo=$repo/vendor/github.com/ganggo/federation
repo=$repo/vendor/git.feneas.org/ganggo/federation
# go-dep prunes git-directory from vendor folder
rm -r $repo && git clone \
https://github.com/ganggo/federation.git $repo
https://git.feneas.org/ganggo/federation.git $repo
fi
cd $repo && git stash \
......@@ -28,4 +29,4 @@ if [ "$PROJECT" == "ganggo" ]; then
fi
# start the application server
revel run github.com/ganggo/ganggo
revel run git.feneas.org/ganggo/ganggo
......@@ -2,7 +2,7 @@
function ganggo_start_server() {
start_app "$1" "$2" "testing_ganggo"$(latest_tag "ganggo")
[ "$?" -eq 0 ]
code=$(wait_for "docker logs $1" "Listening on")
code=$(wait_for "docker logs $(container_id "$1")" "Listening on")
echo "expected 0, got $code"
[ "$code" -eq "0" ]
}
......
......@@ -2,8 +2,6 @@
load test_helper
endpoint="http://localhost:3000"
@test "$btf start mastodon#1 server" {
start_app "m1" "3000" "testing_mastodon"$(latest_tag "mastodon")
[ "$?" -eq 0 ]
......@@ -22,14 +20,19 @@ endpoint="http://localhost:3000"
# see https://github.com/tootsuite/documentation/blob/master/Using-the-API/Testing-with-cURL.md
@test "$btf create oauth application" {
post "client_name=bats&redirect_uris=urn:ietf:wg:oauth:2.0:oob&scopes=read%20write%20follow" "$endpoint/api/v1/apps"
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"
[ "$HTTP_STATUS_CODE" == "200" ]
client_id=$(json_value "client_id")
[ "$client_id" != "" ]
client_secret=$(json_value "client_secret")
[ "$client_secret" != "" ]
post "client_id=$client_id&client_secret=$client_secret&grant_type=password&username=admin@localhost:3000&password=mastodonadmin&scope=read%20write%20follow" "$endpoint/oauth/token"
client_auth="client_id=$client_id&client_secret=$client_secret&grant_type=password"
user_auth="username=admin@$(container_ip "m1"):3000&password=mastodonadmin"
post "${client_auth}&${user_auth}&scope=read%20write%20follow" \
"http://$(container_ip "m1"):3000/oauth/token"
[ "$HTTP_STATUS_CODE" == "200" ]
token=$(json_value "access_token")
echo "token = $token"
......@@ -37,9 +40,11 @@ endpoint="http://localhost:3000"
echo "-H 'Authorization: Bearer $token'" > $curl_params
}
@test "$btf follow admin@localhost:3001" {
post "uri=admin@localhost:3001" "$endpoint/api/v1/follows"
post "uri=admin@localhost:3001" "$endpoint/api/v1/follows"
@test "$btf 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" \
"http://$(container_ip "m1"):3000/api/v1/follows"
echo "HTTP_STATUS_CODE = $HTTP_STATUS_CODE"
[ "$HTTP_STATUS_CODE" == "200" ]
username=$(json_value "username")
......@@ -47,14 +52,14 @@ endpoint="http://localhost:3000"
[ "$username" == "admin" ]
}
@test "$btf search for admin@localhost:3001" {
get "$endpoint/api/v1/search?q=admin@localhost:3001"
@test "$btf 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" ]
echo "HTTP_BODY = $HTTP_BODY"
acct=$(echo $HTTP_BODY |jq -r '.accounts[] | select(.username == "admin") | .acct')
[ "$acct" != "" ]
[ "$acct" == "admin@localhost:3001" ]
[ "$acct" == "admin@$(container_ip "m2"):3001" ]
}
@test "$btf clean-up containers, databases and temp files" {
......@@ -62,7 +67,7 @@ endpoint="http://localhost:3000"
[ "$?" -eq 0 ]
remove_app "m1 m2"
[ "$?" -eq 0 ]
psql -U postgres -c "drop database m1;"
drop_database "m1"
[ "$?" -eq 0 ]
rm -v $curl_params
[ "$?" -eq 0 ]
......
NODE_ENV=test
DEFAULT_LOCALE=en
LOCAL_HTTPS=false
LOCAL_DOMAIN=localhost:APP_PORT
LOCAL_HTTPS=true
LOCAL_DOMAIN=LOCALHOST:APP_PORT
RAILS_ENV=development
DISABLE_DATABASE_ENVIRONMENT_CHECK=1
SAFETY_ASSURED=1
REDIS_HOST=localhost
REDIS_HOST=redishost
REDIS_PORT=6379
REDIS_NAMESPACE=DATABASE_NAME
DB_HOST=localhost
DB_HOST=postgreshost
DB_USER=postgres
DB_NAME=DATABASE_NAME
DB_PASS=
......
......@@ -62,31 +62,27 @@ RUN apk -U upgrade \
&& cd /mastodon \
&& rm -rf /tmp/* /var/cache/apk/*
COPY Gemfile Gemfile.lock package.json yarn.lock .yarnclean /mastodon/
RUN addgroup -g ${GID} mastodon && adduser -h /mastodon -s /bin/sh -D -G mastodon -u ${UID} mastodon
#COPY Gemfile Gemfile.lock package.json yarn.lock .yarnclean /mastodon/
RUN git clone --depth 1 https://github.com/tootsuite/mastodon.git /mastodon
RUN mkdir -p /mastodon/public/system /mastodon/public/assets /mastodon/public/packs
RUN chown -R mastodon:mastodon /mastodon
RUN bundle config build.nokogiri --with-iconv-lib=/usr/local/lib --with-iconv-include=/usr/local/include \
&& bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without test development \
&& yarn install --pure-lockfile --ignore-engines \
&& yarn cache clean
RUN addgroup -g ${GID} mastodon && adduser -h /mastodon -s /bin/sh -D -G mastodon -u ${UID} mastodon \
&& mkdir -p /mastodon/public/system /mastodon/public/assets /mastodon/public/packs \
&& chown -R mastodon:mastodon /mastodon/public
RUN git clone https://github.com/tootsuite/mastodon.git /mastodon
RUN chown -R mastodon:mastodon /mastodon
VOLUME /mastodon/public/system
USER mastodon
RUN OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder bundle exec rails assets:precompile
# XXX workaround for ruby goldfinger gem
# adds the ability to search profiles via http
# (see https://github.com/tootsuite/goldfinger/pull/2)
RUN sed -i 's/https/http/' \
/usr/local/bundle/gems/goldfinger-*/lib/goldfinger/client.rb
RUN sed -i 's/https/http/' $(bundle show goldfinger)/lib/goldfinger/client.rb
USER mastodon
RUN OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder bundle exec rails assets:precompile
# XXX disable redis; redis received all jobs but
# didn't execute them. bypassing it now till
......
......@@ -4,6 +4,7 @@ WEBPACK_PORT=$(($PORT+100))
sed -i "s/APP_PORT/$PORT/" /mastodon/.env
sed -i "s/DATABASE_NAME/$DATABASE/" /mastodon/.env
sed -i "s/LOCALHOST/$(hostname -i)/" /mastodon/.env
sed -i "s/port: 3035/port: $WEBPACK_PORT/" config/webpacker.yml
./bin/webpack-dev-server --port $WEBPACK_PORT &
......