Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Conversation

@cpascual
Copy link
Member

@cpascual cpascual commented Jan 13, 2017

Fix #365. (and also fix #261 as a side-effect)

Taurus4 introduced a regression related to the merge of TaurusAttribute
and TaurusConfiguration. The TangoAttribute.push_event method handles
all events but it doesn't do it properly for configuration-related
error events received before the TangoAttribute has been initialized.

In this situation, the TangoAttribute ends up flagged as subscribed
but the subscription was not actually done, preventing to become
properly subscribed when a non-error event comes later on.
It also may incorrectly deactivate the polling mechanism.

Refactor the push_event code to clean it and correctly handle conf
errors.

Notes:

Taurus4 introduced a regression related to the merge of TaurusAttribute
and TaurusConfiguration. The TangoAttribute.push_event method handles
all events but it doesn't do it properly for configuration-related
error events received before the TangoAttribute has been initialized.

In this situation, the TangoAttribute ends up flagged as subscribed
but the subscription was not actually done, preventing to become
properly subscribed when a non-error event comes later on.
It also may incorrectly deactivate the polling mechanism.

Refactor the push_event code to clean it and correctly handle conf
errors.
@cpascual cpascual added the bug label Jan 13, 2017
@cpascual cpascual modified the milestone: Jan17 Jan 13, 2017
@cpascual
Copy link
Member Author

Note that travis shows many failures in tests... they need to be investigated before accepting this PR

@cpascual
Copy link
Member Author

Investigating the travis errors, with @sagiss ... It seems like they are (again) linked to #261, i.e., they are spurious failures, hard to reproduce outside travis.

After forcing a re-run, we went from 8 errors to only 1:

======================================================================

/usr/local/lib/python2.7/dist-packages/taurus-4.0.3a0-py2.7.egg/taurus/core/resource/test/res/attr_resources_file.py

FAIL: test_texts (taurus.qt.qtgui.panel.test.test_taurusvalue.TaurusValueTest)

Testing texts(expected=('double_scalar', '1.23', '0.0 mm', 'mm'), model='tango:TangoSchemeTest/unittest/temp-1/double_scalar')

----------------------------------------------------------------------

Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/taurus-4.0.3a0-py2.7.egg/taurus/test/base.py", line 113, in newTest

    return helper(**helper_kwargs)

  File "/usr/local/lib/python2.7/dist-packages/taurus-4.0.3a0-py2.7.egg/taurus/qt/qtgui/panel/test/test_taurusvalue.py", line 77, in texts

    self.assertEqual(got, expected, msg)

AssertionError: wrong text for "tango:TangoSchemeTest/unittest/temp-1/double_scalar":

 expected: ('double_scalar', '1.23', '0.0 mm', 'mm')

 got: ('double_scalar', '-----', 'None', '')

----------------------------------------------------------------------

Ran 560 tests in 78.112s

FAILED (failures=1, skipped=11)

I am re-running it again in the hope that we get a clean build in travis to confirm that this is all #261 - related

@mrosanes
Copy link
Collaborator

On docker cpascual/taurus-test (launching the taurustestsuite outside travis), I managed to reproduce the failures that were appearing before on Travis.

root@taurus-test:/# 
...
======================================================================
FAIL: test_write_read_attr_13 (taurus.core.tango.test.test_tangoattribute.AttributeTestCase)
Testing write_read_attr(attrname='short_scalar', expected={'warnings': [, ], 'wvalue': , 'rvalue': , 'data_format': 0, 'label': 'short_scalar', 'writable': True, 'range': [, ], 'alarms': [, ], 'type': 0}, expected_attrv={'w_value': 1000, 'quality': , 'value': 1000}, setvalue=)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/taurus/lib/taurus/test/base.py", line 113, in newTest
    return helper(**helper_kwargs)
  File "/home/taurus/lib/taurus/core/tango/test/test_tangoattribute.py", line 771, in write_read_attr
    self.assertTrue(isinstance(read_value, TangoAttrValue), msg)
