Compare commits

...
Author SHA1 Message Date
Michal Klos 16aa00bc94 feat: [OCISDEV-741] litmus 2026-03-31 01:56:16 +02:00
Michal Klos 3b03263179 feat: [OCISDEV-741] litmus 2026-03-31 01:42:05 +02:00
Michal Klos f5014671bb feat: [OCISDEV-741] litmus 2026-03-31 01:26:54 +02:00
Michal Klos a2e9964daf feat: [OCISDEV-741] litmus 2026-03-31 01:06:06 +02:00
Michal Klos 158f82f025 feat: [OCISDEV-741] litmus 2026-03-31 00:48:38 +02:00
Michal Klos 6bb1d58164 feat: [OCISDEV-741] litmus 2026-03-31 00:38:18 +02:00
Michal Klos 72b54e8b26 feat: [OCISDEV-741] litmus 2026-03-31 00:27:35 +02:00
Michal Klos a4885db6c6 feat: [OCISDEV-741] litmus 2026-03-31 00:12:14 +02:00
Michal Klos 1f956e636f feat: [OCISDEV-741] litmus 2026-03-31 00:07:44 +02:00
Michal Klos 60f2aa3066 feat: [OCISDEV-741] litmus 2026-03-31 00:04:16 +02:00
Michal Klos c84763e178 feat: [OCISDEV-741] litmus 2026-03-30 23:29:46 +02:00
Michal Klos 51cfa4ac05 feat: [OCISDEV-741] litmus 2026-03-30 21:59:46 +02:00
Michal Klos 40672c3720 feat: [OCISDEV-741] litmus 2026-03-30 21:39:25 +02:00
Michal Klos a3b590e73b feat: [OCISDEV-741] litmus 2026-03-30 20:56:49 +02:00
Michal Klos cdfaee0f3b feat: [OCISDEV-741] litmus 2026-03-30 20:26:34 +02:00
Michal Klos 62b63d39c3 feat: [OCISDEV-741] litmus 2026-03-30 18:51:20 +02:00
Michal Klos 8b835d5788 feat: [OCISDEV-741] litmus 2026-03-30 18:26:37 +02:00
Michal Klos 6637c37f89 feat: [OCISDEV-741] litmus 2026-03-30 18:26:37 +02:00
3 changed files with 575 additions and 245 deletions

No files matched your search

