\Tests\FeatureQueueWorkerServiceTest

Worker 守护服务回归

被测对象:QueueWorkerService 全方法 守护约定:① 心跳写实例心跳键 + 注册表(started_at 首次登记保留) ② 失联 = 注册表在但心跳键过期 ③ sync 同步模式不告警且 start 拒绝 ④ pause/resume/restart 走官方缓存键(illuminate:queue:* 契约)。

Summary

Methods
Properties
Constants
test_heartbeat_writes_instance_and_keeps_started_at()
test_status_running_and_sync_no_alarm()
test_stale_instance_is_self_healed()
test_pause_resume_toggles_official_key()
test_restart_writes_official_key()
test_remove_instance_cleans_up()
test_start_rejected_in_sync_mode()
test_start_rejected_when_worker_running()
No public properties found
No constants found
createJobCenterSchema()
requireRedis()
buildCacheRegistry()
setUp()
No protected properties found
N/A
No private methods found
$service
N/A

Properties

Methods

test_heartbeat_writes_instance_and_keeps_started_at()

test_heartbeat_writes_instance_and_keeps_started_at() : void

心跳:写当前进程心跳键(TTL=失联阈值)+ 注册表项;二次心跳保留首次 started_at

test_status_running_and_sync_no_alarm()

test_status_running_and_sync_no_alarm() : void

状态:有心跳 = 运行中(running 计数);sync 同步模式即使无 worker 也不告警

test_stale_instance_is_self_healed()

test_stale_instance_is_self_healed() : void

失联自愈:注册表有残留但心跳键过期(进程被杀无 WorkerStopping 事件)→ status 自愈清除僵尸项

test_pause_resume_toggles_official_key()

test_pause_resume_toggles_official_key() : void

暂停/恢复:写/清官方暂停键(illuminate:queue:paused:sync:default),paused 同步反映

test_restart_writes_official_key()

test_restart_writes_official_key() : void

重启:写官方重启键(时间戳变化即平滑退出)

test_remove_instance_cleans_up()

test_remove_instance_cleans_up() : void

注销:清除心跳键与注册表项

test_start_rejected_in_sync_mode()

test_start_rejected_in_sync_mode() : void

start:同步模式(sync)任务当场执行,无需 worker 进程——拒绝并给出明确文案

test_start_rejected_when_worker_running()

test_start_rejected_when_worker_running() : void

start:worker 已在运行(有心跳)时拒绝重复启动

createJobCenterSchema()

createJobCenterSchema() : void

队列中心三表最小 schema(类型注册表 + 执行台账 + Laravel 原生队列表)

requireRedis()

requireRedis() : void

Redis 依赖探针:直连 Redis 的测试(限流/会话/验证码)在无 Redis 环境(如 CI) 跳过而非失败——其余用例不受影响。CI 可设 TEST_REQUIRE_REDIS=1 强制模式: Redis 不可达即失败而非跳过,安全回归套件不允许静默消失。

buildCacheRegistry()

buildCacheRegistry(array  $items) : void

建缓存注册表最小 schema(td_sys_cache)并灌入注册项。

测试跑 sqlite :memory:,生产迁移含 PostgreSQL 专属 DDL 跑不通(DataScopeServiceTest 同因自建 schema); 而 CacheManager::registry() 现已从数据库表读取——凡走注册表的测试(remember/get/key/失效推导) 必须在 setUp 先调用本方法,否则注册表为空、remember 未登记名会走「自动登记」路径。

Parameters

array $items

setUp()

setUp() : void