AssertionError: read() for "short_scalar" did not return a TangoAttrValue (got a NoneType)

======================================================================
FAIL: test_write_read_attr_16 (taurus.core.tango.test.test_tangoattribute.AttributeTestCase)
Testing write_read_attr(attrname='double_scalar', expected={'wvalue': , 'rvalue': , 'type': 1}, expected_attrv={'w_value': 3, 'quality': , 'value': 3}, setvalue=)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/taurus/lib/taurus/test/base.py", line 113, in newTest
    return helper(**helper_kwargs)
  File "/home/taurus/lib/taurus/core/tango/test/test_tangoattribute.py", line 771, in write_read_attr
    self.assertTrue(isinstance(read_value, TangoAttrValue), msg)
AssertionError: read() for "double_scalar" did not return a TangoAttrValue (got a NoneType)

======================================================================
FAIL: test_write_read_attr_17 (taurus.core.tango.test.test_tangoattribute.AttributeTestCase)
Testing write_read_attr(attrname='double_scalar', expected={'wvalue': , 'rvalue': }, expected_attrv={'wvalue': , 'rvalue': , 'quality': }, setvalue=)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/taurus/lib/taurus/test/base.py", line 113, in newTest
    return helper(**helper_kwargs)
  File "/home/taurus/lib/taurus/core/tango/test/test_tangoattribute.py", line 771, in write_read_attr
    self.assertTrue(isinstance(read_value, TangoAttrValue), msg)
AssertionError: read() for "double_scalar" did not return a TangoAttrValue (got a NoneType)

======================================================================
FAIL: test_write_read_attr_18 (taurus.core.tango.test.test_tangoattribute.AttributeTestCase)
Testing write_read_attr(attrname='double_scalar', expected={'alarms': [, ], 'range': [, ], 'name': 'double_scalar', 'warnings': [, ], 'wvalue': , 'rvalue': , 'type': 1}, expected_attrv={'wvalue': , 'w_value': 10, 'rvalue': , 'quality': , 'value': 10}, setvalue=)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/taurus/lib/taurus/test/base.py", line 113, in newTest
    return helper(**helper_kwargs)
  File "/home/taurus/lib/taurus/core/tango/test/test_tangoattribute.py", line 771, in write_read_attr
    self.assertTrue(isinstance(read_value, TangoAttrValue), msg)
AssertionError: read() for "double_scalar" did not return a TangoAttrValue (got a NoneType)

======================================================================
FAIL: test_write_read_attr_19 (taurus.core.tango.test.test_tangoattribute.AttributeTestCase)
Testing write_read_attr(attrname='float_scalar', expected={'wvalue': , 'rvalue': , 'type': 1}, expected_attrv={'w_value': 3, 'quality': , 'value': 3}, setvalue=)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/taurus/lib/taurus/test/base.py", line 113, in newTest
    return helper(**helper_kwargs)
  File "/home/taurus/lib/taurus/core/tango/test/test_tangoattribute.py", line 771, in write_read_attr
    self.assertTrue(isinstance(read_value, TangoAttrValue), msg)
AssertionError: read() for "float_scalar" did not return a TangoAttrValue (got a NoneType)

======================================================================
FAIL: test_write_read_attr_20 (taurus.core.tango.test.test_tangoattribute.AttributeTestCase)
Testing write_read_attr(attrname='float_scalar', expected={'wvalue': , 'rvalue': }, expected_attrv=': , 'rvalue': , 'quality': }, setvalue=)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/taurus/lib/taurus/test/base.py", line 113, in newTest
    return helper(**helper_kwargs)
  File "/home/taurus/lib/taurus/core/tango/test/test_tangoattribute.py", line 771, in write_read_attr
    self.assertTrue(isinstance(read_value, TangoAttrValue), msg)
AssertionError: read() for "float_scalar" did not return a TangoAttrValue (got a NoneType)

======================================================================
FAIL: test_write_read_attr_21 (taurus.core.tango.test.test_tangoattribute.AttributeTestCase)
Testing write_read_attr(attrname='float_scalar', expected={'alarms': [, ], 'range': [, ], 'name': 'float_scalar', 'warnings': [, ],': , 'rvalue': , 'type': 1}, expected_attrv={'wvalue': , 'w_value': 10, : , 'quality': , 'value': 10}, setvalue=)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/taurus/lib/taurus/test/base.py", line 113, in newTest
    return helper(**helper_kwargs)
  File "/home/taurus/lib/taurus/core/tango/test/test_tangoattribute.py", line 771, in write_read_attr
    self.assertTrue(isinstance(read_value, TangoAttrValue), msg)
AssertionError: read() for "float_scalar" did not return a TangoAttrValue (got a NoneType)

======================================================================
FAIL: test_write_read_attr_24 (taurus.core.tango.test.test_tangoattribute.AttributeTestCase)
Testing write_read_attr(attrname='boolean_scalar', expected={'writable': True, 'alarms': [None, None], 'range': [None, None], 'warnings': [None, None], ' False, 'rvalue': False, 'type': 3}, expected_attrv={'wvalue': False, 'w_value': False, 'rvalue': False, 'quality': , 'value': setvalue=False)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/taurus/lib/taurus/test/base.py", line 113, in newTest
    return helper(**helper_kwargs)
  File "/home/taurus/lib/taurus/core/tango/test/test_tangoattribute.py", line 771, in write_read_attr
    self.assertTrue(isinstance(read_value, TangoAttrValue), msg)
AssertionError: read() for "boolean_scalar" did not return a TangoAttrValue (got a NoneType)

----------------------------------------------------------------------
Ran 560 tests in 79.258s

FAILED (failures=8, skipped=11)


cmft and others added 5 commits January 19, 2017 09:05
The test-timer test is not deterministic. It may fail occasionally
(e.g. if the machine is overloaded) cause testsuite failures that
interfere with CI.

Exclude this test in travis.
AttributeTestCase.write_read_attr helper uses attr.write(with_read=True)
for reading the value. This may lead to reading None in some cases
 (e.g. attr.isUsingEvents() returns True) and cause the test to fail.

Do separated write and read (without cache) instead.
BaseWidgetTestCase based tests make calls to QApplication.processEvents
to emulate the Qt main loop. It seems that a single call is sometimes
insufficient to process all needed events for the test, which causes
spurious failures (see taurus-org#261)

As a workaround, implement a BaseWidgetTestCase.processEvents method
that loops several times over QApplication.processEvents and use it in
the tests.

Also remove previous workaround based on sleeps after setModel.

Also re-enable skipped tauruslabel background tests since this fix
seems to make them work again.
Some tests were commented out because they break test isolation.

The fix of taurus-org#365 may have solved the root cause of this, so reenable them.
Some random test failures (see taurus-org#261) seem to be related to test DS not
being properly initialized. Add a waiting time (controlled by the
TAURUS_STARTER_WAIT env var) during starting of DS to alleviate this.
Set TAURUS_STARTER_WAIT to 5 in Travis (i.e., wait 5 s after each DS
start)
@cpascual
Copy link
Member Author

I included several commits (cherry-picked and reworked from cmft#3) that should boost the robustness of the testsuite (they fix/work-around causes of #261).

@cpascual cpascual requested review from cmft and removed request for cmft January 19, 2017 09:45
@cpascual
Copy link
Member Author

@cmft and me reviewed (and pair-programmed) this, so I am accepting the PR

@cpascual cpascual merged commit 476ccca into taurus-org:develop Jan 19, 2017
@cpascual cpascual deleted the bug-365 branch July 14, 2017 13:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TangoAttribute may not properly handle errors in config events Random failures in testsuite (workaround exists, but proper fix is pending)

3 participants