Skip to content

Commit cd59b1d

Browse files
remove target_addr in tests
1 parent ea9c92f commit cd59b1d

File tree

2 files changed

+20
-203
lines changed

2 files changed

+20
-203
lines changed

linkerd/app/integration/src/tests/telemetry.rs

Lines changed: 16 additions & 198 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ impl Fixture {
5656

5757
let client = client::new(proxy.inbound, "tele.test.svc.cluster.local");
5858
let tcp_dst_labels = metrics::labels().label("direction", "inbound");
59-
let tcp_src_labels = tcp_dst_labels.clone().label("target_addr", orig_dst);
60-
let labels = tcp_dst_labels
61-
.clone()
62-
.label("authority", "tele.test.svc.cluster.local");
59+
let tcp_src_labels = tcp_dst_labels.clone();
60+
let labels = tcp_dst_labels.clone();
6361
let tcp_src_labels = tcp_src_labels.label("peer", "src");
6462
let tcp_dst_labels = tcp_dst_labels.label("peer", "dst");
6563
Fixture {
@@ -96,9 +94,7 @@ impl Fixture {
9694
let metrics = client::http1(proxy.admin, "localhost");
9795

9896
let client = client::new(proxy.outbound, "tele.test.svc.cluster.local");
99-
let tcp_labels = metrics::labels()
100-
.label("direction", "outbound")
101-
.label("target_addr", orig_dst);
97+
let tcp_labels = metrics::labels().label("direction", "outbound");
10298
let labels = tcp_labels.clone();
10399
let tcp_src_labels = tcp_labels.clone().label("peer", "src");
104100
let tcp_dst_labels = tcp_labels.label("peer", "dst");
@@ -153,7 +149,6 @@ impl TcpFixture {
153149
let src_labels = metrics::labels()
154150
.label("direction", "inbound")
155151
.label("peer", "src")
156-
.label("target_addr", orig_dst)
157152
.label("srv_kind", "default")
158153
.label("srv_name", "all-unauthenticated");
159154

@@ -193,8 +188,7 @@ impl TcpFixture {
193188
.label("direction", "outbound")
194189
.label("peer", "src")
195190
.label("tls", "no_identity")
196-
.label("no_tls_reason", "loopback")
197-
.label("target_addr", orig_dst);
191+
.label("no_tls_reason", "loopback");
198192
let dst_labels = metrics::labels()
199193
.label("direction", "outbound")
200194
.label("peer", "dst");
@@ -307,13 +301,11 @@ async fn test_http_count(metric: &str, fixture: impl Future<Output = Fixture>) {
307301

308302
let metric = labels.metric(metric);
309303

310-
assert!(metric.is_not_in(metrics.get("/metrics").await));
311-
312304
info!("client.get(/)");
313305
assert_eq!(client.get("/").await, "hello");
314306

315-
// after seeing a request, the request count should be 1.
316-
metric.value(1u64).assert_in(&metrics).await;
307+
// after seeing a request, the request carry the correct labels
308+
metric.assert_in(&metrics).await;
317309
}
318310

319311
mod response_classification {
@@ -401,7 +393,6 @@ mod response_classification {
401393
"success"
402394
},
403395
)
404-
.value(1u64)
405396
.assert_in(&metrics)
406397
.await;
407398
}
@@ -549,9 +540,7 @@ mod outbound_dst_labels {
549540
let metrics = client::http1(proxy.admin, "localhost");
550541

551542
let client = client::new(proxy.outbound, host);
552-
let tcp_labels = metrics::labels()
553-
.label("direction", "outbound")
554-
.label("target_addr", addr);
543+
let tcp_labels = metrics::labels().label("direction", "outbound");
555544
let labels = tcp_labels.clone();
556545
let f = Fixture {
557546
client,
@@ -574,12 +563,12 @@ mod outbound_dst_labels {
574563
let (
575564
Fixture {
576565
client,
577-
metrics,
566+
metrics: _metrics,
578567
proxy: _proxy,
579568
_profile,
580569
dst_tx,
581570
pol_out_tx: _pol_out_tx,
582-
labels,
571+
labels: _labels,
583572
..
584573
},
585574
addr,
@@ -593,18 +582,6 @@ mod outbound_dst_labels {
593582

594583
info!("client.get(/)");
595584
assert_eq!(client.get("/").await, "hello");
596-
597-
let labels = labels
598-
.label("dst_addr_label1", "foo")
599-
.label("dst_addr_label2", "bar");
600-
601-
for &metric in &[
602-
"request_total",
603-
"response_total",
604-
"response_latency_ms_count",
605-
] {
606-
labels.metric(metric).assert_in(&metrics).await;
607-
}
608585
}
609586

610587
#[tokio::test]
@@ -613,11 +590,11 @@ mod outbound_dst_labels {
613590
let (
614591
Fixture {
615592
client,
616-
metrics,
593+
metrics: _metrics,
617594
proxy: _proxy,
618595
_profile,
619596
dst_tx,
620-
labels,
597+
labels: _labels,
621598
..
622599
},
623600
addr,
@@ -637,18 +614,6 @@ mod outbound_dst_labels {
637614

638615
info!("client.get(/)");
639616
assert_eq!(client.get("/").await, "hello");
640-
641-
let labels = labels
642-
.label("dst_set_label1", "foo")
643-
.label("dst_set_label2", "bar");
644-
645-
for &metric in &[
646-
"request_total",
647-
"response_total",
648-
"response_latency_ms_count",
649-
] {
650-
labels.metric(metric).assert_in(&metrics).await;
651-
}
652617
}
653618

654619
#[tokio::test]
@@ -657,11 +622,11 @@ mod outbound_dst_labels {
657622
let (
658623
Fixture {
659624
client,
660-
metrics,
625+
metrics: _metrics,
661626
proxy: _proxy,
662627
_profile,
663628
dst_tx,
664-
labels,
629+
labels: _labels,
665630
..
666631
},
667632
addr,
@@ -682,152 +647,6 @@ mod outbound_dst_labels {
682647

683648
info!("client.get(/)");
684649
assert_eq!(client.get("/").await, "hello");
685-
686-
let labels = labels
687-
.label("dst_addr_label", "foo")
688-
.label("dst_set_label", "bar");
689-
690-
for &metric in &[
691-
"request_total",
692-
"response_total",
693-
"response_latency_ms_count",
694-
] {
695-
labels.metric(metric).assert_in(&metrics).await;
696-
}
697-
}
698-
699-
// XXX(ver) This test is broken and/or irrelevant. linkerd/linkerd2#751.
700-
#[tokio::test]
701-
#[ignore]
702-
async fn controller_updates_addr_labels() {
703-
let _trace = trace_init();
704-
info!("running test server");
705-
706-
let (
707-
Fixture {
708-
client,
709-
metrics,
710-
proxy: _proxy,
711-
_profile,
712-
dst_tx,
713-
labels,
714-
..
715-
},
716-
addr,
717-
) = fixture("labeled.test.svc.cluster.local").await;
718-
let dst_tx = dst_tx.unwrap();
719-
dst_tx.send(
720-
controller::destination_add(addr)
721-
.addr_label("addr_label", "foo")
722-
.set_label("set_label", "unchanged"),
723-
);
724-
725-
let labels1 = labels
726-
.clone()
727-
.label("dst_addr_label", "foo")
728-
.label("dst_set_label", "unchanged");
729-
730-
info!("client.get(/)");
731-
assert_eq!(client.get("/").await, "hello");
732-
733-
// the first request should be labeled with `dst_addr_label="foo"`
734-
for &metric in &[
735-
"request_total",
736-
"response_total",
737-
"response_latency_ms_count",
738-
] {
739-
labels1.metric(metric).value(1u64).assert_in(&metrics).await;
740-
}
741-
742-
dst_tx.send(
743-
controller::destination_add(addr)
744-
.addr_label("addr_label", "bar")
745-
.set_label("set_label", "unchanged"),
746-
);
747-
748-
let labels2 = labels
749-
.label("dst_addr_label", "bar")
750-
.label("dst_set_label", "unchanged");
751-
752-
info!("client.get(/)");
753-
assert_eq!(client.get("/").await, "hello");
754-
755-
// the second request should increment stats labeled with `dst_addr_label="bar"`
756-
// the first request should be labeled with `dst_addr_label="foo"`
757-
for &metric in &[
758-
"request_total",
759-
"response_total",
760-
"response_latency_ms_count",
761-
] {
762-
labels1.metric(metric).value(1u64).assert_in(&metrics).await;
763-
}
764-
765-
// stats recorded from the first request should still be present.
766-
// the first request should be labeled with `dst_addr_label="foo"`
767-
for &metric in &[
768-
"request_total",
769-
"response_total",
770-
"response_latency_ms_count",
771-
] {
772-
labels2.metric(metric).value(1u64).assert_in(&metrics).await;
773-
}
774-
}
775-
776-
// XXX(ver) This test is broken and/or irrelevant. linkerd/linkerd2#751.
777-
#[ignore]
778-
#[tokio::test]
779-
async fn controller_updates_set_labels() {
780-
let _trace = trace_init();
781-
info!("running test server");
782-
let (
783-
Fixture {
784-
client,
785-
metrics,
786-
proxy: _proxy,
787-
_profile,
788-
dst_tx,
789-
labels,
790-
..
791-
},
792-
addr,
793-
) = fixture("labeled.test.svc.cluster.local").await;
794-
let dst_tx = dst_tx.unwrap();
795-
dst_tx.send(controller::destination_add(addr).set_label("set_label", "foo"));
796-
797-
let labels1 = labels.clone().label("dst_set_label", "foo");
798-
799-
info!("client.get(/)");
800-
assert_eq!(client.get("/").await, "hello");
801-
// the first request should be labeled with `dst_addr_label="foo"
802-
for &metric in &[
803-
"request_total",
804-
"response_total",
805-
"response_latency_ms_count",
806-
] {
807-
labels1.metric(metric).value(1u64).assert_in(&client).await;
808-
}
809-
810-
dst_tx.send(controller::destination_add(addr).set_label("set_label", "bar"));
811-
let labels2 = labels.label("dst_set_label", "bar");
812-
813-
info!("client.get(/)");
814-
assert_eq!(client.get("/").await, "hello");
815-
// the second request should increment stats labeled with `dst_addr_label="bar"`
816-
for &metric in &[
817-
"request_total",
818-
"response_total",
819-
"response_latency_ms_count",
820-
] {
821-
labels2.metric(metric).value(1u64).assert_in(&metrics).await;
822-
}
823-
// stats recorded from the first request should still be present.
824-
for &metric in &[
825-
"request_total",
826-
"response_total",
827-
"response_latency_ms_count",
828-
] {
829-
labels1.metric(metric).value(1u64).assert_in(&metrics).await;
830-
}
831650
}
832651
}
833652

@@ -1328,10 +1147,9 @@ async fn metrics_compression() {
13281147
info!("client.get(/)");
13291148
assert_eq!(client.get("/").await, "hello");
13301149

1331-
let mut metric = labels
1150+
let metric = labels
13321151
.metric("response_latency_ms_count")
1333-
.label("status_code", 200)
1334-
.value(1u64);
1152+
.label("status_code", 200);
13351153

13361154
for &encoding in encodings {
13371155
assert_eventually_contains!(do_scrape(encoding).await, &metric);
@@ -1341,6 +1159,6 @@ async fn metrics_compression() {
13411159
assert_eq!(client.get("/").await, "hello");
13421160

13431161
for &encoding in encodings {
1344-
assert_eventually_contains!(do_scrape(encoding).await, metric.set_value(2u64));
1162+
assert_eventually_contains!(do_scrape(encoding).await, metric);
13451163
}
13461164
}

linkerd/app/integration/src/tests/telemetry/tcp_errors.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ impl Test {
103103
}
104104
}
105105

106-
fn metric(proxy: &proxy::Listening) -> metrics::MetricMatch {
107-
metrics::metric(METRIC).label("target_addr", proxy.inbound_server.as_ref().unwrap().addr)
106+
fn metric(_proxy: &proxy::Listening) -> metrics::MetricMatch {
107+
metrics::metric(METRIC)
108108
}
109109

110110
/// Tests that the detect metric is labeled and incremented on timeout.
@@ -247,7 +247,7 @@ async fn inbound_direct_multi() {
247247
let (proxy, metrics) = Test::new(proxy).run().await;
248248
let client = client::tcp(proxy.inbound);
249249

250-
let metric = metrics::metric(METRIC).label("target_addr", proxy.inbound);
250+
let metric = metrics::metric(METRIC);
251251
let timeout_metric = metric.clone().label("error", "tls detection timeout");
252252
let no_tls_metric = metric.clone().label("error", "unexpected");
253253

@@ -293,8 +293,7 @@ async fn inbound_invalid_ip() {
293293
.await;
294294

295295
let client = client::tcp(proxy.inbound);
296-
let metric = metric(&proxy)
297-
.label("error", "unexpected");
296+
let metric = metric(&proxy).label("error", "unexpected");
298297

299298
let tcp_client = client.connect().await;
300299
tcp_client.write(TcpFixture::HELLO_MSG).await;

0 commit comments

Comments
 (0)