Skip to content

Commit

Permalink
use new config test mode to test WEB_CONCURRENCY defaults
Browse files Browse the repository at this point in the history
a little faster and a little more robust
  • Loading branch information
dzuelke committed Jan 24, 2024
1 parent ae6bfc1 commit b9a5466
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions test/spec/php_shared_concurrency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,90 +18,90 @@
context "setting concurrency via .user.ini memory_limit" do
it "calculates concurrency correctly" do
retry_until retry: 3, sleep: 5 do
expect(expect_exit(code: 0) { @app.run("./waitforit.sh 15 'ready for connections' heroku-php-#{server} --verbose docroot/", :return_obj => true) }.output)
expect(expect_exit(code: 0) { @app.run("heroku-php-#{server} -tt docroot/", :return_obj => true) }.output)
.to match("PHP memory_limit is 32M Bytes")
.and match("Starting php-fpm with 16 workers...")
.and match("pm.max_children = 16")
end
end
it "always launches at least one worker" do
retry_until retry: 3, sleep: 5 do
expect(expect_exit(code: 0) { @app.run("./waitforit.sh 15 'ready for connections' heroku-php-#{server} --verbose docroot/onegig/", :return_obj => true) }.output)
expect(expect_exit(code: 0) { @app.run("heroku-php-#{server} -tt docroot/onegig/", :return_obj => true) }.output)
.to match("PHP memory_limit is 1024M Bytes")
.and match("Starting php-fpm with 1 workers...")
.and match("pm.max_children = 1")
end
end
it "is only done for a .user.ini directly in the document root" do
retry_until retry: 3, sleep: 5 do
expect(expect_exit(code: 0) { @app.run("./waitforit.sh 15 'ready for connections' heroku-php-#{server} --verbose", :return_obj => true) }.output)
expect(expect_exit(code: 0) { @app.run("heroku-php-#{server} -tt", :return_obj => true) }.output)
.to match("PHP memory_limit is 128M Bytes")
.and match("Starting php-fpm with 4 workers...")
.and match("pm.max_children = 4")
end
end
end

context "setting concurrency via FPM config memory_limit" do
it "calculates concurrency correctly" do
retry_until retry: 3, sleep: 5 do
expect(expect_exit(code: 0) { @app.run("./waitforit.sh 15 'ready for connections' heroku-php-#{server} --verbose -F conf/fpm.include.conf", :return_obj => true) }.output)
expect(expect_exit(code: 0) { @app.run("heroku-php-#{server} -tt -F conf/fpm.include.conf", :return_obj => true) }.output)
.to match("PHP memory_limit is 32M Bytes")
.and match("Starting php-fpm with 16 workers...")
.and match("pm.max_children = 16")
end
end
it "always launches at least one worker" do
retry_until retry: 3, sleep: 5 do
expect(expect_exit(code: 0) { @app.run("./waitforit.sh 15 'ready for connections' heroku-php-#{server} --verbose -F conf/fpm.onegig.conf", :return_obj => true) }.output)
expect(expect_exit(code: 0) { @app.run("heroku-php-#{server} -tt -F conf/fpm.onegig.conf", :return_obj => true) }.output)
.to match("PHP memory_limit is 1024M Bytes")
.and match("Starting php-fpm with 1 workers...")
.and match("pm.max_children = 1")
end
end
it "takes precedence over a .user.ini memory_limit" do
retry_until retry: 3, sleep: 5 do
expect(expect_exit(code: 0) { @app.run("./waitforit.sh 15 'ready for connections' heroku-php-#{server} --verbose -F conf/fpm.include.conf docroot/onegig/", :return_obj => true) }.output)
expect(expect_exit(code: 0) { @app.run("heroku-php-#{server} -tt -F conf/fpm.include.conf docroot/onegig/", :return_obj => true) }.output)
.to match("PHP memory_limit is 32M Bytes")
.and match("Starting php-fpm with 16 workers...")
.and match("pm.max_children = 16")
end
end
end

