This is an automated email from the ASF dual-hosted git repository.
sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new cecf8e7 Fixed race condition in C++ test
testTlsDetectPulsarSslWithHostNameValidation (#3593)
cecf8e7 is described below
commit cecf8e77f66d0ceddf726f09f4b56de2fdf1147a
Author: Matteo Merli <[email protected]>
AuthorDate: Wed Feb 13 18:28:52 2019 -0800
Fixed race condition in C++ test
testTlsDetectPulsarSslWithHostNameValidation (#3593)
### Motivation
Fixed flaky test in
`AuthPluginTest.testTlsDetectPulsarSslWithHostNameValidation`. The failure
was due to the fact that test is creating a producer asynchronously but not
waiting for the
future to be completed.
---
pulsar-client-cpp/tests/AuthPluginTest.cc | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/pulsar-client-cpp/tests/AuthPluginTest.cc
b/pulsar-client-cpp/tests/AuthPluginTest.cc
index 86a6acb..8e43ebc 100644
--- a/pulsar-client-cpp/tests/AuthPluginTest.cc
+++ b/pulsar-client-cpp/tests/AuthPluginTest.cc
@@ -140,24 +140,18 @@ TEST(AuthPluginTest, testTlsDetectPulsarSsl) {
}
TEST(AuthPluginTest, testTlsDetectPulsarSslWithHostNameValidation) {
- try {
- ClientConfiguration config = ClientConfiguration();
- config.setTlsTrustCertsFilePath(caPath);
- config.setTlsAllowInsecureConnection(false);
- config.setAuth(pulsar::AuthTls::create(clientPublicKeyPath,
clientPrivateKeyPath));
- config.setValidateHostName(true);
+ ClientConfiguration config = ClientConfiguration();
+ config.setTlsTrustCertsFilePath(caPath);
+ config.setTlsAllowInsecureConnection(false);
+ config.setValidateHostName(true);
+ config.setAuth(pulsar::AuthTls::create(clientPublicKeyPath,
clientPrivateKeyPath));
- Client client(serviceUrlTls, config);
- std::string topicName = "persistent://private/auth/test-tls-detect";
+ Client client(serviceUrlTls, config);
+ std::string topicName =
"persistent://private/auth/testTlsDetectPulsarSslWithHostNameValidation";
- Producer producer;
- Promise<Result, Producer> producerPromise;
- client.createProducerAsync(topicName,
WaitForCallbackValue<Producer>(producerPromise));
- } catch (const std::exception& ex) {
- EXPECT_EQ(ex.what(), std::string("handshake: certificate verify
failed"));
- } catch (...) {
- FAIL() << "Expected handshake: certificate verify failed";
- }
+ Producer producer;
+ Result res = client.createProducer(topicName, producer);
+ ASSERT_EQ(ResultConnectError, res);
}
TEST(AuthPluginTest, testTlsDetectHttps) {