~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to .pc/ubuntu-show-tests.patch/run_tests.sh

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
set -eu
 
4
 
 
5
function usage {
 
6
  echo "Usage: $0 [OPTION]..."
 
7
  echo "Run Nova's test suite(s)"
 
8
  echo ""
 
9
  echo "  -V, --virtual-env        Always use virtualenv.  Install automatically if not present"
 
10
  echo "  -N, --no-virtual-env     Don't use virtualenv.  Run tests in local environment"
 
11
  echo "  -s, --no-site-packages   Isolate the virtualenv from the global Python environment"
 
12
  echo "  -r, --recreate-db        Recreate the test database (deprecated, as this is now the default)."
 
13
  echo "  -n, --no-recreate-db     Don't recreate the test database."
 
14
  echo "  -x, --stop               Stop running tests after the first error or failure."
 
15
  echo "  -f, --force              Force a clean re-build of the virtual environment. Useful when dependencies have been added."
 
16
  echo "  -p, --pep8               Just run PEP8 and HACKING compliance check"
 
17
  echo "  -P, --no-pep8            Don't run static code checks"
 
18
  echo "  -c, --coverage           Generate coverage report"
 
19
  echo "  -h, --help               Print this usage message"
 
20
  echo "  --hide-elapsed           Don't print the elapsed time for each test along with slow test list"
 
21
  echo ""
 
22
  echo "Note: with no options specified, the script will try to run the tests in a virtual environment,"
 
23
  echo "      If no virtualenv is found, the script will ask if you would like to create one.  If you "
 
24
  echo "      prefer to run tests NOT in a virtual environment, simply pass the -N option."
 
25
  exit
 
26
}
 
27
 
 
28
function process_option {
 
29
  case "$1" in
 
30
    -h|--help) usage;;
 
31
    -V|--virtual-env) always_venv=1; never_venv=0;;
 
32
    -N|--no-virtual-env) always_venv=0; never_venv=1;;
 
33
    -s|--no-site-packages) no_site_packages=1;;
 
34
    -r|--recreate-db) recreate_db=1;;
 
35
    -n|--no-recreate-db) recreate_db=0;;
 
36
    -m|--patch-migrate) patch_migrate=1;;
 
37
    -w|--no-patch-migrate) patch_migrate=0;;
 
38
    -f|--force) force=1;;
 
39
    -p|--pep8) just_pep8=1;;
 
40
    -P|--no-pep8) no_pep8=1;;
 
41
    -c|--coverage) coverage=1;;
 
42
    -*) noseopts="$noseopts $1";;
 
43
    *) noseargs="$noseargs $1"
 
44
  esac
 
45
}
 
46
 
 
47
venv=.venv
 
48
with_venv=tools/with_venv.sh
 
49
always_venv=0
 
50
never_venv=0
 
51
force=0
 
52
no_site_packages=0
 
53
installvenvopts=
 
54
noseargs=
 
55
noseopts=
 
56
wrapper=""
 
57
just_pep8=0
 
58
no_pep8=0
 
59
coverage=0
 
60
recreate_db=1
 
61
patch_migrate=1
 
62
 
 
63
export NOSE_WITH_OPENSTACK=1
 
64
export NOSE_OPENSTACK_COLOR=1
 
65
export NOSE_OPENSTACK_RED=0.05
 
66
export NOSE_OPENSTACK_YELLOW=0.025
 
67
export NOSE_OPENSTACK_SHOW_ELAPSED=1
 
68
export NOSE_OPENSTACK_STDOUT=1
 
69
 
 
70
export LANG=en_US.UTF-8
 
71
export LANGUAGE=en_US:en
 
72
export LC_ALL=C
 
73
 
 
74
for arg in "$@"; do
 
75
  process_option $arg
 
76
done
 
77
 
 
78
# If enabled, tell nose to collect coverage data
 
79
if [ $coverage -eq 1 ]; then
 
80
    noseopts="$noseopts --with-coverage --cover-package=nova"
 
81
fi
 
82
 
 
83
if [ $no_site_packages -eq 1 ]; then
 
84
  installvenvopts="--no-site-packages"
 
85
fi
 
