Reviewed:  https://review.opendev.org/c/openstack/neutron/+/866178
Committed: 
https://opendev.org/openstack/neutron/commit/26c55efe34f317409e4277154bac4617db0d57cc
Submitter: "Zuul (22348)"
Branch:    master

commit 26c55efe34f317409e4277154bac4617db0d57cc
Author: Anton Kurbatov <[email protected]>
Date:   Wed Nov 30 15:04:34 2022 +0000

    Do not emit ssl warnings in the test_ssl_connection test
    
    Since python3.10 we get a warning inside the ovs.stream module:
    
    Warnings: {message : DeprecationWarning('ssl.PROTOCOL_TLS is
    deprecated'), category : 'DeprecationWarning', filename :
    'python3.10/site-packages/ovs/stream.py', lineno : 794, line : None}
    
    or using python console:
    
    >>> ssl.SSLContext(ssl.PROTOCOL_SSLv23)
    <stdin>:1: DeprecationWarning: ssl.PROTOCOL_TLS is deprecated
    <ssl.SSLContext object at 0x7f98620223c0>
    >>>
    
    This patch mocks the 'Connection.run' method that emits this warning
    inside a thread. This patch also fixes a failure in the
    test_distributed_port_binding_deleted_by_port_deletion test that was
    catching the ssl warning from test_ssl_connection and therefore
    failing.
    
    Closes-Bug: #1998343
    Signed-off-by: Anton Kurbatov <[email protected]>
    Change-Id: I6a4b9222a63a0d0271069eb12d0c97dd3821a2cc


** Changed in: neutron
       Status: In Progress => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1998343

Title:
  Unittest test_distributed_port_binding_deleted_by_port_deletion fails:
  DeprecationWarning('ssl.PROTOCOL_TLS is deprecated')

Status in neutron:
  Fix Released

Bug description:
  I got an error in the test_distributed_port_binding_deleted_by_port_deletion 
test on my CI run [1].
  Also I found the same failure in another CI run [2]

  FAIL: 
neutron.tests.unit.plugins.ml2.test_db.Ml2DvrDBTestCase.test_distributed_port_binding_deleted_by_port_deletion
  tags: worker-0
  ----------------------------------------------------------------------
  stderr: {{{
  
/home/zuul/src/opendev.org/openstack/neutron/.tox/shared/lib/python3.10/site-packages/ovs/stream.py:794:
 DeprecationWarning: ssl.PROTOCOL_TLS is deprecated
    ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
  
/home/zuul/src/opendev.org/openstack/neutron/.tox/shared/lib/python3.10/site-packages/ovs/stream.py:794:
 DeprecationWarning: ssl.PROTOCOL_TLS is deprecated
    ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
  }}}

  Traceback (most recent call last):
    File "/home/zuul/src/opendev.org/openstack/neutron/neutron/tests/base.py", 
line 182, in func
      return f(self, *args, **kwargs)
    File 
"/home/zuul/src/opendev.org/openstack/neutron/neutron/tests/unit/plugins/ml2/test_db.py",
 line 535, in test_distributed_port_binding_deleted_by_port_deletion
      self.assertEqual(
    File 
"/home/zuul/src/opendev.org/openstack/neutron/.tox/shared/lib/python3.10/site-packages/testtools/testcase.py",
 line 393, in assertEqual
      self.assertThat(observed, matcher, message)
    File 
"/home/zuul/src/opendev.org/openstack/neutron/.tox/shared/lib/python3.10/site-packages/testtools/testcase.py",
 line 480, in assertThat
      raise mismatch_error
  testtools.matchers._impl.MismatchError: [] != [<warnings.WarningMessage 
object at 0x7f65a6cdd3c0>]: Warnings: {message : 
DeprecationWarning('ssl.PROTOCOL_TLS is deprecated'), category : 
'DeprecationWarning', filename : 
'/home/zuul/src/opendev.org/openstack/neutron/.tox/shared/lib/python3.10/site-packages/ovs/stream.py',
 lineno : 794, line : None}

  I have spent some time and seem to have found the reason for this behavior on 
python 3.10.
  First of all, since python3.10 we get a warning when using ssl.PROTOCOL_TLS 
[3]:

  [root@node0 neutron]# python
  Python 3.10.8+ (heads/3.10-dirty:ca3c480, Nov 30 2022, 12:16:40) [GCC 4.8.5 
20150623 (Red Hat 4.8.5-44)] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import ssl
  >>> ssl.SSLContext(ssl.PROTOCOL_SSLv23)
  <stdin>:1: DeprecationWarning: ssl.PROTOCOL_TLS is deprecated
  <ssl.SSLContext object at 0x7f98620223c0>
  >>>

  I also found that the `test_ssl_connection` test case affects catching 
warnings in the test_distributed_port_binding_deleted_by_port_deletion test 
case.
  I was then able to reproduce the issue like this:

  [root@node0 neutron]# cat run_list.txt
  
neutron.tests.unit.agent.ovsdb.native.test_connection.ConfigureSslConnTestCase.test_ssl_connection
  
neutron.tests.unit.plugins.ml2.test_db.Ml2DvrDBTestCase.test_distributed_port_binding_deleted_by_port_deletion
  [root@node0 neutron]# git diff
  diff --git a/neutron/tests/unit/plugins/ml2/test_db.py 
b/neutron/tests/unit/plugins/ml2/test_db.py
  index 578a01a..d837871 100644
  --- a/neutron/tests/unit/plugins/ml2/test_db.py
  +++ b/neutron/tests/unit/plugins/ml2/test_db.py
  @@ -531,6 +531,8 @@ class Ml2DvrDBTestCase(testlib_api.SqlTestCase):
               router_id='router_id',
               status=constants.PORT_STATUS_DOWN).create()
           with warnings.catch_warnings(record=True) as warning_list:
  +            import time
  +            time.sleep(0.1)
               port.delete()
               self.assertEqual(
                   [], warning_list,
  [root@node0 neutron]# source .tox/shared/bin/activate
  (shared) [root@node0 neutron]# stestr run --concurrency=1 --load-list 
./run_list.txt
  ...
  
neutron.tests.unit.plugins.ml2.test_db.Ml2DvrDBTestCase.test_distributed_port_binding_deleted_by_port_deletion
  
--------------------------------------------------------------------------------------------------------------
  Captured traceback:
  ~~~~~~~~~~~~~~~~~~~
      Traceback (most recent call last):
        File "/root/github/neutron/neutron/tests/base.py", line 182, in func
      return f(self, *args, **kwargs)
        File "/root/github/neutron/neutron/tests/unit/plugins/ml2/test_db.py", 
line 537, in test_distributed_port_binding_deleted_by_port_deletion
      self.assertEqual(
        File 
"/root/github/neutron/.tox/shared/lib/python3.10/site-packages/testtools/testcase.py",
 line 393, in assertEqual
      self.assertThat(observed, matcher, message)
        File 
"/root/github/neutron/.tox/shared/lib/python3.10/site-packages/testtools/testcase.py",
 line 480, in assertThat
      raise mismatch_error
      testtools.matchers._impl.MismatchError: [] != [<warnings.WarningMessage 
object at 0x7f701cb5f640>]: Warnings: {message : 
DeprecationWarning('ssl.PROTOCOL_TLS is deprecated'), category : 
'DeprecationWarning', filename : 
'/root/github/neutron/.tox/shared/lib/python3.10/site-packages/ovs/stream.py', 
lineno : 794, line : None}

  ======
  Totals
  ======
  Ran: 2 tests in 1.3571 sec.
   - Passed: 1
   - Skipped: 0
   - Expected Fail: 0
   - Unexpected Success: 0
   - Failed: 1
  Sum of execute time for each test: 1.3053 sec.

  
  [1] 
https://zuul.opendev.org/t/openstack/build/8e0dd6e817394911aa0baffe07798b13
  [2] 
https://zuul.opendev.org/t/openstack/build/9f7881818f7842b38d31ed44ffa8a4f3
  [3] https://github.com/python/cpython/blob/3.10/Modules/_ssl.c#L3038

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1998343/+subscriptions


-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp

Reply via email to