Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .zed/debug.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Project-local debug tasks
//
// For more documentation on how to configure debug tasks,
// see: https://zed.dev/docs/debugger
// Project-local debug tasks
//
// For more documentation on how to configure debug tasks,
// see: https://zed.dev/docs/debugger
[
{
"label": "main",
"adapter": "Delve",
"program": "${ZED_WORKTREE_ROOT}/cmd/apiserver/main.go",
"args": ["-c", "${ZED_WORKTREE_ROOT}/config.yaml"],
"request": "launch",
"mode": "debug",
"env": {
"SERVICE_NAME": "api-server"
// "API_SERVER_SERVER_BIND": ":8090"
// "API_SERVER_CONFIG_PATH": "${workspaceFolder}/config.yaml"
}
},
{
"label": "init",
"adapter": "Delve",
"request": "launch",
"mode": "debug",
"program": "${ZED_WORKTREE_ROOT}/cmd/apiserver/main.go",
"args": ["init"],
"env": {
"SERVICE_NAME": "qqlx",
"QQLX_CONFIG_PATH": "${ZED_WORKTREE_ROOT}/config.yaml"
}
}
]
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ require (
golang.org/x/oauth2 v0.27.0
gorm.io/driver/mysql v1.6.0
gorm.io/gorm v1.30.0
resty.dev/v3 v3.0.0-beta.4
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,5 @@ modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds=
modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
modernc.org/sqlite v1.20.3 h1:SqGJMMxjj1PHusLxdYxeQSodg7Jxn9WWkaAQjKrntZs=
modernc.org/sqlite v1.20.3/go.mod h1:zKcGyrICaxNTMEHSr1HQ2GUraP0j+845GYw37+EyT6A=
resty.dev/v3 v3.0.0-beta.4 h1:2O77oFymtA4NT8AY87wAaSgSGUBk2yvvM1qno9VRXZU=
resty.dev/v3 v3.0.0-beta.4/go.mod h1:NTOerrC/4T7/FE6tXIZGIysXXBdgNqwMZuKtxpea9NM=
57 changes: 57 additions & 0 deletions test/http/http_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package http_test

import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
"testing"
"time"

"resty.dev/v3"
)

func TestCurl(t *testing.T) {
client := resty.New()
defer client.Close()
// loc, _ := time.LoadLocation("Asia/Shanghai")
// tt, _ := time.ParseInLocation("2006-01-02 15:04:05", "2025-12-02 13:43:10", loc)
// nt := strconv.FormatInt(tt.Unix(), 10)
// fmt.Printf("nt: %s\n", nt)

ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop()

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
sigChan := make(chan os.Signal, 2)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
go func() {
<-sigChan
fmt.Println("Ctrl+C received, shutting down...")
cancel()
}()

for {
select {
case <-ticker.C:
nt := time.Now()
fmt.Printf("nt: %s\n", nt.Format("2006-01-02 15:04:05"))
res, err := client.R().
SetQueryParams(map[string]string{
"query": `sum by (container) (max_over_time(DCGM_FI_DEV_GPU_UTIL{namespace="a1-prod", container="qwen-image"}[1m])) / 100`,
// "query": `sum (DCGM_FI_DEV_GPU_UTIL{namespace="a1-prod", container="qwen-image"}) by (container) / 100`,
"time": fmt.Sprintf("%d", nt.Unix()),
}).
Get("http://10.99.1.12:30737/api/v1/query")
if err != nil {
t.Fatalf("查询失败: %s\n", err)
}
fmt.Printf("res: %+v\n", res)
case <-ctx.Done():
fmt.Println("Application stopped.")
return
}
}
}