• Icon: Sub-task Sub-task
    • Resolution: Done
    • Icon: Medium Medium
    • Frankfurt Release
    • None
    • sli/plugins
    • None

       

       The dmaap plugin's package init contains code which unconditionally connects to a consul service on module load.

      This connection is used to retrieve configuration  for the dmaap plugin, but this configuration is not actually required at import time, only when the plugin code is actually being used. Thus, the configuration should be lazy-loaded at the time it's first used.

      Executing such code at import time is poor practice in general and actually break test setup earlier in python3. After applying normal 2 to 3 compatibility conversions, While pytest would execute the tests normally, running through tox/coverage results in breakage during collecting the tests. Compare the following with the attached outpu:

      ccsdk/plugins/dmaap$ PYTHONPATH=$PWD pytest tests/
      ============================= test session starts ==============================
      platform linux -- Python 3.6.8, pytest-5.2.2, py-1.8.0, pluggy-0.13.0
      rootdir: ccsdk/plugins/dmaap
      plugins: forked-1.1.3, cov-2.8.1, xdist-1.30.0
      collected 7 items                                                              
      tests/test_consulif.py ..                                                [ 28%]
      tests/test_dmaapcontrollerif.py .                                        [ 42%]
      tests/test_dr_lifecycle.py .                                             [ 57%]
      tests/test_mr_lifecycle.py .                                             [ 71%]
      tests/test_plugin.py .                                                   [ 85%]
      tests/test_utils.py .                                                    [100%]
      ============================== 7 passed in 0.13s =============================== 

            mirlos mirlos
            mirlos mirlos
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: