mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-05 16:07:33 +00:00
test(gateway): isolate signed-history allocation measurement
This commit is contained in:
1 parent
38605c1fe8
commit
217925ca0b
1 file changed
+17
@@ -3,6 +3,8 @@ package service
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -75,6 +77,21 @@ func signedThinkingHistoryBody() []byte {
|
||||
}
|
||||
|
||||
func TestFilterThinkingBlocksSignedHistorySkipsDecode(t *testing.T) {
|
||||
// AllocsPerRun reads process-wide counters. Background workers from other
|
||||
// service tests can otherwise make unchanged signed history fail this check.
|
||||
const isolatedEnv = "SUB2API_TEST_SIGNED_HISTORY_ALLOCS"
|
||||
if os.Getenv(isolatedEnv) != "1" {
|
||||
binary, err := os.Executable()
|
||||
require.NoError(t, err)
|
||||
cmd := exec.CommandContext(t.Context(), binary,
|
||||
"-test.run=^TestFilterThinkingBlocksSignedHistorySkipsDecode$",
|
||||
"-test.count=1", "-test.timeout=30s")
|
||||
cmd.Env = append(os.Environ(), isolatedEnv+"=1")
|
||||
output, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, "%s", output)
|
||||
return
|
||||
}
|
||||
|
||||
body := signedThinkingHistoryBody()
|
||||
allocs := testing.AllocsPerRun(5, func() {
|
||||
got := filterThinkingBlocksInternal(body, false)
|
||||
|
||||
Reference in new issue
Block a user