feat: add dependency shutdown and configurable service endpoints
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify source-generated root entrypoints with real local processes only."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
@@ -85,6 +86,8 @@ def serve(args, project, env, transport, sig, strict_exit, contract=False, logs=
|
||||
else:
|
||||
raise RuntimeError('server readiness timed out')
|
||||
if contract:
|
||||
status, body = request(base + '/health/ready')
|
||||
assert status == 200 and json.loads(body) == {'code': 0, 'msg': 'success', 'data': {'status': 'ready'}}
|
||||
status, body = request(base + '/check?kind=fixed')
|
||||
assert status == 400 and json.loads(body) == {'code': 400002, 'msg': '用户名格式不正确', 'data': None}
|
||||
assert json.loads(request(base + '/missing')[1])['msg'] == '接口不存在'
|
||||
@@ -128,6 +131,9 @@ def serve(args, project, env, transport, sig, strict_exit, contract=False, logs=
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--report", type=Path, default=ROOT / "performance/managedProjectLocal.json")
|
||||
args = parser.parse_args()
|
||||
started = time.monotonic()
|
||||
env = dict(os.environ, GOWORK='off', GOFLAGS='')
|
||||
# Prevent inherited project configuration from binding a real server or loading secrets.
|
||||
@@ -156,10 +162,11 @@ def main():
|
||||
for transport in ('nethttp', 'native'):
|
||||
serve([str(work/'managedExample')], example, env, transport, signal.SIGTERM, True, contract=True, logs=work)
|
||||
sources = ['cmd/go-omni/apigen/generate.go', 'cmd/go-omni/apigen/templates.go', 'cmd/go-omni/apigen/startup.go', 'cmd/go-omni/apigen/managed_test.go', 'cmd/go-omni/apigen/contractChanges.go', 'cmd/go-omni/apigen/logicCheck.go', 'cmd/go-omni/apigen/write.go', 'cmd/go-omni/api.go', 'config/config.go', 'httpx/transfer.go', 'httpx/multipart.go', 'scripts/verifyManagedProject.py']
|
||||
sources += ['lifecycle/controller.go', 'health/health.go', 'config/endpoints.go', 'httpx/response.go', 'app/app.go', 'app/transport.go']
|
||||
sources += [str(p.relative_to(ROOT)) for p in (ROOT/'cmd/go-omni/scaffold/templates').glob('api-*.tmpl')]
|
||||
sources += [str(p.relative_to(ROOT)) for p in (ROOT/'cmd/go-omni/apigen/testdata/managed').glob('*.go')]
|
||||
report = {'passed': True, 'mode': 'localSource', 'durationSeconds': round(time.monotonic()-started, 2), 'checks': ['rootGoRun', 'rootGoBuild', 'stableRegeneration', 'checkMainOwnership', 'contractChangePreview', 'logicSignatureCheckPersists', 'businessSourcePreserved', 'fixedConsumerBuild', 'nethttpSIGINT', 'nethttpSIGTERM', 'nativeSIGINT', 'nativeSIGTERM', 'listenerReleased', 'temporaryProcessesRemoved', 'nethttpGeneratedTransfers', 'nativeGeneratedTransfers', 'malformedMultipart400', 'goOwnedErrors', 'default404And405'], 'sourceHashes': {p: hashlib.sha256((ROOT/p).read_bytes()).hexdigest() for p in sources}}
|
||||
(ROOT/'performance/managedProjectLocal.json').write_text(json.dumps(report, indent=2)+'\n')
|
||||
args.report.write_text(json.dumps(report, indent=2)+'\n')
|
||||
print('PASS generated root project: go run/build, regeneration, nethttp/native signals; temporary files removed')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user