kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danburk...@apache.org
Subject [1/3] kudu git commit: [flaky tests] Fix ClientTest.TestFailedDnsResolution
Date Tue, 11 Oct 2016 00:32:41 GMT
Repository: kudu
Updated Branches:
  refs/heads/master ac519fde8 -> 64ec12149


[flaky tests] Fix ClientTest.TestFailedDnsResolution

In this test we're testing that we get dns resolution error back when
a dns resolution error fails. However there is a narrow window in which
the returned error might be a master GetTabletLocations() RPC instead,
because of KUDU-1466.

This changes the test to retry until it gets the appropriate error.

Change-Id: I9fa3ceb7215d60cd23efabf729731254524e1625
Reviewed-on: http://gerrit.cloudera.org:8080/4643
Reviewed-by: Alexey Serbin <aserbin@cloudera.com>
Tested-by: David Ribeiro Alves <dralves@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/1956c9d8
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/1956c9d8
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/1956c9d8

Branch: refs/heads/master
Commit: 1956c9d8739b8374a53fceb2a5753de6151bba31
Parents: ac519fd
Author: David Alves <dralves@apache.org>
Authored: Wed Oct 5 20:53:32 2016 -0700
Committer: David Ribeiro Alves <dralves@apache.org>
Committed: Mon Oct 10 18:27:05 2016 +0000

----------------------------------------------------------------------
 src/kudu/client/client-test.cc | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/1956c9d8/src/kudu/client/client-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/client-test.cc b/src/kudu/client/client-test.cc
index 8b8456b..2919280 100644
--- a/src/kudu/client/client-test.cc
+++ b/src/kudu/client/client-test.cc
@@ -1916,21 +1916,35 @@ TEST_F(ClientTest, TestWriteTimeout) {
 TEST_F(ClientTest, TestFailedDnsResolution) {
   shared_ptr<KuduSession> session = client_->NewSession();
   ASSERT_OK(session->SetFlushMode(KuduSession::MANUAL_FLUSH));
+  const string kMasterError = "timed out after deadline expired: GetTableLocations RPC";
 
   // First time disable dns resolution.
   // Set the timeout to be short since we know it can't succeed, but not to the point where
we
   // can timeout before getting the dns error.
   {
-    google::FlagSaver saver;
-    FLAGS_fail_dns_resolution = true;
-    session->SetTimeoutMillis(500);
-    ASSERT_OK(ApplyInsertToSession(session.get(), client_table_, 1, 1, "row"));
-    Status s = session->Flush();
-    ASSERT_TRUE(s.IsIOError()) << "unexpected status: " << s.ToString();
-    gscoped_ptr<KuduError> error = GetSingleErrorFromSession(session.get());
-    ASSERT_TRUE(error->status().IsTimedOut()) << error->status().ToString();
-    ASSERT_STR_CONTAINS(error->status().ToString(),
-                        "Network error: Failed to resolve address for TS");
+    for (int i = 0;;i++) {
+      google::FlagSaver saver;
+      FLAGS_fail_dns_resolution = true;
+      session->SetTimeoutMillis(500);
+      ASSERT_OK(ApplyInsertToSession(session.get(), client_table_, 1, 1, "row"));
+      Status s = session->Flush();
+      ASSERT_TRUE(s.IsIOError()) << "unexpected status: " << s.ToString();
+      gscoped_ptr<KuduError> error = GetSingleErrorFromSession(session.get());
+      ASSERT_TRUE(error->status().IsTimedOut()) << error->status().ToString();
+
+      // Due to KUDU-1466 there is a narrow window in which the error reported might be that
the
+      // GetTableLocations RPC to the master timed out instead of the expected dns resolution
error.
+      // In that case just loop again.
+
+      if (error->status().ToString().find(kMasterError) != std::string::npos) {
+        ASSERT_LE(i, 10) << "Didn't get a dns resolution error after 10 tries.";
+        continue;
+      }
+
+      ASSERT_STR_CONTAINS(error->status().ToString(),
+                          "Network error: Failed to resolve address for TS");
+      break;
+    }
   }
 
   // Now re-enable dns resolution, the write should succeed.


Mime
View raw message