Commit 08c61880 authored by Valentin Reis's avatar Valentin Reis

packaging fix.

parent 9a011e40
Pipeline #5024 canceled with stage
#### integration testing
#### `argotk`
Integration tests that validate the argo stack, leveraging the 'argopkgs'
repository. The intended usage is to override (some of) the source(s) with WIP
version(s), as part of development or continuous integration.
This is a stack executor for argo. It can be used standalone and drives CI tests.
It should be used via [argotest](https://xgitlab.cels.anl.gov/argo/argotest).
### Usage (tl;dr, I already have nix on my machine.)
```bash
nix-shell -E '
(import( builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";
}) {
#nrm-src = /path/to/nrm
#libnrm-src = /path/to/nrm
#containers-src = /path/to/nrm
}).test' --run "argotk.hs TestHello"
```
### Usage (in three parts)
- [**1**] Get Nix: `curl https://nixos.org/nix/install | sh`
- [**2**] Use the `test` attribute of the argotest' nix attribute set to enter a
test environment. For example, we can run default tests on the
"argopkgs-pinned" version of argo components using:
```bash
nix-shell -E '
let
argotest-src =
builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";
};
argotest = import argotest-src {};
in
argotest.test'
```
This environment has all the necessary Argo components in its PATH. The
argotest function has various arguments, defined in the default.nix file at the
rooto of this repository. They all have default values. For a more involved
example, let's get a custom test environment.
Here, we'll use an environment that uses a local `nrm` source, the master
`libnrm` branch and a specific revision of the `containers` branch. We'l'l use
the master `argotest` branch for that:
```nix
nix-shell -E '{ argotest ? (builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";})
}:
(import argotest {
nrm-src = /path/to/nrm;
libnrm-src = builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/libnrm.git;
ref="master"; };
containers-src = builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/containers.git;
ref="fancy-branch-name";
rev="commit-revisions-string";
};
}).test' --run 'argotk.hs TestHello'
```
- [**3**] The `test`environment contains the `argotk.hs` tool, which runs various
operations on the argo stack:
Commands list:
#### Usage
```{.bash}
argotk.hs --help
argotk --help
```
Output:
```{.txt pipe="sh"}
root/argotk/argotk.hs --help
argotk --help
```
Detailed help:
```{.bash}
argotk.hs TestHello --help
argotk TestHello --help
```
Output:
```{.txt pipe="sh"}
root/argotk/argotk.hs TestHello --help
```
#### Misc
Alternatively, one can use the `--run` option to run a test directly:
```bash
nix-shell -E '
(import( builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";
}) {}).test' --run "argotk.hs TestHello"
argotk TestHello --help
```
#### WARNINGS
There are a few things one has to be aware of using this workflow:
- Builds may fail if the local source repositories are dirty with old build files.
- Without using the `rev` argument, the `builtins.fetchGit` nix command
prefetches and buffers its output, with an expiration time that ranges ten
minutes by default. Use a local checkout if you need to modify some of these
sources on the fly.
### Hacking
- edit `.README.md` in place of README.md.
- see `default.nix`
- the ./shake.hs build file takes care of a few things for the development
workflow (readme and completion generation).
- edit `.README.md` in place of README.md and run ./shake.hs as a pre-commit hook.
#### integration testing
#### `argotk`
Integration tests that validate the argo stack, leveraging the
'argopkgs' repository. The intended usage is to override (some of) the
source(s) with WIP version(s), as part of development or continuous
integration.
This is a stack executor for argo. It can be used standalone and drives
CI tests. It should be used via
[argotest](https://xgitlab.cels.anl.gov/argo/argotest).
### Usage (tl;dr, I already have nix on my machine.)
#### Usage
``` {.bash}
nix-shell -E '
(import( builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";
}) {
#nrm-src = /path/to/nrm
#libnrm-src = /path/to/nrm
#containers-src = /path/to/nrm
}).test' --run "argotk.hs TestHello"
```
### Usage (in three parts)
- \[**1**\] Get Nix: `curl https://nixos.org/nix/install | sh`
- \[**2**\] Use the `test` attribute of the argotest' nix attribute
set to enter a test environment. For example, we can run default
tests on the "argopkgs-pinned" version of argo components using:
``` {.bash}
nix-shell -E '
let
argotest-src =
builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";
};
argotest = import argotest-src {};
in
argotest.test'
```
This environment has all the necessary Argo components in its PATH. The
argotest function has various arguments, defined in the default.nix file
at the rooto of this repository. They all have default values. For a
more involved example, let's get a custom test environment.
Here, we'll use an environment that uses a local `nrm` source, the
master `libnrm` branch and a specific revision of the `containers`
branch. We'l'l use the master `argotest` branch for that:
``` {.nix}
nix-shell -E '{ argotest ? (builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";})
}:
(import argotest {
nrm-src = /path/to/nrm;
libnrm-src = builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/libnrm.git;
ref="master"; };
containers-src = builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/containers.git;
ref="fancy-branch-name";
rev="commit-revisions-string";
};
}).test' --run 'argotk.hs TestHello'
```
- \[**3**\] The `test`environment contains the `argotk.hs` tool, which
runs various operations on the argo stack:
Commands list:
``` {.bash}
argotk.hs --help
argotk --help
```
Output:
``` {.txt}
Usage: argotk.hs COMMAND
Usage: argotk COMMAND
Available options:
COMMAND Type of test to run. There are extensive options
......@@ -90,162 +24,84 @@ Available options:
Available commands:
clean Clean sockets, logfiles.
daemon-only Set up and launch the daemon in synchronous mode,
with properly cleaned sockets, logfiles.
full-stack Setup stack and run a command in a container.
TestHello test1: Setup stack and check that a hello world app
sends message back to cmd.
TestListen test2: Setup stack and check that argo-perf-wrapper
sends at least one message to the daemon.
TestPerfwrapper test3: Setup stack and check that argo-perf-wrapper
DaemonOnly testSet up and launch the daemon in synchronous mode.
DaemonAndApp testSet up and start daemon, run a command in a
container.
CsvLogs testSet up and start daemon, run a command in a
container and log performance+power+progress.
TestHello testSetup stack and check that a hello world app
sends message back to cmd's stdout.
TestListen testSetup stack, run command and check that cmd
listen receives at least the container_exit message
from the daemon.
TestPerfwrapper testSetup stack and check that argo-perf-wrapper
sends at least one *performance* message to cmd
listen through the daemon.
TestPower test4: Setup stack and check that argo-perf-wrapper
sends at least one *power* message to cmd listen
through the daemon.
tests Run all tests
TestPower testSetup stack and check that the daemon sends at
least one *power* message to cmd listen.
TestAMG testSetup stack, run AMG and check that it sends at
least one progress message to the daemon.
TestSTREAM testSetup stack, run STREAM and check that it sends
at least one progress message to the daemon.
RunAMG testSet up and start daemon, run app in a container.
RunSTREAM testSet up and start daemon, run app in a container.
tests Run hardware-independent CI tests
```
Detailed help:
``` {.bash}
argotk.hs TestHello --help
argotk TestHello --help
```
Output:
``` {.txt}
Usage: argotk.hs TestHello [--application APP]
[--container_name ARGO_CONTAINER_UUID]
[--output_dir DIR] [--manifest_directory DIR]
[--manifest_name FILENAME] [--cmd_run_out FILENAME]
[--cmd_run_err FILENAME] [--cmd_listen_out FILENAME]
[--cmd_listen_err FILENAME] [--daemon_out FILENAME]
[--daemon_err FILENAME] [--nrm_log FILENAME]
[--message_daemon_stdout STRING]
[--message_daemon_stderr STRING]
[--message_cmd_run_stdout STRING]
[--message_cmd_run_stderr STRING]
[--message_cmd_listen_stdout STRING]
[--message_cmd_listen_stderr STRING]
test1: Setup stack and check that a hello world app sends message back to cmd.
Usage: argotk TestHello [-v|--verbose] [--app APP]
[--container_name ARGO_CONTAINER_UUID]
[--output_dir DIR] [--manifest_directory DIR]
[--manifest_name FILENAME] [--daemon BEHAVIOR]
[--cmd_run BEHAVIOR] [--cmd_listen BEHAVIOR]
[--cmd_listen_performance BEHAVIOR]
[--cmd_listen_progress BEHAVIOR]
[--cmd_listen_power BEHAVIOR] [ARGS]
testSetup stack and check that a hello world app sends message back to cmd's
stdout.
Available options:
--application APP Target application executable name. PATH is
inherited. (default: "echo")
-v,--verbose Enable verbose mode
--app APP Target application executable name. PATH is
inherited. (default: AppName "echo")
--container_name ARGO_CONTAINER_UUID
Container name (default: "testContainer")
--output_dir DIR Working directory. (default: FilePath "_output")
Container
name (default: ContainerName "testContainer")
--output_dir DIR Working
directory. (default: WorkingDirectory (FilePath "_output"))
--manifest_directory DIR Manifest lookup
directory (default: FilePath "/nix/store/9hbj77178wrp2pv8qs6d063afhdymgk2-manifests")
directory (default: ManifestDir (FilePath "/tmp"))
--manifest_name FILENAME Manifest file basename (relative to
--manifest_directory) (default: FilePath "basic.json")
--cmd_run_out FILENAME Output file (relative to --output_dir), "cmd run"
stdout (default: FilePath "cmd_run_out.log")
--cmd_run_err FILENAME Output file (relative to --output_dir), "cmd run"
stderr (default: FilePath "cmd_run_err.log")
--cmd_listen_out FILENAME
Output file (relative to --output_dir), "cmd listen"
stdout (default: FilePath "cmd_listen_out.log")
--cmd_listen_err FILENAME
Output file (relative to --output_dir), "cmd listen"
stderr (default: FilePath "cmd_listen_err.log")
--daemon_out FILENAME Output file (relative to --output_dir), daemon
stdout (default: FilePath "daemon_out.log")
--daemon_err FILENAME Output file (relative to --output_dir), daemon
stderr (default: FilePath "daemon_err.log")
--nrm_log FILENAME Output file (relative to --output_dir), daemon
log (default: FilePath "nrm.log")
--message_daemon_stdout STRING
The appearance of this character string in the daemon
stdout will be monitored during execution. When
observed, the stack will be killed and a return code
of 0 will be returned.
--message_daemon_stderr STRING
The appearance of this character string in the daemon
stdout will be monitored during execution. When
observed, the stack will be killed and a return code
of 0 will be returned.
--message_cmd_run_stdout STRING
The appearance of this character string in the cmd
run stdout will be monitored during execution. When
observed, the stack will be killed and a return code
of 0 will be
returned. (default: "someComplicatedMessage")
--message_cmd_run_stderr STRING
The appearance of this character string in the cmd
run stdout will be monitored during execution. When
observed, the stack will be killed and a return code
of 0 will be
returned. (default: "someComplicatedMessage")
--message_cmd_listen_stdout STRING
The appearance of this character string in the cmd
listen stdout will be monitored during execution.
When observed, the stack will be killed and a return
code of 0 will be returned.
--message_cmd_listen_stderr STRING
The appearance of this character string in the cmd
listen stdout will be monitored during execution.
When observed, the stack will be killed and a return
code of 0 will be returned.
--manifest_directory) (default: ManifestName (FilePath "basic.json"))
--daemon BEHAVIOR `daemon`
behavior (default: JustRun (StdOutLog "daemon_out.log") (StdErrLog "daemon_err.log"))
--cmd_run BEHAVIOR `cmd run`
behavior (default: Test (TestText (TextBehaviorStdout (WaitFor "someComplicatedMessage")) (TextBehaviorStderr ExpectClean)) (StdOutLog "monitored-cmdrun-out.log") (StdErrLog "monitored-cmdrun-err.log"))
--cmd_listen BEHAVIOR `cmd listen` behavior (default: DontRun)
--cmd_listen_performance BEHAVIOR
`cmd listen --filter performance`
behavior (default: DontRun)
--cmd_listen_progress BEHAVIOR
`cmd listen --filter progress`
behavior (default: DontRun)
--cmd_listen_power BEHAVIOR
`cmd listen --filter power`
behavior (default: DontRun)
ARGS Application arguments.
-h,--help Show this help text
```
#### Misc
Alternatively, one can use the `--run` option to run a test directly:
``` {.bash}
nix-shell -E '
(import( builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";
}) {}).test' --run "argotk.hs TestHello"
```
#### WARNINGS
There are a few things one has to be aware of using this workflow:
- Builds may fail if the local source repositories are dirty with old
build files.
- Without using the `rev` argument, the `builtins.fetchGit` nix
command prefetches and buffers its output, with an expiration time
that ranges ten minutes by default. Use a local checkout if you need
to modify some of these sources on the fly.
### Example CI setup
``` {.yml}
integration.test:
stage: test
script:
- nix-shell -E '{ argotest ? (builtins.fetchGit {
url = https://xgitlab.cels.anl.gov/argo/argotest.git;
ref="master";})
}:
(import argotest { containers-src = ./. ; }).test' \
--run 'argotk.hs TestHello'
artifacts:
paths:
- argotest/_output/cmd_err.log
- argotest/_output/cmd_out.log
- argotest/_output/daemon_out.log
- argotest/_output/daemon_out.log
- argotest/_output/nrm.log
- argotest/_output/time.log
expire_in: 1 week
except:
- /^wip\/.*/
- /^WIP\/.*/
tags:
- integration
```
### Hacking
- edit `.README.md` in place of README.md.
- see `default.nix`
- the ./shake.hs build file takes care of a few things for the
development workflow (readme and completion generation).
- edit `.README.md` in place of README.md and run ./shake.hs as a
pre-commit hook.
......@@ -11,10 +11,6 @@ let
};
};
devInputs = with hpkgs; with pkgs; [
sysstat
];
devHPackages = with hpkgs; [
cabal-install
apply-refact
......@@ -27,11 +23,23 @@ let
];
in rec
{
inherit(hpkgs) argotk;
inherit (hpkgs) argotk;
hack = hpkgs.shellFor {
packages = p: with p; [ argotk ];
withHoogle = true;
buildInputs = devInputs ++ devHPackages;
buildInputs = devHPackages;
};
preCommit = pkgs.mkShell {
name = "shake";
MANIFESTS = "/tmp";
buildInputs = [
(pkgs.haskellPackages.ghcWithPackages (p: with p; [
argotk
shake
(pkgs.haskell.lib.doJailbreak panpipe)
]))
];
};
}
#! /usr/bin/env nix-shell
#! nix-shell -i runhaskell -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [shake])"
#! nix-shell -i runhaskell -A preCommit
import Development.Shake
import Development.Shake.FilePath
......@@ -13,18 +13,15 @@ main = shakeArgs shakeOptions $ do
want ["README.md", "completion/argotk.sh"]
"completion/*.sh"
%> \out -> mkCompletionRule out "bash" $ takeFileName out -<.> "hs"
%> \out -> do
let cplA = cmd "argotk" ["--bash-completion-script", "argotk"]
(Stdout cplScript) <- cplA
liftIO $ writeFile out cplScript
"README.md" %> \out -> do
let template = ".README.md"
need [template , "argotk/argotk.hs" , "argo/src/Argo/Stack.hs"]
need [template , "src/argotk.hs" , "src/Argo/Stack.hs"]
(Stdout panpipe) <- cmd "which panpipe"
cmd_ "pandoc --filter"
[take (length panpipe - 1) panpipe, template, "-o", out]
where
mkCompletionAction str sn =
(sn, cmd ("argotk/" ++ sn) ["--" ++ str ++ "-completion-script", sn])
mkCompletionRule out str fn = do
let (needed, cplA) = mkCompletionAction str fn
(Stdout cplScript) <- cplA
liftIO $ writeFile out cplScript
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