From 606baa0c8d22aa98859b9b9462def72650797a8b Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Tue, 19 Mar 2019 15:30:32 +0100 Subject: [PATCH 1/3] Small typo correction in manual scenario --- test/manual/Cardano/Launcher/POSIXSpec.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/manual/Cardano/Launcher/POSIXSpec.md b/test/manual/Cardano/Launcher/POSIXSpec.md index 9ddb5bd9fb4..8e8a19f8185 100644 --- a/test/manual/Cardano/Launcher/POSIXSpec.md +++ b/test/manual/Cardano/Launcher/POSIXSpec.md @@ -60,7 +60,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 `SIGTERM` signal to this pid using `kill ` +- Send a `SIGTERM` signal to this pid using `kill ` - Run `ps -ef | grep cardano`, there's no more process running: the launcher, the wallet and the chain producer have all stopped. @@ -68,15 +68,17 @@ signals are correctly handled on a unix system. ### `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 @@ -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 ` +- Send a `SIGKILL` signal to this pid using `kill -9 ` - 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. - From 234a75939a87940704279353f7ff4629e3d2e461 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Tue, 19 Mar 2019 17:58:47 +0100 Subject: [PATCH 2/3] tiny modification to the LauncheSpec test --- test/unit/Cardano/LauncherSpec.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unit/Cardano/LauncherSpec.hs b/test/unit/Cardano/LauncherSpec.hs index 37b833aa23e..63c0f5c2302 100644 --- a/test/unit/Cardano/LauncherSpec.hs +++ b/test/unit/Cardano/LauncherSpec.hs @@ -30,11 +30,11 @@ spec = do it "One 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 ()) + [ Command "./test/data/Launcher/forever.sh" [] (pure ()) + , Command "./test/data/Launcher/once.sh" ["14"] (pure ()) ] (ProcessHasExited name code) <- launch commands - name `shouldBe` cmdName (commands !! 0) + name `shouldBe` cmdName (commands !! 1) code `shouldBe` (ExitFailure 14) it "Process executes a command before they start" $ do From 214157b0ab26d58c2258879a068f4bf49906d375 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Tue, 19 Mar 2019 18:23:13 +0100 Subject: [PATCH 3/3] LauncheSpec - add new tests with different order of commands --- test/unit/Cardano/LauncherSpec.hs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/test/unit/Cardano/LauncherSpec.hs b/test/unit/Cardano/LauncherSpec.hs index 63c0f5c2302..124ae5664f8 100644 --- a/test/unit/Cardano/LauncherSpec.hs +++ b/test/unit/Cardano/LauncherSpec.hs @@ -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 ()) @@ -28,7 +28,25 @@ 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 ()) + ] + (ProcessHasExited name code) <- launch commands + 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 ())