44
55Usage: E2E_ARGS='--run-part 1' python3 tests/acceptance/run-e2e.py
66Optional: TIKA_NEEDED=true, KEYCLOAK_NEEDED=true
7+ Optional: K8S=true, TEST_SERVER_URL=<url> - run against an already-deployed
8+ k8s OCIS instance (see .github/workflows/k8s.yml) instead of starting one
9+ locally. All other *_NEEDED flags are ignored in this mode.
710"""
811
912import json
@@ -120,6 +123,43 @@ def main() -> int:
120123 file = sys .stderr )
121124 return 1
122125
126+ repo_root = Path (__file__ ).resolve ().parents [2 ]
127+ web_dir = repo_root / "web"
128+
129+ if not (web_dir / "node_modules" ).exists ():
130+ pkg_manager = json .loads ((web_dir / "package.json" ).read_text ()).get ("packageManager" , "pnpm" )
131+ run (["npm" , "install" , "--silent" , "--global" , "--force" , pkg_manager ])
132+ subprocess .run (["pnpm" , "config" , "set" , "store-dir" , "./.pnpm-store" ],
133+ cwd = web_dir , check = True )
134+ subprocess .run (["pnpm" , "install" ], cwd = web_dir , check = True )
135+ subprocess .run (["pnpm" , "exec" , "playwright" , "install" , "--with-deps" , "chromium" ],
136+ cwd = web_dir , check = True )
137+
138+ if os .environ .get ("K8S" , "" ).lower () == "true" :
139+ # oCIS is already running as a Helm-deployed k8s cluster (see
140+ # .github/workflows/k8s.yml) -- unlike the flow below, there's no local
141+ # binary to build, init, or start. Just confirm it's up and point
142+ # Playwright straight at it.
143+ ocis_url = os .environ ["TEST_SERVER_URL" ]
144+ wait_for (lambda : ocis_healthy (ocis_url ), 120 , "ocis" )
145+ print ("ocis ready." )
146+
147+ playwright_env = {
148+ ** os .environ ,
149+ "BASE_URL_OCIS" : ocis_url ,
150+ "HEADLESS" : "true" ,
151+ "RETRY" : "3" ,
152+ "REPORT_TRACING" : "false" ,
153+ "BROWSER" : "chromium" ,
154+ }
155+ print (f"Running e2e: { e2e_args } " )
156+ result = subprocess .run (
157+ ["bash" , "run-e2e.sh" ] + shlex .split (e2e_args ),
158+ cwd = web_dir / "tests/e2e" ,
159+ env = playwright_env ,
160+ )
161+ return result .returncode
162+
123163 tika_needed = os .environ .get ("TIKA_NEEDED" , "" ).lower () == "true"
124164 keycloak_needed = os .environ .get ("KEYCLOAK_NEEDED" , "" ).lower () == "true"
125165 mfa_needed = os .environ .get ("MFA_NEEDED" , "" ).lower () == "true"
@@ -131,7 +171,6 @@ def main() -> int:
131171 # MFA mode runs ocis behind keycloak with TOTP enforced
132172 keycloak_needed = keycloak_needed or mfa_needed or vault_storage_needed
133173
134- repo_root = Path (__file__ ).resolve ().parents [2 ]
135174 ocis_bin = repo_root / "ocis/bin/ocis"
136175 wrapper_bin = repo_root / "tests/ociswrapper/bin/ociswrapper"
137176 # The federated suite must address the primary as localhost instead of
@@ -141,7 +180,6 @@ def main() -> int:
141180 # suite), which only lists localhost:9200.
142181 ocis_url = "https://localhost:9200" if federated_needed else "https://127.0.0.1:9200"
143182 ocis_config_dir = Path .home () / ".ocis/config"
144- web_dir = repo_root / "web"
145183
146184 # build ocis + ociswrapper only if not already provided (e.g. via artifact)
147185 if not ocis_bin .exists ():
@@ -150,15 +188,6 @@ def main() -> int:
150188 run (["make" , "-C" , str (repo_root / "tests/ociswrapper" ), "build" ],
151189 env = {"GOWORK" : "off" })
152190
153- if not (web_dir / "node_modules" ).exists ():
154- pkg_manager = json .loads ((web_dir / "package.json" ).read_text ()).get ("packageManager" , "pnpm" )
155- run (["npm" , "install" , "--silent" , "--global" , "--force" , pkg_manager ])
156- subprocess .run (["pnpm" , "config" , "set" , "store-dir" , "./.pnpm-store" ],
157- cwd = web_dir , check = True )
158- subprocess .run (["pnpm" , "install" ], cwd = web_dir , check = True )
159- subprocess .run (["pnpm" , "exec" , "playwright" , "install" , "--with-deps" , "chromium" ],
160- cwd = web_dir , check = True )
161-
162191 # init ocis
163192 run ([str (ocis_bin ), "init" , "--insecure" , "true" ])
164193 # tests/config/ci/app-registry.yaml maps its one mimetype to "FakeOffice", the
0 commit comments