stfc / rucio

Rucio - Scientific Data Management
http://rucio.cern.ch
Apache License 2.0
0 stars 0 forks source link

Seemingly random test failures when list_scopes has no value for filter #43

Closed patrick-austin closed 4 years ago

patrick-austin commented 4 years ago

Motivation

Tests such as test_list_dids_recursive were failing when the REST layer of list_scopes didn't pass an argument for filter. This has been prevented by setting filter={}, but the underlying cause should be looked into at some point. The failures were not consistent (not all suites were failing, the suites that did weren't always the same).

Modification

?

patrick-austin commented 4 years ago

Error(s) were caused whenever the filter argument was not passed to the API level list_scopes function. Because Python only creates mutable default arguments once at function definition (as opposed to creating a new empty dictionary every time it's called), setting filter['scope']=InternalScope(scope='*', vo=vo) changes this default dictionary for subsequent calls. This meant passing InternalScope an InternalScope rather than a string, which was ultimately the error causing failures. Use of empty dictionaries for default arguments is widespread at the API level, but is normally benign because we either pass the filter straight through to core or we edit entries that already exist. But in order to limit lists to a single VO, we can now add in filters for scope and account at the API level in cases where they weren't in the filters beforehand. I ran into this with list_accounts when writing tests, but it shouldn't normally be an issue as when called from the REST level it always has a filter argument passed. In order to prevent any issues when calling list_scopes, list_accounts or list_replication_rules without filters, have altered each function to create a new dictionary if it receives an empty one, thus modifying this new dictionary and not the default one.