experimenter icon indicating copy to clipboard operation
experimenter copied to clipboard

Intermittent test failure in NimbusExperimentsListVIew

Open b4handjr opened this issue 3 months ago • 0 comments

______________ NimbusExperimentsListViewTest.test_filter_version _______________
[gw2] linux -- Python 3.13.6 /usr/local/bin/python3.13

self = <django.db.backends.utils.CursorWrapper object at 0xe21b62af6a50>
sql = 'INSERT INTO "auth_user" ("password", "last_login", "is_superuser", "username", "first_name", "last_name", "email", "is_staff", "is_active", "date_joined") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING "auth_user"."id"'
params = ('', None, False, '[email protected]', 'Kristine', 'Anderson', ...)
ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0xe21b62af6a50>})

    def _execute(self, sql, params, *ignored_wrapper_args):
        # Raise a warning during app initialization (stored_app_configs is only
        # ever set during testing).
        if not apps.ready and not apps.stored_app_configs:
            warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)
        self.db.validate_no_broken_transaction()
        with self.db.wrap_database_errors:
            if params is None:
                # params default might be backend specific.
                return self.cursor.execute(sql)
            else:
>               return self.cursor.execute(sql, params)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E               psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "auth_user_username_key"
E               DETAIL:  Key (username)=([email protected]) already exists.

/usr/local/lib/python3.13/site-packages/django/db/backends/utils.py:105: UniqueViolation

The above exception was the direct cause of the following exception:

self = <experimenter.nimbus_ui.tests.test_views.NimbusExperimentsListViewTest testMethod=test_filter_version>

    def test_filter_version(self):
        version = NimbusExperiment.Version.FIREFOX_120
        experiment = NimbusExperimentFactory.create(
            status=NimbusExperiment.Status.LIVE, firefox_min_version=version
        )
        [
>           NimbusExperimentFactory.create(
                status=NimbusExperiment.Status.LIVE, firefox_min_version=v
            )
            for v in {*list(NimbusExperiment.Version)} - {version}
        ]

experimenter/nimbus_ui/tests/test_views.py:444: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
experimenter/experiments/tests/factories.py:687: in create
    experiment = super().create(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/factory/django.py:121: in _generate
    return super()._generate(strategy, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/factory/base.py:465: in _generate
    return step.build()
           ^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/factory/builder.py:283: in build
    postgen_results[declaration_name] = declaration.declaration.evaluate_post(
/usr/local/lib/python3.13/site-packages/factory/declarations.py:652: in evaluate_post
    return self.call(instance, step, postgen_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/factory/declarations.py:683: in call
    return self.function(
experimenter/experiments/tests/factories.py:547: in subscribers
    self.subscribers.add(UserFactory.create())
                         ^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/factory/base.py:528: in create
    return cls._generate(enums.CREATE_STRATEGY, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/factory/django.py:121: in _generate
    return super()._generate(strategy, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/factory/base.py:465: in _generate
    return step.build()
           ^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/factory/builder.py:274: in build
    instance = self.factory_meta.instantiate(
/usr/local/lib/python3.13/site-packages/factory/base.py:317: in instantiate
    return self.factory._create(model, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/factory/django.py:174: in _create
    return manager.create(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/django/db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/django/db/models/query.py:663: in create
    obj.save(force_insert=True, using=self.db)
/usr/local/lib/python3.13/site-packages/django/contrib/auth/base_user.py:65: in save
    super().save(*args, **kwargs)
/usr/local/lib/python3.13/site-packages/django/db/models/base.py:902: in save
    self.save_base(
/usr/local/lib/python3.13/site-packages/django/db/models/base.py:1008: in save_base
    updated = self._save_table(
/usr/local/lib/python3.13/site-packages/django/db/models/base.py:1169: in _save_table
    results = self._do_insert(
/usr/local/lib/python3.13/site-packages/django/db/models/base.py:1210: in _do_insert
    return manager._insert(
/usr/local/lib/python3.13/site-packages/django/db/models/manager.py:87: in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/django/db/models/query.py:1868: in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/django/db/models/sql/compiler.py:1882: in execute_sql
    cursor.execute(sql, params)
/usr/local/lib/python3.13/site-packages/django/db/backends/utils.py:79: in execute
    return self._execute_with_wrappers(
/usr/local/lib/python3.13/site-packages/django/db/backends/utils.py:92: in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/django/db/backends/utils.py:100: in _execute
    with self.db.wrap_database_errors:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/local/lib/python3.13/site-packages/django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <django.db.backends.utils.CursorWrapper object at 0xe21b62af6a50>
sql = 'INSERT INTO "auth_user" ("password", "last_login", "is_superuser", "username", "first_name", "last_name", "email", "is_staff", "is_active", "date_joined") VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING "auth_user"."id"'
params = ('', None, False, '[email protected]', 'Kristine', 'Anderson', ...)
ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0xe21b62af6a50>})

    def _execute(self, sql, params, *ignored_wrapper_args):
        # Raise a warning during app initialization (stored_app_configs is only
        # ever set during testing).
        if not apps.ready and not apps.stored_app_configs:
            warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)
        self.db.validate_no_broken_transaction()
        with self.db.wrap_database_errors:
            if params is None:
                # params default might be backend specific.
                return self.cursor.execute(sql)
            else:
>               return self.cursor.execute(sql, params)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E               django.db.utils.IntegrityError: duplicate key value violates unique constraint "auth_user_username_key"
E               DETAIL:  Key (username)=([email protected]) already exists.

/usr/local/lib/python3.13/site-packages/django/db/backends/utils.py:105: IntegrityError

Seen here

┆Issue is synchronized with this Jira Task

b4handjr avatar Nov 05 '25 17:11 b4handjr