3 changed files with 39 additions and 0 deletions

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
name: ci
on: [push]
jobs:
test:
runs-on: host
steps:
- name: install python
run: apk add --no-cache python3 py3-pip ca-certificates git curl github-cli tar 2>&1 | tail -3; python3 --version; git --version
- name: clone repo
run: |
rm -rf src
git clone https://gitea.tose.top/admin/codex-app-server.git src
cd src && git rev-parse HEAD
- name: host tests
run: cd src && python3 -m unittest discover -s tests -v
- name: cloud tests
run: cd src && python3 -m unittest discover -s cloud/tests -v
- name: deploy tests
run: cd src && python3 -m unittest discover -s deploy/tests -v
+8
View File
@@ -170,6 +170,14 @@ class BridgeTestCase(unittest.TestCase):
state, _ = read_state(self.tmp.name) state, _ = read_state(self.tmp.name)
self.assertEqual(effective_holder(self.tmp.name, state), self.assertEqual(effective_holder(self.tmp.name, state),
"agent") "agent")
# Gitea runner filesystem mtime lags wall clock by ~1ms
# (measured 0.2-1.0ms in runner container), so a
# back-to-back write can appear older than updated_at.
# Sleep BEFORE writing, so the control file is genuinely
# newer (sleeping after the write does not change its
# mtime). The test's intent is "newer control wins",
# not "same-millisecond writes are ordered".
time.sleep(0.05)
write_control(self.tmp.name, "user") write_control(self.tmp.name, "user")
self.assertEqual(effective_holder(self.tmp.name, state), self.assertEqual(effective_holder(self.tmp.name, state),
"user") "user")
+12
View File
@@ -214,7 +214,19 @@ class BrowserProxyTestCase(unittest.TestCase):
db.commit() db.commit()
finally: finally:
db.close() db.close()
# Terminal status ends the stream, but a waiting
# heartbeat may fire first on a loaded runner; drain
# waiting frames until EOF instead of requiring the
# first line after the update to be EOF.
for _ in range(20):
line = resp.readline().decode("utf-8") line = resp.readline().decode("utf-8")
if line == "":
break
if line.strip() == "":
continue
payload = json.loads(line[6:]) if line.startswith("data: ") else {}
if not payload.get("waiting"):
break
self.assertEqual(line, "") self.assertEqual(line, "")
finally: finally:
conn.close() conn.close()