Episode 19: Nextcloud AIO, OpenCloud and Seafile measured with the same test data on the same server

This commit is contained in:
Maximilian Grimm 2026-10-24 20:37:53 +02:00
parent 76a3132a17
commit 145d318452
70 changed files with 3296 additions and 0 deletions

81
filesync/client/api.py Normal file
View file

@ -0,0 +1,81 @@
#!/usr/bin/env python3
"""ep19fs API-Helfer (Clients). Zugang aus /root/ep19fs/env (0600), nie ausgeben.
api.py P cmd [args] P = nc|oc|sf
rmtree PATH Ordner auf dem Server löschen und Papierkorb leeren
count PATH Dateien (rekursiv) und Bytes unter PATH auf dem Server
exists PATH HTTP-Status eines Pfads
"""
import os, sys, json, time, requests, xml.etree.ElementTree as ET
from urllib.parse import quote, unquote
E = {k: v.strip("'") for k, v in (l.strip().split('=', 1) for l in open(os.environ.get('EP19ENV','/root/ep19fs/env')) if '=' in l and not l.startswith('#'))}
P, cmd = sys.argv[1], sys.argv[2]
s = requests.Session()
DAV = 'DAV:'
def nc():
u = E['NC_URL']; s.auth = (E['NC_USER'], E['NC_PASS']); return u, f"{u}/remote.php/dav/files/{E['NC_USER']}"
def oc():
u = E['OC_URL']; s.auth = (E['OC_USER'], E['OC_TOKEN']); return u, f"{u}/remote.php/dav/spaces/{E['OC_SPACE']}"
def sfdav():
u = E['SF_URL']; s.auth = (E['SF_USER'], E['SF_PASS']); return u, f"{u}/seafdav"
def base():
return {'nc': nc, 'oc': oc, 'sf': sfdav}[P]()
def propfind(url, depth='infinity'):
r = s.request('PROPFIND', url, headers={'Depth': depth}, data='<?xml version="1.0"?><d:propfind xmlns:d="DAV:"><d:prop><d:resourcetype/><d:getcontentlength/></d:prop></d:propfind>')
return r
def walk(url):
files = 0; size = 0
r = propfind(url, 'infinity')
if r.status_code == 207 and P != 'sf':
for resp in ET.fromstring(r.content).findall(f'{{{DAV}}}response'):
isdir = resp.find(f'.//{{{DAV}}}collection') is not None
if not isdir:
files += 1; cl = resp.find(f'.//{{{DAV}}}getcontentlength'); size += int(cl.text) if cl is not None and cl.text else 0
return files, size
# Tiefe 1 rekursiv
stack = [url]
while stack:
cur = stack.pop(); r = propfind(cur, '1')
if r.status_code != 207: return None, r.status_code
for i, resp in enumerate(ET.fromstring(r.content).findall(f'{{{DAV}}}response')):
if i == 0: continue
href = resp.find(f'{{{DAV}}}href').text
if resp.find(f'.//{{{DAV}}}collection') is not None:
stack.append(url.split('/remote.php')[0].split('/seafdav')[0] + href if href.startswith('/') else href)
else:
files += 1; cl = resp.find(f'.//{{{DAV}}}getcontentlength'); size += int(cl.text) if cl is not None and cl.text else 0
return files, size
if cmd == 'count':
u, d = base(); print(*walk(d + '/' + quote(sys.argv[3].strip('/'))))
elif cmd == 'exists':
u, d = base(); print(propfind(d + '/' + quote(sys.argv[3].strip('/')), '0').status_code)
elif cmd == 'ls':
u, d = base(); r = propfind(d + '/' + quote(sys.argv[3].strip('/')), '1')
names = [unquote(x.find(f'{{{DAV}}}href').text.rstrip('/').split('/')[-1]) for x in ET.fromstring(r.content).findall(f'{{{DAV}}}response')][1:]
print(r.status_code, sorted(names))
elif cmd == 'restore': # restore NAME ORIGPATH: Element aus dem Papierkorb zurückholen
u, d = base(); name, orig = sys.argv[3], sys.argv[4]
if P == 'nc':
tb = f"{u}/remote.php/dav/trashbin/{E['NC_USER']}/trash"
body = '<?xml version="1.0"?><d:propfind xmlns:d="DAV:" xmlns:nc="http://nextcloud.org/ns"><d:prop><nc:trashbin-filename/><nc:trashbin-original-location/></d:prop></d:propfind>'
else:
tb = f"{u}/remote.php/dav/spaces/trash-bin/{E['OC_SPACE']}"
body = '<?xml version="1.0"?><d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:prop><oc:trashbin-original-filename/><oc:trashbin-original-location/></d:prop></d:propfind>'
t0 = time.time(); r = s.request('PROPFIND', tb, headers={'Depth': '1'}, data=body)
items = []
for x in ET.fromstring(r.content).findall(f'{{{DAV}}}response')[1:]:
loc = [e.text for e in x.iter() if e.tag.endswith('original-location')]
items.append((x.find(f'{{{DAV}}}href').text, loc[0] if loc else ''))
print('Papierkorb:', len(items), 'Einträge', [l for h, l in items])
href = [h for h, l in items if l and l.strip('/') == orig.strip('/')][0]
host = u.split('/remote.php')[0]
dest = f"{u}/remote.php/dav/trashbin/{E['NC_USER']}/restore/{name}" if P == 'nc' else f"{d}/{quote(orig.strip('/'))}"
r = s.request('MOVE', host + href, headers={'Destination': dest})
print(f'MOVE {r.status_code}, Wiederherstellung auf dem Server {time.time()-t0:.2f} s')
elif cmd == 'mkcol':
u, d = base(); r = s.request('MKCOL', d + '/' + quote(sys.argv[3].strip('/'))); print('MKCOL', r.status_code)
elif cmd == 'rmtree':
u, d = base(); r = s.delete(d + '/' + quote(sys.argv[3].strip('/'))); print('DELETE', r.status_code)
if P == 'nc':
r = s.delete(f"{u}/remote.php/dav/trashbin/{E['NC_USER']}/trash"); print('empty trash', r.status_code)
elif P == 'oc':
r = s.delete(f"{u}/remote.php/dav/spaces/trash-bin/{E['OC_SPACE']}"); print('empty trash', r.status_code)

