MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / test_load_generator

Function test_load_generator

src/environmentd/tests/sql.rs:2141–2184  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2139#[mz_ore::test]
2140#[allow(clippy::disallowed_methods)]
2141fn test_load_generator() {
2142 let server = test_util::TestHarness::default()
2143 .unsafe_mode()
2144 .start_blocking();
2145 server.enable_feature_flags(&[
2146 "enable_create_table_from_source",
2147 "enable_load_generator_counter",
2148 ]);
2149 let mut client = server.connect(postgres::NoTls).unwrap();
2150
2151 client
2152 .batch_execute("CREATE SOURCE counter FROM LOAD GENERATOR COUNTER (TICK INTERVAL '1ms')")
2153 .unwrap();
2154
2155 client
2156 .batch_execute("CREATE TABLE counter_tbl FROM SOURCE counter")
2157 .unwrap();
2158
2159 let row = client
2160 .query_one("SELECT count(*), mz_now()::text FROM counter_tbl", &[])
2161 .unwrap();
2162 let initial_count: i64 = row.get(0);
2163 let timestamp_millis: String = row.get(1);
2164 let timestamp_millis: i64 = timestamp_millis.parse().unwrap();
2165 const WAIT: i64 = 100;
2166 let next = timestamp_millis + WAIT;
2167 let expect = initial_count + WAIT;
2168 Retry::default()
2169 .retry(|_| {
2170 let row = client
2171 .query_one(
2172 &format!("SELECT count(*) FROM counter_tbl AS OF AT LEAST {next}"),
2173 &[],
2174 )
2175 .unwrap();
2176 let count: i64 = row.get(0);
2177 if count < expect {
2178 Err(format!("expected {expect}, got {count}"))
2179 } else {
2180 Ok(())
2181 }
2182 })
2183 .unwrap();
2184}
2185
2186#[mz_ore::test]
2187#[allow(clippy::disallowed_methods)]

Callers

nothing calls this directly

Calls 10

start_blockingMethod · 0.80
unsafe_modeMethod · 0.80
enable_feature_flagsMethod · 0.80
unwrapMethod · 0.80
batch_executeMethod · 0.80
connectMethod · 0.45
query_oneMethod · 0.45
getMethod · 0.45
parseMethod · 0.45
retryMethod · 0.45

Tested by

no test coverage detected