Commit dbe1676
authored
fix(tests): clean up gptme_N sessions in tmux test fixture (#926)
* fix(tests): clean up gptme_N sessions in tmux test fixture
The cleanup fixture only cleaned up sessions matching gptme_{worker_id}_*
but new_session() creates sessions named gptme_N (simple numeric suffix).
These sessions were not cleaned up between tests, causing failures when
sessions from previous tests still existed.
This fix extends the cleanup to also remove gptme_N pattern sessions
(where N is just digits) in addition to the worker-prefixed ones.
Fixes flaky test: TestNewSession::test_increments_session_id
* fix(tests): use worker-isolated session in test_lists_created_sessions
The test was using new_session() which creates gptme_N format sessions.
In parallel testing with pytest-xdist, other workers' cleanup could
remove these sessions before the test verifies them, causing race
condition failures.
Now uses _create_test_session() which creates worker-prefixed sessions
(gptme_gw0_1, etc.) that are isolated from other workers' cleanup.
* fix(tests): add tmux session cleanup for test_cli::test_tmux
Add cleanup_tmux_sessions fixture to prevent cross-test contamination
when running tests in parallel. The test_cli::test_tmux test runs the
actual gptme CLI which creates gptme_N sessions internally, and these
can leak between test runs.
Changes:
- Add cleanup_tmux_sessions fixture in conftest.py that cleans up
gptme_N sessions before and after tests
- Apply fixture to test_tmux in test_cli.py
- Add xdist_group marker to ensure tmux tests run on same worker
Fixes the CI failure where test_tmux was capturing output from a
different test run's tmux session.
* fix(tests): add xdist_group to all tmux tests for serialization
All tmux tests now run on the same worker to prevent race conditions
where tests creating gptme_N sessions interfere with each other.
The test_cli::test_tmux was still failing because test_tools_tmux.py
tests (like test_increments_session_id) create gptme_N sessions without
the xdist_group marker, allowing parallel execution that causes
session name collisions.
By adding xdist_group('tmux') at the module level to test_tools_tmux.py,
all tmux-related tests now run serially on the same worker.
* Revert "fix(tests): add xdist_group to all tmux tests for serialization"
This reverts commit ffc35da.
* style(tests): use regex for tmux session pattern matching
Use re.compile(r'^gptme_\d+$') for cleaner session name matching
instead of string splitting. Improves readability as suggested in
code review.
Addresses review feedback on PR #926.
* fix(tests): serialize tests using new_session() to avoid race conditions
Tests that call new_session() directly create gptme_N sessions that can
conflict with other workers' cleanup. This commit:
1. Removes automatic cleanup of gptme_N sessions from the autouse fixture
(only keeps worker-specific gptme_{worker_id}_* cleanup)
2. Creates a new cleanup_new_session_sessions fixture for tests that need
gptme_N session cleanup (non-autouse, must be explicitly requested)
3. Marks TestNewSession, TestKillSession, and test_auto_prefixes_session_id
with @pytest.mark.xdist_group('tmux_new_session') to ensure they run
serially on the same worker, preventing race conditions
This approach isolates the problematic tests without affecting the
performance of other tmux tests that use worker-isolated sessions.
* fix(tests): align xdist_group name for test_cli::test_tmux
Changed xdist_group from 'tmux' to 'tmux_new_session' to match the
group used in test_tools_tmux.py. This ensures ALL tests that create
gptme_N sessions run on the same worker, preventing race conditions.
* fix(tests): use worker-isolated sessions in TestKillSession
The test_kills_session test was failing in CI because new_session()
creates gptme_N sessions which can be killed by other workers' cleanup.
Fix: Use _create_test_session() which creates worker-isolated sessions
(gptme_{worker_id}_N) that aren't affected by other workers' cleanup.
This removes the need for xdist_group on TestKillSession since the
sessions are now worker-isolated by design.1 parent 1ee053a commit dbe1676
3 files changed
+107
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
154 | 199 | | |
155 | 200 | | |
156 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
| 348 | + | |
348 | 349 | | |
349 | 350 | | |
350 | 351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
71 | 76 | | |
72 | 77 | | |
73 | 78 | | |
74 | | - | |
| 79 | + | |
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
| |||
83 | 88 | | |
84 | 89 | | |
85 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
86 | 116 | | |
87 | 117 | | |
88 | 118 | | |
| |||
94 | 124 | | |
95 | 125 | | |
96 | 126 | | |
| 127 | + | |
97 | 128 | | |
98 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
99 | 134 | | |
100 | | - | |
| 135 | + | |
101 | 136 | | |
102 | 137 | | |
103 | 138 | | |
104 | 139 | | |
105 | 140 | | |
106 | | - | |
| 141 | + | |
107 | 142 | | |
108 | 143 | | |
109 | 144 | | |
| |||
122 | 157 | | |
123 | 158 | | |
124 | 159 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 160 | + | |
| 161 | + | |
130 | 162 | | |
131 | | - | |
132 | | - | |
133 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
134 | 168 | | |
135 | 169 | | |
136 | 170 | | |
137 | 171 | | |
138 | 172 | | |
139 | 173 | | |
140 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
141 | 178 | | |
142 | | - | |
| 179 | + | |
143 | 180 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
| 181 | + | |
| 182 | + | |
151 | 183 | | |
152 | 184 | | |
153 | 185 | | |
| |||
187 | 219 | | |
188 | 220 | | |
189 | 221 | | |
190 | | - | |
191 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
192 | 228 | | |
193 | 229 | | |
194 | 230 | | |
| |||
0 commit comments