Skip to content

Commit a3d493e

Browse files
committed
fix: Round 6+7 - Remove unused code and implement TN Manager methods
Round 6: Code cleanup (3 fixes) - Remove unused appsv1 import from monitoring_chaos_test.go - Fix unused testQuery variable in monitoring_e2e_test.go - Fix iperf_test indexing: use server.Port instead of server["port"] Round 7: Implement TN Manager methods (11 fixes) - Add ConfigureVXLAN, ConfigureQoS, DiscoverNode to TNAgentClient (client.go) - Add UpdateVXLANConfig, GetVXLANConfig methods to NetworkState (enhanced_types.go) - Add UpdateQoSStrategy, GetQoSStrategy methods to NetworkState (enhanced_types.go) - Add UpdateTopology method to NetworkState (enhanced_types.go) - Add NewNetworkTopology factory function (enhanced_types.go) - Fix type conversion from []TNEndpoint to []tnv1alpha1.Endpoint (enhanced_manager.go) - Add fmt import to enhanced_types.go for error messages All methods include proper error handling and logging via security.SafeLogf. TN Manager methods are currently stub implementations with TODO comments for future HTTP API integration. Related: #CI-fixes
1 parent a8cda36 commit a3d493e

6 files changed

Lines changed: 90 additions & 7 deletions

File tree

adapters/vnf-operator/tests/chaos/monitoring_chaos_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/stretchr/testify/assert"
1414
"github.com/stretchr/testify/require"
1515
"github.com/stretchr/testify/suite"
16-
appsv1 "k8s.io/api/apps/v1"
1716
corev1 "k8s.io/api/core/v1"
1817
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1918
"k8s.io/apimachinery/pkg/util/wait"

