The B5 full-stack rehearsal caught a silent accounting killer: with the production switch set (inbound on, outbound off) the generated v2ray_api stats block omitted the outbounds list, and sing-box then registers NO counters at all — QueryStats answered zero entries while real traffic flowed (A/B against the real core: adding the list produced full user/inbound/outbound counters). - builder: whenever the stats block is generated, emit inbounds, users and outbounds together; the gates now only decide whether the block exists - master: enforce the inbound category gate at recording time in the agent traffic report (the whole-network accounting switch semantics: off period is never counted); onlines stay ungated - golden gate test updated to the corrected contract
30 lines
682 B
Go
30 lines
682 B
Go
package agent
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// Throwaway live probe (B5 rehearsal): query the rehearsal core's
|
|
// v2ray_api stats service with the production client code.
|
|
func TestZZProbeLiveStats(t *testing.T) {
|
|
c := newSingboxStatsClient(func() string { return "probe" })
|
|
addr := os.Getenv("ZZ_STATS_ADDR")
|
|
if addr == "" {
|
|
addr = "127.0.0.1:10086"
|
|
}
|
|
c.SetAddr(addr)
|
|
ctx, cancel := context.WithTimeout(context.Background(), 8*time.Second)
|
|
defer cancel()
|
|
entries, err := c.queryStats(ctx)
|
|
if err != nil {
|
|
t.Fatalf("queryStats: %v", err)
|
|
}
|
|
t.Logf("entries: %d", len(entries))
|
|
for _, e := range entries {
|
|
t.Logf(" %s = %d", e.Name, e.Value)
|
|
}
|
|
}
|