+213 -245
View File
@@ -5,259 +5,227 @@ on:
workflow_dispatch:
jobs:
coding-standard:
name: coding-standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: "8.4"
extensions: curl, xml, mbstring, zip
tools: composer
- name: PHP code style
run: |
make vendor-bin-codestyle
make vendor-bin-codesniffer
make test-php-style
- name: Check env var annotations
run: make check-env-var-annotations
# coding-standard:
# name: coding-standard
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# - uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
# with:
# php-version: "8.4"
# extensions: curl, xml, mbstring, zip
# tools: composer
# - name: PHP code style
# run: |
# make vendor-bin-codestyle
# make vendor-bin-codesniffer
# make test-php-style
# - name: Check env var annotations
# run: make check-env-var-annotations
#
# check-gherkin-standard:
# name: check-gherkin-standard
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
# with:
# node-version: "24"
# - name: Lint feature files
# run: |
# npm install -g @gherlint/gherlint@1.1.0
# make test-gherkin-lint
#
# check-suites-in-expected-failures:
# name: check-suites-in-expected-failures
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# - name: Check suites
# run: bash tests/acceptance/check-deleted-suites-in-expected-failure.sh
#
# build-and-test:
# name: build-and-test
# needs: [coding-standard, check-gherkin-standard, check-suites-in-expected-failures]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# - uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
# with:
# go-version-file: go.mod
# cache: true
#
# - name: Build ocis
# run: make -C ocis build
#
# - name: Unit tests
# run: make test
#
# local-api-tests:
# name: ${{ matrix.suite }}
# needs: [build-and-test]
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# suite:
# # contract & locks
# - apiContract
# - apiLocks
# # settings & notifications (needs email)
# - apiSettings
# - apiNotification
# - apiCors
# # graph
# - apiGraphUser
# - apiGraph
# - apiGraphGroup
# # spaces & dav
# - apiSpaces
# - apiSpacesShares
# - apiSpacesDavOperation
# - apiDownloads
# - apiAsyncUpload
# - apiDepthInfinity
# - apiArchiver
# - apiActivities
# # search
# - apiSearch1
# # - apiSearch2
# - apiSearchContent # needs Tika
# # sharing
# - apiSharingNgShares
# - apiReshare
# - apiSharingNgPermissions
# - apiSharingNgAdditionalShareRole
# - apiSharingNgDriveInvitation
# - apiSharingNgItemInvitation
# - apiSharingNgDriveLinkShare
# - apiSharingNgItemLinkShare
# - apiSharingNgLinkShareManagement
# # auth
# - apiAuthApp
# # antivirus (needs ClamAV)
# - apiAntivirus
# # federation (needs email + federation ocis)
# # - apiOcm
# # collaboration (needs WOPI)
# # - apiCollaboration
# steps:
# - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
#
# - uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
# with:
# go-version-file: go.mod
# cache: true
#
# - name: Install libcurl 8.12.0 from source
# run: |
# sudo apt-get update -qq
# sudo apt-get install -y libssl-dev libnghttp2-dev libpsl-dev libldap-dev libssh-dev zlib1g-dev libvips-dev
# cd /tmp
# curl -sLO https://curl.se/download/curl-8.12.0.tar.gz
# tar xzf curl-8.12.0.tar.gz
# cd curl-8.12.0
# ./configure --with-ssl --with-zlib --with-nghttp2 --prefix=/usr/local --enable-versioned-symbols --silent
# make -j$(nproc) --silent
# sudo make install --silent
# sudo ldconfig
# curl --version | head -1
# php -r '
# $v = curl_version()["version"];
# echo "PHP curl: $v\n";
# if (version_compare($v, "8.12.0", "<")) {
# fwrite(STDERR, "FATAL: PHP sees libcurl $v, need >= 8.12.0\n");
# exit(1);
# }
# '
#
# - uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
# with:
# php-version: "8.4"
# extensions: curl, xml, mbstring, zip
# tools: composer
#
# - name: Run ${{ matrix.suite }}
# run: BEHAT_SUITES=${{ matrix.suite }} python3 tests/acceptance/run-github.py
#
# core-api-tests:
# name: ${{ matrix.suite }}
# needs: [build-and-test]
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# suite:
# - "coreApiShareManagementBasicToShares,coreApiShareManagementToShares"
# - "coreApiSharees,coreApiSharePublicLink2"
# - "coreApiShareOperationsToShares1,coreApiShareOperationsToShares2,coreApiSharePublicLink1,coreApiShareCreateSpecialToShares1,coreApiShareCreateSpecialToShares2,coreApiShareUpdateToShares"
# - "coreApiTrashbin,coreApiTrashbinRestore,coreApiWebdavEtagPropagation1,coreApiWebdavEtagPropagation2"
# steps:
# - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
# - uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
# with:
# go-version-file: go.mod
# cache: true
#
# - name: Install libcurl 8.12.0 from source
# run: |
# sudo apt-get update -qq
# sudo apt-get install -y libssl-dev libnghttp2-dev libpsl-dev libldap-dev libssh-dev zlib1g-dev libvips-dev
# cd /tmp
# curl -sLO https://curl.se/download/curl-8.12.0.tar.gz
# tar xzf curl-8.12.0.tar.gz
# cd curl-8.12.0
# ./configure --with-ssl --with-zlib --with-nghttp2 --prefix=/usr/local --enable-versioned-symbols --silent
# make -j$(nproc) --silent
# sudo make install --silent
# sudo ldconfig
# curl --version | head -1
# php -r '
# $v = curl_version()["version"];
# echo "PHP curl: $v\n";
# if (version_compare($v, "8.12.0", "<")) {
# fwrite(STDERR, "FATAL: PHP sees libcurl $v, need >= 8.12.0\n");
# exit(1);
# }
# '
#
# - uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
# with:
# php-version: "8.4"
# extensions: curl, xml, mbstring, zip
# tools: composer
#
# - name: Run ${{ matrix.suite }}
# run: >
# BEHAT_SUITES="${{ matrix.suite }}"
# ACCEPTANCE_TEST_TYPE=core-api
# EXPECTED_FAILURES_FILE=tests/acceptance/expected-failures-API-on-OCIS-storage.md
# python3 tests/acceptance/run-github.py
#
# - name: Upload test logs
# if: failure()
# uses: actions/upload-artifact@v4
# with:
# name: test-logs-${{ matrix.suite }}
# path: tests/acceptance/output/
check-gherkin-standard:
name: check-gherkin-standard
litmus:
name: litmus
needs: []
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "24"
- name: Lint feature files
run: |
npm install -g @gherlint/gherlint@1.1.0
make test-gherkin-lint
check-suites-in-expected-failures:
name: check-suites-in-expected-failures
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check suites
run: bash tests/acceptance/check-deleted-suites-in-expected-failure.sh
build-and-test:
name: build-and-test
needs: [coding-standard, check-gherkin-standard, check-suites-in-expected-failures]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Build ocis
run: make -C ocis build
- name: Unit tests
run: make test
local-api-tests:
name: ${{ matrix.suite }}
needs: [build-and-test]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
suite:
# contract & locks
- apiContract
- apiLocks
# settings & notifications (needs email)
- apiSettings
- apiNotification
- apiCors
# graph
- apiGraphUser
- apiGraph
- apiGraphGroup
# spaces & dav
- apiSpaces
- apiSpacesShares
- apiSpacesDavOperation
- apiDownloads
- apiAsyncUpload
- apiDepthInfinity
- apiArchiver
- apiActivities
# search
- apiSearch1
# - apiSearch2
- apiSearchContent # needs Tika
# sharing
- apiSharingNgShares
- apiReshare
- apiSharingNgPermissions
- apiSharingNgAdditionalShareRole
- apiSharingNgDriveInvitation
- apiSharingNgItemInvitation
- apiSharingNgDriveLinkShare
- apiSharingNgItemLinkShare
- apiSharingNgLinkShareManagement
# auth
- apiAuthApp
# antivirus (needs ClamAV)
- apiAntivirus
# federation (needs email + federation ocis)
# - apiOcm
# collaboration (needs WOPI)
# - apiCollaboration
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
cache: true
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "24"
- name: Enable pnpm
run: corepack enable && corepack prepare pnpm@10.28.1 --activate
- name: Install libcurl 8.12.0 from source
run: |
sudo apt-get update -qq
sudo apt-get install -y libssl-dev libnghttp2-dev libpsl-dev libldap-dev libssh-dev zlib1g-dev libvips-dev
cd /tmp
curl -sLO https://curl.se/download/curl-8.12.0.tar.gz
tar xzf curl-8.12.0.tar.gz
cd curl-8.12.0
./configure --with-ssl --with-zlib --with-nghttp2 --prefix=/usr/local --enable-versioned-symbols --silent
make -j$(nproc) --silent
sudo make install --silent
sudo ldconfig
curl --version | head -1
php -r '
$v = curl_version()["version"];
echo "PHP curl: $v\n";
if (version_compare($v, "8.12.0", "<")) {
fwrite(STDERR, "FATAL: PHP sees libcurl $v, need >= 8.12.0\n");
exit(1);
}
'
- uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: "8.4"
extensions: curl, xml, mbstring, zip
tools: composer
- name: Run ${{ matrix.suite }}
run: BEHAT_SUITES=${{ matrix.suite }} python3 tests/acceptance/run-github.py
cli-tests:
needs: [build-and-test]
name: ${{ matrix.suite }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
suite:
- cliCommands,apiServiceAvailability # grouped like drone; needs ClamAV + email
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
cache: true
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "24"
- name: Enable pnpm
run: corepack enable && corepack prepare pnpm@10.28.1 --activate
- uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: "8.4"
extensions: curl, xml, mbstring, zip
tools: composer
- name: Run ${{ matrix.suite }}
run: BEHAT_SUITES="${{ matrix.suite }}" python3 tests/acceptance/run-github.py
core-api-tests:
name: ${{ matrix.suite }}
needs: [build-and-test]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
suite:
- "coreApiShareManagementBasicToShares,coreApiShareManagementToShares"
- "coreApiSharees,coreApiSharePublicLink2"
- "coreApiShareOperationsToShares1,coreApiShareOperationsToShares2,coreApiSharePublicLink1,coreApiShareCreateSpecialToShares1,coreApiShareCreateSpecialToShares2,coreApiShareUpdateToShares"
- "coreApiTrashbin,coreApiTrashbinRestore,coreApiWebdavEtagPropagation1,coreApiWebdavEtagPropagation2"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
cache: true
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "24"
- name: Enable pnpm
run: corepack enable && corepack prepare pnpm@10.28.1 --activate
- name: Install libcurl 8.12.0 from source
run: |
sudo apt-get update -qq
sudo apt-get install -y libssl-dev libnghttp2-dev libpsl-dev libldap-dev libssh-dev zlib1g-dev libvips-dev
cd /tmp
curl -sLO https://curl.se/download/curl-8.12.0.tar.gz
tar xzf curl-8.12.0.tar.gz
cd curl-8.12.0
./configure --with-ssl --with-zlib --with-nghttp2 --prefix=/usr/local --enable-versioned-symbols --silent
make -j$(nproc) --silent
sudo make install --silent
sudo ldconfig
curl --version | head -1
php -r '
$v = curl_version()["version"];
echo "PHP curl: $v\n";
if (version_compare($v, "8.12.0", "<")) {
fwrite(STDERR, "FATAL: PHP sees libcurl $v, need >= 8.12.0\n");
exit(1);
}
'
- uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: "8.4"
extensions: curl, xml, mbstring, zip
tools: composer
- name: Run ${{ matrix.suite }}
run: >
BEHAT_SUITES="${{ matrix.suite }}"
ACCEPTANCE_TEST_TYPE=core-api
EXPECTED_FAILURES_FILE=tests/acceptance/expected-failures-API-on-OCIS-storage.md
python3 tests/acceptance/run-github.py
- name: Upload test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-logs-${{ matrix.suite }}
path: tests/acceptance/output/
- name: Run litmus
run: python3 tests/acceptance/run-litmus.py
all-acceptance-tests:
needs: [local-api-tests, cli-tests, core-api-tests]
needs: [litmus]
runs-on: ubuntu-latest
if: always()
steps:
+295
View File
@@ -0,0 +1,295 @@
#!/usr/bin/env python3
"""
Run litmus WebDAV compliance tests locally and in GitHub Actions CI.
Config sourced from .drone.star litmus() / setupForLitmus() — single source of truth.
Usage: python3 tests/acceptance/run-litmus.py
"""
import json
import os
import re
import shutil
import signal
import subprocess
import sys
import time
from pathlib import Path
# ---------------------------------------------------------------------------
# Constants (mirroring .drone.star)
# ---------------------------------------------------------------------------
# HTTPS — matching drone: ocis init generates a self-signed cert; proxy uses TLS by default.
# Host-side curl calls use -k (insecure) to skip cert verification.
OCIS_URL = "https://127.0.0.1:9200"
LITMUS_IMAGE = "owncloudci/litmus:latest"
LITMUS_TESTS = "basic copymove props http"
SHARE_ENDPOINT = "ocs/v2.php/apps/files_sharing/api/v1/shares"
def get_docker_bridge_ip() -> str:
"""Return the Docker bridge gateway IP, reachable from host and Docker containers."""
r = subprocess.run(
["docker", "network", "inspect", "bridge",
"--format", "{{range .IPAM.Config}}{{.Gateway}}{{end}}"],
capture_output=True, text=True, check=True,
)
return r.stdout.strip()
def base_server_env(repo_root: Path, ocis_config_dir: str, ocis_public_url: str) -> dict:
"""OCIS server environment matching drone ocisServer() for litmus."""
return {
"OCIS_URL": ocis_public_url,
"OCIS_CONFIG_DIR": ocis_config_dir,
"STORAGE_USERS_DRIVER": "ocis",
"PROXY_ENABLE_BASIC_AUTH": "true",
# No PROXY_TLS override — drone lets ocis use its default TLS (self-signed cert from init)
# IDP excluded: its static assets are absent when running as a host process
"OCIS_EXCLUDE_RUN_SERVICES": "idp",
"OCIS_LOG_LEVEL": "error",
"IDM_CREATE_DEMO_USERS": "true",
"IDM_ADMIN_PASSWORD": "admin",
"FRONTEND_SEARCH_MIN_LENGTH": "2",
"OCIS_ASYNC_UPLOADS": "true",
"OCIS_EVENTS_ENABLE_TLS": "false",
"NATS_NATS_HOST": "0.0.0.0",
"NATS_NATS_PORT": "9233",
"OCIS_JWT_SECRET": "some-ocis-jwt-secret",
"EVENTHISTORY_STORE": "memory",
"WEB_UI_CONFIG_FILE": str(repo_root / "tests/config/drone/ocis-config.json"),
}
def wait_for(condition_fn, timeout: int, label: str) -> None:
deadline = time.time() + timeout
while not condition_fn():
if time.time() > deadline:
print(f"Timeout waiting for {label}", file=sys.stderr)
sys.exit(1)
time.sleep(1)
def ocis_healthy(ocis_url: str) -> bool:
r = subprocess.run(
["curl", "-sk", "-uadmin:admin",
f"{ocis_url}/graph/v1.0/users/admin",
"-w", "%{http_code}", "-o", "/dev/null"],
capture_output=True, text=True,
)
return r.stdout.strip() == "200"
def setup_for_litmus(ocis_url: str) -> tuple:
"""
Translate tests/config/drone/setup-for-litmus.sh to Python.
Returns (space_id, public_token).
"""
# get personal space ID
r = subprocess.run(
["curl", "-sk", "-uadmin:admin", f"{ocis_url}/graph/v1.0/me/drives"],
capture_output=True, text=True, check=True,
)
drives = json.loads(r.stdout)
space_id = ""
for drive in drives.get("value", []):
if drive.get("driveType") == "personal":
web_dav_url = drive.get("root", {}).get("webDavUrl", "")
# last non-empty path segment (same as cut -d"/" -f6 in bash)
space_id = [p for p in web_dav_url.split("/") if p][-1]
break
if not space_id:
print("ERROR: could not determine personal space ID", file=sys.stderr)
sys.exit(1)
print(f"SPACE_ID={space_id}")
# create test folder as einstein
subprocess.run(
["curl", "-sk", "-ueinstein:relativity", "-X", "MKCOL",
f"{ocis_url}/remote.php/webdav/new_folder"],
capture_output=True, check=True,
)
# create share from einstein to admin
r = subprocess.run(
["curl", "-sk", "-ueinstein:relativity",
f"{ocis_url}/{SHARE_ENDPOINT}",
"-d", "path=/new_folder&shareType=0&permissions=15&name=new_folder&shareWith=admin"],
capture_output=True, text=True, check=True,
)
share_id_match = re.search(r"<id>(.+?)</id>", r.stdout)
if share_id_match:
share_id = share_id_match.group(1)
# accept the share as admin
subprocess.run(
["curl", "-X", "POST", "-sk", "-uadmin:admin",
f"{ocis_url}/{SHARE_ENDPOINT}/pending/{share_id}"],
capture_output=True, check=True,
)
# create public share as einstein
r = subprocess.run(
["curl", "-sk", "-ueinstein:relativity",
f"{ocis_url}/{SHARE_ENDPOINT}",
"-d", "path=/new_folder&shareType=3&permissions=15&name=new_folder"],
capture_output=True, text=True, check=True,
)
public_token = ""
token_match = re.search(r"<token>(.+?)</token>", r.stdout)
if token_match:
public_token = token_match.group(1)
print(f"PUBLIC_TOKEN={public_token}")
return space_id, public_token
def run_litmus(name: str, endpoint: str, capture_debug: bool = False) -> int:
print(f"\nTesting endpoint [{name}]: {endpoint}", flush=True)
container_name = f"litmus-{name}" if capture_debug else None
cmd = ["docker", "run"]
if container_name:
cmd += ["--name", container_name]
else:
cmd += ["--rm"]
cmd += [
"-e", f"LITMUS_URL={endpoint}",
"-e", "LITMUS_USERNAME=admin",
"-e", "LITMUS_PASSWORD=admin",
"-e", f"TESTS={LITMUS_TESTS}",
LITMUS_IMAGE,
# No extra CMD — ENTRYPOINT is already litmus-wrapper; passing it again
# would make the wrapper use the path as LITMUS_URL, overriding the env var.
]
result = subprocess.run(cmd)
if capture_debug and container_name:
# try to copy debug.log from the container
for log_path in ["/debug.log", "/tmp/debug.log", "/home/debug.log"]:
r = subprocess.run(
["docker", "cp", f"{container_name}:{log_path}", f"/tmp/litmus-debug-{name}.log"],
capture_output=True,
)
if r.returncode == 0:
try:
with open(f"/tmp/litmus-debug-{name}.log") as f:
content = f.read()
print(f"\n--- litmus debug.log ({log_path}) ---", flush=True)
print(content[:3000], flush=True)
except Exception:
pass
break
subprocess.run(["docker", "rm", "-f", container_name], capture_output=True)
return result.returncode
def main() -> int:
repo_root = Path(__file__).resolve().parents[2]
ocis_bin = repo_root / "ocis/bin/ocis"
ocis_config_dir = Path.home() / ".ocis/config"
# build (matching drone: restores binary from cache, then runs ocis server directly)
subprocess.run(["make", "-C", str(repo_root / "ocis"), "build"], check=True)
# Docker bridge gateway IP: reachable from both the host (via docker0 interface)
# and Docker containers (via bridge network default gateway). Use this as OCIS_URL
# so that any redirects OCIS generates stay on a hostname the litmus container
# can follow — matching how drone uses "ocis-server:9200" consistently.
# HTTPS: owncloudci/litmus accepts insecure (self-signed) certs, just like drone does.
bridge_ip = get_docker_bridge_ip()
litmus_base = f"https://{bridge_ip}:9200"
print(f"Docker bridge IP: {bridge_ip}", flush=True)
# assemble server env first — same env vars drone sets on the container before
# running `ocis init`, so IDM_ADMIN_PASSWORD=admin is present during init and
# the config is written with the correct password (not a random one)
server_env = {**os.environ}
server_env.update(base_server_env(repo_root, str(ocis_config_dir), litmus_base))
# init ocis with full server env (mirrors drone: env is set before ocis init runs)
subprocess.run(
[str(ocis_bin), "init", "--insecure", "true"],
env=server_env,
check=True,
)
# Diagnostic: print generated config (drone does this too)
ocis_yaml = ocis_config_dir / "ocis.yaml"
if ocis_yaml.exists():
print("\n--- ocis.yaml ---", flush=True)
print(ocis_yaml.read_text()[:2000], flush=True)
shutil.copy(
repo_root / "tests/config/drone/app-registry.yaml",
ocis_config_dir / "app-registry.yaml",
)
# start ocis server directly (matching drone: no ociswrapper for litmus)
print("Starting ocis...", flush=True)
ocis_proc = subprocess.Popen(
[str(ocis_bin), "server"],
env=server_env,
)
def cleanup(*_):
try:
ocis_proc.terminate()
except Exception:
pass
signal.signal(signal.SIGTERM, cleanup)
signal.signal(signal.SIGINT, cleanup)
try:
wait_for(lambda: ocis_healthy(OCIS_URL), 300, "ocis")
print("ocis ready.", flush=True)
space_id, _ = setup_for_litmus(OCIS_URL)
# Diagnostic: full HTTP trace for WebDAV OPTIONS and PROPFIND from the host
for label, curl_args in [
("OPTIONS no-auth", ["-X", "OPTIONS"]),
("OPTIONS auth", ["-u", "admin:admin", "-X", "OPTIONS"]),
("PROPFIND auth", ["-u", "admin:admin", "-X", "PROPFIND", "-H", "Depth: 0"]),
]:
r = subprocess.run(
["curl", "-vsk"] + curl_args + [f"{OCIS_URL}/remote.php/webdav"],
capture_output=True, text=True,
)
print(f"\n--- {label} ---", flush=True)
print((r.stdout + r.stderr)[:1500], flush=True)
# Diagnostic: confirm WebDAV endpoint reachable from Docker bridge network (HTTPS, insecure)
webdav_url = f"https://{bridge_ip}:9200/remote.php/webdav"
wget_cmd = f"wget -S --no-check-certificate --spider '{webdav_url}' 2>&1; echo exit:$?"
r = subprocess.run(
["docker", "run", "--rm", "--entrypoint", "sh", LITMUS_IMAGE, "-c", wget_cmd],
capture_output=True, text=True, timeout=30,
)
print(f"\n--- docker-bridge WebDAV (https) rc={r.returncode} ---", flush=True)
print((r.stdout + r.stderr)[:400], flush=True)
endpoints = [
("old-endpoint", f"{litmus_base}/remote.php/webdav"),
("new-endpoint", f"{litmus_base}/remote.php/dav/files/admin"),
("new-shared", f"{litmus_base}/remote.php/dav/files/admin/Shares/new_folder/"),
("old-shared", f"{litmus_base}/remote.php/webdav/Shares/new_folder/"),
("spaces-endpoint", f"{litmus_base}/remote.php/dav/spaces/{space_id}"),
]
failed = []
for i, (name, endpoint) in enumerate(endpoints):
rc = run_litmus(name, endpoint, capture_debug=(i == 0))
if rc != 0:
failed.append(name)
if failed:
print(f"\nFailed endpoints: {', '.join(failed)}", file=sys.stderr)
return 1
print("\nAll litmus tests passed.")
return 0
finally:
cleanup()
if __name__ == "__main__":
sys.exit(main())
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
OCIS_BIN="$REPO_ROOT/ocis/bin/ocis"
WRAPPER_BIN="$REPO_ROOT/tests/ociswrapper/bin/ociswrapper"
OCIS_URL="https://localhost:9200"
OCIS_CONFIG_DIR="$HOME/.ocis/config"
# build
make -C "$REPO_ROOT/ocis" build
GOWORK=off make -C "$REPO_ROOT/tests/ociswrapper" build
# init + start ocis
"$OCIS_BIN" init --insecure true
cp "$REPO_ROOT/tests/config/drone/app-registry.yaml" "$OCIS_CONFIG_DIR/app-registry.yaml"
OCIS_URL=$OCIS_URL \
OCIS_CONFIG_DIR=$OCIS_CONFIG_DIR \
STORAGE_USERS_DRIVER=ocis \
PROXY_ENABLE_BASIC_AUTH=true \
OCIS_EXCLUDE_RUN_SERVICES=idp \
OCIS_LOG_LEVEL=error \
IDM_CREATE_DEMO_USERS=true \
IDM_ADMIN_PASSWORD=admin \
OCIS_ASYNC_UPLOADS=true \
OCIS_EVENTS_ENABLE_TLS=false \
NATS_NATS_HOST=0.0.0.0 \
NATS_NATS_PORT=9233 \
OCIS_JWT_SECRET=some-ocis-jwt-secret \
WEB_UI_CONFIG_FILE="$REPO_ROOT/tests/config/drone/ocis-config.json" \
"$WRAPPER_BIN" serve \
--bin "$OCIS_BIN" \
--url "$OCIS_URL" \
--admin-username admin \
--admin-password admin &
WRAPPER_PID=$!
trap "kill $WRAPPER_PID 2>/dev/null || true" EXIT
echo "Waiting for ocis..."
timeout 300 bash -c \
"while [ \$(curl -sk -uadmin:admin $OCIS_URL/graph/v1.0/users/admin \
-w %{http_code} -o /dev/null) != 200 ]; do sleep 1; done"
echo "ocis ready."
# setup: creates test folder, share, and exports SPACE_ID + PUBLIC_TOKEN to .env
TEST_SERVER_URL=$OCIS_URL bash "$REPO_ROOT/tests/config/drone/setup-for-litmus.sh"
source .env
# run litmus against each WebDAV endpoint
ENDPOINTS=(
"$OCIS_URL/remote.php/webdav"
"$OCIS_URL/remote.php/dav/files/admin"
"$OCIS_URL/remote.php/dav/files/admin/Shares/new_folder/"
"$OCIS_URL/remote.php/webdav/Shares/new_folder/"
"$OCIS_URL/remote.php/dav/spaces/$SPACE_ID"
)
for ENDPOINT in "${ENDPOINTS[@]}"; do
echo "Testing endpoint: $ENDPOINT"
docker run --rm --network host \
-e LITMUS_URL="$ENDPOINT" \
-e LITMUS_USERNAME=admin \
-e LITMUS_PASSWORD=admin \
-e TESTS="basic copymove props http" \
owncloudci/litmus:latest
done