Skip to content

Commit ebe4240

Browse files
committed
Fix CI: update tests for simplified dashboard, fix Node SDK publish
- Remove references to DashboardStats.Nodes, Edges, UniqueTags, TaskExecutors in tests (fields removed in dashboard simplification) - Add npm ci before npm publish in Node SDK workflow so tsc can find @types/node during prepublishOnly
1 parent 19bce8a commit ebe4240

6 files changed

Lines changed: 17 additions & 76 deletions

File tree

.github/workflows/publish-node-sdk.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ jobs:
217217
env:
218218
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
219219
run: |
220+
# Install dependencies so prepublishOnly (tsc) can find @types/node
221+
npm ci
220222
# Publish with linux tag
221223
if [ "${{ needs.setup.outputs.environment }}" = "test" ]; then
222224
npm publish --tag dev --access public

tests/dashboard_test.go

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,12 @@ func TestDashboardStatsWithNodes(t *testing.T) {
9494
if stats.TotalRequests < 2 {
9595
t.Fatalf("expected at least 2 requests, got %d", stats.TotalRequests)
9696
}
97-
if len(stats.Nodes) != 2 {
98-
t.Fatalf("expected 2 nodes in list, got %d", len(stats.Nodes))
97+
// Nodes registered without a version should appear as "<1.7.0"
98+
if stats.Versions == nil {
99+
t.Fatal("expected non-nil Versions map")
99100
}
100-
101-
// Verify no IPs leak in addresses
102-
for _, node := range stats.Nodes {
103-
if strings.Contains(node.Address, "127.0.0.1") {
104-
t.Fatalf("node address should be a pilot address, not an IP: %s", node.Address)
105-
}
106-
}
107-
108-
// Verify node addresses are pilot addresses (not IPs)
109-
for _, node := range stats.Nodes {
110-
if strings.Contains(node.Address, "127.0.0.1") {
111-
t.Fatalf("node address should be a pilot address, not IP: %s", node.Address)
112-
}
101+
if stats.Versions["<1.7.0"] != 2 {
102+
t.Fatalf("expected 2 nodes with version <1.7.0, got %d", stats.Versions["<1.7.0"])
113103
}
114104
}
115105

tests/fuzz_registry_server_test.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,6 @@ func TestRegistryServerDashboardStatsEmpty(t *testing.T) {
163163
if stats.TotalRequests != 0 {
164164
t.Fatalf("expected 0 requests, got %d", stats.TotalRequests)
165165
}
166-
if stats.UniqueTags != 0 {
167-
t.Fatalf("expected 0 unique tags, got %d", stats.UniqueTags)
168-
}
169-
if stats.TaskExecutors != 0 {
170-
t.Fatalf("expected 0 task executors, got %d", stats.TaskExecutors)
171-
}
172166
if stats.UptimeSecs < 0 {
173167
t.Fatalf("uptime should be non-negative, got %d", stats.UptimeSecs)
174168
}
@@ -594,8 +588,8 @@ func TestRegistryClientSetTags(t *testing.T) {
594588
}
595589

596590
stats := s.GetDashboardStats()
597-
if stats.UniqueTags < 1 {
598-
t.Fatal("expected at least 1 unique tag")
591+
if stats.TotalNodes < 1 {
592+
t.Fatal("expected at least 1 node after tag set")
599593
}
600594
}
601595

@@ -1280,8 +1274,8 @@ func TestRegistryClientSetTaskExec(t *testing.T) {
12801274
}
12811275

12821276
stats := s.GetDashboardStats()
1283-
if stats.TaskExecutors != 1 {
1284-
t.Fatalf("expected 1 task executor, got %d", stats.TaskExecutors)
1277+
if stats.TotalNodes != 1 {
1278+
t.Fatalf("expected 1 node, got %d", stats.TotalNodes)
12851279
}
12861280
}
12871281

tests/snapshot_test.go

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,6 @@ func TestSnapshotSaveLoad(t *testing.T) {
346346
t.Logf(" Total Requests: %d", statsBefore.TotalRequests)
347347
t.Logf(" Total Nodes: %d", statsBefore.TotalNodes)
348348
t.Logf(" Active Nodes: %d", statsBefore.ActiveNodes)
349-
t.Logf(" Unique Tags: %d", statsBefore.UniqueTags)
350-
t.Logf(" Task Executors: %d", statsBefore.TaskExecutors)
351349
t.Logf(" Uptime: %d seconds", statsBefore.UptimeSecs)
352350

353351
// Trigger snapshot
@@ -413,8 +411,6 @@ func TestSnapshotSaveLoad(t *testing.T) {
413411
t.Logf(" Total Requests: %d", statsAfter.TotalRequests)
414412
t.Logf(" Total Nodes: %d", statsAfter.TotalNodes)
415413
t.Logf(" Active Nodes: %d", statsAfter.ActiveNodes)
416-
t.Logf(" Unique Tags: %d", statsAfter.UniqueTags)
417-
t.Logf(" Task Executors: %d", statsAfter.TaskExecutors)
418414
t.Logf(" Trust Links: %d", statsAfter.TotalTrustLinks)
419415
t.Logf(" Uptime: %d seconds", statsAfter.UptimeSecs)
420416

@@ -427,37 +423,8 @@ func TestSnapshotSaveLoad(t *testing.T) {
427423
t.Errorf("TotalNodes not restored: before=%d, after=%d",
428424
statsBefore.TotalNodes, statsAfter.TotalNodes)
429425
}
430-
if statsAfter.UniqueTags != statsBefore.UniqueTags {
431-
t.Errorf("UniqueTags not restored: before=%d, after=%d",
432-
statsBefore.UniqueTags, statsAfter.UniqueTags)
433-
}
434-
if statsAfter.TaskExecutors != statsBefore.TaskExecutors {
435-
t.Errorf("TaskExecutors not restored: before=%d, after=%d",
436-
statsBefore.TaskExecutors, statsAfter.TaskExecutors)
437-
}
438-
439-
// Validate nodes are restored
440-
if len(statsAfter.Nodes) != 3 {
441-
t.Errorf("expected 3 nodes, got %d", len(statsAfter.Nodes))
442-
}
443-
444-
// Validate POLO scores are restored
445-
poloScores := make(map[int]bool)
446-
for _, node := range statsAfter.Nodes {
447-
poloScores[node.PoloScore] = true
448-
}
449-
expectedScores := []int{150, 45, 92}
450-
for _, score := range expectedScores {
451-
if !poloScores[score] {
452-
t.Errorf("POLO score %d not found in restored nodes", score)
453-
}
454-
}
455-
456-
// Validate online status (nodes should be stale after restart)
457-
for _, node := range statsAfter.Nodes {
458-
if node.Online {
459-
t.Logf("Warning: node %s is online after restart (might be ok)", node.Address)
460-
}
426+
if statsAfter.TotalNodes != 3 {
427+
t.Errorf("expected 3 nodes, got %d", statsAfter.TotalNodes)
461428
}
462429

463430
t.Logf("\n✅ Snapshot save/load test passed")

tests/tags_test.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,8 @@ func TestSetTagsDashboardAPI(t *testing.T) {
290290
t.Fatalf("decode JSON: %v", err)
291291
}
292292

293-
if len(stats.Nodes) != 1 {
294-
t.Fatalf("expected 1 node, got %d", len(stats.Nodes))
295-
}
296-
if len(stats.Nodes[0].Tags) != 2 {
297-
t.Fatalf("expected 2 tags, got %d: %v", len(stats.Nodes[0].Tags), stats.Nodes[0].Tags)
298-
}
299-
if stats.UniqueTags != 2 {
300-
t.Fatalf("expected 2 unique tags, got %d", stats.UniqueTags)
293+
if stats.TotalNodes != 1 {
294+
t.Fatalf("expected 1 node, got %d", stats.TotalNodes)
301295
}
302296
}
303297

tests/task_exec_test.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,8 @@ func TestSetTaskExecDashboardAPI(t *testing.T) {
228228
t.Fatalf("decode JSON: %v", err)
229229
}
230230

231-
if stats.TaskExecutors != 1 {
232-
t.Fatalf("expected 1 task executor, got %d", stats.TaskExecutors)
233-
}
234-
if len(stats.Nodes) != 1 {
235-
t.Fatalf("expected 1 node, got %d", len(stats.Nodes))
236-
}
237-
if !stats.Nodes[0].TaskExec {
238-
t.Fatal("expected node task_exec=true in dashboard")
231+
if stats.TotalNodes != 1 {
232+
t.Fatalf("expected 1 node, got %d", stats.TotalNodes)
239233
}
240234
}
241235

0 commit comments

Comments
 (0)