Skip to content

Commit e86e95d

Browse files
[tests-only] test: setup for running wopi API tests locally (#2139)
* test: setup for running wopi API tests locally Signed-off-by: Saw-jan <saw.jan.grg3e@gmail.com> * docs: add docs to run wopi API tests Signed-off-by: Saw-jan <saw.jan.grg3e@gmail.com> * chore: remove unnecessary target Signed-off-by: Saw-jan <saw.jan.grg3e@gmail.com> * test: export compose file env Signed-off-by: Saw-jan <saw.jan.grg3e@gmail.com> * docs(test): use posix examples Signed-off-by: Saw-jan <saw.jan.grg3e@gmail.com> * adapt for macos --------- Signed-off-by: Saw-jan <saw.jan.grg3e@gmail.com> Co-authored-by: Viktor Scharf <v.scharf@opencloud.eu>
1 parent 7b367c7 commit e86e95d

6 files changed

Lines changed: 180 additions & 35 deletions

File tree

.woodpecker.star

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3293,7 +3293,7 @@ def wopiCollaborationService(name):
32933293
environment["COLLABORATION_APP_ADDR"] = "https://onlyoffice"
32943294
environment["COLLABORATION_APP_ICON"] = "https://onlyoffice/web-apps/apps/documenteditor/main/resources/img/favicon.ico"
32953295
elif name == "fakeoffice":
3296-
environment["COLLABORATION_SERVICE_NAME"] = "collboration-fakeoficce"
3296+
environment["COLLABORATION_SERVICE_NAME"] = "collaboration-fakeoffice"
32973297
environment["COLLABORATION_APP_NAME"] = "FakeOffice"
32983298
environment["COLLABORATION_APP_PRODUCT"] = "Microsoft"
32993299
environment["COLLABORATION_APP_ADDR"] = "http://fakeoffice:8080"

tests/README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Basically we have two sources for feature tests and test suites:
1919

2020
At the moment, both can be applied to OpenCloud.
2121

22-
As a storage backend, we support the OpenCloud native storage, also called `decomposed`. This stores files directly on disk. Along with that we also provide `decomposeds3`, `posix` storage drivers.
22+
As a storage backend, we support the OpenCloud native storage, also called `decomposed`. This stores files directly on disk. Along with that we also provide `decomposeds3`, `posix` storage drivers.
2323

2424
You can invoke two types of test suite runs:
2525

@@ -154,6 +154,23 @@ make -C tests/acceptance/docker test-core-feature-decomposed-storage
154154
Note:
155155
The test suites transferred from core have `coreApi` prefixed
156156

157+
### Running Collaboration API Tests Locally
158+
159+
Running collaboration API tests requires extra services. You can enable the required services by providing the environment variable `ENABLE_WOPI=true` while running the tests.
160+
161+
```bash
162+
ENABLE_WOPI=true \
163+
BEHAT_FEATURE='tests/acceptance/features/apiCollaboration/checkFileInfo.feature' \
164+
make -C tests/acceptance/docker test-opencloud-feature-posix-storage
165+
```
166+
167+
If the tests fail due to the servers not being ready, you can re-run the tests using the following command:
168+
169+
```bash
170+
BEHAT_FEATURE='tests/acceptance/features/apiCollaboration/checkFileInfo.feature' \
171+
make -C tests/acceptance/docker run-test
172+
```
173+
157174
### OpenCloud Image to Be Tested (Skip Local Image Build)
158175

159176
By default, the tests will be run against the docker image built from your current working state of the OpenCloud repository. For some purposes it might also be handy to use an OpenCloud image from Docker Hub. Therefore, you can provide the optional flag `OC_IMAGE_TAG=...` which must contain an available docker tag of the [opencloud-eu/opencloud registry on Docker Hub](https://hub.docker.com/r/opencloud-eu/opencloud) (e.g. 'latest').
@@ -573,17 +590,17 @@ The sample `fontsMap.json` file is located in `tests/config/drone/fontsMap.json`
573590
### Build dev docker
574591

575592
```bash
576-
make -C opencloud dev-docker
593+
make -C opencloud dev-docker
577594
```
578595

579596
### Choose STORAGE_DRIVER
580-
By default, the system uses `posix` storage. However, you can override this by setting the `STORAGE_DRIVER` environment variable.
581597

598+
By default, the system uses `posix` storage. However, you can override this by setting the `STORAGE_DRIVER` environment variable.
582599

583-
### Run a script that starts the openCloud server in the docker and runs the API tests locally (for debugging purposes)
600+
### Run a script that starts the openCloud server in the docker and runs the API tests locally (for debugging purposes)
584601

585602
```bash
586-
STORAGE_DRIVER=posix ./tests/acceptance/run_api_tests.sh
603+
STORAGE_DRIVER=posix ./tests/acceptance/run_api_tests.sh
587604
```
588605

589606
## Running WOPI Validator Tests
@@ -611,6 +628,7 @@ TEST_GROUP=BaseWopiViewing docker compose -f tests/acceptance/docker/src/wopi-va
611628
```
612629

613630
### for macOS use arm image
631+
614632
```bash
615633
WOPI_VALIDATOR_IMAGE=scharfvi/wopi-validator \
616634
TEST_GROUP=BaseWopiViewing \

tests/acceptance/docker/Makefile

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.ONESHELL:
12
SHELL := bash
23

34
# define standard colors
@@ -24,7 +25,7 @@ endif
2425

2526
## user input
2627
BEHAT_FEATURE ?=
27-
28+
TEST_SOURCE ?= opencloud
2829

2930
ifdef OC_IMAGE_TAG
3031
BUILD_DEV_IMAGE := 0
@@ -224,28 +225,31 @@ $(targets):
224225

225226
.PHONY: testSuite
226227
testSuite: $(OC_WRAPPER) build-dev-image clean-docker-container
227-
@if [ -n "${START_CEPH}" ]; then \
228-
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
229-
COMPOSE_FILE=src/ceph.yml \
230-
docker compose run start_ceph; \
228+
@COMPOSE_FILE_VAR="$(COMPOSE_FILE)"; \
229+
\
230+
if [ "${STORAGE_DRIVER}" = "decomposeds3" ]; then \
231+
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
232+
docker compose -f src/ceph.yml run start_ceph; \
233+
fi; \
234+
if [ "${START_EMAIL}" = "true" ]; then \
235+
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
236+
docker compose -f src/email.yml run start_email; \
237+
fi; \
238+
if [ "${START_ANTIVIRUS}" = "true" ]; then \
239+
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
240+
docker compose -f src/antivirus.yml run start_antivirus; \
241+
fi; \
242+
if [ "${START_TIKA}" = "true" ]; then \
243+
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
244+
docker compose -f src/tika.yml run tika-service; \
231245
fi; \
232-
if [ "${START_EMAIL}" == "true" ]; then \
233-
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
234-
COMPOSE_FILE=src/email.yml \
235-
docker compose run start_email; \
246+
if [ "${ENABLE_WOPI}" = "true" ]; then \
247+
COMPOSE_FILE_VAR="$${COMPOSE_FILE_VAR}:src/wopi.yml"; \
236248
fi; \
237-
if [ "${START_ANTIVIRUS}" == "true" ]; then \
238-
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
239-
COMPOSE_FILE=src/antivirus.yml \
240-
docker compose run start_antivirus; \
241-
fi; \
242-
if [ "${START_TIKA}" == "true" ]; then \
243-
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
244-
COMPOSE_FILE=src/tika.yml \
245-
docker compose run tika-service; \
246-
fi; \
249+
\
250+
247251
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
248-
COMPOSE_FILE=$(COMPOSE_FILE) \
252+
COMPOSE_FILE=$${COMPOSE_FILE_VAR} \
249253
STORAGE_DRIVER=$(STORAGE_DRIVER) \
250254
TEST_SOURCE=$(TEST_SOURCE) \
251255
WITH_WRAPPER=$(WITH_WRAPPER) \
@@ -263,13 +267,11 @@ testSuite: $(OC_WRAPPER) build-dev-image clean-docker-container
263267
.PHONY: show-test-logs
264268
show-test-logs: ## show logs of test
265269
@COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
266-
COMPOSE_FILE=$(COMPOSE_FILE) \
267270
docker compose logs --no-log-prefix -f acceptance-tests | less
268271

269272
.PHONY: ps
270273
ps: ## show docker status
271274
@COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
272-
COMPOSE_FILE=$(COMPOSE_FILE) \
273275
docker compose ps
274276

275277
$(OC_WRAPPER):
@@ -285,7 +287,7 @@ build-dev-image:
285287

286288
.PHONY: clean-dev-docker-image
287289
clean-dev-docker-image: ## clean docker image built during acceptance tests
288-
@docker image rm opencloud-eu/opencloud:dev || true
290+
@docker image rm opencloudeu/opencloud:dev || true
289291

290292
.PHONY: clean-docker-container
291293
clean-docker-container: ## clean docker containers created during acceptance tests
@@ -328,6 +330,17 @@ start-server: $(OC_WRAPPER) ## build and start server
328330
TEST_SOURCE=opencloud \
329331
STORAGE_DRIVER=$(STORAGE_DRIVER) \
330332
OC_ASYNC_UPLOADS=true \
331-
SEARCH_EXTRACTOR_TYPE=tika \
333+
SEARCH_EXTRACTOR_TYPE=$(SEARCH_EXTRACTOR_TYPE) \
332334
OC_ADD_RUN_SERVICES=notifications \
333335
docker compose up -d --build --force-recreate
336+
337+
.PHONY: run-test
338+
run-test:
339+
COMPOSE_PROJECT_NAME=$(COMPOSE_PROJECT_NAME) \
340+
STORAGE_DRIVER=$(STORAGE_DRIVER) \
341+
TEST_SOURCE=$(TEST_SOURCE) \
342+
BEHAT_SUITE=$(BEHAT_SUITE) \
343+
BEHAT_FEATURE=$(BEHAT_FEATURE) \
344+
DIVIDE_INTO_NUM_PARTS=$(DIVIDE_INTO_NUM_PARTS) \
345+
RUN_PART=$(RUN_PART) \
346+
docker compose -f src/acceptance.yml up
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
mkdir -p /var/www/onlyoffice/Data/certs
6+
cd /var/www/onlyoffice/Data/certs
7+
openssl req -x509 -newkey rsa:4096 -keyout onlyoffice.key -out onlyoffice.crt -sha256 -days 365 -batch -nodes
8+
chmod 400 /var/www/onlyoffice/Data/certs/onlyoffice.key
9+
10+
/app/ds/run-document-server.sh

tests/acceptance/docker/src/opencloud-base.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
services:
22
opencloud-server:
33
image: opencloudeu/opencloud:dev
4-
entrypoint: [ "/bin/sh", "/usr/bin/serve-opencloud.sh" ]
4+
entrypoint: ["/bin/sh", "/usr/bin/serve-opencloud.sh"]
55
user: root
66
environment:
77
WITH_WRAPPER: $WITH_WRAPPER
@@ -22,7 +22,6 @@ services:
2222
OC_ASYNC_UPLOADS: $OC_ASYNC_UPLOADS
2323
OC_ADD_RUN_SERVICES: $OC_ADD_RUN_SERVICES
2424
PROXY_HTTP_ADDR: "0.0.0.0:9200"
25-
OC_JWT_SECRET: "some-random-jwt-secret"
2625

2726
# decomposeds3 specific settings
2827
STORAGE_USERS_DECOMPOSEDS3_ENDPOINT: http://ceph:8080
@@ -52,9 +51,9 @@ services:
5251
# fonts map for txt thumbnails (including unicode support)
5352
THUMBNAILS_TXT_FONTMAP_FILE: "/woodpecker/src/github.com/opencloud-eu/opencloud/tests/config/drone/fontsMap.json"
5453
ports:
55-
- '9200:9200'
56-
- '5200:5200' ## ocwrapper
57-
- '9174:9174' ## notifications debug
54+
- "9200:9200"
55+
- "5200:5200" ## ocwrapper
56+
- "9174:9174" ## notifications debug
5857
volumes:
5958
- ../../../config:/woodpecker/src/github.com/opencloud-eu/opencloud/tests/config
6059
- ../../../ocwrapper/bin/ocwrapper:/usr/bin/ocwrapper
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
x-common_config: &common_config
2+
image: opencloudeu/opencloud:dev
3+
restart: unless-stopped
4+
entrypoint: /bin/sh
5+
command: ["-c", "opencloud collaboration server"]
6+
user: root
7+
8+
x-common_env: &common_env
9+
OC_CONFIG_DIR: /etc/opencloud
10+
MICRO_REGISTRY: nats-js-kv
11+
MICRO_REGISTRY_ADDRESS: opencloud-server:9233
12+
COLLABORATION_LOG_LEVEL: info
13+
COLLABORATION_GRPC_ADDR: 0.0.0.0:9301
14+
COLLABORATION_HTTP_ADDR: 0.0.0.0:9300
15+
COLLABORATION_DEBUG_ADDR: 0.0.0.0:9304
16+
COLLABORATION_APP_PROOF_DISABLE: true
17+
COLLABORATION_APP_INSECURE: true
18+
COLLABORATION_CS3API_DATAGATEWAY_INSECURE: true
19+
COLLABORATION_WOPI_SECRET: some-wopi-secret
20+
21+
x-config_volume: &config_volume
22+
- config:/etc/opencloud
23+
24+
x-depends_on: &depends_on
25+
- opencloud-server
26+
27+
services:
28+
opencloud-server:
29+
environment:
30+
OC_CONFIG_DIR: /etc/opencloud
31+
GATEWAY_GRPC_ADDR: 0.0.0.0:9142
32+
NATS_NATS_HOST: 0.0.0.0
33+
NATS_NATS_PORT: 9233
34+
volumes: *config_volume
35+
36+
fakeoffice:
37+
image: alpine:latest
38+
entrypoint: /bin/sh
39+
command:
40+
[
41+
"-c",
42+
"while true; do echo -e \"HTTP/1.1 200 OK\n\n$(cat /fakeoffice-discovery.xml)\" | nc -l -k -p 8080; done",
43+
]
44+
healthcheck:
45+
test: ["CMD", "curl", "-f", "http://fakeoffice:8080"]
46+
volumes:
47+
- ./../../../config/woodpecker/hosting-discovery.xml:/fakeoffice-discovery.xml
48+
49+
collabora:
50+
image: collabora/code:24.04.5.1.1
51+
environment:
52+
DONT_GEN_SSL_CERT: set
53+
extra_params: --o:ssl.enable=true --o:ssl.termination=true --o:welcome.enable=false --o:net.frame_ancestors=https://opencloud-server:9200
54+
entrypoint: /bin/sh
55+
command: ["-c", "coolconfig generate-proof-key; /start-collabora-online.sh"]
56+
57+
onlyoffice:
58+
image: onlyoffice/documentserver:7.5.1
59+
environment:
60+
WOPI_ENABLED: true
61+
USE_UNAUTHORIZED_STORAGE: true
62+
entrypoint: bash /entrypoint.sh
63+
volumes:
64+
- ./onlyoffice-entrypoint.sh:/entrypoint.sh
65+
66+
collaboration-fakeoffice:
67+
<<: *common_config
68+
environment:
69+
<<: *common_env
70+
COLLABORATION_SERVICE_NAME: collaboration-fakeoffice
71+
COLLABORATION_APP_NAME: FakeOffice
72+
COLLABORATION_APP_PRODUCT: Microsoft
73+
COLLABORATION_APP_ADDR: http://fakeoffice:8080
74+
COLLABORATION_WOPI_SRC: http://collaboration-fakeoffice:9300
75+
volumes: *config_volume
76+
depends_on: *depends_on
77+
78+
collaboration-collabora:
79+
<<: *common_config
80+
environment:
81+
<<: *common_env
82+
COLLABORATION_SERVICE_NAME: collaboration-collabora
83+
COLLABORATION_APP_NAME: Collabora
84+
COLLABORATION_APP_PRODUCT: Collabora
85+
COLLABORATION_APP_ADDR: https://collabora:9980
86+
COLLABORATION_APP_ICON: https://collabora:9980/favicon.ico
87+
COLLABORATION_WOPI_SRC: http://collaboration-collabora:9300
88+
volumes: *config_volume
89+
depends_on: *depends_on
90+
91+
collaboration-onlyoffice:
92+
<<: *common_config
93+
environment:
94+
<<: *common_env
95+
COLLABORATION_SERVICE_NAME: collaboration-onlyoffice
96+
COLLABORATION_APP_NAME: OnlyOffice
97+
COLLABORATION_APP_PRODUCT: OnlyOffice
98+
COLLABORATION_APP_ADDR: https://onlyoffice
99+
COLLABORATION_APP_ICON: https://onlyoffice/web-apps/apps/documenteditor/main/resources/img/favicon.ico
100+
COLLABORATION_WOPI_SRC: http://collaboration-onlyoffice:9300
101+
volumes: *config_volume
102+
depends_on: *depends_on
103+
104+
volumes:
105+
config:

0 commit comments

Comments
 (0)