Fix Tachyon APK discovery and release package revision 122-r2
OpenWrt IPK and APK / Validate source and resolve stable SDKs (push) Waiting to run

This commit is contained in:
kzolotarev95 committed 2026-11-22 00:07:08 +04:00
1 parent 70a4705e67
commit 927aec8ffe
18 files changed
+496 -45

No files matched your search

+4
View File
@@ -1,5 +1,9 @@
# Версия v122
Исправления Tachyon для APK 3.0.5 выпускаются как пакетная ревизия 122-r2
с тегом v122-r2. Номер интерфейсов остаётся v122; исходный тег v122 и пакеты
122-r1 сохраняются.
Выпуск использует main и отдельный тег v122. GitHub Actions собирает IPK/APK,
проверяет их и прикладывает к Releases → v122 после успешного завершения сборок
и установки/обновления/удаления в OpenWrt VM. Выпущенная v121 сохраняется.
+5
View File
@@ -84,6 +84,11 @@ class PackageTests(unittest.TestCase):
text = (ROOT / "files" / name).read_text(encoding="utf-8")
self.assertIn("OpenWrt Remote Hub v" + version, text)
def test_package_revision_has_its_own_tag_without_renaming_the_panel(self):
for values, expected in [(('122','1'),'v122'), (('122','2'),'v122-r2'), (('123','1'),'v123')]:
with self.subTest(values=values), mock.patch.object(p,'versions',return_value=values):
self.assertEqual(p.release_tag(), expected)
def test_package_scripts_defer_procd_lifecycle_to_openwrt_for_apk_and_ipk(self):
script = p.package_hook("postinst")
self.assertNotIn("configure ]", script)
+41 -3
View File
@@ -137,7 +137,7 @@ curl() {
[ "$TEST_HTTP" != fail ] || return 7
for last do :; done
case "$last" in
*/api/agent/v1/health) printf '{"core_running":false}' ;;
*/api/agent/v1/health) [ "${TEST_API:-1}" = 1 ] || return 22; printf '{"core_running":false}' ;;
*/api/agent/v1/openapi.json) printf '{"info":{"version":"2.0.0-beta.14"}}' ;;
*) printf '%s' "$TEST_HTTP" ;;
esac
@@ -180,17 +180,55 @@ print(str(value).lower() if isinstance(value,bool) else value)' "$@"
def test_apk_discovery_and_legacy_luci(self):
code = r'''
apk() { if [ "$2" = -v ]; then echo tachyon-2.0.0-r1; else printf 'base-files\ntachyon\n'; fi; }
apk() {
case "$1" in
info) printf 'base-files\ntachyon\n' ;;
list) printf 'tachyon 2.0.0-r1\n' ;;
*) return 1 ;;
esac
}
tachyon_json force
'''
result = self.run_shell(code)
self.assertEqual(json.loads(result.stdout)['package_version'], '2.0.0-r1')
with (self.root / 'uci').open('a') as config:
config.write('tachyon.settings.listen_port=1602\n')
result = self.harness.run_shell(self.mocks + 'tachyon_json force', TEST_VERSION='1.3.13', TEST_HTTP='403', TEST_SERVICE='true')
result = self.harness.run_shell(self.mocks + 'tachyon_json force', TEST_VERSION='1.3.13', TEST_HTTP='403', TEST_SERVICE='true', TEST_API='0')
self.assertEqual(json.loads(result.stdout)['mode'], 'luci')
self.assertEqual(json.loads(result.stdout)['port'], 0)
def test_apk_305_description_is_not_a_version_and_manifest_selects_standalone(self):
result = self.run_shell(r'''
apk() {
case "$1:$2" in
info:) printf 'base-files\ntachyon\n' ;;
info:-v) printf 'tachyon: Pure-Rust routing orchestrator and web panel for OpenWrt (aarch64)\ntachyon: https://github.com/Dushnilin/tachyon\ntachyon: 7136 KiB\n' ;;
list:--installed) printf 'tachyon 2.0.0~beta.15-r1\n' ;;
*) return 1 ;;
esac
}
tachyon_json force
''')
status = json.loads(result.stdout)
self.assertEqual(status['mode'], 'standalone')
self.assertEqual(status['port'], 1680)
self.assertEqual(status['package_version'], '2.0.0~beta.15-r1')
self.assertTrue(status['available'])
def test_actual_api_recovers_missing_or_stale_package_version(self):
for version in ('', '1.3.13'):
result = self.harness.run_shell(self.mocks + 'tachyon_json force',
TEST_VERSION=version, TEST_HTTP='200', TEST_SERVICE='true')
status = json.loads(result.stdout)
self.assertEqual(status['mode'], 'standalone')
self.assertEqual(status['port'], 1680)
self.assertEqual(status['version'], '2.0.0-beta.14')
def test_luci_login_response_is_not_proof_of_an_unknown_tachyon_ui(self):
result = self.harness.run_shell(self.mocks + 'tachyon_json force',
TEST_VERSION='', TEST_API='0', TEST_HTTP='403', TEST_SERVICE='true')
self.assertFalse(json.loads(result.stdout)['available'])
def test_custom_web_port_and_no_reconfigure_when_manually_stopped(self):
with (self.root / 'uci').open('a') as config:
config.write('tachyon.settings.listen_port=1800\n')
+37
View File
@@ -0,0 +1,37 @@
// Browser regression: an absent version must not move the action into the header.
const {chromium} = require('playwright');
const fs = require('node:fs');
const vm = require('node:vm');
const assert = require('node:assert/strict');
const source = fs.readFileSync('vps/owrt-remote-hub.py', 'utf8');
const start = source.indexOf('function renderTachyon(router) {{');
const end = source.indexOf('\nfunction render(list)', start);
const escape = s => String(s).replace(/[&<>"']/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
const context = {escapeHtml:escape, escapeAttr:escape};
vm.createContext(context);
vm.runInContext(source.slice(start,end).replaceAll('{{','{').replaceAll('}}','}'), context);
(async () => {
const browser = await chromium.launch({headless:true, ...(process.env.OWRT_TEST_BROWSER_BIN ? {executablePath:process.env.OWRT_TEST_BROWSER_BIN} : {})});
try {
for (const [width,height] of [[1280,900],[390,844],[844,390]]) {
const page = await browser.newPage({viewport:{width,height}});
const cards = ['2.0.0-beta.15','', '2.0.0~beta.15-r1'].map(version =>
'<section class="card">'+context.renderTachyon({permissions:{admin:true},tachyon:{installed:true,online:true,version,url:'/tachyon/test/'}})+'</section>').join('');
await page.setContent('<style>*{box-sizing:border-box}body{margin:12px;font:13px Arial;background:#21192e;color:#fff}.cards{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.card{min-width:0}.btn{display:inline-flex;align-items:center;justify-content:center;min-height:34px;padding:8px 12px;border:1px solid #736387;border-radius:7px;background:#3b3049;color:white;text-decoration:none;font-weight:bold}@media(max-width:600px){.cards{grid-template-columns:1fr}}</style><div class="cards">'+cards+'</div>');
const boxes = await page.locator('.tachyonIntegration').evaluateAll(items => items.map(el => {
const box=el.getBoundingClientRect(), meta=el.querySelector('.tachyonMeta').getBoundingClientRect(), action=el.querySelector('.tachyonAction').getBoundingClientRect();
return {height:box.height,actionTop:action.top-box.top,metaBottom:meta.bottom-box.top,overflow:el.scrollWidth>el.clientWidth,center:Math.abs((action.left+action.width/2)-(box.left+box.width/2))};
}));
for (const box of boxes) {
assert(!box.overflow,`${width}: overflowing card`);
assert(box.actionTop>=box.metaBottom+7,`${width}: action must be below metadata`);
assert(box.center<1,`${width}: centered button`);
assert(Math.abs(box.actionTop-boxes[0].actionTop)<1,`${width}: version changed action placement`);
assert(Math.abs(box.height-boxes[0].height)<1,`${width}: version changed block height`);
}
if (process.env.OWRT_TEST_SCREENSHOT_DIR) await page.screenshot({path:process.env.OWRT_TEST_SCREENSHOT_DIR+`/tachyon-cards-${width}.png`,fullPage:true});
await page.close();
}
console.log('TACHYON_CARD_LAYOUT_OK: desktop, portrait and landscape');
} finally { await browser.close(); }
})().catch(error => {console.error(error);process.exitCode=1;});
+20 -2
View File
@@ -5,6 +5,7 @@ import shlex
import shutil
import subprocess
import tempfile
import sys
import unittest
from test_host_policy import ROOT, SH
@@ -17,6 +18,7 @@ class DeployTests(unittest.TestCase):
self.addCleanup(self.temp.cleanup)
self.root = Path(self.temp.name)
self.env = dict(os.environ)
self.env['TEST_PYTHON'] = Path(sys.executable).as_posix()
if os.name == 'nt':
self.env['PATH'] = str(Path(SH).parent) + os.pathsep + self.env['PATH']
self.targets = {name: self.root / name for name in ('agent', 'tachyon.sh')}
@@ -29,8 +31,14 @@ class DeployTests(unittest.TestCase):
original = {'agent': '/usr/sbin/owrt-remote', 'tachyon.sh': '/usr/lib/owrt-remote/tachyon.sh'}[name]
self.script = self.script.replace('echo ' + original, 'echo ' + shlex.quote(target.as_posix()))
self.script = self.script.replace('/etc/init.d/owrt-remote restart', 'test_restart')
self.script = self.script.replace('/usr/sbin/owrt-remote tachyon-status', "printf '{\"checked\":true}'")
mocks = '''
ubus() { printf '{}'; }
ubus() {
case "$1:$2:$3" in
call:service:add) "$TEST_PYTHON" -c 'import json,sys; data=json.loads(sys.argv[1]); assert data["instances"]["once"]["command"][0]=="/bin/sh"' "$4" ;;
*) printf '{}' ;;
esac
}
jsonfilter() { printf true; }
timeout() { return 0; }
busybox() { return 127; }
@@ -39,7 +47,7 @@ sleep() { :; }
'''
self.script = mocks + self.script.replace('test -r /usr/lib/owrt-remote/control.sh', 'true')
def deploy(self, action='Install', bad=False, fail=False, no_timeout=False):
def deploy(self, action='Install', bad=False, fail=False, no_timeout=False, deferred=False):
stage = self.root / 'stage'
stage.mkdir()
for name, source in {'agent': 'files/usr/sbin/owrt-remote', 'tachyon.sh': 'files/usr/lib/owrt-remote/tachyon.sh'}.items():
@@ -47,6 +55,7 @@ sleep() { :; }
stage.joinpath(name).write_text(text, encoding='utf-8', newline='\n')
script = self.script.replace('stage=/tmp/__UPLOAD_NAME__', 'stage=' + shlex.quote(stage.as_posix()))
script = script.replace('__UPLOAD_NAME__', 'sandbox').replace('__KIND__', 'Router').replace('__ACTION__', action)
script = script.replace('__DEFER_RESTART__', '1' if deferred else '0')
if no_timeout:
# Model the optional applet missing from both PATH and BusyBox.
script = script.replace('command -v timeout >/dev/null 2>&1', 'false')
@@ -97,6 +106,15 @@ sleep() { :; }
self.assertNotIn('restoring files', result.stderr)
self.assert_original()
def test_reverse_ssh_install_queues_independent_restart_after_file_checks(self):
# A direct restart would close the SSH connection carrying deployment.
# The old restart mock intentionally fails; deferred mode must skip it.
result = self.deploy(deferred=True, fail=True)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIn('TACHYON_RESTART_QUEUED', result.stdout)
self.assertNotIn('TACHYON_INTEGRATION_Router_Install_OK', result.stdout)
self.assertNotIn('restoring files', result.stderr)
if __name__ == '__main__':
unittest.main()
+92
View File
@@ -0,0 +1,92 @@
"""Reverse SSH verification must validate the actual router API, not the badge."""
from contextlib import closing, redirect_stdout
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
import io
import json
from pathlib import Path
import sqlite3
import tempfile
import threading
import time
import unittest
class DetectionVerificationTests(unittest.TestCase):
def setUp(self):
self.temp = tempfile.TemporaryDirectory()
self.addCleanup(self.temp.cleanup)
self.db = Path(self.temp.name) / 'hub.db'
self.body = b'{"core_running":false}'
owner = self
class Backend(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200); self.end_headers(); self.wfile.write(owner.body)
def log_message(self, *args): pass
self.server = ThreadingHTTPServer(('127.0.0.1', 0), Backend)
self.thread = threading.Thread(target=self.server.serve_forever, daemon=True)
self.thread.start(); self.addCleanup(self.close)
with closing(sqlite3.connect(self.db)) as db, db:
db.execute('create table routers(id text,last_seen real,status_json text,tachyon_entry_port integer,deleted_at integer default 0)')
db.execute('insert into routers(id,last_seen,status_json,tachyon_entry_port) values(?,?,?,?)', ('node-12', time.time(), json.dumps({
'xray':'running', 'tachyon':{'mode':'standalone','available':True,'version':'2.0.0-beta.15'}}), self.server.server_port))
def close(self):
self.server.shutdown(); self.server.server_close(); self.thread.join(timeout=3)
def verify(self, action='Install'):
source = (Path(__file__).resolve().parents[1] / 'vps/deploy-tachyon-detection-fix.ps1').read_text(encoding='utf-8')
code = source.split("$Verify = @'\n",1)[1].split("\n'@",1)[0]
code = code.replace('/var/lib/owrt-remote/hub.db',self.db.as_posix()).replace('__ROUTER_ID__','node-12')
code = code.replace('__SINCE__',str(int(time.time())-10)).replace('__ACTION__',action)
code = code.replace('range(40)','range(1)').replace('time.sleep(2)','time.sleep(0)')
output = io.StringIO()
with redirect_stdout(output): exec(compile(code,'verification','exec'),{})
return output.getvalue()
def status(self):
source = (Path(__file__).resolve().parents[1] / 'vps/deploy-tachyon-detection-fix.ps1').read_text(encoding='utf-8')
code = source.split("$Status = @'\n",1)[1].split("\n'@",1)[0]
code = code.replace('/var/lib/owrt-remote/hub.db',self.db.as_posix()).replace('__ROUTER_ID__','node-12')
output = io.StringIO()
try:
with redirect_stdout(output): exec(compile(code,'status','exec'),{})
except SystemExit as result:
return result.code, output.getvalue()
raise AssertionError('Status must explicitly report its return code')
def test_standalone_route_with_stopped_core_is_still_a_working_web_api(self):
self.assertIn('TACHYON_DETECTION_Router_Install_OK',self.verify())
def test_luci_html_instead_of_tachyon_is_rejected(self):
self.body = b'<html>LuCI login</html>'
with self.assertRaisesRegex(SystemExit,'Result not confirmed'): self.verify()
def test_wrong_api_field_type_is_rejected(self):
self.body = b'{"core_running":"false"}'
with self.assertRaisesRegex(SystemExit,'Result not confirmed'): self.verify()
def test_stale_heartbeat_cannot_confirm_deployment(self):
with closing(sqlite3.connect(self.db)) as db, db: db.execute('update routers set last_seen=0')
with self.assertRaisesRegex(SystemExit,'Result not confirmed'): self.verify()
def test_rollback_can_restore_legacy_detection(self):
with closing(sqlite3.connect(self.db)) as db, db:
db.execute('update routers set status_json=?',(json.dumps({'xray':'running','tachyon':{'mode':'luci'}}),))
self.assertIn('TACHYON_DETECTION_Router_Rollback_OK',self.verify('Rollback'))
def test_status_checks_the_selected_router_without_changing_database(self):
before = self.db.read_bytes()
rc, output = self.status()
self.assertEqual(rc, 0, output)
self.assertIn('TACHYON_CHECK_OK: node-12', output)
self.assertIn('2.0.0-beta.15', output)
self.assertEqual(self.db.read_bytes(), before)
def test_status_rejects_luci_html_and_reports_failure(self):
self.body = b'<html>LuCI</html>'
rc, output = self.status()
self.assertEqual(rc, 1, output)
self.assertIn('TACHYON_CHECK_FAILED: node-12', output)
if __name__ == '__main__': unittest.main()
+3
View File
@@ -16,6 +16,9 @@ assert(html.includes('Открыть Tachyon'));
assert(html.includes('target="_blank"'));
assert(html.includes('Online'));
assert(html.includes('href="/tachyon/a/"'));
assert(html.includes('tachyonMeta'));
assert(html.includes('tachyonAction'));
assert(context.renderTachyon({permissions:{admin:true}, tachyon:{installed:true, online:true, url:'/tachyon/a/'}}).includes('Tachyon</strong>'));
router.tachyon.online = false;
assert(context.renderTachyon(router).includes('Offline'));
router.permissions.admin = false;