Skip to content

Commit 82375f2

Browse files
author
Hugo Barrera
authored
Merge pull request #823 from pimutils/next
Run test servers with Docker
2 parents 3037c15 + cd86ea7 commit 82375f2

25 files changed

+383
-135
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[submodule "tests/storage/servers/baikal"]
2-
path = tests/storage/servers/baikal
3-
url = https://github.com/vdirsyncer/baikal-testserver
41
[submodule "tests/storage/servers/owncloud"]
52
path = tests/storage/servers/owncloud
63
url = https://github.com/vdirsyncer/owncloud-testserver

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ repos:
55
- id: trailing-whitespace
66
args: [--markdown-linebreak-ext=md]
77
- id: end-of-file-fixer
8+
exclude: '.travis.yml'
89
- id: check-toml
910
- id: check-added-large-files
1011
- id: debug-statements

.travis.yml

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
{
22
"branches": {
33
"only": [
4-
"auto",
5-
"next",
6-
"master",
7-
"/^.*-maintenance$/"
4+
"master"
85
]
96
},
107
"cache": "pip",
@@ -25,40 +22,56 @@
2522
"python": "3.6"
2623
},
2724
{
28-
"env": "BUILD=test DAV_SERVER=radicale REQUIREMENTS=release ",
25+
"env": "BUILD=test REQUIREMENTS=release",
2926
"python": "3.5"
3027
},
3128
{
32-
"env": "BUILD=test DAV_SERVER=xandikos REQUIREMENTS=release ",
29+
"env": "BUILD=test-storage DAV_SERVER=radicale REQUIREMENTS=release ",
3330
"python": "3.5"
3431
},
3532
{
36-
"env": "BUILD=test DAV_SERVER=radicale REQUIREMENTS=minimal ",
33+
"env": "BUILD=test-storage DAV_SERVER=xandikos REQUIREMENTS=release ",
3734
"python": "3.5"
3835
},
3936
{
40-
"env": "BUILD=test DAV_SERVER=xandikos REQUIREMENTS=minimal ",
37+
"env": "BUILD=test REQUIREMENTS=minimal",
4138
"python": "3.5"
4239
},
4340
{
44-
"env": "BUILD=test DAV_SERVER=radicale REQUIREMENTS=release ",
41+
"env": "BUILD=test-storage DAV_SERVER=radicale REQUIREMENTS=minimal ",
42+
"python": "3.5"
43+
},
44+
{
45+
"env": "BUILD=test-storage DAV_SERVER=xandikos REQUIREMENTS=minimal ",
46+
"python": "3.5"
47+
},
48+
{
49+
"env": "BUILD=test REQUIREMENTS=release",
4550
"python": "3.6"
4651
},
4752
{
48-
"env": "BUILD=test DAV_SERVER=xandikos REQUIREMENTS=release ",
53+
"env": "BUILD=test-storage DAV_SERVER=radicale REQUIREMENTS=release ",
4954
"python": "3.6"
5055
},
5156
{
52-
"env": "BUILD=test DAV_SERVER=fastmail REQUIREMENTS=release ",
57+
"env": "BUILD=test-storage DAV_SERVER=xandikos REQUIREMENTS=release ",
58+
"python": "3.6"
59+
},
60+
{
61+
"env": "BUILD=test-storage DAV_SERVER=fastmail REQUIREMENTS=release ",
5362
"if": "NOT (type IN (pull_request))",
5463
"python": "3.6"
5564
},
5665
{
57-
"env": "BUILD=test DAV_SERVER=radicale REQUIREMENTS=minimal ",
66+
"env": "BUILD=test REQUIREMENTS=minimal",
67+
"python": "3.6"
68+
},
69+
{
70+
"env": "BUILD=test-storage DAV_SERVER=radicale REQUIREMENTS=minimal ",
5871
"python": "3.6"
5972
},
6073
{
61-
"env": "BUILD=test DAV_SERVER=xandikos REQUIREMENTS=minimal ",
74+
"env": "BUILD=test-storage DAV_SERVER=xandikos REQUIREMENTS=minimal ",
6275
"python": "3.6"
6376
},
6477
{
@@ -70,5 +83,8 @@
7083
"script": [
7184
"make -e $BUILD"
7285
],
86+
"services": [
87+
"docker"
88+
],
7389
"sudo": true
7490
}

