MCPcopy Create free account
hub / github.com/bitdriftlabs/pulse / elision

Function elision

pulse-proxy/src/test/integration/multi_node.rs:150–219  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

148
149#[tokio::test]
150async fn elision() {
151 let (bind_resolver, helper1, helper2) = start_multi_node().await;
152 let mut upstream1 = FakeWireUpstream::new("fake_upstream1", bind_resolver.clone()).await;
153 let mut stream1 = TcpStream::connect(bind_resolver.local_tcp_addr("inflow:tcp_1"))
154 .await
155 .unwrap();
156 let mut stream2 = TcpStream::connect(bind_resolver.local_tcp_addr("inflow:tcp_2"))
157 .await
158 .unwrap();
159
160 // 0, 9, and 19 should be reported.
161 let current_time = 1;
162 let lines = (0 .. 20)
163 .map(|i| {
164 format!(
165 "node_request.count 0 {} source=server-0\n",
166 current_time + i
167 )
168 })
169 .collect_vec();
170
171 // To avoid out of order samples we need to wait for every sample to be received before sending
172 // the next one.
173 for (i, line) in lines.iter().enumerate() {
174 if i % 2 == 0 {
175 write_all(&mut stream1, &[line]).await;
176 } else {
177 write_all(&mut stream2, &[line]).await;
178 }
179
180 helper1
181 .stats_helper()
182 .wait_for_counter_eq(
183 i as u64 + 1,
184 "pulse_proxy:pipeline:messages_routed",
185 &labels! {
186 "src" => "internode",
187 "src_type" => "processor",
188 "dest" => "populate_cache",
189 "dest_type" => "processor",
190 },
191 )
192 .await;
193 }
194
195 assert_eq!(
196 parse_carbon_metrics(&[&lines[0], &lines[9], &lines[19]]),
197 upstream1.wait_for_num_metrics(3).await
198 );
199
200 assert_eq!(
201 (current_time + 18).to_string(),
202 make_admin_request(
203 bind_resolver.local_tcp_addr("admin1"),
204 "/last_elided?metric=node_request.count"
205 )
206 .await
207 );

Callers

nothing calls this directly

Calls 7

start_multi_nodeFunction · 0.85
newFunction · 0.85
write_allFunction · 0.85
cloneMethod · 0.80
local_tcp_addrMethod · 0.80
stats_helperMethod · 0.80
shutdownMethod · 0.45

Tested by

no test coverage detected