diff --git a/ci/README.md b/ci/README.md deleted file mode 100644 index 515fa240ef3c0699129a35cbcd87ff023bdb7310..0000000000000000000000000000000000000000 --- a/ci/README.md +++ /dev/null @@ -1,60 +0,0 @@ -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' -``` diff --git a/ci/analyze-coverage.bash b/ci/analyze-coverage.bash deleted file mode 100755 index 6422ee4854abaeb476d54fb3a26a3489ab5c4523..0000000000000000000000000000000000000000 --- a/ci/analyze-coverage.bash +++ /dev/null @@ -1,37 +0,0 @@ -#!/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 diff --git a/ci/build.bash b/ci/build.bash deleted file mode 100755 index 5f9e7a5164dee0730c8430165be8ca2c6ff113d6..0000000000000000000000000000000000000000 --- a/ci/build.bash +++ /dev/null @@ -1,16 +0,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) diff --git a/ci/default.nix b/ci/default.nix deleted file mode 100644 index d5c64a584befeac96bca3eb718be1dcf66c348a8..0000000000000000000000000000000000000000 --- a/ci/default.nix +++ /dev/null @@ -1,53 +0,0 @@ -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 diff --git a/ci/local.nix b/ci/local.nix deleted file mode 100644 index 1c65e739b1ca0a5b5d43b54b975699a89c561067..0000000000000000000000000000000000000000 --- a/ci/local.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ 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 - ''; -}) diff --git a/ci/pin-batsim.bash b/ci/pin-batsim.bash deleted file mode 100755 index e0d89bea92484b95da1bbf1c2cf300db24ca68c1..0000000000000000000000000000000000000000 --- a/ci/pin-batsim.bash +++ /dev/null @@ -1,13 +0,0 @@ -#!/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 diff --git a/ci/run-tests.bash b/ci/run-tests.bash deleted file mode 100755 index 68037744a8059e577e159b0769e85c9a02a6761a..0000000000000000000000000000000000000000 --- a/ci/run-tests.bash +++ /dev/null @@ -1,45 +0,0 @@ -#!/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} diff --git a/ci/test-deps.nix b/ci/test-deps.nix deleted file mode 100644 index d81183dd98e4fc6f0b9993118884adcf433f5ebe..0000000000000000000000000000000000000000 --- a/ci/test-deps.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ 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 - ]; -} diff --git a/ci/test-env.nix b/ci/test-env.nix deleted file mode 100644 index 9c4fa51eadb9a0ffd6be1d1dc790e9d7e78a9656..0000000000000000000000000000000000000000 --- a/ci/test-env.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ 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 ]; -} diff --git a/ci/update-batsched_dev-cache.bash b/ci/update-batsched_dev-cache.bash deleted file mode 100755 index ff0f9b642f276c17144fc8512532d2c2f100ce1a..0000000000000000000000000000000000000000 --- a/ci/update-batsched_dev-cache.bash +++ /dev/null @@ -1,6 +0,0 @@ -#!/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 diff --git a/ci/update-dependencies-cache.bash b/ci/update-dependencies-cache.bash deleted file mode 100755 index 0684be70f8034e773032416ead06d0e57f33d52e..0000000000000000000000000000000000000000 --- a/ci/update-dependencies-cache.bash +++ /dev/null @@ -1,7 +0,0 @@ -#!/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 diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index 9df0ce1916172219329ebbb4faf41dcc80c16233..0000000000000000000000000000000000000000 --- a/test/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -test: - nix-shell ../ci -A test_deps_pinned --command 'cd .. && bash ./ci/run-tests.bash' diff --git a/test/README.md b/test/README.md index 877a581bffda6a8bac4487ecfcd344ed56e1296c..68c1c437c53a0dd6092f05bc00ba27947629cad4 100644 --- a/test/README.md +++ b/test/README.md @@ -1,10 +1,18 @@ ### 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