Makefile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,17 @@ export TESTSERVER_BASE := ./tests/storage/servers/
4646
CODECOV_PATH = /tmp/codecov.sh
4747

4848
ifeq ($(CI), true)
49+
test-storage:
50+
curl -s https://codecov.io/bash > $(CODECOV_PATH)
51+
$(PYTEST) tests/storage/
52+
bash $(CODECOV_PATH) -c -F storage
4953
test:
5054
curl -s https://codecov.io/bash > $(CODECOV_PATH)
5155
$(PYTEST) tests/unit/
5256
bash $(CODECOV_PATH) -c -F unit
5357
$(PYTEST) tests/system/
5458
bash $(CODECOV_PATH) -c -F system
55-
$(PYTEST) tests/storage/
56-
bash $(CODECOV_PATH) -c -F storage
59+
[ "$(ETESYNC_TESTS)" = "false" ] || make test-storage
5760
else
5861
test:
5962
$(PYTEST)
@@ -81,11 +84,15 @@ install-test: install-servers install-dev
8184
fi
8285
[ -z "$(TEST_EXTRA_PACKAGES)" ] || pip install $(TEST_EXTRA_PACKAGES)
8386

87+
install-test-storage: install-test
88+
# This is just an alias
89+
true
90+
8491
install-style: install-docs install-dev
85-
pip install -U flake8 flake8-import-order flake8-bugbear
92+
pip install pre-commit
8693

8794
style:
88-
flake8
95+
pre-commit run --all
8996
! git grep -i syncroniz */*
9097
! git grep -i 'text/icalendar' */*
9198
sphinx-build -W -b html ./docs/ ./docs/_build/html/

docker-compose.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: '3'
2+
3+
services:
4+
xandikos:
5+
build: docker/xandikos/
6+
ports:
7+
- '8000:8000'
8+
9+
radicale:
10+
build: docker/radicale/
11+
ports:
12+
- '8001:8001'
13+
14+
baikal:
15+
build: docker/baikal/
16+
ports:
17+
- '8002:80'

docker/baikal/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Based on https://github.com/ckulka/baikal-docker
2+
# Sadly, we can't override the VOLUME it has set, and we want some static
3+
# config.
4+
FROM php:7.4-apache
5+
ENV VERSION 0.7.0
6+
7+
ADD https://github.com/sabre-io/Baikal/releases/download/$VERSION/baikal-$VERSION.zip .
8+
RUN apt-get update && apt-get install -y sqlite3 unzip
9+
RUN unzip -q baikal-$VERSION.zip -d /var/www/
10+
11+
RUN chown -R www-data:www-data /var/www/baikal && \
12+
docker-php-ext-install pdo pdo_mysql
13+
14+
COPY apache.conf /etc/apache2/sites-enabled/000-default.conf
15+
COPY start.sh /opt/
16+
RUN a2enmod rewrite
17+
18+
COPY baikal.yaml /var/www/baikal/config/baikal.yaml
19+
COPY configure.sql /configure.sql
20+
21+
RUN touch /var/www/baikal/Specific/INSTALL_DISABLED
22+
RUN cat /configure.sql | sqlite3 /var/www/baikal/Specific/db/db.sqlite
23+
24+
RUN chmod -R 777 /var/www/baikal/Specific/ /var/www/baikal/config/
25+
26+
CMD [ "sh", "/opt/start.sh" ]

