#!/bin/bash
set -e

echo "========================================================================"
echo "🧪 定时调度与手动触发测试"
echo "========================================================================"

echo ""
echo "1️⃣ 验证数据库配置"
echo "----------------------------------------"
export DB_HOST=rm-t4nh1xx6o2a6vj8qu3o.mysql.singapore.rds.aliyuncs.com
export DB_PORT=3306
export DB_USER=ad_rw
export DB_PASSWORD=p82SzuW4kAP3LJXcQGso
export DB_NAME=tencent_ad_autoput

source .venv/bin/activate
python3 << 'EOFPYTHON'
from db import get_system_config

cron = get_system_config('cron_schedule')
run_on_startup = get_system_config('run_on_startup')

print(f"✅ cron_schedule: {cron}")
print(f"   = UTC 03:00 = 北京时间 11:00")
print(f"✅ run_on_startup: {run_on_startup}")
EOFPYTHON

echo ""
echo "2️⃣ 启动服务器测试（后台运行）"
echo "----------------------------------------"
echo "⚠️  需要手动启动服务器测试："
echo "   cd /Users/liulidong/project/agent/Agent/examples/auto_put_ad_mini"
echo "   source .venv/bin/activate"
echo "   python server.py"
echo ""
echo "   然后在另一个终端执行："
echo "   curl http://localhost:8080/health | jq ."
echo "   curl -X POST http://localhost:8080/trigger"

echo ""
echo "========================================================================"
echo "✅ 配置验证完成"
echo "========================================================================"
echo ""
echo "📝 详细使用说明请查看：SCHEDULER_GUIDE.md"

