fix(telemetry): use correct TopologyId field in integration test (#8714)
* fix(telemetry): use correct TopologyId field in integration test The proto field was renamed from cluster_id to topology_id but the integration test was not updated, causing a compilation error. * ci: add telemetry integration test workflow Runs the telemetry integration test (server startup, protobuf marshaling, client send, metrics/stats/instances API checks) on changes to telemetry/ or weed/telemetry/. * fix(telemetry): improve error message specificity in integration test * fix(ci): pre-build telemetry server binary for integration test go run compiles the server on the fly, which exceeds the 15s startup timeout in CI. Build the binary first so the test starts instantly. * fix(telemetry): fix ClusterId references in server and CI build path - Replace ClusterId with TopologyId in server storage and API handler (same rename as the integration test fix) - Fix CI build: telemetry server has its own go.mod, so build from within its directory * ci(telemetry): add least-privilege permissions to workflow Scope the workflow token to read-only repository contents, matching the convention used in go.yml. * fix(telemetry): set TopologyId in client integration test The client only populates TopologyId when SetTopologyId has been called. The test was missing this call, causing the server to reject the request with 400 (missing required field). * fix(telemetry): delete clusterInfo metric on instance cleanup The cleanup loop removed all per-instance metrics except clusterInfo, leaking that label set after eviction.
This commit is contained in:
@@ -85,16 +85,25 @@ func startTelemetryServer() (*exec.Cmd, error) {
|
||||
return nil, fmt.Errorf("failed to get working directory: %v", err)
|
||||
}
|
||||
|
||||
// Navigate to the server directory (from main seaweedfs directory)
|
||||
serverDir := filepath.Join(testDir, "telemetry", "server")
|
||||
|
||||
cmd := exec.Command("go", "run", ".",
|
||||
"-port="+serverPort,
|
||||
// Use pre-built binary if available (faster in CI), otherwise fall back to go run
|
||||
args := []string{
|
||||
"-port=" + serverPort,
|
||||
"-dashboard=false",
|
||||
"-cleanup=1m",
|
||||
"-max-age=1h")
|
||||
"-max-age=1h",
|
||||
}
|
||||
|
||||
cmd.Dir = serverDir
|
||||
serverBin := filepath.Join(testDir, "telemetry", "server", "telemetry-server")
|
||||
var cmd *exec.Cmd
|
||||
if _, err := os.Stat(serverBin); err == nil {
|
||||
fmt.Printf("Using pre-built binary: %s\n", serverBin)
|
||||
cmd = exec.Command(serverBin, args...)
|
||||
} else {
|
||||
fmt.Println("No pre-built binary found, using go run")
|
||||
serverDir := filepath.Join(testDir, "telemetry", "server")
|
||||
cmd = exec.Command("go", append([]string{"run", "."}, args...)...)
|
||||
cmd.Dir = serverDir
|
||||
}
|
||||
|
||||
// Create log files for server output
|
||||
logFile, err := os.Create("telemetry-server-test.log")
|
||||
@@ -174,9 +183,9 @@ func testProtobufMarshaling() error {
|
||||
}
|
||||
|
||||
// Verify data
|
||||
if testData2.ClusterId != testData.ClusterId {
|
||||
return fmt.Errorf("protobuf data mismatch: expected %s, got %s",
|
||||
testData.ClusterId, testData2.ClusterId)
|
||||
if testData2.TopologyId != testData.TopologyId {
|
||||
return fmt.Errorf("TopologyId mismatch: expected %s, got %s",
|
||||
testData.TopologyId, testData2.TopologyId)
|
||||
}
|
||||
|
||||
if testData2.VolumeServerCount != testData.VolumeServerCount {
|
||||
@@ -190,6 +199,7 @@ func testProtobufMarshaling() error {
|
||||
func testTelemetryClient() error {
|
||||
// Create telemetry client
|
||||
client := telemetry.NewClient(serverURL+"/api/collect", true)
|
||||
client.SetTopologyId("test-topology-12345")
|
||||
|
||||
// Create test data using protobuf format
|
||||
testData := &proto.TelemetryData{
|
||||
|
||||
Reference in New Issue
Block a user