context "setting WEB_CONCURRENCY explicitly" do
it "uses the explicit value" do
retry_until retry: 3, sleep: 5 do
expect(expect_exit(code: 0) { @app.run("./waitforit.sh 15 'ready for connections' heroku-php-#{server} --verbose", :return_obj => true, :heroku => {:env => "WEB_CONCURRENCY=22"}) }.output)
expect(expect_exit(code: 0) { @app.run("heroku-php-#{server} -tt", :return_obj => true, :heroku => {:env => "WEB_CONCURRENCY=22"}) }.output)
.to match("\\$WEB_CONCURRENCY env var is set, skipping automatic calculation")
.and match("Starting php-fpm with 22 workers...")
.and match("pm.max_children = 22")
end
end
it "overrides a .user.ini memory_limit" do
retry_until retry: 3, sleep: 5 do
expect(expect_exit(code: 0) { @app.run("./waitforit.sh 15 'ready for connections' heroku-php-#{server} --verbose docroot/onegig/", :return_obj => true, :heroku => {:env => "WEB_CONCURRENCY=22"}) }.output)
expect(expect_exit(code: 0) { @app.run("heroku-php-#{server} -tt docroot/onegig/", :return_obj => true, :heroku => {:env => "WEB_CONCURRENCY=22"}) }.output)
.to match("\\$WEB_CONCURRENCY env var is set, skipping automatic calculation")
.and match("Starting php-fpm with 22 workers...")
.and match("pm.max_children = 22")
end
end
it "overrides an FPM config memory_limit" do
retry_until retry: 3, sleep: 5 do
expect(expect_exit(code: 0) { @app.run("./waitforit.sh 15 'ready for connections' heroku-php-#{server} --verbose -F conf/fpm.onegig.conf", :return_obj => true, :heroku => {:env => "WEB_CONCURRENCY=22"}) }.output)
expect(expect_exit(code: 0) { @app.run("heroku-php-#{server} -tt -F conf/fpm.onegig.conf", :return_obj => true, :heroku => {:env => "WEB_CONCURRENCY=22"}) }.output)
.to match("\\$WEB_CONCURRENCY env var is set, skipping automatic calculation")
.and match("Starting php-fpm with 22 workers...")
.and match("pm.max_children = 22")
end
end
end

context "running on a Performance-L dyno" do
it "restricts the app to 6 GB of RAM", :if => series < "7.4" do
retry_until retry: 3, sleep: 5 do
expect(expect_exit(code: 0) { @app.run("./waitforit.sh 15 'ready for connections' heroku-php-#{server} --verbose", :return_obj => true, :heroku => {:size => "Performance-L"}) }.output)
expect(expect_exit(code: 0) { @app.run("heroku-php-#{server} -tt", :return_obj => true, :heroku => {:size => "Performance-L"}) }.output)
.to match("Detected 15032385536 Bytes of RAM")
.and match("Limiting to 6G Bytes of RAM usage")
.and match("Starting php-fpm with 48 workers...")
.and match("pm.max_children = 48")
end
end

it "uses all available RAM for PHP-FPM workers", :unless => series < "7.4" do
retry_until retry: 3, sleep: 5 do
expect(expect_exit(code: 0) { @app.run("./waitforit.sh 15 'ready for connections' heroku-php-#{server} --verbose", :return_obj => true, :heroku => {:size => "Performance-L"}) }.output)
expect(expect_exit(code: 0) { @app.run("heroku-php-#{server} -tt", :return_obj => true, :heroku => {:size => "Performance-L"}) }.output)
.to match("Detected 15032385536 Bytes of RAM")
.and match("Starting php-fpm with 112 workers...")
.and match("pm.max_children = 112")
end
end
end
Expand Down

0 comments on commit b9a5466

Please sign in to comment.