Skip to content
Snippets Groups Projects
Commit e837a21f authored by Millian Poquet's avatar Millian Poquet
Browse files

[test,ci,doc] clean outdated ci/test scripts+doc

parent d8c198bf
No related branches found
No related tags found
No related merge requests found
This directory is essentially a nix repository with some scripts.
# Packages overview
## batsched_local
This is the current version of batsched (built from current file hierarchy).
## batsim_pinned
This is the current *reference* Batsim version for batsched.
batsched should always work with this version.
## batsim_dev
This is the up-to-date Batsim version.
batsched should work with this version.
## test_deps_(pinned|dev)
The list of packages needed to run tests.
This is meant to be used as a shell, not meant to be installed.
## test_(pinned|dev)
A shell used to run tests. Essentially batsim_local + test_deps.
Not meant to be installed either.
# Useful commands
In all the following examples, the current directory is expected to be
batsched's root.
## Building packages
This can be done via `nix-build`. Result will be in `./result/`.
Some examples:
``` bash
nix-build ./ci -A batsched_local
nix-build ./ci -A batsim_pinned
```
## Install packages
This is done via `nix-env`:
``` bash
nix-env -f ./ci -iA batsched_local
nix-env -f ./ci -iA batsim_dev
```
To uninstall them, use `nix-env --uninstall`.
## Get into a shell to build packages
`nix-shell` is your friend here. Example:
``` bash
nix-shell ./ci -A batsched_local
# your shell now has all batsched's build dependencies!
# you can freely build the project (cmake, make...)
```
## Run the tests
This is essentially "run the test script in the desired environment".
``` bash
# test current batsched with batsim_pinned:
nix-shell ./ci -A test_pinned --command './ci/run-tests.bash'
# or test with batsim_dev:
nix-shell ./ci -A test_dev --command './ci/run-tests.bash'
```
#!/usr/bin/env nix-shell
#! nix-shell . -i bash -A test_deps_pinned
set -eu
echo "Prepare directories"
rm -rf ./cover
mkdir -p ./cover/tmp
cd ./cover/tmp
echo "Call gcov"
gcov_files=$(find ../../build -name '*.gcda')
for gcov_file in ${gcov_files[@]}; do
gcov ${gcov_file} 1>/dev/null 2>&1
done
echo "Only keep interesting files"
interesting_sources=$(find ../../src -name '*.?pp' | sort | grep -v 'pempek_assert\|taywee_args')
set +e
for interesting_source in ${interesting_sources[@]}; do
interesting_file="./$(basename ${interesting_source}).gcov"
cp -f ${interesting_file} ../ 2>/dev/null
done
set -e
cd ../..
rm -rf ./cover/tmp
echo "Run gcovr analysis (human-readable report)"
gcovr -gk -o ./cover/summary.txt
cat ./cover/summary.txt
echo "Run gcovr analysis (html report)"
rm -rf ./cover/html
mkdir -p ./cover/html
gcovr -gk --html-details -o ./cover/html/index.html
exit 0
#!/usr/bin/env nix-shell
#! nix-shell . -i bash -A batsched_local
set -eux
# Start from a clean build directory
rm -rf ./build
mkdir -p ./build
# Usual cmake build stuff
cd ./build
cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-Denable_warnings=ON \
-Dtreat_warnings_as_errors=OFF \
-Ddo_coverage=ON
make -j $(nproc)
let
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/18.03.tar.gz") {};
kapack = import
( fetchTarball "https://github.com/oar-team/kapack/archive/master.tar.gz") {};
in
let
callPackage = pkgs.lib.callPackageWith (pkgs // pkgs.xlibs // self // kapack);
self = rec {
inherit pkgs kapack;
# Redefine some packages for clarity's sake
batexpe = kapack.batexpe;
batsim_pinned = (kapack.batsim.override {simgrid = kapack.simgrid_dev_working; }).overrideAttrs (attrs: rec {
name = "batsim-${version}";
version = "3.0.0-pinned";
src = pkgs.fetchgit {
url = "https://framagit.org/batsim/batsim.git";
rev = "12db5085210ac24d82657b21fafe0ca198dcf48d";
sha256 = "07b9npm5qvrzanp14rwp743dxsh7dwpvpywmlpxla5j4kxk665hc";
};
});
batsim_dev = (kapack.batsim.override {simgrid = kapack.simgrid_dev_working; }).overrideAttrs (attrs: rec {
nativeBuildInputs = attrs.nativeBuildInputs ++ [kapack.intervalset];
name = "batsim-${version}";
version = "3.1.0-dev";
src = fetchTarball "https://gitlab.inria.fr/batsim/batsim/repository/master/archive.tar.gz";
});
pytest = pkgs.python36Packages.pytest;
gcovr = kapack.gcovr;
# Packages defined in this tree
batsched_local = callPackage ./local.nix {};
test_deps_pinned = callPackage ./test-deps.nix {
batsim = batsim_pinned;
};
test_deps_dev = callPackage ./test-deps.nix {
batsim = batsim_dev;
};
# Packages meant to be used as shells
test_pinned = callPackage ./test-env.nix {
batsched = batsched_local;
test_deps = test_deps_pinned;
};
test_dev = callPackage ./test-env.nix {
batsched = batsched_local;
test_deps = test_deps_dev;
};
};
in
self
{ stdenv, batsched_dev }:
(batsched_dev.override {}).overrideAttrs (attrs: rec {
name = "batsched-1.4.0-nix-ci";
src = stdenv.lib.sourceByRegex ../. [
"^src$"
"^src/algo$"
"^src/external$"
".*\.cpp$" ".*\.hpp$"
"^cmake$"
"^cmake/Modules$"
".*\.cmake"
".*\.cmake.in"
"^CMakeLists\.txt$"
];
enableParallelBuilding = true;
doCheck = false;
preConfigure = ''
# Always start from a clean build directory
rm -rf ./build
'';
})
#!/usr/bin/env nix-shell
#! nix-shell . -i bash -A test_deps_dev
if [ "$#" -ne 1 ]; then
echo 'usage: pin-batsim.bash BATSIM-REV'
exit 1
fi
rev=$1
nix-prefetch-git \
--url https://framagit.org/batsim/batsim.git \
--rev ${rev} \
> batsim-pinned.json
#!/usr/bin/env nix-shell
#! nix-shell . -i bash -A test_deps_pinned
set -eu
initial_dir=$(realpath .)
# Run a redis server if needed
redis_launched_here=0
r=$(ps faux | grep redis-server | grep -v grep | wc -l)
if [ $r -eq 0 ]
then
echo "Running a Redis server..."
redis-server>/dev/null &
redis_launched_here=1
while ! nc -z localhost 6379; do
sleep 1
done
fi
# Add built batsched in PATH
export PATH=$(realpath ./build):${PATH}
# Set TEST_ROOT so simulation input files can be found
export TEST_ROOT=$(realpath ./test)
# Print which versions are used
echo "batsched realpath: $(realpath $(which batsched))"
echo "batsim realpath: $(realpath $(which batsim))"
echo "robin realpath: $(realpath $(which robin))"
# Execute the tests (TODO: clean tests)
cd test
pytest
failed=$?
# Stop the redis server if it has been launched by this script
if [ $redis_launched_here -eq 1 ]
then
echo "Stopping the Redis server..."
killall redis-server
fi
cd ${initial_dir}
exit ${failed}
{ stdenv, batsim, batexpe,
which, redis, procps, psmisc, pytest, gcovr,
nix-prefetch-git
}:
stdenv.mkDerivation rec {
name = "batsched-test-deps";
# This package is not meant to be built
unpackPhase = "true";
installPhase = "true";
propagatedBuildInputs = [ batsim batexpe
which redis procps psmisc pytest gcovr
nix-prefetch-git
];
}
{ stdenv, batsched, test_deps }:
stdenv.mkDerivation rec {
name = "batsched-test-env";
# This package is not meant to be built
unpackPhase = "true";
installPhase = "true";
propagatedBuildInputs = [ batsched test_deps ];
}
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p nix
set -eu
# Build up-to-date batsched_dev package, push it on binary cache
nix-build https://github.com/oar-team/kapack/archive/master.tar.gz -A batsched_dev | cachix push batsim
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p nix
set -eu
# (re)build up-to-date CI batsched package + deps, push them on binary cache
nix-build ./ci -A test_pinned | cachix push batsim
nix-build ./ci -A test_dev | cachix push batsim
test:
nix-shell ../ci -A test_deps_pinned --command 'cd .. && bash ./ci/run-tests.bash'
### Running tests
``` bash
nix-shell ../release.nix -A integration_tests --command 'pytest'
# or just pytest, but you must prepare your env...
```
make test
# or pytest, but you must prepare your env, run redis...
Optionally, use Batsim's binary cache to avoid recompiling many things (e.g., SimGrid).
``` bash
nix-env -iA cachix -f https://cachix.org/api/v1/install # installs cachix
cachix use batsim # add Batsim's cachix storage as a Nix remote cache
```
### How it works?
### How does it work?
0. nix-shell puts you into an environment where batsched, batsim, robin, redis, etc. are available (code in [release.nix])
1. pytest generates combinations of test input (code in [conftest.py])
2. for each combination of inputs: (code in [test_runner.py])
1. pytest generates a [robin] input file
......@@ -19,11 +27,12 @@ robin test-instances/FAILING-TEST.yaml
You can also run batsim and batsched in different terminals:
``` bash
# feel free to hack — e.g., prepend commands with gdb, valgrind...
# feel free to hack these files — e.g., prepend commands with gdb, valgrind...
./test-out/FAILING-TEST/cmd/batsim.bash
./test-out/FAILING-TEST/cmd/sched.bash
```
[release.nix]: ../release.nix
[conftest.py]: ./conftest.py
[test_runner.py]: ./test_runner.py
[robin]: https://framagit.org/batsim/batexpe
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment