rds-data 0.0.0.3 → 0.0.0.4
raw patch · 3 files changed
+40/−7 lines, 3 filesdep ~hw-polysemy
Dependency ranges changed: hw-polysemy
Files
- integration/Test/Data/RdsData/Migration/ConnectionSpec.hs +8/−1
- rds-data.cabal +5/−5
- testlib/Data/RdsData/Polysemy/Test/Cluster.hs +27/−1
integration/Test/Data/RdsData/Migration/ConnectionSpec.hs view
@@ -37,11 +37,18 @@ -- cabal test rds-data-test --test-options "--pattern \"/RDS integration test/\"" tasty_rds_integration_test :: Tasty.TestTree tasty_rds_integration_test =- TC.withContainers (setupContainers' "localstack/localstack-pro:3.1.0") $ \getContainer ->+ TC.withContainers (setupContainers' "localstack/localstack-pro:latest") $ \getContainer -> H.testProperty "RDS integration test" $ propertyOnce $ localWorkspace "rds-data" $ runLocalTestEnv getContainer $ do rdsClusterDetails <- createRdsDbCluster "rds_data_migration" getContainer + dbClusterArn <- rdsClusterDetails ^. the @"createDbClusterResponse" . the @"dbCluster" . _Just . the @"dbClusterArn"+ & nothingFail+ runReaderResourceAndSecretArnsFromResponses rdsClusterDetails $ do+ waitUntilRdsDbClusterAvailable dbClusterArn+ & trapFail @AWS.Error+ & jotShowDataLog @AwsLogEntry+ initialiseDb & trapFail @RdsDataError & trapFail @AWS.Error
rds-data.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.6 name: rds-data-version: 0.0.0.3+version: 0.0.0.4 synopsis: Codecs for use with AWS rds-data description: Codecs for use with AWS rds-data. category: Data@@ -39,10 +39,10 @@ common hedgehog { build-depends: hedgehog >= 1.4 && < 2 } common hedgehog-extras { build-depends: hedgehog-extras >= 0.6.0.2 && < 0.7 } common http-client { build-depends: http-client >= 0.5.14 && < 0.8 }-common hw-polysemy-amazonka { build-depends: hw-polysemy:amazonka >= 0.2.14.2 && < 0.3 }-common hw-polysemy-core { build-depends: hw-polysemy:core >= 0.2.14.2 && < 0.3 }-common hw-polysemy-hedgehog { build-depends: hw-polysemy:hedgehog >= 0.2.14.2 && < 0.3 }-common hw-polysemy-testcontainers-localstack { build-depends: hw-polysemy:testcontainers-localstack >= 0.2.14.2 && < 0.3 }+common hw-polysemy-amazonka { build-depends: hw-polysemy:amazonka >= 0.2.14.5 && < 0.3 }+common hw-polysemy-core { build-depends: hw-polysemy:core >= 0.2.14.5 && < 0.3 }+common hw-polysemy-hedgehog { build-depends: hw-polysemy:hedgehog >= 0.2.14.5 && < 0.3 }+common hw-polysemy-testcontainers-localstack { build-depends: hw-polysemy:testcontainers-localstack >= 0.2.14.5 && < 0.3 } common microlens { build-depends: microlens >= 0.4.13 && < 0.5 } common mtl { build-depends: mtl >= 2 && < 3 } common optparse-applicative { build-depends: optparse-applicative >= 0.18.1.0 && < 0.19 }
testlib/Data/RdsData/Polysemy/Test/Cluster.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-}@@ -11,6 +12,7 @@ module Data.RdsData.Polysemy.Test.Cluster ( RdsClusterDetails(..), createRdsDbCluster,+ waitUntilRdsDbClusterAvailable, ) where import qualified Amazonka as AWS@@ -26,12 +28,14 @@ import qualified Data.Text.Encoding as T import qualified Data.UUID as UUID import qualified Data.UUID.V4 as UUID+import HaskellWorks.Control.Monad import HaskellWorks.Polysemy import HaskellWorks.Polysemy.Amazonka import HaskellWorks.Polysemy.Amazonka.LocalStack (getLocalStackEndpoint, inspectContainer)+import HaskellWorks.Polysemy.Control.Concurrent import HaskellWorks.Polysemy.Hedgehog-import HaskellWorks.Prelude+import HaskellWorks.Polysemy.Prelude import HaskellWorks.TestContainers.LocalStack import Lens.Micro @@ -108,3 +112,25 @@ & trapFail pure (RdsClusterDetails createDbClusterResponse createSecetResp)++waitUntilRdsDbClusterAvailable :: ()+ => HasCallStack+ => Member (Embed IO) r+ => Member (Error AWS.Error) r+ => Member (Reader AWS.Env) r+ => Member (DataLog AwsLogEntry) r+ => Member Resource r+ => Text+ -> Sem r ()+waitUntilRdsDbClusterAvailable dbClusterArn =+ withFrozenCallStack do+ repeatNWhileM_ 24 $ \_ -> do+ result <- sendAws $+ AWS.newDescribeDBClusters+ & the @"dbClusterIdentifier" .~ Just dbClusterArn++ let mStatus = result ^? the @"dbClusters" . _Just . each . the @"status" . _Just++ if mStatus == Just "available"+ then pure False+ else threadDelay 1_000_000 >> pure True