docker/baikal/apache.conf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Shameless copied from https://github.com/ckulka/baikal-docker/blob/master/files/apache.conf
2+
3+
<VirtualHost *:80>
4+
5+
# InjectedServerAlias dav.example.org dav.example.io
6+
DocumentRoot /var/www/baikal/html
7+
8+
RewriteEngine On
9+
RewriteRule /.well-known/carddav /dav.php [R,L]
10+
RewriteRule /.well-known/caldav /dav.php [R,L]
11+
12+
<Directory "/var/www/baikal/html">
13+
Options None
14+
Options +FollowSymlinks
15+
AllowOverride All
16+
17+
# Confiugration for apache-2.2:
18+
Order allow,deny
19+
Allow from all
20+
21+
# Confiugration for apache-2.4:
22+
Require all granted
23+
</Directory>
24+
25+
</VirtualHost>

docker/baikal/baikal.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
system:
2+
configured_version: 0.7.0
3+
timezone: Europe/Paris
4+
card_enabled: true
5+
cal_enabled: true
6+
dav_auth_type: Basic
7+
admin_passwordhash: 6a890c3aa185845a4bee1e1caed92e1faaf2dec6772291dca301cef6782e3bce
8+
auth_realm: BaikalDAV
9+
invite_from: noreply@localhost
10+
database:
11+
sqlite_file: /var/www/baikal/Specific/db/db.sqlite
12+
mysql: false
13+
mysql_host: ''
14+
mysql_dbname: ''
15+
mysql_username: ''
16+
mysql_password: ''
17+
encryption_key: bdf3bec969736e122e6d5f72c282c49e
18+
configured_version: ''

