()
| 110 | #[mz_ore::test(tokio::test(flavor = "multi_thread", worker_threads = 1))] |
| 111 | #[allow(clippy::disallowed_methods)] |
| 112 | async fn test_no_block() { |
| 113 | // We manually time out the test because it's better than relying on CI to time out, because |
| 114 | // an actual failure (as opposed to a CI timeout) causes `services.log` to be uploaded. |
| 115 | |
| 116 | // Allow the use of banned rdkafka methods, because we are just in tests. |
| 117 | #[allow(clippy::disallowed_methods)] |
| 118 | let test_case = async move { |
| 119 | println!("test_no_block: starting server"); |
| 120 | let server = test_util::TestHarness::default().start().await; |
| 121 | server |
| 122 | .enable_feature_flags(&["enable_connection_validation_syntax"]) |
| 123 | .await; |
| 124 | |
| 125 | println!("test_no_block: starting mock HTTP server"); |
| 126 | let mut schema_registry_server = MockHttpServer::new().await; |
| 127 | |
| 128 | println!("test_no_block: connecting to server"); |
| 129 | let client = server.connect().await.unwrap(); |
| 130 | |
| 131 | let slow_task = task::spawn(|| "slow_client", async move { |
| 132 | println!("test_no_block: in thread; executing create source"); |
| 133 | let result = client |
| 134 | .batch_execute(&format!( |
| 135 | "CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (URL 'http://{}') WITH (VALIDATE = false);", |
| 136 | schema_registry_server.addr, |
| 137 | )) |
| 138 | .await; |
| 139 | println!("test_no_block: in thread; create CSR conn done"); |
| 140 | result.unwrap(); |
| 141 | |
| 142 | let admin: AdminClient<_> = ClientConfig::new() |
| 143 | .set("bootstrap.servers", &*KAFKA_ADDRS) |
| 144 | .create() |
| 145 | .expect("Admin client creation failed"); |
| 146 | |
| 147 | let new_topic = NewTopic::new("foo", 1, TopicReplication::Fixed(1)); |
| 148 | let topic_results = admin |
| 149 | .create_topics([&new_topic], &AdminOptions::new()) |
| 150 | .await |
| 151 | .expect("topic creation failed"); |
| 152 | match topic_results[0] { |
| 153 | Ok(_) | Err((_, RDKafkaErrorCode::TopicAlreadyExists)) => {} |
| 154 | Err((ref err, _)) => panic!("failed to ensure topic: {err}"), |
| 155 | } |
| 156 | |
| 157 | let result = client |
| 158 | .batch_execute(&format!( |
| 159 | "CREATE CONNECTION kafka_conn TO KAFKA (BROKER '{}', SECURITY PROTOCOL PLAINTEXT) WITH (VALIDATE = false)", |
| 160 | &*KAFKA_ADDRS, |
| 161 | )) |
| 162 | .await; |
| 163 | println!("test_no_block: in thread; create Kafka conn done"); |
| 164 | result.unwrap(); |
| 165 | |
| 166 | let result = client |
| 167 | .batch_execute( |
| 168 | "CREATE SOURCE foo \ |
| 169 | FROM KAFKA CONNECTION kafka_conn (TOPIC 'foo') \ |
nothing calls this directly
no test coverage detected