Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix flaky sponsor test #2567

Open
JacobCoffee opened this issue Sep 16, 2024 · 0 comments
Open

tests: fix flaky sponsor test #2567

JacobCoffee opened this issue Sep 16, 2024 · 0 comments
Assignees
Labels
tests Relates to the test suite

Comments

@JacobCoffee
Copy link
Member

JacobCoffee commented Sep 16, 2024

This is a flaky test that fails periodically after latest updates
https://github.com/python/pythondotorg/actions/runs/10887332034/job/30209329967?pr=2527


======================================================================
ERROR: test_save_info_for_image_asset (sponsors.tests.test_forms.SponsorRequiredAssetsFormTest.test_save_info_for_image_asset)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/django/db/backends/utils.py", line 87, in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.ForeignKeyViolation: insert or update on table "sponsors_benefitfeatureconfiguration" violates foreign key constraint "sponsors_benefitfeat_polymorphic_ctype_id_0ce3d544_fk_django_co"
DETAIL:  Key (polymorphic_ctype_id)=(100) is not present in table "django_content_type".


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

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/django/test/testcases.py", line 419, in _setup_and_call
    self._post_teardown()
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/django/test/testcases.py", line 1279, in _post_teardown
    self._fixture_teardown()
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/django/test/testcases.py", line 1509, in _fixture_teardown
    connections[db_name].check_constraints()
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/django/db/backends/postgresql/base.py", line 383, in check_constraints
    cursor.execute("SET CONSTRAINTS ALL IMMEDIATE")
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/django/db/backends/utils.py", line 87, in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.IntegrityError: insert or update on table "sponsors_benefitfeatureconfiguration" violates foreign key constraint "sponsors_benefitfeat_polymorphic_ctype_id_0ce3d544_fk_django_co"
DETAIL:  Key (polymorphic_ctype_id)=(100) is not present in table "django_content_type".

Originally posted by @JacobCoffee in #2527 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Relates to the test suite
Projects
None yet
Development

No branches or pull requests

1 participant