docker/baikal/configure.sql

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
PRAGMA foreign_keys=OFF;
2+
BEGIN TRANSACTION;
3+
CREATE TABLE addressbooks (
4+
id integer primary key asc NOT NULL,
5+
principaluri text NOT NULL,
6+
displayname text,
7+
uri text NOT NULL,
8+
description text,
9+
synctoken integer DEFAULT 1 NOT NULL
10+
);
11+
INSERT INTO addressbooks VALUES(1,'principals/baikal','Default Address Book','default','Default Address Book for Baikal',1);
12+
CREATE TABLE cards (
13+
id integer primary key asc NOT NULL,
14+
addressbookid integer NOT NULL,
15+
carddata blob,
16+
uri text NOT NULL,
17+
lastmodified integer,
18+
etag text,
19+
size integer
20+
);
21+
CREATE TABLE addressbookchanges (
22+
id integer primary key asc NOT NULL,
23+
uri text,
24+
synctoken integer NOT NULL,
25+
addressbookid integer NOT NULL,
26+
operation integer NOT NULL
27+
);
28+
CREATE TABLE calendarobjects (
29+
id integer primary key asc NOT NULL,
30+
calendardata blob NOT NULL,
31+
uri text NOT NULL,
32+
calendarid integer NOT NULL,
33+
lastmodified integer NOT NULL,
34+
etag text NOT NULL,
35+
size integer NOT NULL,
36+
componenttype text,
37+
firstoccurence integer,
38+
lastoccurence integer,
39+
uid text
40+
);
41+
CREATE TABLE calendars (
42+
id integer primary key asc NOT NULL,
43+
synctoken integer DEFAULT 1 NOT NULL,
44+
components text NOT NULL
45+
);
46+
INSERT INTO calendars VALUES(1,1,'VEVENT,VTODO');
47+
CREATE TABLE calendarinstances (
48+
id integer primary key asc NOT NULL,
49+
calendarid integer,
50+
principaluri text,
51+
access integer,
52+
displayname text,
53+
uri text NOT NULL,
54+
description text,
55+
calendarorder integer,
56+
calendarcolor text,
57+
timezone text,
58+
transparent bool,
59+
share_href text,
60+
share_displayname text,
61+
share_invitestatus integer DEFAULT '2',
62+
UNIQUE (principaluri, uri),
63+
UNIQUE (calendarid, principaluri),
64+
UNIQUE (calendarid, share_href)
65+
);
66+
INSERT INTO calendarinstances VALUES(1,1,'principals/baikal',NULL,'Default calendar','default','Default calendar',0,'','Europe/Paris',NULL,NULL,NULL,2);
67+
CREATE TABLE calendarchanges (
68+
id integer primary key asc NOT NULL,
69+
uri text,
70+
synctoken integer NOT NULL,
71+
calendarid integer NOT NULL,
72+
operation integer NOT NULL
73+
);
74+
CREATE TABLE calendarsubscriptions (
75+
id integer primary key asc NOT NULL,
76+
uri text NOT NULL,
77+
principaluri text NOT NULL,
78+
source text NOT NULL,
79+
displayname text,
80+
refreshrate text,
81+
calendarorder integer,
82+
calendarcolor text,
83+
striptodos bool,
84+
stripalarms bool,
85+
stripattachments bool,
86+
lastmodified int
87+
);
88+
CREATE TABLE schedulingobjects (
89+
id integer primary key asc NOT NULL,
90+
principaluri text NOT NULL,
91+
calendardata blob,
92+
uri text NOT NULL,
93+
lastmodified integer,
94+
etag text NOT NULL,
95+
size integer NOT NULL
96+
);
97+
CREATE TABLE locks (
98+
id integer primary key asc NOT NULL,
99+
owner text,
100+
timeout integer,
101+
created integer,
102+
token text,
103+
scope integer,
104+
depth integer,
105+
uri text
106+
);
107+
CREATE TABLE principals (
108+
id INTEGER PRIMARY KEY ASC NOT NULL,
109+
uri TEXT NOT NULL,
110+
email TEXT,
111+
displayname TEXT,
112+
UNIQUE(uri)
113+
);
114+
INSERT INTO principals VALUES(1,'principals/baikal','[email protected]','Baikal');
115+
CREATE TABLE groupmembers (
116+
id INTEGER PRIMARY KEY ASC NOT NULL,
117+
principal_id INTEGER NOT NULL,
118+
member_id INTEGER NOT NULL,
119+
UNIQUE(principal_id, member_id)
120+
);
121+
CREATE TABLE propertystorage (
122+
id integer primary key asc NOT NULL,
123+
path text NOT NULL,
124+
name text NOT NULL,
125+
valuetype integer NOT NULL,
126+
value string
127+
);
128+
CREATE TABLE users (
129+
id integer primary key asc NOT NULL,
130+
username TEXT NOT NULL,
131+
digesta1 TEXT NOT NULL,
132+
UNIQUE(username)
133+
);
134+
INSERT INTO users VALUES(1,'baikal','3b0845b235b7e985ce5905ab8df45e1a');
135+
CREATE INDEX addressbookid_synctoken ON addressbookchanges (addressbookid, synctoken);
136+
CREATE INDEX calendarid_synctoken ON calendarchanges (calendarid, synctoken);
137+
CREATE INDEX principaluri_uri ON calendarsubscriptions (principaluri, uri);
138+
CREATE UNIQUE INDEX path_property ON propertystorage (path, name);
139+
COMMIT;

docker/baikal/start.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
# Shameless copied from https://raw.githubusercontent.com/ckulka/baikal-docker/master/files/start.sh
3+
4+
# Inject ServerName and ServerAlias if specified
5+
APACHE_CONFIG="/etc/apache2/sites-available/000-default.conf"
6+
if [ ! -z ${BAIKAL_SERVERNAME+x} ]
7+
then
8+
sed -i "s/# InjectedServerName .*/ServerName $BAIKAL_SERVERNAME/g" $APACHE_CONFIG
9+
fi
10+
11+
if [ ! -z ${BAIKAL_SERVERALIAS+x} ]
12+
then
13+
sed -i "s/# InjectedServerAlias .*/ServerAlias $BAIKAL_SERVERALIAS/g" $APACHE_CONFIG
14+
fi
15+
16+
apache2-foreground

0 commit comments

Comments
 (0)