Skip to content

Commit

Permalink
Merge pull request #87 from input-output-hk/piotr/8/qa-review
Browse files Browse the repository at this point in the history
QA review of #8
  • Loading branch information
piotr-iohk authored Mar 19, 2019
2 parents 39b048a + 214157b commit c93b82b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
11 changes: 6 additions & 5 deletions test/manual/Cardano/Launcher/POSIXSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,25 @@ signals are correctly handled on a unix system.
11003 10983 75 09:42 pts/1 00:03:30 cardano-http-bridge start --port 8080
11071 10983 58 09:42 pts/1 00:02:41 cardano-wallet-server --wallet-server-port 8090 --http-bridge-port 8080 --network mainnet
```
- Send a `SIGTERM` signal to this pid using `kill <pid>`
- Send a `SIGTERM` signal to this pid using `kill <pid>`
- Run `ps -ef | grep cardano`, there's no more process running: the launcher,
the wallet and the chain producer have all stopped.


### `SIGKILL`

> **Disclaimer**
>
>
> The semantic of `SIGKILL` doesn't allow us to do any clean-up after receiving
> it (we can't shove a signal handler for a `SIGKILL`!). So, if one kills the
> launcher, one doesn't kill the sub-processes the launcher has started. This
> should be handled at the OS level, or via different mechanism (like, having a
> shared socket between the launcher and its children).
>
> As a consequence, sending a `SIGKILL` to the launcher will NOT terminates the
> As a consequence, sending a `SIGKILL` to the launcher will NOT terminate the
> sub-processes started by the launcher. This is, for now, a known limitation.
>
> Please note that steps below are therefore currently invalid!
- Start the launcher in background using `stack exec -- cardano-wallet-launcher &`
- Run `ps -ef | grep cardano` and lookup the `pid` of the launcher process (and
Expand All @@ -88,8 +90,7 @@ signals are correctly handled on a unix system.
11003 10983 75 09:42 pts/1 00:03:30 cardano-http-bridge start --port 8080
11071 10983 58 09:42 pts/1 00:02:41 cardano-wallet-server --wallet-server-port 8090 --http-bridge-port 8080 --network mainnet
```
- Send a `SIGKILL` signal to this pid using `kill -9 <pid>`
- Send a `SIGKILL` signal to this pid using `kill -9 <pid>`
- Run `ps -ef | grep cardano`, and control that the launcher isn't running
anymore. The wallet server and the underlying chain producer should however
still be up-and-running.

22 changes: 20 additions & 2 deletions test/unit/Cardano/LauncherSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Test.Hspec
{-# ANN spec ("HLint: ignore Use head" :: String) #-}
spec :: Spec
spec = do
it "One process exits with 0, others are cancelled" $ do
it "1st process exits with 0, others are cancelled" $ do
let commands =
[ Command "./test/data/Launcher/once.sh" ["0"] (pure ())
, Command "./test/data/Launcher/forever.sh" [] (pure ())
Expand All @@ -28,7 +28,16 @@ spec = do
name `shouldBe` cmdName (commands !! 0)
code `shouldBe` ExitSuccess

it "One process exits with 14, others are cancelled" $ do
it "2nd process exits with 0, others are cancelled" $ do
let commands =
[ Command "./test/data/Launcher/forever.sh" [] (pure ())
, Command "./test/data/Launcher/once.sh" ["0"] (pure ())
]
(ProcessHasExited name code) <- launch commands
name `shouldBe` cmdName (commands !! 1)
code `shouldBe` ExitSuccess

it "1st process exits with 14, others are cancelled" $ do
let commands =
[ Command "./test/data/Launcher/once.sh" ["14"] (pure ())
, Command "./test/data/Launcher/forever.sh" [] (pure ())
Expand All @@ -37,6 +46,15 @@ spec = do
name `shouldBe` cmdName (commands !! 0)
code `shouldBe` (ExitFailure 14)

it "2nd process exits with 14, others are cancelled" $ do
let commands =
[ Command "./test/data/Launcher/forever.sh" [] (pure ())
, Command "./test/data/Launcher/once.sh" ["14"] (pure ())
]
(ProcessHasExited name code) <- launch commands
name `shouldBe` cmdName (commands !! 1)
code `shouldBe` (ExitFailure 14)

it "Process executes a command before they start" $ do
mvar <- newEmptyMVar
let before = putMVar mvar "executed"
Expand Down

0 comments on commit c93b82b

Please sign in to comment.