Commit 0aad2c2b authored by Valentin Reis's avatar Valentin Reis

Merge branch '1-base-features' into 'master'

Resolve "Base features"

See merge request argo/argotest!2
parents 7991c67f 5d8ecd9a
Pipeline #4626 passed with stage
in 6 seconds
...@@ -18,10 +18,18 @@ integration.test: ...@@ -18,10 +18,18 @@ integration.test:
stage: test stage: test
script: script:
- BUILD=$PWD - BUILD=$PWD
- cd `mktemp -d`
- git clone https://xgitlab.cels.anl.gov/argo/argotest.git - git clone https://xgitlab.cels.anl.gov/argo/argotest.git
- cd argotest - cd argotest
- nix-shell -A test --run ./integration.hs --arg nrm-src $BUILD - nix-shell -A test --run "./argotk.hs helloworld" --arg nrm-src ../.
artifacts:
paths:
- argotest/cmd_err.log
- argotest/cmd_out.log
- argotest/daemon_out.log
- argotest/daemon_out.log
- argotest/nrm.log
- argotest/time.log
expire_in: 1 week
except: except:
- /^wip\/.*/ - /^wip\/.*/
- /^WIP\/.*/ - /^WIP\/.*/
......
...@@ -21,7 +21,7 @@ import System.Posix.Signals ...@@ -21,7 +21,7 @@ import System.Posix.Signals
data StackArgs = StackArgs data StackArgs = StackArgs
{ dargs :: Text --"Daemon arguments. Properly quote this." { dargs :: Text --"Daemon arguments. Properly quote this."
, app :: FilePath --"Input file, target application script" , app :: Text --"Target application call, sh+path valid"
, manifest :: FilePath --"Input file, manifest." , manifest :: FilePath --"Input file, manifest."
, cmd_out :: FilePath --"Output file, application stdout" , cmd_out :: FilePath --"Output file, application stdout"
, cmd_err :: FilePath --"Output file, application stderr" , cmd_err :: FilePath --"Output file, application stderr"
...@@ -33,7 +33,7 @@ data StackArgs = StackArgs ...@@ -33,7 +33,7 @@ data StackArgs = StackArgs
instance Default StackArgs where instance Default StackArgs where
def = StackArgs def = StackArgs
{ dargs = "" { dargs = ""
, app = "echo \"Dummy app: Hello world!\"" , app = "echo \"HelloWorld\""
, manifest = "manifests/basic.json" , manifest = "manifests/basic.json"
, cmd_out = "cmd_out.log" , cmd_out = "cmd_out.log"
, cmd_err = "cmd_err.log" , cmd_err = "cmd_err.log"
...@@ -50,7 +50,6 @@ colorShell color s = setC color *> s *> setC White ...@@ -50,7 +50,6 @@ colorShell color s = setC color *> s *> setC White
printInfo :: Text -> Shell () printInfo :: Text -> Shell ()
printError :: Text -> Shell () printError :: Text -> Shell ()
printWarning :: Text -> Shell () printWarning :: Text -> Shell ()
printInfo = printf ("Info:"%s) printInfo = printf ("Info:"%s)
printWarning = colorShell Yellow . printf ("Warning:"%s) printWarning = colorShell Yellow . printf ("Warning:"%s)
printError = colorShell Red . printf ("Error:"%s) printError = colorShell Red . printf ("Error:"%s)
...@@ -106,6 +105,6 @@ prepareDaemonShell dargs daemon_out daemon_err nrm_log = do ...@@ -106,6 +105,6 @@ prepareDaemonShell dargs daemon_out daemon_err nrm_log = do
ExitFailure n -> do printInfo "Contents of argo_nodeos_config_exit_message: \n" ExitFailure n -> do printInfo "Contents of argo_nodeos_config_exit_message: \n"
view $ cat ["./argo_nodeos_config_exit_message"] view $ cat ["./argo_nodeos_config_exit_message"]
die ("Clean config failed with exit code " <> repr n) die ("Clean config failed with exit code " <> repr n)
printInfo $ format ("Running the daemon: see main log at "%fp%"\n") nrm_log printInfo $ format ("Running the daemon, main log at "%fp%", stdout at "%fp%", stderr at "%fp%"\n") nrm_log daemon_out daemon_err
export "ARGO_NODEOS_CONFIG" (format fp confPath') export "ARGO_NODEOS_CONFIG" (format fp confPath')
return $ sh $ inshell (format (fp%" "%s%" --nrm_log="%fp%" >"%fp%" 2>"%fp) daemonPath dargs nrm_log daemon_out daemon_err) empty return $ sh $ inshell (format (fp%" "%s%" --nrm_log="%fp%" >"%fp%" 2>"%fp) daemonPath dargs nrm_log daemon_out daemon_err) empty
#! /usr/bin/env nix-shell #! /usr/bin/env runhaskell
#! nix-shell -i runhaskell -A test
{-# LANGUAGE {-# LANGUAGE
OverloadedStrings OverloadedStrings
...@@ -20,11 +19,20 @@ opts :: Parser (IO ()) ...@@ -20,11 +19,20 @@ opts :: Parser (IO ())
opts = subparser opts = subparser
( command "clean" (info (pure $ runClean def) idm)<> help "Target for the greeting" ( command "clean" (info (pure $ runClean def) idm)<> help "Target for the greeting"
<> command "daemon" (info (pure $ runDaemon def) idm) <> command "daemon" (info (pure $ runDaemon def) idm)
<> command "helloworld" (info (pure $ runSimpleStack def) idm) ) <> command "helloworld" (info (pure $ runHelloWorld def ) idm) )
main :: IO () main :: IO ()
main = join $ execParser (info (opts <**>helper) idm) main = join $ execParser (info (opts <**>helper) idm)
runHelloWorld :: StackArgs -> IO ()
runHelloWorld a@StackArgs{..} = do
let passStr = "HelloWorldFromApp"
runSimpleStack $ a {app = format ("echo "%s) passStr}
readTextFile cmd_err >>= \x -> case match (has "HelloWorldFromApp") x of
[] -> die ("Hello world app failed to run.")
_ -> sh $ printInfo "The hello world app executed properly in a \
\container and its message was received by `cmd`.\n"
runSimpleStack :: StackArgs -> IO () runSimpleStack :: StackArgs -> IO ()
runSimpleStack a@StackArgs{..} = sh $ do runSimpleStack a@StackArgs{..} = sh $ do
cleanLeftovers daemon_out daemon_err cmd_out cmd_err time_file nrm_log cleanLeftovers daemon_out daemon_err cmd_out cmd_err time_file nrm_log
...@@ -39,7 +47,7 @@ runSimpleStack a@StackArgs{..} = sh $ do ...@@ -39,7 +47,7 @@ runSimpleStack a@StackArgs{..} = sh $ do
printInfo "Launching the application through cmd.\n" printInfo "Launching the application through cmd.\n"
(_,t) <- time $ (_,t) <- time $
shell (format ("cmd run -u toto "%fp%" "%fp%" > "%fp%" 2>"%fp) manifest app cmd_out cmd_err) empty >>= \case shell (format ("cmd run -u toto "%fp%" "%s%" > "%fp%" 2>"%fp) manifest app cmd_out cmd_err) empty >>= \case
ExitSuccess -> printInfo "cmd has exited successfuly.\n" ExitSuccess -> printInfo "cmd has exited successfuly.\n"
ExitFailure n -> die ("cmd failed with exit code " <> repr n <> ExitFailure n -> die ("cmd failed with exit code " <> repr n <>
" . The application logs are at " <> repr cmd_out <> " " <> repr cmd_err ) " . The application logs are at " <> repr cmd_out <> " " <> repr cmd_err )
...@@ -54,6 +62,5 @@ runClean StackArgs{..} = sh $ ...@@ -54,6 +62,5 @@ runClean StackArgs{..} = sh $
cleanLeftovers daemon_out daemon_err cmd_out cmd_err time_file nrm_log cleanLeftovers daemon_out daemon_err cmd_out cmd_err time_file nrm_log
runDaemon :: StackArgs -> IO () runDaemon :: StackArgs -> IO ()
runDaemon StackArgs{..} = sh $ do runDaemon StackArgs{..} = sh $
daemonShell <- prepareDaemonShell dargs daemon_out daemon_err nrm_log prepareDaemonShell dargs daemon_out daemon_err nrm_log >>= id
daemonShell
...@@ -19,13 +19,36 @@ let ...@@ -19,13 +19,36 @@ let
in rec in rec
{ {
dev-beforelib = hpkgs.shellFor { dev-lib = hpkgs.shellFor {
packages = p: with p; [ argotest ]; packages = p: with p; [ argotest ];
withHoogle = true; withHoogle = true;
buildInputs = with hpkgs; with pkgs; [ cabal-install ghcid buildInputs = with hpkgs; with pkgs; [ cabal-install ghcid
hlint sysstat hdevtools]; hlint sysstat hdevtools];
}; };
dev-test = pkgs.stdenv.mkDerivation rec {
name = "env";
env = pkgs.buildEnv { name = name; paths = buildInputs; };
buildInputs = [
(hpkgs.ghcWithPackages (p: [
p.argotest
p.turtle
p.data-default
p.managed
p.ansi-terminal
p.unix
p.system-filepath
p.async
]))
containers
hpkgs.hdevtools
hpkgs.hlint
hpkgs.ghcid
amg
nrm
];
};
test = pkgs.stdenv.mkDerivation rec { test = pkgs.stdenv.mkDerivation rec {
name = "env"; name = "env";
env = pkgs.buildEnv { name = name; paths = buildInputs; }; env = pkgs.buildEnv { name = name; paths = buildInputs; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment