Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
c158a31b
Unverified
Commit
c158a31b
authored
6 years ago
by
Jeremy Bowman
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #18636 from edx/jmbowman/TE-2659
TE-2659 Fix coverage with remote xdist workers
parents
18edbf60
2580e08b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pavelib/utils/envs.py
+29
-0
29 additions, 0 deletions
pavelib/utils/envs.py
pavelib/utils/test/suites/pytest_suite.py
+27
-13
27 additions, 13 deletions
pavelib/utils/test/suites/pytest_suite.py
with
56 additions
and
13 deletions
pavelib/utils/envs.py
+
29
−
0
View file @
c158a31b
...
...
@@ -12,6 +12,7 @@ import memcache
from
lazy
import
lazy
from
path
import
Path
as
path
from
paver.easy
import
sh
from
six.moves
import
configparser
from
pavelib.utils.cmd
import
django_cmd
...
...
@@ -251,6 +252,22 @@ class Env(object):
)
return
unicode
(
value
).
strip
()
@classmethod
def
covered_modules
(
cls
):
"""
List the source modules listed in .coveragerc for which coverage
will be measured.
"""
coveragerc
=
configparser
.
RawConfigParser
()
coveragerc
.
read
(
cls
.
PYTHON_COVERAGERC
)
modules
=
coveragerc
.
get
(
'
run
'
,
'
source
'
)
result
=
[]
for
module
in
modules
.
split
(
'
\n
'
):
module
=
module
.
strip
()
if
module
:
result
.
append
(
module
)
return
result
@lazy
def
env_tokens
(
self
):
"""
...
...
@@ -295,3 +312,15 @@ class Env(object):
Return a dictionary of feature flags configured by the environment.
"""
return
self
.
env_tokens
.
get
(
'
FEATURES
'
,
dict
())
@classmethod
def
rsync_dirs
(
cls
):
"""
List the directories that should be synced during pytest-xdist
execution. Needs to include all modules for which coverage is
measured, not just the tests being run.
"""
result
=
set
()
for
module
in
cls
.
covered_modules
():
result
.
add
(
module
.
split
(
'
/
'
)[
0
])
return
result
This diff is collapsed.
Click to expand it.
pavelib/utils/test/suites/pytest_suite.py
+
27
−
13
View file @
c158a31b
...
...
@@ -119,6 +119,23 @@ class SystemTestSuite(PytestSuite):
self
.
processes
=
int
(
self
.
processes
)
def
_under_coverage_cmd
(
self
,
cmd
):
"""
If self.run_under_coverage is True, it returns the arg
'
cmd
'
altered to be run under coverage. It returns the command
unaltered otherwise.
"""
if
self
.
run_under_coverage
:
if
self
.
xdist_ip_addresses
:
for
module
in
Env
.
covered_modules
():
cmd
.
append
(
'
--cov
'
)
cmd
.
append
(
module
)
else
:
cmd
.
append
(
'
--cov
'
)
cmd
.
append
(
'
--cov-report=
'
)
return
cmd
@property
def
cmd
(
self
):
if
self
.
django_toxenv
:
...
...
@@ -148,12 +165,8 @@ class SystemTestSuite(PytestSuite):
xdist_string
=
'
--tx ssh=ubuntu@{}//python=
"
source /edx/app/edxapp/edxapp_env;
'
\
'
python
"
//chdir=
"
/edx/app/edxapp/edx-platform
"'
.
format
(
ip
)
cmd
.
append
(
xdist_string
)
already_synced_dirs
=
set
()
for
test_path
in
self
.
test_id
.
split
():
test_root_dir
=
test_path
.
split
(
'
/
'
)[
0
]
if
test_root_dir
not
in
already_synced_dirs
:
cmd
.
append
(
'
--rsyncdir {}
'
.
format
(
test_root_dir
))
already_synced_dirs
.
add
(
test_root_dir
)
for
rsync_dir
in
Env
.
rsync_dirs
():
cmd
.
append
(
'
--rsyncdir {}
'
.
format
(
rsync_dir
))
else
:
if
self
.
processes
==
-
1
:
cmd
.
append
(
'
-n auto
'
)
...
...
@@ -256,12 +269,8 @@ class LibTestSuite(PytestSuite):
xdist_string
=
'
--tx ssh=ubuntu@{}//python=
"
source /edx/app/edxapp/edxapp_env;
'
\
'
python
"
//chdir=
"
/edx/app/edxapp/edx-platform
"'
.
format
(
ip
)
cmd
.
append
(
xdist_string
)
already_synced_dirs
=
set
()
for
test_path
in
self
.
test_id
.
split
():
test_root_dir
=
test_path
.
split
(
'
/
'
)[
0
]
if
test_root_dir
not
in
already_synced_dirs
:
cmd
.
append
(
'
--rsyncdir {}
'
.
format
(
test_root_dir
))
already_synced_dirs
.
add
(
test_root_dir
)
for
rsync_dir
in
Env
.
rsync_dirs
():
cmd
.
append
(
'
--rsyncdir {}
'
.
format
(
rsync_dir
))
if
self
.
eval_attr
:
cmd
.
append
(
"
-a
'
{}
'"
.
format
(
self
.
eval_attr
))
...
...
@@ -277,7 +286,12 @@ class LibTestSuite(PytestSuite):
unaltered otherwise.
"""
if
self
.
run_under_coverage
:
cmd
.
append
(
'
--cov
'
)
if
self
.
xdist_ip_addresses
:
for
module
in
Env
.
covered_modules
():
cmd
.
append
(
'
--cov
'
)
cmd
.
append
(
module
)
else
:
cmd
.
append
(
'
--cov
'
)
if
self
.
append_coverage
:
cmd
.
append
(
'
--cov-append
'
)
cmd
.
append
(
'
--cov-report=
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment