Skip to content

Commit 0e365ee

Browse files
committed
Switch out StatefulSet for Deployment
1 parent 84c06a0 commit 0e365ee

File tree

6 files changed

+32
-254
lines changed

6 files changed

+32
-254
lines changed

e2e/lease_count_test.go

Lines changed: 0 additions & 192 deletions
This file was deleted.

e2e/main_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type KeyValue struct {
8888
Value string
8989
}
9090

91-
type StatefulSetConfig struct {
91+
type DeploymentConfig struct {
9292
Replicas int
9393
Image string
9494
Args []KeyValue
@@ -156,21 +156,21 @@ func renderAndApplyManifests(ctx context.Context, cfg *envconf.Config) (context.
156156
return ctx, nil
157157
}
158158

159-
func deployAndWaitForStatefulSet(statefulSet client.Object) func(context.Context, *testing.T, *envconf.Config) context.Context {
159+
func deployAndWaitForDeployment(deployment client.Object) func(context.Context, *testing.T, *envconf.Config) context.Context {
160160
return func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
161161
client := cfg.Client()
162-
err := client.Resources().Create(ctx, statefulSet)
162+
err := client.Resources().Create(ctx, deployment)
163163
if err != nil {
164-
t.Fatalf("could not create StatefulSet: %v", err)
164+
t.Fatalf("could not create Deployment: %v", err)
165165
}
166166

167167
err = wait.For(
168-
conditions.New(client.Resources()).DeploymentAvailable(statefulSet.GetName(), statefulSet.GetNamespace()),
168+
conditions.New(client.Resources()).DeploymentAvailable(deployment.GetName(), deployment.GetNamespace()),
169169
wait.WithTimeout(1*time.Minute),
170170
wait.WithInterval(10*time.Second),
171171
)
172172
if err != nil {
173-
t.Fatalf("waiting for StatefulSet deployment failed: %v", err)
173+
t.Fatalf("waiting for Deployment failed: %v", err)
174174
}
175175

176176
return ctx

e2e/metrics_assertions_test.go

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func getMetricsGaugeValue(url string, name string) (int, error) {
3434
return value, nil
3535
}
3636

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 {
3838
return func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
3939
client := cfg.Client()
4040

@@ -45,7 +45,7 @@ func assertAgentsAreConnected(expectedConnections int, serviceHost string, admin
4545
}
4646

4747
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")
4949
if err != nil {
5050
t.Fatalf("couldn't get agent metric 'konnectivity_network_proxy_agent_open_server_connections' for pod %v", agentPod.Name)
5151
}
@@ -59,7 +59,7 @@ func assertAgentsAreConnected(expectedConnections int, serviceHost string, admin
5959
}
6060
}
6161

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 {
6363
return func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
6464
client := cfg.Client()
6565

@@ -70,7 +70,7 @@ func assertServersAreConnected(expectedConnections int, serviceHost string, admi
7070
}
7171

7272
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")
7474
if err != nil {
7575
t.Fatalf("couldn't get agent metric 'konnectivity_network_proxy_server_ready_backend_connections' for pod %v", serverPod.Name)
7676
}
@@ -83,28 +83,3 @@ func assertServersAreConnected(expectedConnections int, serviceHost string, admi
8383
return ctx
8484
}
8585
}
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

Comments
 (0)