From d0a8e3d6217f2924b864393d425b6d7582370d07 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 1 Aug 2014 17:52:40 -0400 Subject: testremote now tests with and without encryption --- Command/TestRemote.hs | 33 +++++++++++++++++++++++---------- doc/git-annex.mdwn | 4 ++++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Command/TestRemote.hs b/Command/TestRemote.hs index 186d067d6..29a2e809c 100644 --- a/Command/TestRemote.hs +++ b/Command/TestRemote.hs @@ -61,7 +61,8 @@ start basesz ws = do showSideAction "generating test keys" ks <- mapM randKey (keySizes basesz) rs <- catMaybes <$> mapM (adjustChunkSize r) (chunkSizes basesz) - next $ perform rs ks + rs' <- concat <$> mapM encryptionVariants rs + next $ perform rs' ks perform :: [Remote] -> [Key] -> CommandPerform perform rs ks = do @@ -73,20 +74,32 @@ perform rs ks = do Just act -> liftIO act next $ cleanup rs ks ok where - desc r' k = unwords - [ "key size" - , show (keySize k) - , "chunk size" - , show (chunkConfig (Remote.config r')) + desc r' k = intercalate "; " $ map unwords + [ [ "key size", show (keySize k) ] + , [ show (chunkConfig (Remote.config r')) ] + , ["encryption", fromMaybe "none" (M.lookup "encryption" (Remote.config r'))] ] --- To adjust a Remote to use a new chunk size, have to re-generate it with --- a modified config. adjustChunkSize :: Remote -> Int -> Annex (Maybe Remote) -adjustChunkSize r chunksize = Remote.generate (Remote.remotetype r) +adjustChunkSize r chunksize = adjustRemoteConfig r + (M.insert "chunk" (show chunksize)) + +-- Variants of a remote with no encryption, and with simple shared +-- encryption. Gpg key based encryption is not tested. +encryptionVariants :: Remote -> Annex [Remote] +encryptionVariants r = do + noenc <- adjustRemoteConfig r (M.insert "encryption" "none") + sharedenc <- adjustRemoteConfig r $ + M.insert "encryption" "shared" . + M.insert "highRandomQuality" "false" + return $ catMaybes [noenc, sharedenc] + +-- Regenerate a remote with a modified config. +adjustRemoteConfig :: Remote -> (Remote.RemoteConfig -> Remote.RemoteConfig) -> Annex (Maybe Remote) +adjustRemoteConfig r adjustconfig = Remote.generate (Remote.remotetype r) (Remote.repo r) (Remote.uuid r) - (M.insert "chunk" (show chunksize) (Remote.config r)) + (adjustconfig (Remote.config r)) (Remote.gitconfig r) test :: Annex.AnnexState -> Remote -> Key -> [TestTree] diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index de5e04233..ba851eef8 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -976,6 +976,10 @@ subdirectories). The --size option can be used to tune the size of the generated objects. + Testing a single remote will use the remote's configuration, + automatically varying the chunk sizes, and with simple shared encryption + enabled and disabled. + * `fuzztest` Generates random changes to files in the current repository, -- cgit v1.2.3