Skip to content

Commit 8a14815

Browse files
Copilotkhauser
andcommitted
Fix code review comments - update service targetPort and test improvements
Co-authored-by: khauser <1460475+khauser@users.noreply.github.com> Signed-off-by: Karsten Ludwig Hauser <KHauser@intershop.com>
1 parent 21ba954 commit 8a14815

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

config/operator/metrics_service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ spec:
88
- name: metrics
99
protocol: TCP
1010
port: 8443
11-
targetPort: metrics
11+
targetPort: 8443

tests/checks/operator_metrics/operator_metrics_test.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ var (
2323
testNamespace = fmt.Sprintf("%s-ns", testName)
2424
clientName = fmt.Sprintf("%s-client", testName)
2525
kedaOperatorMetricsURL = "https://keda-add-ons-http-operator-metrics.keda:8443/metrics"
26-
kedaOperatorMetricsHTTPURL = "http://keda-add-ons-http-operator-metrics.keda:8443/metrics"
2726
operatorPodSelector = "app.kubernetes.io/instance=operator"
2827
)
2928

@@ -88,12 +87,8 @@ func TestOperatorMetrics(t *testing.T) {
8887
t.Log("Test 1: Verify HTTPS endpoint is available")
8988
testHTTPSEndpoint(t)
9089

91-
// Test 2: HTTP should not work (redirected or refused)
92-
t.Log("Test 2: Verify HTTP endpoint is not accessible")
93-
testHTTPEndpointNotAccessible(t)
94-
95-
// Test 3: Verify metrics are returned
96-
t.Log("Test 3: Verify metrics content")
90+
// Test 2: Verify metrics are returned
91+
t.Log("Test 2: Verify metrics content")
9792
testMetricsContent(t)
9893

9994
// cleanup
@@ -115,16 +110,6 @@ func testHTTPSEndpoint(t *testing.T) {
115110
"HTTPS endpoint should respond (either with metrics or authentication error)")
116111
}
117112

118-
func testHTTPEndpointNotAccessible(t *testing.T) {
119-
// Try HTTP - should fail or redirect
120-
cmd := fmt.Sprintf("curl --max-time 10 %s", kedaOperatorMetricsHTTPURL)
121-
out, errOut, err := ExecCommandOnSpecificPod(t, clientName, testNamespace, cmd)
122-
123-
// HTTP should not work since we're using SecureServing
124-
assert.True(t, err != nil || strings.Contains(errOut, "Empty reply") || strings.Contains(out, "Empty reply"),
125-
"HTTP endpoint should not be accessible. Output: %s, Error: %s", out, errOut)
126-
}
127-
128113
func testMetricsContent(t *testing.T) {
129114
// Get the operator pod name
130115
pods, err := KubeClient.CoreV1().Pods("keda").List(context.Background(), metav1.ListOptions{

0 commit comments

Comments
 (0)