diff --git a/tests/Dockerfile b/tests/Dockerfile index b5f55c3..945a23b 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -3,12 +3,9 @@ FROM ubuntu:jammy ## Base tools installations RUN apt-get update && \ - apt-get install -y software-properties-common apt-utils wget tree sudo && \ - # ca-certificates is required for wget downloads, apt utils for ppa additions. Optimisations here don't end well - ## Google direct - wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \ - apt-get install -y --no-install-recommends ./google-chrome-stable_current_amd64.deb libxss1 netcat && \ - rm google-chrome-stable_current_amd64.deb && \ + apt-get install -y software-properties-common apt-utils wget tree sudo netcat && \ + # Install Chromium from apt instead of Chrome .deb + apt-get install -y chromium-browser && \ ## Node ppa wget -qO- https://deb.nodesource.com/setup_18.x | bash - && \ apt-get update && \ diff --git a/tests/hardhat.config.js b/tests/hardhat.config.js index 639007f..4755dc9 100755 --- a/tests/hardhat.config.js +++ b/tests/hardhat.config.js @@ -48,7 +48,7 @@ module.exports = { artifacts: "./artifacts" }, mocha: { - timeout: 10000, + timeout: 60000, parallel: true } } \ No newline at end of file diff --git a/tests/run.sh b/tests/run.sh index e23eecb..616b5af 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -15,12 +15,12 @@ totalRuntime=0 synthesis() { if [ $? -eq 0 ]; then - currentRuntime=$(($(date +%s%N) - $date)) + currentRuntime=$(($(date +%s) - $startdate)) totalRuntime=$(($totalRuntime + $currentRuntime)) - if [ $currentRuntime -gt 10000000000 ]; then - Results="$Results$1 ⏰ $(($currentRuntime / 1000000000)), " + if [ $currentRuntime -gt 10 ]; then + Results="$Results$1 ⏰ $(($currentRuntime ))s, " else - Results="$Results$1 ✅ $(($currentRuntime / 1000000000)), " + Results="$Results$1 ✅ $(($currentRuntime ))s, " fi else Results=$Results$1" ❌, " @@ -31,7 +31,7 @@ synthesis() { } #@ Should replicate the production environement -BaseOptions="--read-only --network none --memory 500M --cpus 2.0 --user 1000:1000 --env USERNAME=🧑‍🎓 --env HOME=/jail --env TMPDIR=/jail --workdir /jail --tmpfs /jail:size=100M,noatime,exec,nodev,nosuid,uid=1000,gid=1000,nr_inodes=5k,mode=1700 --volume $TEMP_STUDENT:/jail/student:ro" +BaseOptions="--platform linux/amd64 --read-only --network none --memory 500M --cpus 2.0 --user 1000:1000 --env USERNAME=🧑‍🎓 --env HOME=/jail --env TMPDIR=/jail --workdir /jail --tmpfs /jail:size=100M,noatime,exec,nodev,nosuid,uid=1000,gid=1000,nr_inodes=5k,mode=1700 --volume $TEMP_STUDENT:/jail/student:ro" if [ ! -z "$1" ]; then if [ "$1" = "clean" ]; then @@ -62,14 +62,14 @@ if [ ! -z "$1" ]; then exit 0 fi # A specific test has been named, we run it with the debug flag - docker build . -t blockchain --progress=plain + docker build . -t blockchain --progress=plain --platform linux/amd64 mkdir -p $TEMP_STUDENT cp $STORAGE_STUDENT/$1.{sol,js,html,mjs} $TEMP_STUDENT 2>/dev/null time docker run $BaseOptions -e DEBUG=true -e EXERCISE="$1" blockchain:latest else # No specific test has been named. Run all tests with a summary at the end echo "▶️ Docker build" - docker build . -t blockchain + docker build . -t blockchain --platform linux/amd64 echo "▶️ Running test" # -e DEBUG=true available mkdir -p $TEMP_STUDENT @@ -78,13 +78,13 @@ else rm $TEMP_STUDENT/* # for debugging, the folder is left and removed at the next run cp $STORAGE_STUDENT/$testname.{sol,js,html,mjs} $TEMP_STUDENT 2>/dev/null sleep 0.1 - date=$(date +%s%N) + startdate=$(date +%s) docker run $BaseOptions -e EXERCISE=$testname blockchain:latest synthesis $testname done sleep 1 echo "▶️ Results" echo $Results - echo "tests ran:$testNumber in avg $(($totalRuntime / 1000000 / $testNumber)) ms" + echo "tests ran:$testNumber in avg $(($totalRuntime / $testNumber)) seconds" fi exit 0