fix(deploy): 等待 Nginx 新配置生效后再验收入口
This commit is contained in:
@@ -16,13 +16,16 @@ import json,os,sys
|
||||
with open(os.environ['CURL_CALLS'],'a') as out:out.write(json.dumps(sys.argv[1:])+'\\n')
|
||||
if os.environ['HTTP_CASE']=='home-error':sys.exit(22)
|
||||
if any('/api/health/update-ready' in arg for arg in sys.argv):
|
||||
print(json.dumps({'status':'ok','service':'wrong-upstream' if os.environ['HTTP_CASE']=='wrong-upstream' else 'easyai-server-main'}))
|
||||
if os.environ['HTTP_CASE']=='delayed-reload' and open(os.environ['CURL_CALLS']).read().count('/api/health/update-ready')==1:
|
||||
print('<html>redirect</html>\\n301');sys.exit(0)
|
||||
print(json.dumps({'status':'ok','service':'wrong-upstream' if os.environ['HTTP_CASE']=='wrong-upstream' else 'easyai-server-main'})+'\\n200')
|
||||
else: print('200',end='')
|
||||
''')
|
||||
curl.chmod(0o755)
|
||||
for name, mode, succeeds in [('home-error', 'ip', False), ('wrong-upstream', 'domain', False), ('healthy', 'ip', True), ('healthy', 'https', True)]:
|
||||
for name, mode, succeeds in [('home-error', 'ip', False), ('wrong-upstream', 'domain', False), ('healthy', 'ip', True), ('healthy', 'https', True), ('delayed-reload', 'domain', True)]:
|
||||
log = root / 'curl.jsonl'
|
||||
log.write_text('')
|
||||
env = {**os.environ, 'PATH': str(root) + os.pathsep + os.environ['PATH'], 'HTTP_CASE': name, 'CURL_CALLS': str(log)}
|
||||
env = {**os.environ, 'PATH': str(root) + os.pathsep + os.environ['PATH'], 'HTTP_CASE': name, 'CURL_CALLS': str(log), 'DEPLOY_PROXY_TIMEOUT_SECONDS':'8' if succeeds else '1'}
|
||||
run = '. ./functions.sh; DEPLOY_MODE="$1"; DEPLOY_IP=192.0.2.10; DEPLOY_DOMAIN=deployment.example; DEPLOY_HTTPS=false; if [ "$1" = https ]; then DEPLOY_MODE=domain; DEPLOY_HTTPS=true; fi; verify_proxy_entry'
|
||||
result = subprocess.run(['bash', '-c', run, 'fixture', mode], cwd=root, env=env, capture_output=True, text=True, timeout=15)
|
||||
assert (result.returncode == 0) == succeeds, (name, mode, result.stdout, result.stderr)
|
||||
|
||||
Reference in New Issue
Block a user