Skip to content

Commit 63d8f65

Browse files
fix flake (#355)
## Fix flaky test in TestRegisterNode_Success_Plugin ### Problem The `TestRegisterNode_Success_Plugin` test was flaky due to non-deterministic map iteration order in Go. The test expected labels in a specific order, but Go's map iteration order is not guaranteed, causing intermittent failures in CI. ### Solution - Sort `extraLabels` map keys alphabetically before iterating to ensure deterministic label ordering - Added `sort` import to `register_node.go`
1 parent fd159c8 commit 63d8f65

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

.changeset/eight-worlds-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"chainlink-deployments-framework": patch
3+
---
4+
5+
Fix flaky test in TestRegisterNode_Success_Plugin

engine/cld/offchain/register_node.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package offchain
33
import (
44
"context"
55
"fmt"
6+
"sort"
67

78
nodev1 "github.com/smartcontractkit/chainlink-protos/job-distributor/v1/node"
89
"github.com/smartcontractkit/chainlink-protos/job-distributor/v1/shared/ptypes"
@@ -42,10 +43,18 @@ func RegisterNode(
4243
Key: "environment",
4344
Value: &environment,
4445
})
45-
for key, value := range extraLabels {
46+
47+
// Sort extraLabels keys to ensure deterministic label ordering
48+
extraLabelKeys := make([]string, 0, len(extraLabels))
49+
for key := range extraLabels {
50+
extraLabelKeys = append(extraLabelKeys, key)
51+
}
52+
sort.Strings(extraLabelKeys)
53+
54+
for _, key := range extraLabelKeys {
4655
labels = append(labels, &ptypes.Label{
4756
Key: key,
48-
Value: pointer.To(value),
57+
Value: pointer.To(extraLabels[key]),
4958
})
5059
}
5160
if isBootstrap {

0 commit comments

Comments
 (0)