diff options
author | Chris Wilson <chris+github@qwirx.com> | 2015-09-20 21:31:23 +0100 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2015-09-20 21:31:23 +0100 |
commit | 2cbdea2166057c3c3996e733d78048d528fa694e (patch) | |
tree | 9ce3c62ce763884772d482b4cee47b3a5781b837 /bin | |
parent | df1a19ece5c1d308c4d08a694309592aa566611f (diff) |
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.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/bbackupd/BackupClientContext.cpp | 22 | ||||
-rw-r--r-- | bin/bbackupd/BackupClientContext.h | 11 |
2 files changed, 23 insertions, 10 deletions
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); } diff --git a/bin/bbackupd/BackupClientContext.h b/bin/bbackupd/BackupClientContext.h index 04af1645..df43a232 100644 --- a/bin/bbackupd/BackupClientContext.h +++ b/bin/bbackupd/BackupClientContext.h @@ -54,11 +54,16 @@ public: bool TcpNiceMode ); virtual ~BackupClientContext(); + private: BackupClientContext(const BackupClientContext &); -public: - virtual BackupProtocolCallable &GetConnection(); +public: + // GetConnection() will open a connection if none is currently open. + virtual BackupProtocolCallable& GetConnection(); + // GetOpenConnection() will not open a connection, just return NULL if there is + // no connection already open. + virtual BackupProtocolCallable* GetOpenConnection() const; void CloseAnyOpenConnection(); int GetTimeout() const; BackupClientDeleteList &GetDeleteList(); @@ -167,7 +172,7 @@ public: // Created: 04/19/2005 // // -------------------------------------------------------------------------- - void SetKeepAliveTime(int iSeconds); + virtual void SetKeepAliveTime(int iSeconds); // -------------------------------------------------------------------------- // |