Skip to content

Commit

Permalink
Tests: Resolve flaky Automatix test
Browse files Browse the repository at this point in the history
Since 7093082 (Improvements of automatix daemon : Closes rucio#5616, rucio#5617
(rucio#5621), 2022-09-02), the `test_automatix` test fails infrequently. The
error message provided suggests, that the `project` variable sometimes
get converted to an integer:

```
=================================== FAILURES ===================================
________________________________ test_automatix ________________________________
[gw1] linux -- Python 3.6.8 /usr/bin/python
/usr/local/lib64/python3.6/site-packages/sqlalchemy/engine/base.py:1803: in _execute_context
    cursor, statement, parameters, context
/usr/local/lib64/python3.6/site-packages/sqlalchemy/engine/default.py:732: in do_execute
    cursor.execute(statement, parameters)
E   psycopg2.errors.UndefinedFunction: operator does not exist: character varying = integer
E   LINE 3: WHERE dev.dids.project = 17420750 AND dev.dids.did_type = 'C...
E                                  ^
E   HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
```

The `project` variable used is initialized via the first 8 characters of
a random uuid4 string. This string contains hexadecimal values, which
can lead to a string with the 8 first characters being just integers.
The probability for that with `(10 / 16) ^ 8 = 2.33%` (if we asume a
uniform distribution) is fairly low, however, we run the tests quite
frequently. This thus is a vaiable candidate for the error.

Postgres seems to be the only engine to automatically convert this
string into a number if possible, all other engines seem to work fine.
  • Loading branch information
Joel Dierkes committed Sep 11, 2022
1 parent 9b666b6 commit 18f4e3f
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/rucio/tests/test_automatix.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
import pytest

from rucio.common.config import config_add_section, config_has_section, config_set, config_remove_option
from rucio.common.utils import generate_uuid
from rucio.common.types import InternalScope
from rucio.core.did import list_dids, list_files
from rucio.core.scope import add_scope
from rucio.daemons.automatix.automatix import automatix
from rucio.rse import rsemanager as rsemgr
from rucio.tests.common import scope_name_generator
from rucio.tests.common import rse_name_generator, scope_name_generator


@pytest.mark.noparallel(reason='changes global configuration value')
Expand All @@ -49,8 +48,7 @@ def test_automatix(vo, root_account, rse_factory):
config_set("automatix", "did_prefix", "/belle/ddm/tests")
config_set("automatix", "separator", "/")

project = generate_uuid()
project = project[:8]
project = rse_name_generator(size=8)
test_dict = {
"type1": {
"probability": 100,
Expand Down

0 comments on commit 18f4e3f

Please sign in to comment.