feat: 支持局域网 HTTPS 直连并持久化插件连接配置

This commit is contained in:
tongtong committed 2026-11-24 16:24:37 +08:00
1 parent 9eba4556db
commit 2203afde3c
15 files changed
+486 -17

No files matched your search

+18 -3
View File
@@ -18,6 +18,12 @@ ROOT = Path(__file__).resolve().parents[1]
class SmokeTest(unittest.TestCase):
def test_sync_build_download_and_second_revision(self):
self.exercise(False)
def test_https_sync_build_download_and_second_revision(self):
self.exercise(True)
def exercise(self, secure):
binary = ROOT / 'dist' / ('remotecompile-windows-amd64.exe' if os.name == 'nt' else 'remotecompile')
if not binary.exists():
self.skipTest(f'Build service binary first: {binary}')
@@ -34,20 +40,29 @@ class SmokeTest(unittest.TestCase):
with socket.socket() as sock:
sock.bind(('127.0.0.1', 0))
port = sock.getsockname()[1]
endpoint = f'http://127.0.0.1:{port}'
endpoint = f'{"https" if secure else "http"}://127.0.0.1:{port}'
env = dict(os.environ, REMOTE_BUILD_TOKEN='test-only-token-abcdefghijklmnopqrstuvwxyz')
process = subprocess.Popen([str(binary), '-listen', f'127.0.0.1:{port}', '-data', str(root / 'data')], env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
command = [str(binary), '-listen', f'127.0.0.1:{port}', '-data', str(root / 'data')]
context = None
if secure:
import ssl
subprocess.run([str(binary), '-init-tls-host', '127.0.0.1', '-tls-dir', str(root/'tls')], check=True, capture_output=True)
command += ['-tls-cert', str(root/'tls/server.crt'), '-tls-key', str(root/'tls/server.key')]
context = ssl.create_default_context(cafile=str(root/'tls/server.crt'))
process = subprocess.Popen(command, env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
try:
for _ in range(100):
try:
req = urllib.request.Request(endpoint + '/api/v1/health', headers={'Authorization': 'Bearer ' + env['REMOTE_BUILD_TOKEN']})
with urllib.request.urlopen(req, timeout=1):
with urllib.request.urlopen(req, timeout=1, context=context):
break
except OSError:
time.sleep(.05)
else:
self.fail('Service did not start')
command = [sys.executable, str(ROOT / 'client' / 'remote_run.py'), str(source), '--url', endpoint]
if secure:
command += ['--server-cert', str(root/'tls/server.crt')]
first = subprocess.run(command, env=env, capture_output=True, text=True, timeout=30)
self.assertEqual(first.returncode, 0, first.stderr)
self.assertEqual(next((source / '.remotecompile').glob('*.apk')).read_bytes(), b'first')