Project

General

Profile

Actions

Cleanup #45901

closed

Feature #40907: mgr/dashboard: REST API improvements

mgr/dashboard/api: reach 100% test coverage in API controllers

Added by Ernesto Puerta almost 4 years ago. Updated about 3 years ago.

Status:
Resolved
Priority:
Normal
Category:
General - Back-end
Target version:
% Done:

100%

Tags:
Backport:
octopus
Reviewed:
Affected Versions:
Pull request ID:

Description

Currently API coverage is quite uneven across endpoints, 40% in average, but ranging from 0% to 71%:

Name                                                                                                                          Stmts   Miss  Cover
-------------------------------------------------------------------------------------------------------------------------------------------------
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/__init__.py                               23     21     9%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/awsauth.py                                80     30    62%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/cherrypy_backports.py                     88     68    23%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/__init__.py                  557    486    13%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/auth.py                       43     16    63%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/cephfs.py                    240     97    60%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/cluster_configuration.py      66     19    71%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/crush_rule.py                 26     17    35%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/erasure_code_profile.py       27     17    37%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/health.py                    127     44    65%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/home.py                       87     68    22%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/host.py                       72     49    32%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/logs.py                       32     22    31%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/mgr_modules.py                77     31    60%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/monitor.py                    24     11    54%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/nfsganesha.py                125     81    35%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/orchestrator.py               69     42    39%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/osd.py                       192    112    42%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/perf_counters.py              51     33    35%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/pool.py                      161     49    70%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/rbd.py                       251     94    63%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/rbd_mirroring.py             295    206    30%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/rgw.py                       255    105    59%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/role.py                       86     26    70%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/settings.py                   44     26    41%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/summary.py                    65     40    38%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/task.py                       14      7    50%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/telemetry.py                  15      9    40%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/controllers/user.py                      124     36    71%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/exceptions.py                             60     38    37%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/module.py                                246    230     7%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/plugins/__init__.py                       40     38     5%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/plugins/debug.py                          36     32    11%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/plugins/feature_toggles.py                77     70     9%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/plugins/pluggy.py                         41     39     5%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/plugins/plugin.py                         22     21     5%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/rest_client.py                           266    132    50%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/security.py                               33     29    12%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/services/access_control.py               561    378    33%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/services/auth.py                         132     49    63%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/services/ceph_service.py                 198     87    56%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/services/cephfs.py                       129     33    74%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/services/cephx.py                         19      8    58%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/services/exception.py                     89     51    43%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/services/ganesha.py                      655    231    65%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/services/iscsi_config.py                  66     60     9%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/services/orchestrator.py                  93     64    31%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/services/progress.py                      38     20    47%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/services/rbd.py                          241     56    77%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/services/rgw_client.py                   292    130    55%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/settings.py                              116    108     7%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/dashboard/tools.py                                 540    230    57%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/mgr_util.py                                        351    326     7%
/home/jenkins-build/build/workspace/ceph-dashboard-pr-backend/src/pybind/mgr/orchestrator/_interface.py                         662    618     7%
-------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                                                                                                          8319   4940    41%

The goal of this tracker is ensuring 100% coverage of controllers (here is where the API interface is exposed). Right now this is hard to achieve because there's "other logic" in those files. For achieving these 2 approaches should be taken in parallel:
- Either moving non-controller logic to services, or tagging that logic not to be included in coverage calculations (check this for reference: Test coverage only matters if it's at 100%). This doesn't mean that the services/other logic shouldn't be covered, but it's not realistic to achieve 100% coverage of all logic, so at least by starting with a subset of it, it should be easier.
- Once the above clean-up was performed, increasing the number of tests to cover 90%-100% of ALL controllers.

Python-coverage offers the comment # pragma: no cover - <rationale> for indicating sections of the code that should be exclude from the coverage calculation.

As a post-step of the back-end api test, if the resulting coverage is below X, the test should fail.


Related issues 1 (0 open1 closed)

Copied to Dashboard - Backport #46672: octopus: mgr/dashboard/api: reach 100% test coverage in API controllersResolvedAlfonso MartínezActions
Actions #1

Updated by Alfonso Martínez almost 4 years ago

  • Status changed from New to In Progress
  • Assignee set to Aashish Sharma
Actions #2

Updated by Aashish Sharma almost 4 years ago

  • Pull request ID set to 35694
Actions #3

Updated by Alfonso Martínez almost 4 years ago

  • Status changed from In Progress to Pending Backport
Actions #4

Updated by Alfonso Martínez almost 4 years ago

  • Copied to Backport #46672: octopus: mgr/dashboard/api: reach 100% test coverage in API controllers added
Actions #5

Updated by Nathan Cutler over 3 years ago

  • Status changed from Pending Backport to Resolved

While running with --resolve-parent, the script "backport-create-issue" noticed that all backports of this issue are in status "Resolved" or "Rejected".

Actions #6

Updated by Alfonso Martínez over 3 years ago

  • % Done changed from 0 to 100
Actions #7

Updated by Ernesto Puerta about 3 years ago

  • Project changed from mgr to Dashboard
  • Category changed from 146 to General - Back-end
Actions

Also available in: Atom PDF