Project

General

Profile

Feature #8354

Feature #8352: Calculate and visualize total code coverage

Visualize total code coverage

Added by Evgeny Novikov about 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Urgent
Category:
Bridge
Target version:
Start date:
08/15/2017
Due date:
10/09/2017
% Done:

100%

Estimated time:
Published in build:

Description

When Bridge will receive total code coverage it will need to visualize it. I assume several issues in comparison to visualization of coverage for verification tasks:
  1. There can be much more files and directories. So you will need to develop more means for showing coverage statistics.
  2. A file describing coverage can occupy much more space as well as its format can be extremely suboptimal for, say, showing coverage of individual files. So you will need to introduce some related improvements, e.g. split this file into multiple files each describing coverage just for a single source or specification file.

Related issues

Blocked by Klever - Feature #8416: Suggest better file archives passing from Core to BridgeClosed09/08/201709/13/2017

Actions

History

#1

Updated by Evgeny Novikov about 3 years ago

  • Priority changed from High to Urgent
  • Target version set to 0.2

Let's do all major tasks related with coverage.

#2

Updated by Vladimir Gratinskiy about 3 years ago

Now only verification reports can receive coverage. Do I need to change other component reports so it accept coverage archives?

#3

Updated by Evgeny Novikov about 3 years ago

Vladimir Gratinskiy wrote:

Now only verification reports can receive coverage. Do I need to change other component reports so it accept coverage archives?

Of course, but I suggest to discuss interface changes after #8416 will be implemented which in turns can be fully implemented just after results of the largest Core refactoring will be in master.

#4

Updated by Vladimir Gratinskiy about 3 years ago

  • Due date set to 09/25/2017
  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Implemented in branch "feature_8354".

#5

Updated by Alexey Polushkin almost 3 years ago

The branch 'feature_8354' conflicts with master. Please, update it

#6

Updated by Evgeny Novikov almost 3 years ago

  • Status changed from Resolved to Open
#7

Updated by Vladimir Gratinskiy almost 3 years ago

  • Status changed from Open to Resolved

The master was merged.

#8

Updated by Evgeny Novikov almost 3 years ago

  • Status changed from Resolved to Open

At the moment Bridge expects total coverage in an incorrect format. Indeed it will be like:

    "coverage": {
        "linux:alloc:irq": "54-qurhs2dk.zip" 
        "linux:alloc:spinlock": "54-9x5rz9kg.zip" 
    }

Regarding visualization I think that a simple table showing rule specifications (coverage dictionary keys) and buttons to corresponding coverage pages will be nice.

#9

Updated by Evgeny Novikov almost 3 years ago

In addition total coverage can be reported not only for component Sub-job but for Core itself.

#10

Updated by Vladimir Gratinskiy almost 3 years ago

  • Due date changed from 09/25/2017 to 10/09/2017
  • Status changed from Open to Resolved

Fixed in branch "multicoverage". Sub-job and Core now support only new format of coverage attribute while verification reports support only old format ("coverage": <archive name>).

#11

Updated by Evgeny Novikov almost 3 years ago

  • Status changed from Resolved to Open

Great! I noticed a minor issue that was likely introduced by recent changes. When I try to download a coverage archive from the coverage page, I get the following exception (Internal Server Error):

Environment:

Request Method: GET
Request URL: http://localhost:8998/reports/component/16340/download_coverage/

Django Version: 1.11
Python Version: 3.6.1
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.humanize',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'jobs',
 'marks',
 'reports',
 'service',
 'tools',
 'users')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware')

Traceback:

File "/home/novikov/.pyenv/versions/virtual-env-3.6.1/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/home/novikov/.pyenv/versions/virtual-env-3.6.1/lib/python3.6/site-packages/django/core/handlers/base.py" in _legacy_get_response
  249.             response = self._get_response(request)

File "/home/novikov/.pyenv/versions/virtual-env-3.6.1/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/home/novikov/.pyenv/versions/virtual-env-3.6.1/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/novikov/.pyenv/versions/virtual-env-3.6.1/lib/python3.6/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  23.                 return view_func(request, *args, **kwargs)

File "/home/novikov/work/klever/bridge/tools/profiling.py" in wait
  133.                 res = f(*args, **kwargs)

File "/home/novikov/work/klever/bridge/reports/views.py" in download_coverage
  777.     if not report.coverage:

Exception Type: AttributeError at /reports/component/16340/download_coverage/
Exception Value: 'ReportComponent' object has no attribute 'coverage'

#12

Updated by Evgeny Novikov almost 3 years ago

As well as there is debug printing in reports.coverage.exec_time that was introduced a long ago and should be either removed or made properly.

