You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2022/10/12 21:30:07 UTC

[kudu] branch master updated: [test] ASSERT_OK instead of CHECK_OK when appropriate

This is an automated email from the ASF dual-hosted git repository.

alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new f55c80e75 [test] ASSERT_OK instead of CHECK_OK when appropriate
f55c80e75 is described below

commit f55c80e75848461eef21c3cdb6f43d907999bfdf
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Mon Aug 29 15:08:53 2022 -0700

    [test] ASSERT_OK instead of CHECK_OK when appropriate
    
    Recently I ran a few tests in FIPS environment, and even if those were
    expected to fail because our test scenarios use very short encryption
    keys to run faster (compared with minimum allowed encryption key size
    required by FIPS 140-2), I was unpleasantly surprised that some of those
    simply crashed instead of exiting gracefully and reporting an error.
    
    This patch addresses that for rpc-test and tls_socket-test.
    
    Change-Id: I48d9bb2def2350c11afc41b9f08fa252c7ead65a
    Reviewed-on: http://gerrit.cloudera.org:8080/19134
    Reviewed-by: Attila Bukor <ab...@apache.org>
    Tested-by: Kudu Jenkins
---
 src/kudu/rpc/rpc-test.cc             | 16 +++++++++++-----
 src/kudu/security/tls_socket-test.cc |  2 +-
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/kudu/rpc/rpc-test.cc b/src/kudu/rpc/rpc-test.cc
index 78403f1dd..67fb75028 100644
--- a/src/kudu/rpc/rpc-test.cc
+++ b/src/kudu/rpc/rpc-test.cc
@@ -29,6 +29,7 @@
 #include <string>
 #include <thread>
 #include <tuple>
+#include <type_traits>
 #include <unordered_map>
 #include <utility>
 #include <vector>
@@ -42,7 +43,6 @@
 #include "kudu/gutil/ref_counted.h"
 #include "kudu/gutil/stl_util.h"
 #include "kudu/gutil/strings/substitute.h"
-#include "kudu/rpc/acceptor_pool.h"
 #include "kudu/rpc/constants.h"
 #include "kudu/rpc/messenger.h"
 #include "kudu/rpc/outbound_call.h"
@@ -73,6 +73,12 @@
 #include "kudu/util/test_macros.h"
 #include "kudu/util/test_util.h"
 
+namespace kudu {
+namespace rpc {
+class AcceptorPool;
+}  // namespace rpc
+}  // namespace kudu
+
 METRIC_DECLARE_counter(queue_overflow_rejections_kudu_rpc_test_CalculatorService_Sleep);
 METRIC_DECLARE_histogram(handler_latency_kudu_rpc_test_CalculatorService_Sleep);
 METRIC_DECLARE_histogram(rpc_incoming_queue_time);
@@ -201,7 +207,7 @@ TEST_P(TestRpc, TestNegotiationDeadlock) {
   if (enable_ssl()) mb.enable_inbound_tls();
 
   shared_ptr<Messenger> messenger;
-  CHECK_OK(mb.Build(&messenger));
+  ASSERT_OK(mb.Build(&messenger));
 
   Sockaddr server_addr = bind_addr();
   ASSERT_OK(StartTestServerWithCustomMessenger(&server_addr, messenger, enable_ssl()));
@@ -439,7 +445,7 @@ TEST_P(TestRpc, TestHighFDs) {
   ElementDeleter d(&fake_files);
   for (int i = 0; i < kNumFakeFiles; i++) {
     unique_ptr<RandomAccessFile> f;
-    CHECK_OK(Env::Default()->NewRandomAccessFile("/dev/zero", &f));
+    ASSERT_OK(Env::Default()->NewRandomAccessFile("/dev/zero", &f));
     fake_files.push_back(f.release());
   }
 
@@ -576,7 +582,7 @@ TEST_P(TestRpc, TestClientConnectionMetrics) {
       // Attach a big sidecar so that we are less likely to be able to send the
       // whole RPC in a single write() call without queueing it.
       int junk;
-      CHECK_OK(rpc->AddOutboundSidecar(RpcSidecar::FromSlice(big_string), &junk));
+      ASSERT_OK(rpc->AddOutboundSidecar(RpcSidecar::FromSlice(big_string), &junk));
       controllers.emplace_back(std::move(rpc));
       p.AsyncRequest(GenericCalculatorService::kAddMethodName, add_req, &add_resp,
                      controllers.back().get(), [&latch]() { latch.CountDown(); });
@@ -1464,7 +1470,7 @@ TEST_P(TestRpc, TestCancellationAsync) {
 
     int idx;
     Slice s(payload.get(), TEST_PAYLOAD_SIZE);
-    CHECK_OK(controller.AddOutboundSidecar(RpcSidecar::FromSlice(s), &idx));
+    ASSERT_OK(controller.AddOutboundSidecar(RpcSidecar::FromSlice(s), &idx));
     req.set_sidecar_idx(idx);
 
     CountDownLatch latch(1);
diff --git a/src/kudu/security/tls_socket-test.cc b/src/kudu/security/tls_socket-test.cc
index 53b1185db..37e8fee18 100644
--- a/src/kudu/security/tls_socket-test.cc
+++ b/src/kudu/security/tls_socket-test.cc
@@ -218,7 +218,7 @@ void handler(int /* signal */) {}
 // contain the address of the remote.
 TEST_F(TlsSocketTest, TestRecvFailure) {
   EchoServer server;
-  server.Start();
+  NO_FATALS(server.Start());
   unique_ptr<Socket> client_sock;
   NO_FATALS(ConnectClient(server.listen_addr(), &client_sock));
   unique_ptr<uint8_t[]> buf(new uint8_t[kEchoChunkSize]);