lhotari commented on a change in pull request #9286: URL: https://github.com/apache/pulsar/pull/9286#discussion_r563602467
########## File path: pulsar-broker/src/test/java/org/apache/pulsar/client/impl/PulsarTestClient.java ########## @@ -0,0 +1,218 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pulsar.client.impl; + +import static org.testng.Assert.assertEquals; +import io.netty.channel.EventLoopGroup; +import io.netty.util.concurrent.DefaultThreadFactory; +import java.io.IOException; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; +import java.util.function.Supplier; +import org.apache.pulsar.client.api.ClientBuilder; +import org.apache.pulsar.client.api.Producer; +import org.apache.pulsar.client.api.PulsarClientException; +import org.apache.pulsar.client.api.Schema; +import org.apache.pulsar.client.impl.conf.ClientConfigurationData; +import org.apache.pulsar.client.impl.conf.ProducerConfigurationData; +import org.apache.pulsar.common.util.netty.EventLoopUtil; +import org.awaitility.Awaitility; + +/** + * A Pulsar Client that is used for testing scenarios where the different + * asynchronous operations of the client-broker interaction must be orchestrated by the test + * so that race conditions caused by the test code can be eliminated. + * + * features: + * - can override remote endpoint protocol version in a thread safe manner + * - can reject new connections from the client to the broker + * - can drop all OpSend messages after they have been added to pendingMessages and processed + * by the client. This simulates a situation where sending messages go to a "black hole". + * - can synchronize operations with the help of the pending message callback which gets + * called after the message to send out has been added to the pending messages in the client. + * + */ +public class PulsarTestClient extends PulsarClientImpl { Review comment: +1, I hope this gets addressed when I revisit the PR and remove unrelated changes. Currently the PulsarTestClient is needed to fix the flaky tests, so perhaps it could be kept in this PR after the unrelated changes have been removed? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
