You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -90,43 +90,141 @@ Some users reported frozen CI nodes with:
90
90
91
91
### Why does the CI node hang? (backtrace debugging)
92
92
93
-
Tests freeze and CI node timeouts (the Ruby process is killed by a CI provider). Add the following script to `spec_helper.rb`. Thanks to that, you will see the backtrace showing what code line causes the hanging problem. Backtrace is visible only if the Ruby process got kill with `USR1` signal. Learn more from this [GitHub issue](https://github.com/rspec/rspec-rails/issues/1353#issuecomment-93173691).
Knapsack Pro would print Ruby threads to the output when tests freeze and CI node timeouts (the Ruby process is killed by a CI provider).
94
+
See the backtrace(s) showing what code line causes the hanging problem. The backtrace is visible only if the Ruby process got killed with one of the OS signals like `HUP`, `INT`, `TERM`, `ABRT`, `QUIT`, `USR1`, or `USR2`.
If the CI provider does not kill the frozen process, you can do it by running the below command in the terminal (when you are ssh-ed into the CI node):
146
+
The non-main thread was stuck at the time due to the following `sleep` in the `a_spec.rb:6` line:
118
147
119
-
```bash
120
-
kill -USR1 <process pid>
148
+
```ruby title="a_spec.rb" showLineNumbers
149
+
describe 'A_describe'do
150
+
it 'A1 test example'do
151
+
expect(1).to eq 1
152
+
153
+
Thread.newdo
154
+
# highlight-start
155
+
sleep10
156
+
# highlight-end
157
+
end
158
+
end
159
+
end
121
160
```
122
161
123
-
Alternatively, you can use the `timeout` program to send the USR1 signal after Knapsack runs too long.
162
+
Use the above approach to discover the root issue of hanging tests in your test suite.
163
+
164
+
:::tip
165
+
166
+
You can use [the `timeout` program](https://man7.org/linux/man-pages/man1/timeout.1.html) to send the `USR1` signal after Knapsack runs too long if the CI provider does not kill the frozen process.
Notice that `600` is in seconds. It sends the signal after 10 minutes of running the command. You may want to adjust that number to ensure the USR1 signal is sent after the process is stuck and not before.
172
+
Notice that `600` is in seconds. It sends the signal after 10 minutes of running the command. You may want to adjust that number to ensure the `USR1` signal is sent after the process is stuck and not before.
173
+
For example, you could use 600 seconds (10 minutes) if you know that your tests take no more than 7 minutes to run.
174
+
175
+
:::
176
+
177
+
:::tip
178
+
179
+
Alternatively, you can check your CI provider documentation to configure a timeout. For example, Github Actions uses:
180
+
181
+
*[`jobs.<job_id>.timeout-minutes`](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes) - The maximum number of minutes to let a job run before GitHub automatically cancels it.
182
+
*[`jobs.<job_id>.steps[*].timeout-minutes`](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepstimeout-minutes) - The maximum number of minutes to run the step before killing the process.
183
+
184
+
:::
185
+
186
+
<details>
187
+
<summary>For legacy versions of `knapsack_pro` older than 7.7.0, please click here.</summary>
188
+
189
+
Tests freeze and CI node timeouts (the Ruby process is killed by a CI provider). Add the following script to `spec_helper.rb`. Thanks to that, you will see the backtrace showing what code line causes the hanging problem. Backtrace is visible only if the Ruby process got kill with `USR1` signal. Learn more from this [GitHub issue](https://github.com/rspec/rspec-rails/issues/1353#issuecomment-93173691).
If the CI provider does not kill the frozen process, you can do it by running the below command in the terminal (when you are ssh-ed into the CI node):
214
+
215
+
```bash
216
+
kill -USR1 <process pid>
217
+
```
218
+
219
+
Alternatively, you can use the `timeout` program to send the USR1 signal after Knapsack runs too long.
Notice that `600` is in seconds. It sends the signal after 10 minutes of running the command. You may want to adjust that number to ensure the USR1 signal is sent after the process is stuck and not before.
226
+
227
+
</details>
130
228
131
229
## Knapsack Pro does not work on a forked repository
0 commit comments