Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA review of #8 #87

Merged
merged 3 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the rational here 😅 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, just wanted to test different orders of commands added to the launcher... added few more test, because this alone didn't make any sense indeed :)

code `shouldBe` (ExitFailure 14)

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