packages feed

tmp-postgres 1.14.0.1 → 1.14.1.0

raw patch · 5 files changed

+102/−48 lines, 5 files

Files

CHANGELOG.md view
@@ -1,24 +1,38 @@ Changelog for tmp-postgres -1.7.1.0-  #35 Add Lenses for configuration.+1.14.1.0+  #122 Fix bug that would prevent temporary directory removal -1.8.0.0-  Get rid of `Partial` prefix. Add a `Complete` prefix to the internal configuration types.-  Remove the `partial` prefix.-  Expand abbreviations.-  Order the Event type creation time.+1.14.0.1+  #129 Fix resource leak in executeProcess -1.9.0.0-  #41 Configurable temporary directory.-  #59 Change EnvVars to EnvironmentVariables.+1.14.0.0+  #126 Check for an empty data directory to give a better error message+  #114 Silent postgresql.conf -1.9.0.1-  Documentation fixes.+1.13.1.2+  #124 Respect database name in withNewDbConfig -1.9.0.2-  Documentation fixes.+1.13.1.1+  #116 Don't create postgres or template1 databases in optionsToDefaultConfig +1.13.1.0+  #113 Faster shutdown using SIGQUIT and removed manual session termination.+  #115 Add password support to optionsToDefaultConfig++1.13.0.0+  #108 'startNewDBConfig' functions added and related.++1.12.0.1+  Documentation fixes++1.12.0.0+  #64 Add the 'withNewDB' and 'withNewDBConfig' functions.++1.11.0.0+  #90 Extend generated config to provide default Handles and connection timeout.+  #81 Create public Config module for better documentation organization.+ 1.10.0.0   #58 Add connection timeout.   Rename partialPlanLoggerL to loggerL.@@ -26,29 +40,21 @@   #31 A silent defaults.   #20 Include stderr in errors. -1.11.0.0-  #90 Extend generated config to provide default Handles and connection timeout.-  #81 Create public Config module for better documentation organization.--1.12.0.0-  #64 Add the 'withNewDB' and 'withNewDBConfig' functions.--1.12.0.1-  Documentation fixes--1.13.0.0-  #108 'startNewDBConfig' functions added and related.+1.9.0.2+  Documentation fixes. -1.13.1.0-  #113 Faster shutdown using SIGQUIT and removed manual session termination.-  #115 Add password support to optionsToDefaultConfig+1.9.0.1+  Documentation fixes. -1.13.1.1-  #116 Don't create postgres or template1 databases in optionsToDefaultConfig+1.9.0.0+  #41 Configurable temporary directory.+  #59 Change EnvVars to EnvironmentVariables. -1.13.1.2-  #124 Respect database name in withNewDbConfig+1.8.0.0+  Get rid of `Partial` prefix. Add a `Complete` prefix to the internal configuration types.+  Remove the `partial` prefix.+  Expand abbreviations.+  Order the Event type creation time. -1.14.0.0-  #126 Check for an empty data directory to give a better error message-  #114 Silent postgresql.conf+1.7.1.0+  #35 Add Lenses for configuration.
resource-soak-test/Main.hs view
@@ -16,9 +16,18 @@ withConn db = bracket (PG.connectPostgreSQL $ toConnectionString db ) PG.close  countPostgresProcesses :: IO Int-countPostgresProcesses = do+countPostgresProcesses = countProcesses "postgres"++countInitdbProcesses :: IO Int+countInitdbProcesses = countProcesses "initdb"++countCreatedbProcesses :: IO Int+countCreatedbProcesses = countProcesses "createdb"++countProcesses :: String -> IO Int+countProcesses processName = do   -- TODO we should restrict to child process-  (exitCode, xs, _) <-  readProcessWithExitCode "pgrep" ["postgres"] []+  (exitCode, xs, _) <-  readProcessWithExitCode "pgrep" [processName] []    unless (exitCode == ExitSuccess || exitCode == ExitFailure 1) $ throwIO exitCode @@ -35,8 +44,11 @@           }      initialContents <- listDirectory directoryPath-    initialCount <- countPostgresProcesses +    initialPostgresCount <- countPostgresProcesses+    initialInitdbCount <- countInitdbProcesses+    initialCreatedbCount <- countCreatedbProcesses+     thread <- async $ withConfig theConfig $ flip withConn $ \conn -> forever $ do       (_one :: Int) <- fmap (PG.fromOnly . head) $ PG.query_ conn "SELECT 1"       threadDelay 1000@@ -47,15 +59,35 @@     void $ waitCatch thread      finalContents <- listDirectory directoryPath-    finalCount <- countPostgresProcesses+    finalPostgresCount <- countPostgresProcesses+    finalInitdbCount <- countInitdbProcesses+    finalCreatedbCount <- countCreatedbProcesses -    unless (initialCount == finalCount) $+    unless (initialPostgresCount == finalPostgresCount) $       throwIO $ userError $ unlines         [ "failed to clean up postgres"         , "had"-        , show initialCount+        , show initialPostgresCount         , "initially and now have"-        , show finalCount+        , show finalPostgresCount+        ]++    unless (initialInitdbCount == finalInitdbCount) $+      throwIO $ userError $ unlines+        [ "failed to clean up initdb"+        , "had"+        , show initialInitdbCount+        , "initially and now have"+        , show finalInitdbCount+        ]++    unless (initialCreatedbCount == finalCreatedbCount) $+      throwIO $ userError $ unlines+        [ "failed to clean up createdb"+        , "had"+        , show initialCreatedbCount+        , "initially and now have"+        , show finalCreatedbCount         ]      unless (initialContents == finalContents) $ do
src/Database/Postgres/Temp/Internal/Config.hs view
@@ -329,7 +329,10 @@         | otherwise = throwIO e   -- I'm trying to prevent new files getting added   -- to the dir as I am deleting the files.-  removeDirectoryRecursive mainDir `catch` ignoreDirIsMissing+  let newName = mainDir <> "_removing"+  handle ignoreDirIsMissing $ uninterruptibleMask_ $ do+    renameDirectory mainDir newName+    removeDirectoryRecursive newName  -- | Either remove a 'CTemporary' directory or do nothing to a 'CPermanent' -- one.
test/Main.hs view
@@ -36,11 +36,19 @@ withNewDbConfig' config db = either throwIO pure <=<   withNewDbConfig config db - countPostgresProcesses :: IO Int-countPostgresProcesses = do+countPostgresProcesses = countProcesses "postgres"++countInitdbProcesses :: IO Int+countInitdbProcesses = countProcesses "initdb"++countCreatedbProcesses :: IO Int+countCreatedbProcesses = countProcesses "createdb"++countProcesses :: String -> IO Int+countProcesses processName = do   -- TODO we should restrict to child process-  (exitCode, xs, _) <-  readProcessWithExitCode "pgrep" ["postgres"] []+  (exitCode, xs, _) <-  readProcessWithExitCode "pgrep" [processName] []    unless (exitCode == ExitSuccess || exitCode == ExitFailure 1) $ throwIO exitCode @@ -49,6 +57,9 @@ testSuccessfulConfigNoTmp :: ConfigAndAssertion -> IO () testSuccessfulConfigNoTmp ConfigAndAssertion {..} = do   initialPostgresCount <- countPostgresProcesses+  initialInitdbCount <- countInitdbProcesses+  initialCreatedbCount <- countCreatedbProcesses+   withConfig' cConfig $ \db -> do     cAssert db     -- check for a valid connection@@ -58,6 +69,8 @@     one `shouldBe` (1 :: Int)    countPostgresProcesses `shouldReturn` initialPostgresCount+  countInitdbProcesses `shouldReturn` initialInitdbCount+  countCreatedbProcesses `shouldReturn` initialCreatedbCount  testSuccessfulConfig :: ConfigAndAssertion -> IO () testSuccessfulConfig configAssert@ConfigAndAssertion{..} = do
tmp-postgres.cabal view
@@ -1,5 +1,5 @@ name:                tmp-postgres-version:             1.14.0.1+version:             1.14.1.0 synopsis: Start and stop a temporary postgres description: Start and stop a temporary postgres. See README.md homepage:            https://github.com/jfischoff/tmp-postgres#readme