Skip to content

Commit

Permalink
remote: fix flaky collectGarbage for MITM test
Browse files Browse the repository at this point in the history
  • Loading branch information
sorki committed Dec 12, 2023
1 parent e374687 commit b233159
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions hnix-store-remote/tests-io/NixDaemonSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module NixDaemonSpec
, spec
) where

import Control.Exception (catch, SomeException)
import Control.Monad (forM_, unless, void)
import Control.Monad.Catch (MonadMask)
import Control.Monad.Conc.Class (MonadConc)
Expand Down Expand Up @@ -465,13 +466,16 @@ makeProtoSpec f flavor = around f $ do
-- clear temp gc roots so the delete works. restarting the nix daemon should also do this...
storeDir <- getStoreDir
let tempRootsDir = Data.Text.unpack $ mconcat [ Data.Text.Encoding.decodeUtf8 (unStoreDir storeDir), "/../var/nix/temproots/" ]
tempRootList <-
liftIO
$ System.Directory.listDirectory
tempRootsDir
liftIO $ forM_ tempRootList $ \entry -> do
System.Directory.removeFile
$ mconcat [ tempRootsDir, "/", entry ]
liftIO $ do
tempRootList <-
System.Directory.listDirectory tempRootsDir
forM_ tempRootList $ \entry -> do
System.Directory.removeFile
$ mconcat [ tempRootsDir, "/", entry ]
-- for MITM, the temp root might get deleted
-- by the daemon as our nested client exists
-- causing TOC/TOU flakiness
`catch` (\(_e :: SomeException) -> pure ())

GCResult{..} <-
collectGarbage
Expand Down

0 comments on commit b233159

Please sign in to comment.