Skip to content

Commit

Permalink
speed up request_slowlog_terminate tests
Browse files Browse the repository at this point in the history
we set a low manual limit for termination, and check via the new boot script config dumper that the defaults are 3s and 30s for log and term
  • Loading branch information
dzuelke committed Jan 23, 2024
1 parent 68e8153 commit 833a7d0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
3 changes: 2 additions & 1 deletion test/fixtures/sigterm/fpm.request_slowlog_timeout.conf
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
request_slowlog_timeout = 3s
request_slowlog_timeout = 1s
request_terminate_timeout = 3s
17 changes: 14 additions & 3 deletions test/spec/php_sigterm_shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
end
end

it "logs slowness after about 3 seconds, prints a trace, and terminates the process after about 30 seconds" do
# launch web server wrapped in a 40 second timeout
it "logs slowness, prints a trace, and terminates the process after configured timeouts" do
# launch web server wrapped in a 10 second timeout
# once web server is ready, `read` unblocks and we curl the sleep() script which will take a few seconds to run
# after `curl` completes, `waitforit.sh` will shut down
cmd = "./waitforit.sh 40 'ready for connections' heroku-php-#{server} --verbose | { read && curl \"localhost:$PORT/index.php?wait=35\"; }"
cmd = "./waitforit.sh 10 'ready for connections' heroku-php-#{server} -F fpm.request_slowlog_timeout.conf --verbose | { read && curl \"localhost:$PORT/index.php?wait=5\"; }"
retry_until retry: 3, sleep: 5 do
output = @app.run(cmd)
# ensure slowlog info and trace is there
Expand All @@ -58,6 +58,17 @@
expect(output).to match(/execution timed out/)
end
end

it "is configured to log slow requests after 3 seconds and terminate them after 30 seconds" do
# we can parse this from the config test output (-tt tests config and dumps PHP-FPM config)
cmd = "heroku-php-#{server} -tt"
retry_until retry: 3, sleep: 5 do
output = @app.run(cmd)
# ensure slowlog info and trace is there
expect(output).to include("request_slowlog_timeout = 3s")
expect(output).to include("request_terminate_timeout = 30s")
end
end
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions test/var/log/parallel_runtime_rspec.heroku-20.log
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@ test/spec/php-7.4_boot-apache2_spec.rb:110
test/spec/php-7.4_boot-nginx_spec.rb:100
test/spec/php-7.4_concurrency-apache2_spec.rb:100
test/spec/php-7.4_concurrency-nginx_spec.rb:90
test/spec/php-7.4_sigterm_spec.rb:140
test/spec/php-7.4_sigterm_spec.rb:95
test/spec/php-8.0_base_spec.rb:52
test/spec/php-8.0_boot-apache2_spec.rb:110
test/spec/php-8.0_boot-nginx_spec.rb:100
test/spec/php-8.0_concurrency-apache2_spec.rb:100
test/spec/php-8.0_concurrency-nginx_spec.rb:90
test/spec/php-8.0_sigterm_spec.rb:140
test/spec/php-8.0_sigterm_spec.rb:95
test/spec/php-8.1_base_spec.rb:52
test/spec/php-8.1_boot-apache2_spec.rb:110
test/spec/php-8.1_boot-nginx_spec.rb:100
test/spec/php-8.1_concurrency-apache2_spec.rb:100
test/spec/php-8.1_concurrency-nginx_spec.rb:90
test/spec/php-8.1_sigterm_spec.rb:140
test/spec/php-8.1_sigterm_spec.rb:95
test/spec/php-8.2_base_spec.rb:52
test/spec/php-8.2_boot-apache2_spec.rb:110
test/spec/php-8.2_boot-nginx_spec.rb:100
test/spec/php-8.2_concurrency-apache2_spec.rb:100
test/spec/php-8.2_concurrency-nginx_spec.rb:90
test/spec/php-8.2_sigterm_spec.rb:140
test/spec/php-8.2_sigterm_spec.rb:95
test/spec/php-8.3_base_spec.rb:52
test/spec/php-8.3_boot-apache2_spec.rb:110
test/spec/php-8.3_boot-nginx_spec.rb:100
test/spec/php-8.3_concurrency-apache2_spec.rb:100
test/spec/php-8.3_concurrency-nginx_spec.rb:90
test/spec/php-8.3_sigterm_spec.rb:140
test/spec/php-8.3_sigterm_spec.rb:95
test/spec/php_default_spec.rb:80
test/spec/platform_spec.rb:65
6 changes: 3 additions & 3 deletions test/var/log/parallel_runtime_rspec.heroku-22.log
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ test/spec/php-8.1_boot-apache2_spec.rb:110
test/spec/php-8.1_boot-nginx_spec.rb:100
test/spec/php-8.1_concurrency-apache2_spec.rb:100
test/spec/php-8.1_concurrency-nginx_spec.rb:90
test/spec/php-8.1_sigterm_spec.rb:140
test/spec/php-8.1_sigterm_spec.rb:95
test/spec/php-8.2_base_spec.rb:52
test/spec/php-8.2_boot-apache2_spec.rb:110
test/spec/php-8.2_boot-nginx_spec.rb:100
test/spec/php-8.2_concurrency-apache2_spec.rb:100
test/spec/php-8.2_concurrency-nginx_spec.rb:90
test/spec/php-8.2_sigterm_spec.rb:140
test/spec/php-8.2_sigterm_spec.rb:95
test/spec/php-8.3_base_spec.rb:52
test/spec/php-8.3_boot-apache2_spec.rb:110
test/spec/php-8.3_boot-nginx_spec.rb:100
test/spec/php-8.3_concurrency-apache2_spec.rb:100
test/spec/php-8.3_concurrency-nginx_spec.rb:90
test/spec/php-8.3_sigterm_spec.rb:140
test/spec/php-8.3_sigterm_spec.rb:95
test/spec/php_default_spec.rb:80
test/spec/platform_spec.rb:65

0 comments on commit 833a7d0

Please sign in to comment.