Skip to content

MeetingHostTests fail depending on test order: MeetingFactory's meeting number and date depend on earlier tests #11971

Done

Description

@rjsparks

Problem

Four tests in MeetingHostTests (ietf/meeting/tests_views.py) pass or fail depending on which tests ran before them in the same process:

  • test_logo_types_checked
  • test_meeting_host_replace_logo
  • test_remove
  • test_remove_with_selected_logo

They pass alone and in the full suite, but fail when InterimTests runs first:

ietf/manage.py test --settings=settings_test --skip-coverage \
    ietf.meeting.tests_views.InterimTests ietf.meeting.tests_views.MeetingHostTests
AssertionError: 302 != 200 : Couldn't retrieve redirection page '/meeting/103/materials': response code was 302 (expected 200)

This was found with the extra InterimTests from #11942. On main the same pair passes, but only because InterimTests happens to create fewer meetings there.

Cause

  • MeetingFactory(type_id='ietf') without a number gets '%02d' % (n + 80), where n is factory_boy's sequence counter. The counter keeps counting across tests within a run; the per-test database rollback doesn't reset it.
  • The meeting's date is derived from its number ((num - 2) // 3 + 1985 for the year), so the date depends on how many meetings earlier tests created.
  • After creating a host, each of these tests calls assertRedirects(r, <materials URL>), which also fetches the materials page and expects a 200. The materials view redirects meetings numbered over 96 to their proceedings once the correction cutoff (the start date plus 50 days by default) has passed.
  • So the tests fail whenever earlier tests push the number into 97–126. Run alone, the meeting is IETF 80 (2011) and the page renders. After InterimTests it reaches 103 (2018-11-20) and the page redirects. Further up, the derived dates are in the future, so the full suite passes.
  • The failing range depends on today's date: each year the factory's derived dates pass, about three more numbers move into it.

MeetingFactory(type_id='ietf') without a number appears in 43 places across eight test modules. Any of them that depends on the meeting's date relative to today has the same exposure.

Options

  • Fix the four tests: give their meetings an explicit number and date, or assert only the redirect's target with fetch_redirect_response=False. That is enough to make them deterministic.
  • Fix MeetingFactory: stop deriving the date from a sequence that crosses test boundaries, for example by defaulting to a date relative to today or by resetting the sequence per test. This removes the whole class of problem, but every test that relies on the current numbers or dates would need checking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions