Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33079423 authored by Nicolas Gelot's avatar Nicolas Gelot
Browse files

Bootstrap functional test

Before to try to optimize spot engines we need to
have some tests to bench the search duration and that
performs some checks on the results
parent cc26dde7
Loading
Loading
Loading
Loading
+15 −1
Original line number Original line Diff line number Diff line
@@ -21,10 +21,24 @@ coding-rules:
  script:
  script:
    - ./manage.sh pep8_check
    - ./manage.sh pep8_check


unittest:
unit-test:
  stage: test
  stage: test
  before_script:
  before_script:
    - ./manage.sh update_dev_packages
    - ./manage.sh update_dev_packages
  script:
  script:
    - ./manage.sh unit_tests
    - ./manage.sh unit_tests
  coverage: '/TOTAL.*\s+(\d+%)$/'
  coverage: '/TOTAL.*\s+(\d+%)$/'

functional-test:
  stage: test
  image: docker:stable
  services:
    - docker:dind
  variables:
    DOCKER_HOST: tcp://docker:2375/
    DOCKER_DRIVER: overlay2
  before_script:
    - docker run -id --rm -v $(pwd):/ws -e DOCKER_HOST=tcp://$(cat /etc/hosts | grep docker | cut -f1):2375/ -w /ws --name spotenv $CI_REGISTRY_IMAGE/env:latest sh
    - docker exec -i spotenv ./manage.sh update_dev_packages
  script:
    - docker exec -i spotenv ./manage.sh functional_tests
+1 −0
Original line number Original line Diff line number Diff line
@@ -6,6 +6,7 @@ RUN dnf install -y\
 wget\
 wget\
 python2-pip\
 python2-pip\
 npm\
 npm\
 docker \
&& dnf groupinstall -y "Development Tools" \
&& dnf groupinstall -y "Development Tools" \
&& pip3 install ipdb ipython \
&& pip3 install ipdb ipython \
&& pip3 install -r /requirements.txt \
&& pip3 install -r /requirements.txt \
+9 −2
Original line number Original line Diff line number Diff line
@@ -41,13 +41,19 @@ pep8_check() {


unit_tests() {
unit_tests() {
    echo '[!] Running unit tests'
    echo '[!] Running unit tests'
    PYTHONPATH="$BASE_DIR" pytest --cov=searx --disable-pytest-warnings "$BASE_DIR/tests/unit"
    PYTHONPATH="$BASE_DIR" pytest --cov=searx "$BASE_DIR/tests/unit"
}

functional_tests() {
    echo '[!] Running unit tests'
    PYTHONPATH="$BASE_DIR" pytest "$BASE_DIR/tests/functional"
}
}


tests() {
tests() {
    set -e
    set -e
    pep8_check
    pep8_check
    unit_tests
    unit_tests
    functional_tests
    set +e
    set +e
}
}


@@ -133,8 +139,9 @@ Commands
    Tests
    Tests
    -----
    -----
    unit_tests           - Run unit tests
    unit_tests           - Run unit tests
    functional_tests     - Run functional tests
    pep8_check           - Pep8 validation
    pep8_check           - Pep8 validation
    tests                - Run all python tests (pep8, unit, robot_tests)
    tests                - Run all python tests (pep8, unit, functional)
"
"
}
}


pytest.ini

0 → 100644
+2 −0
Original line number Original line Diff line number Diff line
[pytest]
addopts = -s --dockerc-build --dockerc-attach-network --disable-pytest-warnings
+1 −0
Original line number Original line Diff line number Diff line
@@ -4,3 +4,4 @@ pycodestyle==2.4.0
mockredispy==2.9.3
mockredispy==2.9.3
pytest==4.1.0
pytest==4.1.0
pytest-cov==2.6.1
pytest-cov==2.6.1
pytest-dockerc==1.0.5
Loading