Project

General

Profile

Cleanup #45901

Feature #40907: mgr/dashboard: REST API improvements

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

Added by Ernesto Puerta 8 months ago. Updated 4 months ago.

Status:
Resolved
Priority:
Normal
Category:
dashboard/backend
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

Copied to mgr - Backport #46672: octopus: mgr/dashboard/api: reach 100% test coverage in API controllers Resolved

History

#1 Updated by Alfonso Martínez 7 months ago

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

#2 Updated by Aashish Sharma 6 months ago

  • Pull request ID set to 35694

#3 Updated by Alfonso Martínez 6 months ago

  • Status changed from In Progress to Pending Backport

#4 Updated by Alfonso Martínez 6 months ago

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

#5 Updated by Nathan Cutler 5 months 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".

#6 Updated by Alfonso Martínez 4 months ago

  • % Done changed from 0 to 100

Also available in: Atom PDF