@@ -34,7 +34,7 @@ func getMetricsGaugeValue(url string, name string) (int, error) {
34
34
return value , nil
35
35
}
36
36
37
- func assertAgentsAreConnected (expectedConnections int , serviceHost string , adminPort int ) func (context.Context , * testing.T , * envconf.Config ) context.Context {
37
+ func assertAgentsAreConnected (expectedConnections int , adminPort int ) func (context.Context , * testing.T , * envconf.Config ) context.Context {
38
38
return func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
39
39
client := cfg .Client ()
40
40
@@ -45,7 +45,7 @@ func assertAgentsAreConnected(expectedConnections int, serviceHost string, admin
45
45
}
46
46
47
47
for _ , agentPod := range agentPods .Items {
48
- numConnections , err := getMetricsGaugeValue (fmt .Sprintf ("%v-%v :%v/metrics" , agentPod .Name , serviceHost , adminPort ), "konnectivity_network_proxy_agent_open_server_connections" )
48
+ numConnections , err := getMetricsGaugeValue (fmt .Sprintf ("%v:%v/metrics" , agentPod .Status . PodIP , adminPort ), "konnectivity_network_proxy_agent_open_server_connections" )
49
49
if err != nil {
50
50
t .Fatalf ("couldn't get agent metric 'konnectivity_network_proxy_agent_open_server_connections' for pod %v" , agentPod .Name )
51
51
}
@@ -59,7 +59,7 @@ func assertAgentsAreConnected(expectedConnections int, serviceHost string, admin
59
59
}
60
60
}
61
61
62
- func assertServersAreConnected (expectedConnections int , serviceHost string , adminPort int ) func (context.Context , * testing.T , * envconf.Config ) context.Context {
62
+ func assertServersAreConnected (expectedConnections int , adminPort int ) func (context.Context , * testing.T , * envconf.Config ) context.Context {
63
63
return func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
64
64
client := cfg .Client ()
65
65
@@ -70,7 +70,7 @@ func assertServersAreConnected(expectedConnections int, serviceHost string, admi
70
70
}
71
71
72
72
for _ , serverPod := range serverPods .Items {
73
- numConnections , err := getMetricsGaugeValue (fmt .Sprintf ("%v-%v :%v/metrics" , serverPod .Name , serviceHost , adminPort ), "konnectivity_network_proxy_server_ready_backend_connections" )
73
+ numConnections , err := getMetricsGaugeValue (fmt .Sprintf ("%v:%v/metrics" , serverPod .Status . PodIP , adminPort ), "konnectivity_network_proxy_server_ready_backend_connections" )
74
74
if err != nil {
75
75
t .Fatalf ("couldn't get agent metric 'konnectivity_network_proxy_server_ready_backend_connections' for pod %v" , serverPod .Name )
76
76
}
@@ -83,28 +83,3 @@ func assertServersAreConnected(expectedConnections int, serviceHost string, admi
83
83
return ctx
84
84
}
85
85
}
86
-
87
- func assertAgentKnownServerCount (expectedServerCount int , serviceHost string , adminPort int ) func (context.Context , * testing.T , * envconf.Config ) context.Context {
88
- return func (ctx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
89
- client := cfg .Client ()
90
-
91
- var agentPods * corev1.PodList
92
- err := client .Resources ().List (ctx , agentPods , resources .WithLabelSelector ("k8s-app=konnectivity-agent" ))
93
- if err != nil {
94
- t .Fatalf ("couldn't get server pods: %v" , err )
95
- }
96
-
97
- for _ , agentPod := range agentPods .Items {
98
- knownServerCount , err := getMetricsGaugeValue (fmt .Sprintf ("%v-%v:%v/metrics" , agentPod .Name , serviceHost , adminPort ), "konnectivity_network_proxy_agent_known_server_count" )
99
- if err != nil {
100
- t .Fatalf ("couldn't get agent metric 'konnectivity_network_proxy_agent_known_server_count' for pod %v" , agentPod .Name )
101
- }
102
-
103
- if knownServerCount != expectedServerCount {
104
- t .Errorf ("incorrect known server count (want: %v, got: %v)" , knownServerCount , expectedServerCount )
105
- }
106
- }
107
-
108
- return ctx
109
- }
110
- }
0 commit comments