File: ci-run

package info (click to toggle)
lava 2019.01-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 24,200 kB
  • sloc: python: 57,974; sh: 1,113; makefile: 329
file content (113 lines) | stat: -rwxr-xr-x 2,850 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash

set -x
set -e

while getopts ":pdstyc" opt; do
  case $opt in
    p)
      # pep8 only
      PEP8=true
      ;;
    d)
      # lava_dispatcher only
      DISPATCH=true
      ;;
    s)
      # lava_server only
      SERVER=true
      ;;
    t)
      # template tests only
      TEMPLATE=true
      ;;
    y)
      # pytest-3 only
      PYTEST=true
      ;;
    c)
      # clean only
      CLEAN=true
      ;;
    ?)
      echo "Usage:"
      echo "-c - clean targets only"
      echo "-p - clean and pep8 only"
      echo "-d - clean, pep8 and dispatcher only"
      echo "-s - clean, pep8 and server only"
      echo "-t - clean, pep8 and templates only"
      echo "Invalid option: -$OPTARG" >&2
      exit 1
      ;;
  esac
done

shift $((OPTIND -1))

if [ -n "${SUDO_USER}" ]; then
    echo "./ci-run should NOT be run using ``sudo``"
    # root is ok but only if root did the git clone
    exit 3
fi

echo "Removing old .pyc files and cache"
echo
find . -name '*.pyc' -delete
rm -rf ./.cache/
rm -rf ./__init__.py
rm -rf lava.egg-info/
rm -rf .pytest_cache/
find . -name __pycache__ -exec rmdir "{}" \; 2>/dev/null || true
find . -name precious -type d -exec rm -rf "{}" \; 2>/dev/null || true

if [ -n "${CLEAN}" ]
then
    exit 0
fi

pep8 --ignore E501,E203,W503,W504 --exclude migrations .

if [ -n "${PEP8}" ]
then
    exit 0
fi

echo "Starting unit tests"
echo
if [ -z "${DISPATCH}"  -a -z "${TEMPLATE}" -a -z "${PYTEST}" ]
then
    echo "If it exists, a broken test database will be deleted without prompting."
    # lava_rest_app is pytest only
    python3 ./lava_server/manage.py test --noinput -v 2 lava_scheduler_app linaro_django_xmlrpc.tests lava_results_app
    if [ -n "${SERVER}" ]
    then
        exit
    fi
    python3 -m unittest discover -v lava_dispatcher/tests
    exit
fi


if [ -n "${DISPATCH}" -a  -z "${TEMPLATE}" -a -z "${PYTEST}" ]
then
    python3 -m unittest discover -v lava_dispatcher/tests
fi

if [ -z "${DISPATCH}" -a  -n "${TEMPLATE}" -a -z "${PYTEST}" ]
then
    python3 -m unittest -vcf lava_scheduler_app.tests.test_base_templates
    python3 -m unittest -vcf lava_scheduler_app.tests.test_templates
    python3 -m unittest -vcf lava_scheduler_app.tests.test_uboot_templates
    python3 -m unittest -vcf lava_scheduler_app.tests.test_fastboot_templates
    python3 -m unittest -vcf lava_scheduler_app.tests.test_grub_templates
    python3 -m unittest -vcf lava_scheduler_app.tests.test_qemu_templates
fi


if [ -z "${DISPATCH}" -a -z "${TEMPLATE}" -a -n "${PYTEST}" ]
then
    PYTHONPATH=. pytest-3 --cache-clear --ds lava_server.settings.development -v \
        lava_scheduler_app/tests lava_results_app/tests linaro_django_xmlrpc/tests.py lava_rest_app/tests.py
    PYTHONPATH=. pytest-3 --cache-clear -v lava_dispatcher/tests
    PYTHONPATH=. pytest-3 --cache-clear -v lava_common/tests
fi