Skip to content

chore(tests): clean leftover test state on shared CI app#256

Open
nijeesh-stream wants to merge 1 commit into
mainfrom
nijeeshjoshy/chore-cleanup-test-channel-types
Open

chore(tests): clean leftover test state on shared CI app#256
nijeesh-stream wants to merge 1 commit into
mainfrom
nijeeshjoshy/chore-cleanup-test-channel-types

Conversation

@nijeesh-stream
Copy link
Copy Markdown
Contributor

@nijeesh-stream nijeesh-stream commented May 12, 2026

Summary

Three test classes routinely fail on CI because the shared test app accumulates state across runs whenever a prior PR's job died before its inline teardown could fire. None of these are SDK behavior bugs — they are infra/seeding gaps that surface as red CI on unrelated PRs.

ChannelTypeTest / CommandTest — 50-item quota

Both classes tear down their state inline at the end of each test. When a CI run dies mid-test before the delete(...) call fires, the leftover entry stays on the shared test app. Once enough zombies accumulate, every new run hits the per-app cap (CustomChannelTypeLimit = 50, CustomCommandLimit = 50 on the backend):

StreamException: CreateChannelType failed with error:
    "your application reached the maximum number of custom channel types (50)"
StreamException: CreateCommand failed with error:
    "your application reached the maximum number of custom commands (50)"

Blocks 17 tests across the two classes. Add a @BeforeAll sweep on each that lists, filters out system defaults, and best-effort deletes the rest.

UserTest — paginated queryBanned misses new ban

Several ban-related tests do User.ban().request() then User.queryBanned().request() and assert the new ban is in the response with assertTrue(bans.stream().anyMatch(...)). queryBanned returns a paginated slice. Once enough zombie bans accumulate on the shared app the just-created ban ends up past page 1 and the assertion fails with expected: <true> but was: <false>.

Fix: @BeforeAll cleanupLeftoverBans that pages through and best-effort unbans each. Affects 5 tests (Can ban user, Can ban user with delete reactions, Can shadow ban user, Can list banned user, Can unban user).

TaskStatusTest — default waitFor too short for deleteMany

Channel.deleteMany(...).request().getTaskId() and then poll TaskStatus.get(taskId) for completion. The default waitFor timeout (5s, defined on BasicTest) is routinely too short for the asynq queue under load. Bump that one test to 5 minutes.

All sweeps are best-effort: anything still in active use returns an error from delete() / unban() and is skipped.

Test plan

  • ./gradlew spotlessCheck compileTestJava — clean
  • CI green on ChannelTypeTest + CommandTest + UserTest + TaskStatusTest

@nijeesh-stream nijeesh-stream force-pushed the nijeeshjoshy/chore-cleanup-test-channel-types branch from 655aee8 to eacfed0 Compare May 12, 2026 18:14
@nijeesh-stream nijeesh-stream changed the title chore(tests): clean leftover channel types + commands before tests run chore(tests): clean leftover test state on shared CI app May 12, 2026
Three test classes routinely fail on CI because the shared test app
accumulates state across runs whenever a prior PR's job died before
its inline teardown could fire:

- ChannelTypeTest / CommandTest: hit the per-app 50-item cap on custom
  channel types and custom commands (CustomChannelTypeLimit /
  CustomCommandLimit on the backend). Add @BeforeAll sweeps that list
  and best-effort delete the non-system entries.

- UserTest: User.queryBanned() returns a paginated slice, so once
  enough zombie bans pile up, the just-created ban under test ends up
  past the first page and the 'assertTrue(stream.anyMatch...)' check
  fails. Add @BeforeAll cleanup that pages through and unbans each.

- TaskStatusTest: the default 5s waitFor was routinely too short for
  Channel.deleteMany under load. Bump that one test to 5 minutes.

All sweeps are best-effort: anything still in use just returns an
error from delete()/unban() and is skipped.
@nijeesh-stream nijeesh-stream force-pushed the nijeeshjoshy/chore-cleanup-test-channel-types branch from eacfed0 to 391dc50 Compare May 12, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant