openvstorage / framework

The Framework is a set of components and tools which brings the user an interface (GUI / API) to setup, extend and manage an Open vStorage platform.
Other
27 stars 23 forks source link

Add support for (unique) constraints in DAL #532

Closed khenderick closed 7 years ago

khenderick commented 8 years ago

Add support for (unique) constraints in DAL. I estimate this to be about 1-3 days of work.

wimpers commented 8 years ago

@khenderick can we summarize the benefits and the issues we will be vulnerable for when not tackling this so we can build a case for the stakeholders.

khenderick commented 8 years ago

It's not required at all, it's a feature that might prevent or reveal some bugs sooner (e.g. getting in situations where multiple almost identical objects are stored while the logic expects only one to be in there). It was a request from @pploegaert that I registered in github while working on investigating such bug (which is at this moment still in there - we have no idea what is adding these duplicate values every now and then)

pploegaert commented 8 years ago

unstable grid setup intermittently has multiple ASD nodes registered for a single IP: http://testrail.openvstorage.com/index.php?/tests/view/1072652&group_by=cases:section_id&group_order=asc&group_id=29858

In [2]: AlbaNodeList.get_albanode_by_ip('172.20.53.250')
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-2-77448b25e3ae> in <module>()
----> 1 AlbaNodeList.get_albanode_by_ip('172.20.53.250')

/opt/OpenvStorage/ovs/dal/lists/albanodelist.pyc in get_albanode_by_ip(ip)
     44                                     'items': [('ip', DataList.operator.EQUALS, ip)]})
     45         if len(nodes) > 1:
---> 46             raise RuntimeError('Multiple ALBA Nodes found with ip {0}'.format(ip))
     47         if len(nodes) == 1:
     48             return nodes[0]

RuntimeError: Multiple ALBA Nodes found with ip 172.20.53.250

In [3]: for an in AlbaNodeList.get_
AlbaNodeList.get_albanode_by_ip       AlbaNodeList.get_albanode_by_node_id  AlbaNodeList.get_albanodes            

In [3]: for an in AlbaNodeList.get_albanodes():
   ...:     print an.ip, an.guid
   ...:     
172.20.53.251 08290306-88aa-4099-8a36-28dffff5d4df
172.20.53.252 516b2bee-320b-40bf-8a65-96a3ac0dda10
172.20.53.250 c685e9ef-ecbe-45c3-93d4-3b09b5891421
172.20.53.250 d9b084c0-9df4-436b-b3a6-8e18e3ea101d
khenderick commented 7 years ago

Fixed by #1006 and openvstorage/framework-alba-plugin#232, packaged in openvstorage-2.7.4-rev.4098.8eb858f and openvstorage-backend-1.7.4-rev.734.a19c024

JeffreyDevloo commented 7 years ago

Information

Trusting unit tests for this feature. The reason being is that a manual test-case could skip multiple scenario's where issues could occur. Unit tests will however test the core functionality, thus covering a wider range of scenario's

If you deem a manual test required, you could execute one as:

from ovs.dal.hybrids.branding import Branding
a = Branding()
a.name = 'a'
a.css = 'x'
a.productname = 'x'
a.is_default = False
a.save()
b = Branding()
b.name = 'a'
b.css = 'y'
b.productname = 'y'
b.is_default = False
b.save()     #  <-- should raise because b's name is identical to a
a.delete()

Steps

Output

Both test were successful (necessity as they run before each merge)

----------------------------------------------------------------------
Ran 63 tests in 0.310s

OK

############
# OVERVIEW #
############

  - TestModule: /opt/OpenvStorage/ovs/dal/tests/test_basic  (63 tests)
    - DURATION: < 1 second
    - SUCCESS: 63

root@ovs-node1:~# ovs unittest /opt/OpenvStorage/ovs/dal/tests/test_hybrids.py
Test file /opt/OpenvStorage/config/templates/cinder-unit-tests/test_openvstorage.py could not be loaded. Error: No module named mock
Test file /opt/OpenvStorage/ovs/dal/tests/test_alba.py could not be loaded. Error: No module named tests.alba_mockups
Test file /opt/OpenvStorage/ovs/lib/tests/alba_tests/test_nsmcheckup.py could not be loaded. Error: No module named tests.alba_mockups

#######################################################################
# Processing test-module /opt/OpenvStorage/ovs/dal/tests/test_hybrids #
#######################################################################

test_objectproperties (test_hybrids.Hybrid) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.125s

OK

############
# OVERVIEW #
############

  - TestModule: /opt/OpenvStorage/ovs/dal/tests/test_hybrids  (1 test)
    - DURATION: < 1 second
    - SUCCESS: 1

Test result

Test passed.

Packages