86
 
 
87
function run_tests {
 
88
  # Cleanup *pyc
 
89
  ${wrapper} find . -type f -name "*.pyc" -delete
 
90
  # Just run the test suites in current environment
 
91
  ${wrapper} $NOSETESTS | tee nosetests.log
 
92
  # If we get some short import error right away, print the error log directly
 
93
  RESULT=$?
 
94
  if [ "$RESULT" -ne "0" ];
 
95
  then
 
96
    ERRSIZE=`wc -l run_tests.log | awk '{print \$1}'`
 
97
    if [ "$ERRSIZE" -lt "40" ];
 
98
    then
 
99
        cat run_tests.log
 
100
    fi
 
101
  else
 
102
    tests_run=$(awk '/^Ran/ {print $2}' nosetests.log)
 
103
    if [ -z "$tests_run" ] || [ "$tests_run" -eq 0 ];
 
104
    then
 
105
        echo "ERROR: Zero tests ran, something is wrong!"
 
106
        echo "This is usually caused by a parse error in some python"
 
107
        echo "file or a failure to set up the environment (i.e. during"
 
108
        echo "temporary database preparation). Running nosetests directly"
 
109
        echo "may offer more clues."
 
110
        return 1
 
111
    fi
 
112
  fi
 
113
  return $RESULT
 
114
}
 
115
 
 
116
 
 
117
function run_pep8 {
 
118
  echo "Running PEP8 and HACKING compliance check..."
 
119
 
 
120
  # Files of interest
 
121
  # NOTE(lzyeval): Avoid selecting nova-api-paste.ini and nova.conf in nova/bin
 
122
  #                when running on devstack.
 
123
  # NOTE(lzyeval): Avoid selecting *.pyc files to reduce pep8 check-up time
 
124
  #                when running on devstack.
 
125
  srcfiles=`find nova -type f -name "*.py" ! -wholename "nova\/openstack*"`
 
126
  srcfiles+=" `find bin -type f ! -name "nova.conf*" ! -name "*api-paste.ini*"`"
 
127
  srcfiles+=" `find tools -type f -name "*.py"`"
 
128
  srcfiles+=" setup.py"
 
129
 
 
130
  # Until all these issues get fixed, ignore.
 
131
  ignore='--ignore=N4,E12,E711,E721,E712'
 
132
 
 
133
  ${wrapper} python tools/hacking.py ${ignore} ${srcfiles}
 
134
 
 
135
  # NOTE(sirp): Dom0 plugins are written for Python 2.4, meaning some HACKING
 
136
  #             checks are too strict.
 
137
  pep8onlyfiles=`find plugins -type f -name "*.py"`
 
138
  pep8onlyfiles+=" `find plugins/xenserver/xenapi/etc/xapi.d/plugins/ -type f -perm +111`"
 
139
  ${wrapper} pep8 ${ignore} ${pep8onlyfiles}
 
140
}
 
141
 
 
142
 
 
143
NOSETESTS="nosetests $noseopts $noseargs"
 
144
 
 
145
if [ $never_venv -eq 0 ]
 
146
then
 
147
  # Remove the virtual environment if --force used
 
148
  if [ $force -eq 1 ]; then
 
149
    echo "Cleaning virtualenv..."
 
150
    rm -rf ${venv}
 
151
  fi
 
152
  if [ -e ${venv} ]; then
 
153
    wrapper="${with_venv}"
 
154
  else
 
155
    if [ $always_venv -eq 1 ]; then
 
156
      # Automatically install the virtualenv
 
157
      python tools/install_venv.py $installvenvopts
 
158
      wrapper="${with_venv}"
 
159
    else
 
160
      echo -e "No virtual environment found...create one? (Y/n) \c"
 
161
      read use_ve
 
162
      if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then
 
163
        # Install the virtualenv and run the test suite in it
 
164
        python tools/install_venv.py $installvenvopts
 
165
        wrapper=${with_venv}
 
166
      fi
 
167
    fi
 
168
  fi
 
169
fi
 
170
 
 
171
# Delete old coverage data from previous runs
 
172
if [ $coverage -eq 1 ]; then
 
173
    ${wrapper} coverage erase
 
174
fi
 
175
 
 
176
if [ $just_pep8 -eq 1 ]; then
 
177
    run_pep8
 
178
    exit
 
179
fi
 
180
 
 
181
if [ $recreate_db -eq 1 ]; then
 
182
    rm -f tests.sqlite
 
183
fi
 
184
 
 
185
run_tests
 
186
 
 
187
# NOTE(sirp): we only want to run pep8 when we're running the full-test suite,
 
188
# not when we're running tests individually. To handle this, we need to
 
189
# distinguish between options (noseopts), which begin with a '-', and
 
190
# arguments (noseargs).
 
191
if [ -z "$noseargs" ]; then
 
192
  if [ $no_pep8 -eq 0 ]; then
 
193
    run_pep8
 
194
  fi
 
195
fi
 
196
 
 
197
if [ $coverage -eq 1 ]; then
 
198
    echo "Generating coverage report in covhtml/"
 
199
    # Don't compute coverage for common code, which is tested elsewhere
 
200
    ${wrapper} coverage html --include='nova/*' --omit='nova/openstack/common/*' -d covhtml -i
 
201
fi