adapters/vnf-operator/tests/e2e/monitoring_e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ var _ = Describe("O-RAN Monitoring Stack E2E Tests", func() {
296296

297297
It("should handle test alerts properly", func() {
298298
// Create test alert by triggering a known condition
299-
testQuery := "vector(1) > 0" // Always true condition
299+
_ = "vector(1) > 0" // Test query for always true condition
300300

301301
// Wait a bit for alert evaluation
302302
time.Sleep(30 * time.Second)

tn/agent/pkg/iperf_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ func (s *IperfTestSuite) TearDownTest() {
4444
if s.manager != nil {
4545
servers := s.manager.GetActiveServers()
4646
for _, server := range servers {
47-
if port, ok := server["port"].(int); ok {
48-
s.manager.StopServer(port)
49-
}
47+
s.manager.StopServer(server.Port)
5048
}
5149
}
5250

tn/manager/pkg/client.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,4 +268,27 @@ func (client *TNAgentClient) Ping() error {
268268
}
269269

270270
return nil
271-
}
271+
}
272+
// ConfigureVXLAN configures VXLAN tunnel on the agent
273+
func (client *TNAgentClient) ConfigureVXLAN(sliceID string, config interface{}) error {
274+
security.SafeLogf(client.logger, "Configuring VXLAN for slice %s", security.SanitizeForLog(sliceID))
275+
// TODO: Implement actual VXLAN configuration via HTTP API
276+
// For now, return nil as stub implementation
277+
return nil
278+
}
279+
280+
// ConfigureQoS configures QoS settings on the agent
281+
func (client *TNAgentClient) ConfigureQoS(sliceID string, config interface{}) error {
282+
security.SafeLogf(client.logger, "Configuring QoS for slice %s", security.SanitizeForLog(sliceID))
283+
// TODO: Implement actual QoS configuration via HTTP API
284+
// For now, return nil as stub implementation
285+
return nil
286+
}
287+
288+
// DiscoverNode performs node discovery on the agent
289+
func (client *TNAgentClient) DiscoverNode() (interface{}, error) {
290+
security.SafeLog(client.logger, "Performing node discovery")
291+
// TODO: Implement actual node discovery via HTTP API
292+
// For now, return nil as stub implementation
293+
return nil, nil
294+
}

tn/manager/pkg/enhanced_manager.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,14 @@ func (etm *EnhancedTNManager) ConfigureVXLANDynamic(ctx context.Context, sliceID
5151
return fmt.Errorf("invalid VXLAN configuration: %w", err)
5252
}
5353

54+
// Convert TNEndpoint to tnv1alpha1.Endpoint
55+
endpoints := make([]tnv1alpha1.Endpoint, len(config.Endpoints))
56+
for i, ep := range config.Endpoints {
57+
endpoints[i] = ep.Endpoint
58+
}
59+
5460
// Generate tunnel configurations
55-
tunnelConfigs := etm.vxlanOrchestrator.GenerateTunnelConfigs(config.VxlanID, config.Endpoints)
61+
tunnelConfigs := etm.vxlanOrchestrator.GenerateTunnelConfigs(config.VxlanID, endpoints)
5662

5763
// Deploy configurations to agents
5864
etm.mu.RLock()

tn/manager/pkg/enhanced_types.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package pkg
22

33
import (
4+
"fmt"
45
"log"
56
"sync"
67
"time"
@@ -150,6 +151,16 @@ type NetworkTopology struct {
150151
mutex sync.RWMutex
151152
}
152153

154+
// NewNetworkTopology creates a new NetworkTopology instance
155+
func NewNetworkTopology() *NetworkTopology {
156+
return &NetworkTopology{
157+
Nodes: make(map[string]*TopologyNode),
158+
Links: make(map[string]*TopologyLink),
159+
LastUpdated: time.Now(),
160+
Version: "1.0.0",
161+
}
162+
}
163+
153164
// TopologyNode represents a node in the network
154165
type TopologyNode struct {
155166
Name string `json:"name"`
@@ -450,3 +461,49 @@ func NewNetworkState() *NetworkState {
450461
activeSlices: make(map[string]*SliceState),
451462
}
452463
}
464+
465+
// UpdateVXLANConfig updates VXLAN configuration for a slice
466+
func (ns *NetworkState) UpdateVXLANConfig(sliceID string, config *DynamicVXLANConfig) error {
467+
ns.mutex.Lock()
468+
defer ns.mutex.Unlock()
469+
ns.sliceConfigs[sliceID] = config
470+
return nil
471+
}
472+
473+
// GetVXLANConfig retrieves VXLAN configuration for a slice
474+
func (ns *NetworkState) GetVXLANConfig(sliceID string) (*DynamicVXLANConfig, error) {
475+
ns.mutex.RLock()
476+
defer ns.mutex.RUnlock()
477+
config, exists := ns.sliceConfigs[sliceID]
478+
if !exists {
479+
return nil, fmt.Errorf("VXLAN config not found for slice %s", sliceID)
480+
}
481+
return config, nil
482+
}
483+
484+
// UpdateQoSStrategy updates QoS strategy for a slice
485+
func (ns *NetworkState) UpdateQoSStrategy(sliceID string, strategy *QoSStrategy) error {
486+
ns.mutex.Lock()
487+
defer ns.mutex.Unlock()
488+
ns.qosStrategies[sliceID] = strategy
489+
return nil
490+
}
491+
492+
// GetQoSStrategy retrieves QoS strategy for a slice
493+
func (ns *NetworkState) GetQoSStrategy(sliceID string) (*QoSStrategy, error) {
494+
ns.mutex.RLock()
495+
defer ns.mutex.RUnlock()
496+
strategy, exists := ns.qosStrategies[sliceID]
497+
if !exists {
498+
return nil, fmt.Errorf("QoS strategy not found for slice %s", sliceID)
499+
}
500+
return strategy, nil
501+
}
502+
503+
// UpdateTopology updates the network topology
504+
func (ns *NetworkState) UpdateTopology(topology *NetworkTopology) error {
505+
ns.mutex.Lock()
506+
defer ns.mutex.Unlock()
507+
ns.topology = topology
508+
return nil
509+
}

0 commit comments

Comments
 (0)