test: 补齐短时间可测验收并修复建群下行卡住

This commit is contained in:
Nixevol
2026-09-30 10:20:47 +08:00
parent 4e3c84366f
commit 479a08ee11
12 changed files with 1078 additions and 87 deletions
+12
View File
@@ -5,6 +5,7 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"
"time"
"git.asio.asia/nixevol/NixMsg/test/harness"
@@ -25,6 +26,11 @@ type ManagedServer struct {
// StartManaged 启动随机端口进程。
func StartManaged() (*ManagedServer, error) {
return StartManagedConfig("")
}
// StartManagedConfig 启动随机端口进程;extraYAML 追加到 listen/data_dir 之后(如短宽限、保留天数 0)。
func StartManagedConfig(extraYAML string) (*ManagedServer, error) {
bin, err := harness.Binary()
if err != nil {
return nil, err
@@ -35,6 +41,12 @@ func StartManaged() (*ManagedServer, error) {
}
cfgPath := filepath.Join(dataDir, "config.yaml")
cfg := fmt.Sprintf("listen: %q\ndata_dir: %q\n", "127.0.0.1:0", filepath.ToSlash(dataDir))
if extraYAML != "" {
cfg += extraYAML
if !strings.HasSuffix(cfg, "\n") {
cfg += "\n"
}
}
if err = os.WriteFile(cfgPath, []byte(cfg), 0o644); err != nil {
_ = os.RemoveAll(dataDir)
return nil, err