Skip to content

Commit 7326c93

Browse files
author
sivakami
committed
track node usage.
1 parent 12c7b76 commit 7326c93

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

test/integration/swiftv2/longRunningCluster/datapath.go

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ type TestScenarios struct {
114114
BuildID string
115115
PodImage string
116116
Scenarios []PodScenario
117-
VnetSubnetCache map[string]VnetSubnetInfo // Cache for vnet/subnet info
118-
NodeUsageTracker map[string]map[string]bool // Tracks which nodes are used per vnet/subnet: "vnet/subnet" -> map[nodeName]bool
117+
VnetSubnetCache map[string]VnetSubnetInfo // Cache for vnet/subnet info
118+
UsedNodes map[string]bool // Tracks which nodes are already used (one pod per node for low-NIC)
119119
}
120120

121121
// VnetSubnetInfo holds network information for a vnet/subnet combination
@@ -337,31 +337,27 @@ func CreateScenarioResources(scenario PodScenario, testScenarios TestScenarios)
337337

338338
// Step 5: Select appropriate node based on scenario
339339
var targetNode string
340-
vnetSubnetKey := fmt.Sprintf("%s/%s", scenario.VnetName, scenario.SubnetName)
341340

342-
// Initialize node usage tracker for this vnet/subnet if not exists
343-
if testScenarios.NodeUsageTracker == nil {
344-
testScenarios.NodeUsageTracker = make(map[string]map[string]bool)
345-
}
346-
if testScenarios.NodeUsageTracker[vnetSubnetKey] == nil {
347-
testScenarios.NodeUsageTracker[vnetSubnetKey] = make(map[string]bool)
341+
// Initialize used nodes tracker if not exists
342+
if testScenarios.UsedNodes == nil {
343+
testScenarios.UsedNodes = make(map[string]bool)
348344
}
349345

350346
if scenario.NodeSelector == "low-nic" {
351347
if len(nodeInfo.LowNicNodes) == 0 {
352348
return fmt.Errorf("scenario %s: no low-NIC nodes available", scenario.Name)
353349
}
354-
// Find first unused node in the pool
350+
// Find first unused node in the pool (low-NIC nodes can only handle one pod)
355351
targetNode = ""
356352
for _, node := range nodeInfo.LowNicNodes {
357-
if !testScenarios.NodeUsageTracker[vnetSubnetKey][node] {
353+
if !testScenarios.UsedNodes[node] {
358354
targetNode = node
359-
testScenarios.NodeUsageTracker[vnetSubnetKey][node] = true
355+
testScenarios.UsedNodes[node] = true
360356
break
361357
}
362358
}
363359
if targetNode == "" {
364-
return fmt.Errorf("scenario %s: all low-NIC nodes already used for %s", scenario.Name, vnetSubnetKey)
360+
return fmt.Errorf("scenario %s: all low-NIC nodes already in use", scenario.Name)
365361
}
366362
} else { // "high-nic"
367363
if len(nodeInfo.HighNicNodes) == 0 {
@@ -370,14 +366,14 @@ func CreateScenarioResources(scenario PodScenario, testScenarios TestScenarios)
370366
// Find first unused node in the pool
371367
targetNode = ""
372368
for _, node := range nodeInfo.HighNicNodes {
373-
if !testScenarios.NodeUsageTracker[vnetSubnetKey][node] {
369+
if !testScenarios.UsedNodes[node] {
374370
targetNode = node
375-
testScenarios.NodeUsageTracker[vnetSubnetKey][node] = true
371+
testScenarios.UsedNodes[node] = true
376372
break
377373
}
378374
}
379375
if targetNode == "" {
380-
return fmt.Errorf("scenario %s: all high-NIC nodes already used for %s", scenario.Name, vnetSubnetKey)
376+
return fmt.Errorf("scenario %s: all high-NIC nodes already in use", scenario.Name)
381377
}
382378
}
383379

test/integration/swiftv2/longRunningCluster/datapath_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ var _ = ginkgo.Describe("Datapath Tests", func() {
9999

100100
// Initialize test scenarios with cache
101101
testScenarios := TestScenarios{
102-
ResourceGroup: rg,
103-
BuildID: buildId,
104-
PodImage: "weibeld/ubuntu-networking",
105-
Scenarios: scenarios,
106-
VnetSubnetCache: make(map[string]VnetSubnetInfo),
107-
NodeUsageTracker: make(map[string]map[string]bool),
102+
ResourceGroup: rg,
103+
BuildID: buildId,
104+
PodImage: "weibeld/ubuntu-networking",
105+
Scenarios: scenarios,
106+
VnetSubnetCache: make(map[string]VnetSubnetInfo),
107+
UsedNodes: make(map[string]bool),
108108
}
109109

110110
// Run indefinitely until test is cancelled
@@ -127,8 +127,8 @@ var _ = ginkgo.Describe("Datapath Tests", func() {
127127
err = DeleteAllScenarios(testScenarios)
128128
gomega.Expect(err).To(gomega.BeNil(), "Failed to delete test scenarios")
129129

130-
// Clear node usage tracker for next iteration
131-
testScenarios.NodeUsageTracker = make(map[string]map[string]bool)
130+
// Clear used nodes tracker for next iteration
131+
testScenarios.UsedNodes = make(map[string]bool)
132132

133133
ginkgo.By(fmt.Sprintf("Completed iteration %d at %s", iteration, time.Now().Format(time.RFC3339)))
134134

0 commit comments

Comments
 (0)