on master help sign in
update test-server to test fd leaks including fsync'd db directory
commit9d8d1cd157726e2ad419753d4105e4b3f2facd5b authorAgentM <agentm@themactionfaction.com> dateSun 25 Mar 2018, 21:32 (9 years ago) parent4b80e46
1 file changed+4−8
test/Server/Main.hs+4−8
test/Server/Main.hs+4−8
@@ -14,7 +14,6 @@ import ProjectM36.IsomorphicSchema
1414import ProjectM36.Base
1515
1616import System.Exit
17−import System.IO
1817
1918import Control.Concurrent
2019import Network.Transport (EndPointAddress)
@@ -28,8 +27,6 @@ import System.Directory
2827#endif
2928
3029testList :: SessionId -> Connection -> MVar () -> Test
31−testList sessionId conn _ = TestList [testFileDescriptorCount]
32−{-
3330testList sessionId conn notificationTestMVar = TestList $ serverTests ++ sessionTests
3431 where
3532 sessionTests = map (\t -> t sessionId conn) [
@@ -47,7 +44,7 @@ testList sessionId conn notificationTestMVar = TestList $ serverTests ++ session
4744 testNotification notificationTestMVar
4845 ]
4946 serverTests = [testRequestTimeout, testFileDescriptorCount]
50−-}
47+
5148main :: IO ()
5249main = do
5350 (serverAddress, _) <- launchTestServer 0
@@ -221,18 +218,17 @@ testFileDescriptorCount :: Test
221218testFileDescriptorCount = TestCase $ do
222219 (serverAddress, serverTid) <- launchTestServer 1000
223220 unusedMVar <- newEmptyMVar
221+ startCount <- fdCount
224222 Right (sess, testConn) <- testConnection serverAddress unusedMVar
225− hPutStrLn stderr "GONK1"
226− startCount <- fdCount
227223 --add a test commit to trigger the fsync machinery
228224 executeDatabaseContextExpr sess testConn (Assign "x" (ExistingRelation relationFalse)) >>= eitherFail
229225 commit sess testConn >>= eitherFail
230226 close testConn
231227 endCount <- fdCount
232228 let fd_diff = endCount - startCount
233− hPutStrLn stderr "GONK2"
234− assertBool ("fd leak: " ++ show fd_diff) (fd_diff == 0)
229+ assertBool ("fd leak: " ++ show fd_diff) (fd_diff <= 0)
235230 killThread serverTid
231+
236232
237233-- returns the number of open file descriptors -- linux only /proc usage
238234fdCount :: IO Int