Compare commits

..

2 Commits

Author SHA1 Message Date
ayflying
3e7c42952b Merge branch 'master' of https://gitea.adesk.com/public_project/utility_go 2025-12-24 15:42:48 +08:00
goldensea
d776c2d3bc 测试代码更新 2025-12-24 15:41:56 +08:00

View File

@@ -57,8 +57,10 @@ func TestGamelog(t *testing.T) {
func TestPressMQ(t *testing.T) {
glsdk, err := gamelog.INIT(&gamelog.SDKConfig{
// 必填
Pid: "yotest", // 项目ID
BaseUrl: "http://47.77.200.131:10101", // 美国BIDB服务器
Pid: "ydspress", // 项目ID
// BaseUrl: "http://47.77.200.131:10101", // 美国BIDB服务器
// BaseUrl: "http://101.37.28.111:10101", // 国内yoyatime服务器BIDB服务器
BaseUrl: "http://47.77.206.131:10201", // 压测服务器
ReportSk: "sngame2025", // xor混淆key
FlushInterval: 6, // 上报间隔
DiskBakPath: "gamelog", // 本地磁盘备份, 用于意外情况下临时保存日志, 请确保该目录持久化(容器内要挂载). 每次启动时或每N次上报时加载到失败队列
@@ -69,12 +71,22 @@ func TestPressMQ(t *testing.T) {
})
// 随机测试事件和属性
events := []string{"e1", "e2", "e3", "e4"}
pms := []map[string]any{
{"a": "1"},
{"a": "2"},
{"a": "3"},
{"a": "4"},
// events := []string{"e1", "e2", "e3", "e4"}
// pms := []map[string]any{
// {"s1": gconv.String(grand.Intn(100))},
// {"s2": gconv.String(grand.Intn(300))},
// {"s3": gconv.String(grand.Intn(500))},
// {"i1": grand.Intn(1000000)},
// {"i2": grand.Intn(9000000)},
// {"f1": gconv.Float64(grand.Intn(1000)) + (gconv.Float64(grand.Intn(1000000)) / 1000.0)},
// {"f2": gconv.Float64(grand.Intn(9000)) + (gconv.Float64(grand.Intn(1000000)) / 1000.0)},
// {"b1": true},
// {"b2": false},
// }
testProp := map[string]any{
"version": "1.18",
"country": "ZH-CN",
}
uuids := []string{}
for i := 0; i < 100; i++ {
@@ -86,11 +98,12 @@ func TestPressMQ(t *testing.T) {
t.Fatal(err)
}
n := 0
const limit = 30000
const limit = 20000
gtest.C(t, func(t *gtest.T) {
go func() {
for {
glsdk.LogLtz(uuids[grand.Intn(len(uuids))], events[grand.Intn(len(events))], pms[grand.Intn(len(pms))])
// glsdk.LogLtz(uuids[grand.Intn(len(uuids))], events[grand.Intn(len(events))], pms[grand.Intn(len(pms))])
glsdk.LogLtz(uuids[grand.Intn(len(uuids))], "PKGame:Default:StepComplete:1:1010", testProp)
// 并发控制
n++
if n%limit == 0 {
@@ -98,7 +111,7 @@ func TestPressMQ(t *testing.T) {
}
}
}()
time.Sleep(time.Second * 120)
time.Sleep(time.Second * 1200)
// 模拟等待信号后优雅关闭
glsdk.Shutdown()
})