From 2cbdea2166057c3c3996e733d78048d528fa694e Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 20 Sep 2015 21:31:23 +0100 Subject: Remove all timing dependency from test_ssl_keepalives(). This test has always been fragile, and usually fails on Travis for reasons unknown, so replace the log parsing and intercepts with simple mocking code. This doesn't cover 100% of what the old test did, including diff timer aborts and the number of blocks used by the uploaded files, but it should be completely robust. --- bin/bbackupd/BackupClientContext.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'bin/bbackupd/BackupClientContext.cpp') diff --git a/bin/bbackupd/BackupClientContext.cpp b/bin/bbackupd/BackupClientContext.cpp index 96f99806..4c0b01ce 100644 --- a/bin/bbackupd/BackupClientContext.cpp +++ b/bin/bbackupd/BackupClientContext.cpp @@ -247,6 +247,11 @@ BackupProtocolCallable &BackupClientContext::GetConnection() return *mapConnection; } +BackupProtocolCallable* BackupClientContext::GetOpenConnection() const +{ + return mapConnection.get(); +} + // -------------------------------------------------------------------------- // // Function @@ -257,18 +262,19 @@ BackupProtocolCallable &BackupClientContext::GetConnection() // -------------------------------------------------------------------------- void BackupClientContext::CloseAnyOpenConnection() { - if(mapConnection.get()) + BackupProtocolCallable* pConnection(GetOpenConnection()); + if(pConnection) { try { // Quit nicely - mapConnection->QueryFinished(); + pConnection->QueryFinished(); } catch(...) { // Ignore errors here } - + // Delete it anyway. mapConnection.reset(); } @@ -299,9 +305,10 @@ void BackupClientContext::CloseAnyOpenConnection() // -------------------------------------------------------------------------- int BackupClientContext::GetTimeout() const { - if(mapConnection.get()) + BackupProtocolCallable* pConnection(GetOpenConnection()); + if(pConnection) { - return mapConnection->GetTimeout(); + return pConnection->GetTimeout(); } return (15*60*1000); @@ -543,7 +550,8 @@ void BackupClientContext::UnManageDiffProcess() // -------------------------------------------------------------------------- void BackupClientContext::DoKeepAlive() { - if (!mapConnection.get()) + BackupProtocolCallable* pConnection(GetOpenConnection()); + if (!pConnection) { return; } @@ -559,7 +567,7 @@ void BackupClientContext::DoKeepAlive() } BOX_TRACE("KeepAliveTime reached, sending keep-alive message"); - mapConnection->QueryGetIsAlive(); + pConnection->QueryGetIsAlive(); mKeepAliveTimer.Reset(mKeepAliveTime * MILLI_SEC_IN_SEC); } -- cgit v1.2.3