View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Clients A und B (Ubuntu 24.04): offizielle Kommandozeilen-Clients plus rclone.
set -x
date -u
apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq squashfs-tools python3-websockets python3-requests unzip fuse3 libfuse2t64 xvfb >/dev/null
# rclone, offizielles Installationsskript
curl -fsSL https://rclone.org/install.sh | bash >/dev/null 2>&1; rclone version | head -1
# Seafile: offizielles apt-Repo linux-clients.seafile.com war am 24.10.2026 nicht erreichbar (TCP-Timeout zu 3.86.184.216:443,
# vom Server und vom Mac). Ersatz: seafile-cli aus Ubuntu 24.04 universe (Paket der Distribution).
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq seafile-cli >/dev/null; dpkg -l seafile-cli seafile-daemon | grep ^ii
# Nextcloud: offizielles AppImage, nextcloudcmd liegt darin
mkdir -p /opt/nc && cd /opt/nc && wget -q https://github.com/nextcloud-releases/desktop/releases/download/v35.0.0/Nextcloud-35.0.0-x86_64.AppImage && chmod +x Nextcloud-35.0.0-x86_64.AppImage && ./Nextcloud-35.0.0-x86_64.AppImage --appimage-extract >/dev/null && find /opt/nc/squashfs-root -name 'nextcloudcmd*'
# OpenCloud: offizielles AppImage, Suche nach einem Kommandozeilen-Client
mkdir -p /opt/oc && cd /opt/oc && wget -q https://github.com/opencloud-eu/desktop/releases/download/v4.0.0/OpenCloud_Desktop-v4.0.0-linux-gcc-x86_64.AppImage && chmod +x OpenCloud_Desktop-v4.0.0-linux-gcc-x86_64.AppImage && ./OpenCloud_Desktop-v4.0.0-linux-gcc-x86_64.AppImage --appimage-extract >/dev/null && ls /opt/oc/squashfs-root/usr/bin/

86
filesync/client/m.sh Normal file
View file