#13

Updated by Vladimir Gratinskiy almost 3 years ago

Fixed.

#14

Updated by Evgeny Novikov almost 3 years ago

  • Status changed from Open to Resolved

Everything works.

#15

Updated by Evgeny Novikov almost 3 years ago

  • Status changed from Resolved to Closed

I merged the branch to master in 37f0c082.

#16

Updated by Ilja Zakharov almost 3 years ago

Cannot perform migration. Seems that it is connected with this issue. Exception:

Running migrations:
Applying reports.0019_new_light_cache...Traceback (most recent call last):
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 110, in execute
return self.cursor.execute(query, args)
File "/home/zakharov/.local/lib/python3.5/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/home/zakharov/.local/lib/python3.5/site-packages/MySQLdb/connections.py", line 42, in defaulterrorhandler
raise errorvalue
File "/home/zakharov/.local/lib/python3.5/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/home/zakharov/.local/lib/python3.5/site-packages/MySQLdb/cursors.py", line 411, in _query
rowcount = self._do_query(q)
File "/home/zakharov/.local/lib/python3.5/site-packages/MySQLdb/cursors.py", line 374, in _do_query
db.query(q)
File "/home/zakharov/.local/lib/python3.5/site-packages/MySQLdb/connections.py", line 270, in query
_mysql.connection.query(self, query)
_mysql_exceptions.IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`kleverbase`.`cache_report_light_resource`, CONSTRAINT `cache_report_light_resource_report_id_bcc36648_fk_report_root_id` FOREIGN KEY (`report_id`) REFERENCES `report_root` (`id`))')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/zakharov/tools/pycharm-2017.1.3/helpers/pycharm/django_manage.py", line 43, in <module>
run_module(manage_file, None, '__main__', True)
File "/usr/lib/python3.5/runpy.py", line 196, in run_module
return run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.5/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/work/zakharov/src/klever/bridge/manage.py", line 27, in <module>
execute_from_command_line(sys.argv)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/core/management/
_init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/zakharov/.local/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/migrations/executor.py", line 145, in migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/migrations/migration.py", line 126, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/migrations/operations/special.py", line 189, in database_forwards
self.code(from_state.apps, schema_editor)
File "/work/zakharov/src/klever/bridge/reports/migrations/0019_new_light_cache.py", line 20, in fill_resources
ComponentResource.objects.bulk_create(resources)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/models/query.py", line 452, in bulk_create
ids = self._batched_insert(objs_without_pk, fields, batch_size)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/models/query.py", line 1068, in _batched_insert
self._insert(item, fields=fields, using=self.db)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/models/query.py", line 1045, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1054, in execute_sql
cursor.execute(sql, params)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/work/zakharov/src/klever/bridge/bridge/
_init__.py", line 32, in execute_wrapper
return original(*args, **kwargs)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/utils.py", line 94, in exit
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/zakharov/.local/lib/python3.5/site-packages/django/db/backends/mysql/base.py", line 110, in execute
return self.cursor.execute(query, args)
File "/home/zakharov/.local/lib/python3.5/site-packages/MySQLdb/cursors.py", line 250, in execute
self.errorhandler(self, exc, value)
File "/home/zakharov/.local/lib/python3.5/site-packages/MySQLdb/connections.py", line 42, in defaulterrorhandler
raise errorvalue
File "/home/zakharov/.local/lib/python3.5/site-packages/MySQLdb/cursors.py", line 247, in execute
res = self._query(query)
File "/home/zakharov/.local/lib/python3.5/site-packages/MySQLdb/cursors.py", line 411, in _query
rowcount = self._do_query(q)
File "/home/zakharov/.local/lib/python3.5/site-packages/MySQLdb/cursors.py", line 374, in _do_query
db.query(q)
File "/home/zakharov/.local/lib/python3.5/site-packages/MySQLdb/connections.py", line 270, in query
_mysql.connection.query(self, query)
django.db.utils.IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`kleverbase`.`cache_report_light_resource`, CONSTRAINT `cache_report_light_resource_report_id_bcc36648_fk_report_root_id` FOREIGN KEY (`report_id`) REFERENCES `report_root` (`id`))')

#17

Updated by Evgeny Novikov almost 3 years ago

  • Status changed from Closed to Open
#18

Updated by Evgeny Novikov almost 3 years ago

  • Status changed from Open to Closed

The mentioned issue likely exists just for MySQL or some strange databases. I could successfully migrate our production database without errors. So, I recommend to drop local databases with such errors. Also, please, switch to PostgreSQL at last!

Also available in: Atom PDF