Skip to content

Commit ed65a96

Browse files
authored
tests: enable external-prometheus-deep with cleanup logic (#5779)
This PR enables the temporarily disabled external-prometheus-deep integration test. This also fixes the clean up issue by essentially moving the external-prometheus resources into `external-prometheus` which has the relevant annotation required to be deleted by `bin/test-cleanup` This PR also updates the test resource label to be `test.linkerd.io/is-test-data-plane` from `linkerd.io/is-test-data-plane` to prevent `linkerd inject` from removing it. Signed-off-by: Tarun Pothulapati <tarunpothulapati@outlook.com>
1 parent 646867d commit ed65a96

File tree

9 files changed

+34
-20
lines changed

9 files changed

+34
-20
lines changed

bin/_test-helpers.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set +e
66

77
##### Test setup helpers #####
88

9-
export default_test_names=(deep external-issuer helm-deep helm-upgrade uninstall upgrade-edge upgrade-stable)
9+
export default_test_names=(deep external-issuer external-prometheus-deep helm-deep helm-upgrade uninstall upgrade-edge upgrade-stable)
1010
export all_test_names=(cluster-domain cni-calico-deep multicluster "${default_test_names[*]}")
1111

1212
tests_usage() {
@@ -374,7 +374,7 @@ install_version() {
374374

375375
#Now we need to install the app that will be used to verify that upgrade does not break anything
376376
kubectl --context="$context" create namespace "$test_app_namespace" > /dev/null 2>&1
377-
kubectl --context="$context" label namespaces "$test_app_namespace" 'linkerd.io/is-test-data-plane'='true' > /dev/null 2>&1
377+
kubectl --context="$context" label namespaces "$test_app_namespace" 'test.linkerd.io/is-test-data-plane'='true' > /dev/null 2>&1
378378
(
379379
set -x
380380
"$linkerd_path" inject "$test_directory/testdata/upgrade_test.yaml" | kubectl --context="$context" apply --namespace="$test_app_namespace" -f - 2>&1

bin/test-cleanup

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ echo "cleaning up multicluster resources, if present [${k8s_context}]"
1919
echo "cleaning up jaeger extension resources, if present [${k8s_context}]"
2020
"$linkerd_path" jaeger uninstall 2> /dev/null | kubectl --context="$k8s_context" delete -f -
2121

22-
echo "cleaning up the all namespaces labelled with linkerd.io/is-test-data-plane"
23-
kubectl --context="$k8s_context" delete ns -l linkerd.io/is-test-data-plane
22+
echo "cleaning up the all namespaces labelled with test.linkerd.io/is-test-data-plane"
23+
kubectl --context="$k8s_context" delete ns -l test.linkerd.io/is-test-data-plane
24+
25+
echo "cleaning up cluster-scoped resources labelled with test.linkerd.io/is-test-data-plane"
26+
kubectl --context="$k8s_context" delete clusterRole,clusterRoleBindings -l test.linkerd.io/is-test-data-plane
2427

2528
echo "cleaning up linkerd resources [${k8s_context}]"
2629
"$linkerd_path" uninstall 2> /dev/null | kubectl --context="$k8s_context" delete -f -

test/integration/edges/testdata/external_prometheus/direct_edges.golden

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
\[
22
\{
33
"src": "prometheus",
4-
"src_namespace": "default",
4+
"src_namespace": "external\-prometheus",
55
"dst": "slow-cooker",
66
"dst_namespace": "{{.Ns}}",
7-
"client_id": "prometheus.default",
7+
"client_id": "prometheus.external\-prometheus",
88
"server_id": "default.{{.Ns}}",
99
"no_tls_reason": ""
1010
\},
1111
\{
1212
"src": "prometheus",
13-
"src_namespace": "default",
13+
"src_namespace": "external\-prometheus",
1414
"dst": "terminus",
1515
"dst_namespace": "{{.Ns}}",
16-
"client_id": "prometheus.default",
16+
"client_id": "prometheus.external\-prometheus",
1717
"server_id": "default.{{.Ns}}",
1818
"no_tls_reason": ""
1919
\},

test/integration/endpoints/endpoints_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestGoodEndpoints(t *testing.T) {
3838
if !TestHelper.ExternalPrometheus() {
3939
cmd = append(cmd, fmt.Sprintf("linkerd-prometheus.%s.svc.cluster.local:9090", vizNs))
4040
} else {
41-
cmd = append(cmd, "prometheus.default.svc.cluster.local:9090")
41+
cmd = append(cmd, "prometheus.external-prometheus.svc.cluster.local:9090")
4242
testDataPath += "/external_prometheus"
4343
}
4444

test/integration/endpoints/testdata/external_prometheus/linkerd_endpoints.golden

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
\[
22
\{
3-
"namespace": "default",
3+
"namespace": "external\-prometheus",
44
"ip": "\d+\.\d+\.\d+\.\d+",
55
"port": 9090,
66
"pod": "prometheus\-[a-f0-9]+\-[a-z0-9]+",
7-
"service": "prometheus.default"
7+
"service": "prometheus.external\-prometheus"
88
\},
99
\{
1010
"namespace": "{{.Ns}}",

test/integration/install_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ func TestInstallOrUpgradeCli(t *testing.T) {
429429
}
430430

431431
// Update args to use external proemtheus
432-
vizArgs = append(vizArgs, "--set", "prometheusUrl=http://prometheus.default.svc.cluster.local:9090", "--set", "prometheus.enabled=false")
432+
vizArgs = append(vizArgs, "--set", "prometheusUrl=http://prometheus.external-prometheus.svc.cluster.local:9090", "--set", "prometheus.enabled=false")
433433
}
434434

435435
// Install Linkerd Viz Extension

test/integration/stat/stat_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestCliStatForLinkerdNamespace(t *testing.T) {
4949

5050
// Retrieve Prometheus pod details
5151
if TestHelper.ExternalPrometheus() {
52-
prometheusNamespace = "default"
52+
prometheusNamespace = "external-prometheus"
5353
prometheusDeployment = "prometheus"
5454
} else {
5555
prometheusNamespace = TestHelper.GetVizNamespace()

test/integration/testdata/external_prometheus.yaml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: external-prometheus
5+
labels:
6+
test.linkerd.io/is-test-data-plane: "true"
7+
---
18
kind: ClusterRole
29
apiVersion: rbac.authorization.k8s.io/v1
310
metadata:
411
name: prometheus
12+
labels:
13+
test.linkerd.io/is-test-data-plane: "true"
514
rules:
615
- apiGroups: [""]
716
resources: ["nodes", "nodes/proxy", "pods"]
@@ -11,26 +20,28 @@ kind: ClusterRoleBinding
1120
apiVersion: rbac.authorization.k8s.io/v1
1221
metadata:
1322
name: prometheus
23+
labels:
24+
test.linkerd.io/is-test-data-plane: "true"
1425
roleRef:
1526
apiGroup: rbac.authorization.k8s.io
1627
kind: ClusterRole
1728
name: prometheus
1829
subjects:
1930
- kind: ServiceAccount
2031
name: prometheus
21-
namespace: default
32+
namespace: external-prometheus
2233
---
2334
kind: ServiceAccount
2435
apiVersion: v1
2536
metadata:
2637
name: prometheus
27-
namespace: default
38+
namespace: external-prometheus
2839
---
2940
kind: ConfigMap
3041
apiVersion: v1
3142
metadata:
3243
name: prometheus-config
33-
namespace: default
44+
namespace: external-prometheus
3445
data:
3546
prometheus.yml: |-
3647
global:
@@ -168,7 +179,7 @@ kind: Service
168179
apiVersion: v1
169180
metadata:
170181
name: prometheus
171-
namespace: default
182+
namespace: external-prometheus
172183
spec:
173184
type: ClusterIP
174185
selector:
@@ -182,7 +193,7 @@ apiVersion: apps/v1
182193
kind: Deployment
183194
metadata:
184195
name: prometheus
185-
namespace: default
196+
namespace: external-prometheus
186197
spec:
187198
replicas: 1
188199
selector:

testutil/kubernetes_helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ func (h *KubernetesHelper) CreateControlPlaneNamespaceIfNotExists(ctx context.Co
113113
}
114114

115115
// CreateDataPlaneNamespaceIfNotExists creates a dataplane namespace if it does not already exist,
116-
// with a linkerd.io/is-test-data-plane label for easier cleanup afterwards
116+
// with a test.linkerd.io/is-test-data-plane label for easier cleanup afterwards
117117
func (h *KubernetesHelper) CreateDataPlaneNamespaceIfNotExists(ctx context.Context, namespace string, annotations map[string]string) error {
118-
return h.createNamespaceIfNotExists(ctx, namespace, annotations, map[string]string{"linkerd.io/is-test-data-plane": "true"})
118+
return h.createNamespaceIfNotExists(ctx, namespace, annotations, map[string]string{"test.linkerd.io/is-test-data-plane": "true"})
119119
}
120120

121121
// KubectlApply applies a given configuration string in a namespace. If the

0 commit comments

Comments
 (0)