@ -0,0 +1,86 @@
#!/usr/bin/env bash
# m.sh: Messschritte auf ep19fs-cli. Client A = Linux-Nutzer clienta, Client B = clientb.
# Zugang aus /root/ep19fs/env (0640, Gruppe ep19). Keine Geheimnisse im Output.
set -u
source /root/ep19fs/lib.sh
set -a; source /root/ep19fs/env; set +a
SRV=203.0.113.10; H=$(echo "${NC_URL:-https://x}" | sed 's#https://##')
A() { sudo -u clienta -H "$@"; }
B() { sudo -u clientb -H "$@"; }
acct() { for u in clienta clientb; do iptables -C OUTPUT -d $SRV -m owner --uid-owner $u -j ACCEPT 2>/dev/null || iptables -I OUTPUT -d $SRV -m owner --uid-owner $u -j ACCEPT; done; }
tx() { iptables -L OUTPUT -v -x -n | awk -v id="$(id -u $1)" '$0 ~ ("owner UID match " id "$") {print $2; exit}'; }
api() { python3 /root/ep19fs/api.py "$@"; }
gb() { python3 -c "print(f'{$1/1e6:.1f} MB')"; }
acct
# ---------- Werkzeug-Aufrufe je Produkt ----------
nc_sync() { # nc_sync USER LOCALDIR REMOTEPATH
sudo -u $1 -H nextcloudcmd -n --non-interactive --path "$3" "$2" "$NC_URL" > /tmp/ncc-$1.log 2>&1; echo "nextcloudcmd exit $? ($(grep -ciE 'error|fail' /tmp/ncc-$1.log) Zeilen mit error/fail im Log)"; }
rc_copy() { # rc_copy USER LOCALDIR REMOTE:PATH
sudo -u $1 -H rclone copy "$2" "$3" --stats-one-line --stats 0 > /tmp/rc-$1.log 2>&1; echo "rclone exit $?"; tail -2 /tmp/rc-$1.log | sed 's/^/ /'; }
oc_sync() { # oc_sync USER LOCALDIR REMOTEFOLDER
sudo -u $1 -H OPENCLOUD_TOKEN="$OC_TOKEN" opencloudcmd --non-interactive -u "$OC_USER" --remote-folder "/$3" "$OC_URL" "$OC_SPACE" "$2" > /tmp/occ-$1.log 2>&1; echo "opencloudcmd exit $? ($(grep -ciE 'error|fail' /tmp/occ-$1.log) Zeilen mit error/fail im Log)"; }
osync() { # osync USER DIR REMOTE : offizieller Client je Produkt
case $P in nc) nc_sync $1 $2 /$3;; oc) oc_sync $1 $2 $3;; esac; }
ls_state() { echo " A: $(cd $1 && find . -type f | sort | head -20 | tr '\n' ' ')"; echo " B: $(cd $2 && find . -type f | sort | head -20 | tr '\n' ' ')"; }
case $1 in
setup-creds) # .netrc und rclone.conf je Nutzer (einmalig), ohne Ausgabe der Werte
for u in clienta clientb; do h=$(eval echo ~$u)
[ -n "${NC_PASS:-}" ] && { printf 'machine %s login %s password %s\n' "$H" "$NC_USER" "$NC_PASS" > $h/.netrc; chmod 600 $h/.netrc; chown $u $h/.netrc; }
mkdir -p $h/.config/rclone; : > $h/.config/rclone/rclone.conf
[ -n "${NC_PASS:-}" ] && printf '[nc]\ntype = webdav\nurl = %s/remote.php/dav/files/%s\nvendor = nextcloud\nuser = %s\npass = %s\n\n' "$NC_URL" "$NC_USER" "$NC_USER" "$(rclone obscure "$NC_PASS")" >> $h/.config/rclone/rclone.conf
[ -n "${OC_TOKEN:-}" ] && printf '[oc]\ntype = webdav\nurl = %s/remote.php/dav/spaces/%s\nvendor = infinitescale\nuser = %s\npass = %s\n\n' "$OC_URL" "$OC_SPACE" "$OC_USER" "$(rclone obscure "$OC_TOKEN")" >> $h/.config/rclone/rclone.conf
[ -n "${SF_PASS:-}" ] && printf '[sf]\ntype = webdav\nurl = %s/seafdav\nvendor = other\nuser = %s\npass = %s\n\n' "$SF_URL" "$SF_USER" "$(rclone obscure "$SF_PASS")" >> $h/.config/rclone/rclone.conf
chown -R $u $h/.config; chmod 600 $h/.config/rclone/rclone.conf; done; echo "creds ok";;
prep) # prep P MODE: lokale Kopie, Ziel auf dem Server leeren (nicht gemessen)
P=$2; MODE=$3; d=/home/clienta/up/$P-$MODE; rm -rf $d; mkdir -p $d; cp -r /data/testset/small /data/testset/big $d/; chown -R clienta $d
case $P in nc|oc) api $P rmtree up-$MODE; api $P mkcol up-$MODE;; esac
echo "prep $P $MODE: $(find $d -type f | wc -l) Dateien lokal";;
up) # up P MODE: Hochladen messen
P=$2; MODE=$3; d=/home/clienta/up/$P-$MODE; b0=$(tx clienta); t0=$(now); echo "start $(ts) UTC"
case $P-$MODE in
nc-official) nc_sync clienta $d /up-official;;
nc-rclone) rc_copy clienta $d nc:up-rclone;;
oc-official) oc_sync clienta $d up-official;;
oc-rclone) rc_copy clienta $d oc:up-rclone;;
esac
t1=$(now); b1=$(tx clienta); echo "ende $(ts) UTC, Dauer $(el $t0 $t1) s, gesendet $(gb $((b1-b0)))"
echo "Server: $(api $P count up-$MODE) (Dateien Bytes)";;
delta) # delta P: 2-GiB-Datei synchron, dann 1 MiB in der Mitte ändern, erneut synchronisieren, Bytes messen
P=$2; d=/home/clienta/d/$P; rm -rf $d; mkdir -p $d; cp /data/testset/big/big.bin $d/; chown -R clienta /home/clienta/d
api $P rmtree delta; api $P mkcol delta
echo "Erstabgleich (nicht bewertet):"; b0=$(tx clienta); t0=$(now); osync clienta $d delta; echo " $(el $t0 $(now)) s, gesendet $(gb $(( $(tx clienta)-b0 )))"
echo "Änderung: dd 1 MiB Zufall an Offset 1024 MiB (conv=notrunc), Dateigröße bleibt 2 GiB"
sudo -u clienta dd if=/dev/urandom of=$d/big.bin bs=1M count=1 seek=1024 conv=notrunc status=none; sha256sum $d/big.bin | cut -c1-16
b0=$(tx clienta); t0=$(now); osync clienta $d delta; t1=$(now); echo "Sync nach Änderung: $(el $t0 $t1) s, gesendet $(gb $(( $(tx clienta)-b0 )))"
echo "rclone zum Vergleich (gleiche Änderung, rclone copy auf denselben Ordner):"
sudo -u clienta dd if=/dev/urandom of=$d/big.bin bs=1M count=1 seek=512 conv=notrunc status=none
b0=$(tx clienta); t0=$(now); rc_copy clienta $d $P:delta; echo " rclone: $(el $t0 $(now)) s, gesendet $(gb $(( $(tx clienta)-b0 )))";;
conflict) # conflict P: dieselbe Datei auf A und B offline geändert
P=$2; da=/home/clienta/c/$P; db=/home/clientb/c/$P; rm -rf $da $db; sudo -u clienta mkdir -p $da; sudo -u clientb mkdir -p $db
api $P rmtree conflict; api $P mkcol conflict
echo "Angebot Version 1" | sudo -u clienta tee $da/angebot.txt >/dev/null; osync clienta $da conflict; osync clientb $db conflict
echo "Ausgangslage nach Erstabgleich:"; ls_state $da $db
echo "Offline: A schreibt 'Version A', B schreibt 'Version B' (kein Sync dazwischen)"
echo "Angebot Version A (Preis 900)" | sudo -u clienta tee $da/angebot.txt >/dev/null; sleep 2
echo "Angebot Version B (Preis 1200)" | sudo -u clientb tee $db/angebot.txt >/dev/null
echo "A synchronisiert zuerst:"; osync clienta $da conflict
echo "B synchronisiert danach:"; osync clientb $db conflict
echo "A synchronisiert noch einmal:"; osync clienta $da conflict
echo "Ergebnis:"; ls_state $da $db
for f in $da/* ; do echo " A $(basename "$f"): $(cat "$f")"; done; for f in $db/* ; do echo " B $(basename "$f"): $(cat "$f")"; done
echo " Server: $(api $P ls conflict)";;
delete) # delete P: Ordner mit 5000 Dateien auf A gelöscht, propagiert das, wie kommt er zurück
P=$2; da=/home/clienta/x/$P; db=/home/clientb/x/$P
if [ "${3:-}" != again ]; then rm -rf $da $db; sudo -u clienta mkdir -p $da; sudo -u clientb mkdir -p $db
api $P rmtree del; api $P mkcol del; cp -r /data/testset/small $da/projekt; chown -R clienta $da; fi
echo "Abgleich A und B:"; t0=$(now); osync clienta $da del; osync clientb $db del; echo " $(el $t0 $(now)) s"
echo " A: $(find $da -type f | wc -l) Dateien, B: $(find $db -type f | wc -l) Dateien, Server: $(api $P count del)"
echo "$(ts) A löscht den Ordner projekt (rm -rf) und synchronisiert"; rm -rf $da/projekt; t0=$(now); osync clienta $da del; echo " A-Sync $(el $t0 $(now)) s"
echo " Server nach A-Sync: $(api $P count del)"
t0=$(now); osync clientb $db del; echo "$(ts) B synchronisiert ($(el $t0 $(now)) s): B hat noch $(find $db -type f | wc -l) Dateien"
echo "$(ts) Wiederherstellen aus dem Papierkorb des Servers (WebDAV MOVE, wie der Knopf in der Weboberfläche):"
t0=$(now); api $P restore projekt del/projekt; echo " Server: $(api $P count del)"
osync clientb $db del; osync clienta $da del; t1=$(now)
echo "$(ts) nach je einem Sync: A $(find $da -type f | wc -l), B $(find $db -type f | wc -l) Dateien; vom Restore-Start bis beide Clients vollständig $(el $t0 $t1) s";;
*) echo "unbekannt: $1";;
esac

59
filesync/client/prop.py Normal file
View file

@ -0,0 +1,59 @@
#!/usr/bin/env python3
"""Änderung auf Client A, wie lange bis sie bei Client B liegt.
prop.py nc|oc N : N Läufe. A schreibt eine kleine Datei und startet sofort seinen Sync (wie ein
Desktop-Client nach der lokalen Änderungserkennung). B synchronisiert, sobald der Server ihn
benachrichtigt (nc: notify_push-Websocket, wie der Desktop-Client) bzw. im Dauerlauf (oc: kein
Push-Kanal für den Kommandozeilen-Client, B startet opencloudcmd direkt wieder, sobald der
vorige Lauf endet). Gemessen: Wanduhr von "Datei auf A geschrieben" bis "Datei auf B vorhanden"."""
import os, sys, time, subprocess, threading, json, asyncio, statistics
P, N = sys.argv[1], int(sys.argv[2])
E = {k: v.strip("'") for k, v in (l.strip().split('=', 1) for l in open('/root/ep19fs/env') if '=' in l and not l.startswith('#'))}
DA, DB = f'/home/clienta/p/{P}', f'/home/clientb/p/{P}'
H = E.get('NC_URL', E.get('OC_URL', '')).replace('https://', '')
def sync(user, d):
if P == 'nc':
cmd = ['nextcloudcmd', '-n', '--non-interactive', '--path', '/prop', d, E['NC_URL']]
else:
cmd = ['opencloudcmd', '--non-interactive', '-u', E['OC_USER'], '--remote-folder', '/prop', E['OC_URL'], E['OC_SPACE'], d]
env = dict(os.environ); env['OPENCLOUD_TOKEN'] = E.get('OC_TOKEN', '')
t = time.time(); r = subprocess.run(['sudo', '-u', user, '-H', '--preserve-env=OPENCLOUD_TOKEN'] + cmd, capture_output=True, env=env)
return time.time() - t, r.returncode
for d, u in ((DA, 'clienta'), (DB, 'clientb')):
subprocess.run(['sudo', '-u', u, 'mkdir', '-p', d])
print(f'# {time.strftime("%H:%M:%S", time.gmtime())} UTC Erstabgleich A und B', flush=True)
print(' A', sync('clienta', DA), ' B', sync('clientb', DB), flush=True)
trigger = threading.Event(); stop = False; bsyncs = []
def b_loop():
while not stop:
if P == 'nc':
if not trigger.wait(1): continue
trigger.clear()
dur, rc = sync('clientb', DB); bsyncs.append(dur)
threading.Thread(target=b_loop, daemon=True).start()
events = []
if P == 'nc':
import websockets
async def listen():
async with websockets.connect(f'wss://{H}/push/ws') as ws:
await ws.send(E['NC_USER']); await ws.send(E['NC_PASS'])
while True:
m = await ws.recv(); events.append((time.time(), m[:40]))
if m.startswith('notify_file'): trigger.set()
threading.Thread(target=lambda: asyncio.run(listen()), daemon=True).start(); time.sleep(3)
print(' notify_push:', events[:1], flush=True)
res = []
for i in range(1, N + 1):
name = f'note-{int(time.time())}-{i}.txt'
t0 = time.time()
subprocess.run(['sudo', '-u', 'clienta', 'sh', '-c', f'echo run {i} > {DA}/{name}'])
da, rc = sync('clienta', DA); ta = time.time()
while not os.path.exists(f'{DB}/{name}'):
if time.time() - t0 > 300: break
time.sleep(0.05)
tb = time.time(); ev = [round(t - ta, 2) for t, m in events if t >= ta and m.startswith('notify_file')][:1]
res.append(tb - t0)
print(f' Lauf {i}: A-Sync {da:.2f} s (rc {rc}), Datei bei B nach {tb - t0:.2f} s' + (f', Push an B {ev[0]} s nach A-Sync-Ende' if ev else ''), flush=True)
time.sleep(5)
stop = True
print(f'Mittel {statistics.mean(res):.2f} s, Median {statistics.median(res):.2f} s, min {min(res):.2f}, max {max(res):.2f} (n={len(res)})')
if bsyncs: print(f'B-Syncläufe: {len(bsyncs)}, Dauer Mittel {statistics.mean(bsyncs):.2f} s')

82
filesync/client/sec.py Normal file
View file

@ -0,0 +1,82 @@
#!/usr/bin/env python3
"""Was geht standardmäßig: Freigabelink ohne Passwort und Ablauf, 10 falsche Anmeldungen.
sec.py P share|brute (P = nc|oc|sf). Anmeldungen über das Web-Anmeldeformular des Produkts."""
import os, sys, re, time, json, requests
E = {k: v.strip("'") for k, v in (l.strip().split('=', 1) for l in open('/root/ep19fs/env') if '=' in l and not l.startswith('#'))}
P, what = sys.argv[1], sys.argv[2]
T = lambda: time.strftime('%H:%M:%S', time.gmtime())
def nc_login(pw):
s = requests.Session(); u = E['NC_URL']
s.get(u + '/login'); tok = s.get(u + '/csrftoken').json()['token']
t = time.time()
r = s.post(u + '/login', data={'user': E['NC_USER'], 'password': pw, 'requesttoken': tok}, headers={'requesttoken': tok, 'Origin': u}, allow_redirects=False)
ok = r.status_code == 303 and '/login' not in r.headers.get('Location', '/login')
return r.status_code, time.time() - t, ok, r.headers.get('Location', '')[-40:]
def sf_login(pw):
s = requests.Session(); u = E['SF_URL']
r = s.get(u + '/accounts/login/'); tok = s.cookies.get('sfcsrftoken') or s.cookies.get('csrftoken')
t = time.time()
r = s.post(u + '/accounts/login/', data={'csrfmiddlewaretoken': tok, 'login': E['SF_USER'], 'password': pw, 'next': '/'}, headers={'Referer': u + '/accounts/login/'}, allow_redirects=False)
ok = r.status_code == 302
captcha = 'captcha' in r.text.lower()
return r.status_code, time.time() - t, ok, ('captcha verlangt' if captcha else '') + re.sub(r'\s+', ' ', ' '.join(re.findall(r'class="error[^"]*"[^>]*>([^<]{0,120})', r.text)))[:120]
def oc_login(pw):
u = E['OC_URL']; s = requests.Session()
body = {'params': [E['OC_USER'], pw, '1'], 'hello': {'scope': 'openid profile email', 'client_id': 'web', 'redirect_uri': u + '/oidc-callback.html', 'flow': 'oidc'}}
t = time.time()
r = s.post(u + '/signin/v1/identifier/_/logon', json=body, headers={'Kopano-Konnect-XSRF': '1', 'Referer': u + '/signin/v1/identifier', 'Origin': u})
ok = r.status_code == 200 and '"success":true' in r.text.replace(' ', '')
return r.status_code, time.time() - t, ok, r.text[:80].replace('\n', ' ')
login = {'nc': nc_login, 'sf': sf_login, 'oc': oc_login}[P]
if what == 'brute':
real = {'nc': 'NC_PASS', 'sf': 'SF_PASS', 'oc': 'OC_PASS'}[P]
print(f'# {T()} UTC: 10 falsche Passwörter für den Admin über das Anmeldeformular, danach das richtige')
for i in range(1, 11):
c, dt, ok, info = login(f'falsch-{i}-xyz')
print(f' {T()} Versuch {i:2d} falsch : HTTP {c}, Antwort nach {dt:6.2f} s, angemeldet={ok} {info}')
c, dt, ok, info = login(E[real])
print(f' {T()} Versuch 11 richtig: HTTP {c}, Antwort nach {dt:6.2f} s, angemeldet={ok} {info}')
if what == 'share' and P == 'nc':
u = E['NC_URL']; a = (E['NC_USER'], E['NC_PASS']); dav = f"{u}/remote.php/dav/files/{E['NC_USER']}"
requests.request('MKCOL', dav + '/freigabe', auth=a); requests.put(dav + '/freigabe/vertrag.txt', data=b'Vertrag Entwurf\n', auth=a)
print(f'# {T()} UTC: öffentlicher Link auf /freigabe, ohne Passwort und ohne Ablaufdatum angefordert (OCS-API, wie der Knopf in der Oberfläche)')
r = requests.post(u + '/ocs/v2.php/apps/files_sharing/api/v1/shares', auth=a, headers={'OCS-APIRequest': 'true', 'Accept': 'application/json'}, data={'path': '/freigabe', 'shareType': 3})
d = r.json()['ocs']; print(' HTTP', r.status_code, 'OCS', d['meta']['statuscode'], d['meta']['message'])
if d['data']:
x = d['data']; print(' expiration =', x.get('expiration'), '| password gesetzt =', bool(x.get('password')), '| permissions =', x.get('permissions'))
link = x['url']; r2 = requests.get(link); print(' anonymer Abruf des Links:', r2.status_code, '| Datei sichtbar:', 'vertrag.txt' in r2.text)
r = requests.get(u + '/ocs/v2.php/cloud/capabilities', auth=a, headers={'OCS-APIRequest': 'true', 'Accept': 'application/json'})
pub = r.json()['ocs']['data']['capabilities']['files_sharing']['public']
print(' capabilities public:', json.dumps({k: pub.get(k) for k in ('enabled', 'password', 'expire_date', 'upload')}))
if what == 'wrongonly': # wrongonly N: nur falsche Versuche, kein richtiger am Ende
n = int(sys.argv[3])
for i in range(1, n + 1):
c, dt, ok, info = login(f'falsch-{i}-xyz')
print(f' {T()} Versuch {i:2d} falsch : HTTP {c}, Antwort nach {dt:6.2f} s {info}', flush=True)
if what == 'share' and P == 'oc':
u = E['OC_URL']; a = (E['OC_USER'], E['OC_TOKEN']); sp = E['OC_SPACE']; dav = f"{u}/remote.php/dav/spaces/{sp}"
requests.request('MKCOL', dav + '/freigabe', auth=a); requests.put(dav + '/freigabe/vertrag.txt', data=b'Vertrag Entwurf\n', auth=a)
r = requests.request('PROPFIND', dav + '/freigabe', auth=a, headers={'Depth': '0'}, data='<?xml version="1.0"?><d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns"><d:prop><oc:fileid/></d:prop></d:propfind>')
fid = re.search(r'<oc:fileid>([^<]+)</oc:fileid>', r.text).group(1)
print(f'# {T()} UTC: öffentlicher Link auf /freigabe, ohne Passwort und ohne Ablaufdatum angefordert (Graph-API createLink, wie der Knopf in der Oberfläche)')
r = requests.post(f"{u}/graph/v1beta1/drives/{sp}/items/{fid}/createLink", auth=a, json={'type': 'view'})
print(' type=view ohne Passwort: HTTP', r.status_code, r.text[:160].replace('\n', ' '))
r = requests.post(f"{u}/graph/v1beta1/drives/{sp}/items/{fid}/createLink", auth=a, json={'type': 'edit'})
print(' type=edit ohne Passwort: HTTP', r.status_code, r.text[:160].replace('\n', ' '))
r = requests.post(f"{u}/graph/v1beta1/drives/{sp}/items/{fid}/createLink", auth=a, json={'type': 'view', 'password': 'Lab-Passwort-19!x'})
j = r.json() if r.ok else {}
print(' type=view mit Passwort: HTTP', r.status_code, '| expirationDateTime =', j.get('expirationDateTime'), '| hasPassword =', j.get('hasPassword'))
r = requests.get(u + '/ocs/v1.php/cloud/capabilities?format=json', auth=a)
pub = r.json()['ocs']['data']['capabilities']['files_sharing']['public']
print(' capabilities public:', json.dumps({k: pub.get(k) for k in ('enabled', 'password', 'expire_date')}))
if what == 'share' and P == 'sf':
u = E['SF_URL']; h = {'Authorization': 'Token ' + E['SF_TOKEN'], 'Accept': 'application/json'}; rid = E['SF_REPO']
requests.post(f"{u}/api2/repos/{rid}/dir/?p=/freigabe", headers=h, data={'operation': 'mkdir'})
up = requests.get(f"{u}/api2/repos/{rid}/upload-link/?p=/freigabe", headers=h).json()
requests.post(up, headers=h, files={'file': ('vertrag.txt', b'Vertrag Entwurf\n')}, data={'parent_dir': '/freigabe'})
print(f'# {T()} UTC: öffentlicher Link auf /freigabe, ohne Passwort und ohne Ablaufdatum angefordert (API v2.1 share-links, wie der Knopf in der Oberfläche)')
r = requests.post(f"{u}/api/v2.1/share-links/", headers=h, json={'repo_id': rid, 'path': '/freigabe/'})
j = r.json(); print(' HTTP', r.status_code, '| is_expired =', j.get('is_expired'), '| expire_date =', j.get('expire_date'), '| password gesetzt =', bool(j.get('password')), '| permissions =', j.get('permissions'))
link = j.get('link')
if link:
r2 = requests.get(link); print(' anonymer Abruf des Links:', r2.status_code, '| Datei sichtbar:', 'vertrag.txt' in r2.text)

110
filesync/client/sf.sh Normal file
View file

@ -0,0 +1,110 @@
#!/usr/bin/env bash
# sf.sh: Seafile-Messschritte mit dem offiziellen Kommandozeilen-Client seaf-cli (Daemon je Nutzer).
# Client A = clienta, Client B = clientb. Zugang aus /root/ep19fs/env. Keine Geheimnisse im Output.
set -u
source /root/ep19fs/lib.sh
eval "$(python3 -c "
for l in open('/root/ep19fs/env'):
if '=' in l: k,v=l.strip().split('=',1); print(f'{k}={v}')
")"
SRV=203.0.113.10
H="Authorization: Token $SF_TOKEN"
tx() { iptables -L OUTPUT -v -x -n | awk -v id="$(id -u $1)" '$0 ~ ("owner UID match " id "$") {print $2; exit}'; }
gb() { python3 -c "print(f'{$1/1e6:.1f} MB')"; }
for u in clienta clientb; do iptables -C OUTPUT -d $SRV -m owner --uid-owner $u -j ACCEPT 2>/dev/null || iptables -I OUTPUT -d $SRV -m owner --uid-owner $u -j ACCEPT; done
sc() { local u=$1; shift; sudo -u $u -H seaf-cli "$@"; }
daemon() { # daemon USER start|stop
local h=$(eval echo ~$1)
if [ "$2" = start ]; then [ -d $h/.ccnet ] || sc $1 init -d $h/seafile-client >/dev/null 2>&1; sc $1 start >/dev/null 2>&1; sleep 2
else sc $1 stop >/dev/null 2>&1; sleep 1; fi; }
mkrepo() { curl -s -H "$H" -d "name=$1" "$SF_URL/api2/repos/" | python3 -c "import json,sys;print(json.load(sys.stdin)['repo_id'])"; }
delrepo() { curl -s -o /dev/null -w "%{http_code}" -X DELETE -H "$H" "$SF_URL/api2/repos/$1/"; }
repoinfo() { curl -s -H "$H" "$SF_URL/api2/repos/$1/" | python3 -c "import json,sys;d=json.load(sys.stdin);print(d.get('file_count','?'),'Dateien,',d.get('size'),'Bytes')"; }
status() { sc $1 status 2>/dev/null | awk -F'\t' -v n="$2" '{gsub(/ +$/,"",$1); gsub(/ +$/,"",$2)} $1==n {print $2" "$3}'; }
waitsync() { # waitsync USER NAME MAXSEC: bis "synchronized"
local t0=$(date +%s) s=""; while :; do s=$(status $1 $2); case "$s" in synchronized*) return 0;; esac
[ $(( $(date +%s)-t0 )) -ge ${3:-1800} ] && { echo " TIMEOUT Status: $s"; return 1; }; sleep 0.5; done; }
waitchange() { # waitchange USER NAME MAXSEC: bis der Status nicht mehr "synchronized" ist
local t0=$(date +%s); while :; do case "$(status $1 $2)" in synchronized*) ;; *) return 0;; esac; [ $(( $(date +%s)-t0 )) -ge ${3:-60} ] && return 1; sleep 0.2; done; }
case $1 in
up) # up K: Testsatz in eine neue Bibliothek hochladen, Zeit bis "synchronized"
K=$2; name=up-official-$K; d=/home/clienta/sfup/$name; rm -rf $d; mkdir -p $d; cp -r /data/testset/small /data/testset/big $d/; chown -R clienta /home/clienta/sfup
daemon clienta start; rid=$(mkrepo $name); b0=$(tx clienta); t0=$(now); echo "start $(ts) UTC, Bibliothek $name"
sc clienta sync -l $rid -s "$SF_URL" -d $d -u "$SF_USER" -p "$SF_PASS" >/dev/null 2>&1
waitsync clienta $name 3600; t1=$(now); b1=$(tx clienta)
echo "ende $(ts) UTC, Dauer $(el $t0 $t1) s, gesendet $(gb $((b1-b0)))"; echo "Server: $(repoinfo $rid)"
sc clienta desync -d $d >/dev/null 2>&1; echo "Bibliothek gelöscht: HTTP $(delrepo $rid)";;
uprc) # uprc K: Testsatz per rclone (WebDAV/SeafDAV) in eine neue Bibliothek
K=$2; name=up-rclone-$K; d=/home/clienta/up/sf-rclone; rm -rf $d; mkdir -p $d; cp -r /data/testset/small /data/testset/big $d/; chown -R clienta /home/clienta/up
rid=$(mkrepo $name); b0=$(tx clienta); t0=$(now); echo "start $(ts) UTC, Bibliothek $name"
sudo -u clienta -H rclone copy $d sf:$name --stats-one-line --stats 0 > /tmp/rc-sf.log 2>&1; echo "rclone exit $?"; tail -2 /tmp/rc-sf.log | sed 's/^/ /'
t1=$(now); b1=$(tx clienta); echo "ende $(ts) UTC, Dauer $(el $t0 $t1) s, gesendet $(gb $((b1-b0)))"; echo "Server: $(repoinfo $rid)"
echo "Bibliothek gelöscht: HTTP $(delrepo $rid)";;
pair) # pair NAME: Bibliothek anlegen, auf A und B synchronisieren (leer)
name=$2; rid=$(mkrepo $name); echo "$rid" > /root/ep19fs/sf-$name.rid
for u in clienta clientb; do daemon $u start; d=/home/$u/sf/$name; [ -d $d ] && sc $u desync -d $d >/dev/null 2>&1; rm -rf $d; sudo -u $u mkdir -p $d; sc $u sync -l $rid -s "$SF_URL" -d $d -u "$SF_USER" -p "$SF_PASS" >/dev/null 2>&1; done
waitsync clienta $name 120; waitsync clientb $name 120; echo "Bibliothek $name auf A und B synchronisiert";;
prop) # prop N: Datei auf A schreiben, Zeit bis sie bei B liegt (beide Daemons laufen)
N=$2; bash $0 pair prop >/dev/null; sum=0
for i in $(seq 1 $N); do f=note-$(date +%s)-$i.txt; t0=$(now); echo "run $i" | sudo -u clienta tee /home/clienta/sf/prop/$f >/dev/null
while [ ! -e /home/clientb/sf/prop/$f ]; do sleep 0.05; [ $(python3 -c "print(int($(now)-$t0))") -ge 300 ] && break; done; t1=$(now)
echo " Lauf $i: Datei bei B nach $(el $t0 $t1) s"; sleep 3; done;;
delta) # delta: 2-GiB-Datei synchron, 1 MiB in der Mitte ändern, Bytes messen
name=delta; rid=$(mkrepo $name); d=/home/clienta/sf/$name; rm -rf $d; mkdir -p $d; cp /data/testset/big/big.bin $d/; chown -R clienta /home/clienta/sf
daemon clienta start; b0=$(tx clienta); t0=$(now); sc clienta sync -l $rid -s "$SF_URL" -d $d -u "$SF_USER" -p "$SF_PASS" >/dev/null 2>&1; waitsync clienta $name 1800
echo "Erstabgleich (nicht bewertet): $(el $t0 $(now)) s, gesendet $(gb $(( $(tx clienta)-b0 )))"; sleep 5
echo "Änderung: dd 1 MiB Zufall an Offset 1024 MiB (conv=notrunc), Dateigröße bleibt 2 GiB"
b0=$(tx clienta); t0=$(now); sudo -u clienta dd if=/dev/urandom of=$d/big.bin bs=1M count=1 seek=1024 conv=notrunc status=none
waitchange clienta $name 120 || echo " (kein Statuswechsel gesehen)"; waitsync clienta $name 1800; t1=$(now); sleep 2; echo "Sync nach Änderung: $(el $t0 $t1) s (inkl. Erkennung), gesendet $(gb $(( $(tx clienta)-b0 )))"
echo "Server: $(repoinfo $rid)";;
conflict) # conflict: dieselbe Datei auf A und B offline geändert
bash $0 pair conf >/dev/null; da=/home/clienta/sf/conf; db=/home/clientb/sf/conf
echo "Angebot Version 1" | sudo -u clienta tee $da/angebot.txt >/dev/null; waitchange clienta conf 30; waitsync clienta conf 120
for i in $(seq 1 120); do [ -e $db/angebot.txt ] && break; sleep 1; done
echo "Ausgangslage: A: $(ls $da | tr '\n' ' ')| B: $(ls $db | tr '\n' ' ')"
echo "$(ts) beide Daemons gestoppt (offline)"; daemon clienta stop; daemon clientb stop
echo "Angebot Version A (Preis 900)" | sudo -u clienta tee $da/angebot.txt >/dev/null; sleep 2
echo "Angebot Version B (Preis 1200)" | sudo -u clientb tee $db/angebot.txt >/dev/null
echo "$(ts) A wieder online"; daemon clienta start; sleep 5; waitsync clienta conf 120; sleep 5
echo "$(ts) B wieder online"; daemon clientb start; sleep 5; waitsync clientb conf 120; sleep 40; waitsync clienta conf 120
echo "Ergebnis $(ts):"; for x in $da/* ; do echo " A $(basename "$x"): $(cat "$x")"; done; for x in $db/* ; do echo " B $(basename "$x"): $(cat "$x")"; done
echo " Server: $(curl -s -H "$H" "$SF_URL/api2/repos/$(cat /root/ep19fs/sf-conf.rid)/dir/?p=/" | python3 -c "import json,sys;print(sorted(x['name'] for x in json.load(sys.stdin)))")";;
delete) # delete: Ordner mit 5000 Dateien auf A gelöscht
bash $0 pair del >/dev/null; rid=$(cat /root/ep19fs/sf-del.rid); da=/home/clienta/sf/del; db=/home/clientb/sf/del
cp -r /data/testset/small $da/projekt; chown -R clienta $da; t0=$(now); waitchange clienta del 60; waitsync clienta del 1800
for i in $(seq 1 1800); do [ "$(find $db -type f | wc -l)" -ge 5000 ] && break; sleep 1; done
echo "Abgleich A und B: $(el $t0 $(now)) s; A $(find $da -type f | wc -l), B $(find $db -type f | wc -l) Dateien; Server $(repoinfo $rid)"
echo "$(ts) A löscht den Ordner projekt (rm -rf)"; t0=$(now); rm -rf $da/projekt
waitchange clienta del 60; waitsync clienta del 300; echo " A synchronisiert nach $(el $t0 $(now)) s, Status A: $(status clienta del)"
for i in $(seq 1 120); do [ ! -d $db/projekt ] && break; sleep 1; done
echo "$(ts) B: $(find $db -type f | wc -l) Dateien (nach $(el $t0 $(now)) s), Status B: $(status clientb del); Server $(repoinfo $rid)"
echo "$(ts) Papierkorb der Bibliothek:"; curl -s -H "$H" "$SF_URL/api/v2.1/repos/$rid/trash/" | python3 -c "
import json,sys;d=json.load(sys.stdin);print(' ',[(x['obj_name'],x['parent_dir'],x['is_dir'],x['commit_id'][:8]) for x in d.get('data',[])][:5])"
t0=$(now); cid=$(curl -s -H "$H" "$SF_URL/api/v2.1/repos/$rid/trash/" | python3 -c "import json,sys;d=json.load(sys.stdin);print([x['commit_id'] for x in d['data'] if x['obj_name']=='projekt'][0])")
echo " Wiederherstellen (wie der Knopf in der Weboberfläche): HTTP $(curl -s -o /tmp/sfrev -w '%{http_code}' -X POST -H "$H" -d "commit_id=$cid" -d "path=/projekt" "$SF_URL/api/v2.1/repos/$rid/trash/revert-dirents/") $(head -c 80 /tmp/sfrev), Server $(el $t0 $(now)) s"
for i in $(seq 1 1800); do [ "$(find $db -type f 2>/dev/null | wc -l)" -ge 5000 ] && [ "$(find $da -type f 2>/dev/null | wc -l)" -ge 5000 ] && break; sleep 1; done
echo "$(ts) A $(find $da -type f | wc -l), B $(find $db -type f | wc -l) Dateien; vom Restore-Start bis beide Clients vollständig $(el $t0 $(now)) s";;
uilib) # uilib: Bibliothek "ui" mit dem Ordner small (5000 Dateien) für Oberfläche und Freigabe
name=ui; rid=$(mkrepo $name); d=/home/clienta/sf/$name; rm -rf $d; mkdir -p $d; cp -r /data/testset/small $d/; chown -R clienta /home/clienta/sf
sc clienta sync -l $rid -s "$SF_URL" -d $d -u "$SF_USER" -p "$SF_PASS" >/dev/null 2>&1; sleep 3; waitsync clienta $name 600; echo "$rid";;
restore) # restore: nur der Wiederherstellungsteil (Papierkorb -> Server -> A und B)
rid=$(cat /root/ep19fs/sf-del.rid); da=/home/clienta/sf/del; db=/home/clientb/sf/del
t0=$(now); cid=$(curl -s -H "$H" "$SF_URL/api/v2.1/repos/$rid/trash/" | python3 -c "import json,sys;d=json.load(sys.stdin);print([x['commit_id'] for x in d['data'] if x['obj_name']=='projekt'][0])")
echo "$(ts) Wiederherstellen (wie der Knopf im Papierkorb der Weboberfläche): HTTP $(curl -s -o /tmp/sfrev -w '%{http_code}' -X POST -H "$H" -d "commit_id=$cid" -d "path=/projekt" "$SF_URL/api/v2.1/repos/$rid/trash/revert-dirents/") $(head -c 80 /tmp/sfrev), Server nach $(el $t0 $(now)) s: $(repoinfo $rid)"
for i in $(seq 1 1800); do [ "$(find $db -type f 2>/dev/null | wc -l)" -ge 5000 ] && [ "$(find $da -type f 2>/dev/null | wc -l)" -ge 5000 ] && break; sleep 1; done
echo "$(ts) A $(find $da -type f | wc -l), B $(find $db -type f | wc -l) Dateien; vom Restore-Start bis beide Clients vollständig $(el $t0 $(now)) s";;
delete2) # delete2: Löschung freigeben (Schwelle hoch), dann aus dem Papierkorb wiederherstellen
rid=$(cat /root/ep19fs/sf-del.rid); da=/home/clienta/sf/del; db=/home/clientb/sf/del
echo "$(ts) seaf-cli config -k delete_confirm_threshold -v 100000 (entspricht dem Bestätigen der Löschung), Daemon A neu gestartet"
sc clienta config -k delete_confirm_threshold -v 100000 >/dev/null; daemon clienta stop; t0=$(now); daemon clienta start
for i in $(seq 1 600); do [ "$(curl -s -H "$H" "$SF_URL/api2/repos/$rid/" | python3 -c "import json,sys;print(json.load(sys.stdin).get('file_count'))")" = 0 ] && break; sleep 1; done
echo " Server leer nach $(el $t0 $(now)) s: $(repoinfo $rid)"
for i in $(seq 1 300); do [ ! -d $db/projekt ] && break; sleep 1; done; echo "$(ts) B: $(find $db -type f | wc -l) Dateien (nach $(el $t0 $(now)) s)"
echo "$(ts) Papierkorb der Bibliothek:"; curl -s -H "$H" "$SF_URL/api/v2.1/repos/$rid/trash/" | python3 -c "
import json,sys;d=json.load(sys.stdin);print(' ',[(x['obj_name'],x['parent_dir'],x['is_dir']) for x in d.get('data',[])][:5])"
t0=$(now); cid=$(curl -s -H "$H" "$SF_URL/api/v2.1/repos/$rid/trash/" | python3 -c "import json,sys;d=json.load(sys.stdin);print([x['commit_id'] for x in d['data'] if x['obj_name']=='projekt'][0])")
echo " Wiederherstellen (wie der Knopf im Papierkorb der Weboberfläche): HTTP $(curl -s -o /tmp/sfrev -w '%{http_code}' -X POST -H "$H" -d "commit_id=$cid" -d "path=/projekt" "$SF_URL/api/v2.1/repos/$rid/trash/revert-dirents/") $(head -c 80 /tmp/sfrev), Server $(el $t0 $(now)) s, $(repoinfo $rid)"
for i in $(seq 1 1800); do [ "$(find $db -type f 2>/dev/null | wc -l)" -ge 5000 ] && [ "$(find $da -type f 2>/dev/null | wc -l)" -ge 5000 ] && break; sleep 1; done
echo "$(ts) A $(find $da -type f | wc -l), B $(find $db -type f | wc -l) Dateien; vom Restore-Start bis beide Clients vollständig $(el $t0 $(now)) s";;
*) echo "unbekannt $1";;
esac

View file

@ -0,0 +1,29 @@
// ui-time.mjs P N : Ladezeit der Dateiliste mit 5000 Dateien im Browser (Chromium headless auf ep19fs-cli).
// Gemessen ab page.goto(Ordner-URL) bis die erste Dateizeile sichtbar ist und bis der Ordnerinhalt
// "fertig" ist (Netzwerk ruhig). Je Lauf neuer Browser-Kontext mit frischer Anmeldung (kalter Cache).
import { chromium } from 'playwright';
import { readFileSync } from 'fs';
const E = Object.fromEntries(readFileSync('/root/ep19fs/env', 'utf8').split('\n').filter(l => l.includes('=')).map(l => [l.slice(0, l.indexOf('=')), l.slice(l.indexOf('=') + 1).replace(/^'|'$/g, '')]));
const [P, N] = [process.argv[2], +process.argv[3] || 3];
const cfg = {
nc: { login: async p => { await p.goto(E.NC_URL + '/login'); await p.fill('#user', E.NC_USER); await p.fill('#password', E.NC_PASS); await p.click('button[type=submit]'); await p.waitForURL(/apps/, { timeout: 60000 }); await p.waitForTimeout(1500); await p.keyboard.press('Escape'); },
url: () => E.NC_URL + '/apps/files/files?dir=/up-official/small', row: '[data-cy-files-list-row-name]' },
oc: { login: async p => { await p.goto(E.OC_URL + '/'); await p.waitForSelector('#oc-login-username', { timeout: 60000 }); await p.fill('#oc-login-username', E.OC_USER); await p.fill('#oc-login-password', E.OC_PASS); await p.click('button[type=submit]'); await p.waitForURL(/files/, { timeout: 60000 }); },
url: () => E.OC_URL + '/files/spaces/personal/admin/up-official/small', row: '[data-item-id]:not(.oc-breadcrumb-list-item)' },
sf: { login: async p => { await p.goto(E.SF_URL + '/accounts/login/'); await p.fill('input[name=login]', E.SF_USER); await p.fill('input[name=password]', E.SF_PASS); await p.click('button[type=submit], input[type=submit]'); await p.waitForTimeout(3000); },
url: () => E.SF_URL + E.SF_SMALL_PATH, row: 'tr[draggable="true"]' },
}[P];
const b = await chromium.launch();
const res = [];
for (let i = 1; i <= N; i++) {
const ctx = await b.newContext({ viewport: { width: 1600, height: 900 }, ignoreHTTPSErrors: false }); const p = await ctx.newPage();
await cfg.login(p);
const t0 = Date.now(); await p.goto(cfg.url(), { waitUntil: 'commit' });
await p.waitForSelector(cfg.row, { timeout: 120000 }); const tFirst = (Date.now() - t0) / 1000;
await p.waitForLoadState('networkidle', { timeout: 120000 }).catch(() => {}); const tIdle = (Date.now() - t0) / 1000;
const rows = await p.locator(cfg.row).count();
console.log(` Lauf ${i}: erste Dateizeile nach ${tFirst.toFixed(2)} s, Netzwerk ruhig nach ${tIdle.toFixed(2)} s, Zeilen im DOM: ${rows}`);
res.push(tFirst); if (i === N) await p.screenshot({ path: `/root/ep19fs/ui-${P}.png` }); await ctx.close();
}
console.log(` Mittel erste Zeile ${(res.reduce((a, b) => a + b, 0) / res.length).toFixed(2)} s (n=${res.length})`);
await b.close();