* [PATCH 0/3] minor test golfing to make worktree smaller
@ 2020-01-26 5:33 Eric Wong
2020-01-26 5:33 ` [PATCH 1/3] test/exec/test_exec: bring worker_processes down to 2 Eric Wong
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2020-01-26 5:33 UTC (permalink / raw)
To: unicorn-public
must. kill. code.
Eric Wong (3):
test/exec/test_exec: bring worker_processes down to 2
test_helper: remove unused `chunked_spawn'
test_upload: use spawn to simplify redirects
test/exec/test_exec.rb | 16 +++++++++-------
test/test_helper.rb | 26 --------------------------
test/unit/test_upload.rb | 13 ++++---------
3 files changed, 13 insertions(+), 42 deletions(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] test/exec/test_exec: bring worker_processes down to 2
2020-01-26 5:33 [PATCH 0/3] minor test golfing to make worktree smaller Eric Wong
@ 2020-01-26 5:33 ` Eric Wong
2020-01-26 5:33 ` [PATCH 2/3] test_helper: remove unused `chunked_spawn' Eric Wong
2020-01-26 5:33 ` [PATCH 3/3] test_upload: use spawn to simplify redirects Eric Wong
2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2020-01-26 5:33 UTC (permalink / raw)
To: unicorn-public
My hardware gets worse and worse every year :<
---
test/exec/test_exec.rb | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/test/exec/test_exec.rb b/test/exec/test_exec.rb
index 8a6b43e..32734c1 100644
--- a/test/exec/test_exec.rb
+++ b/test/exec/test_exec.rb
@@ -45,8 +45,9 @@ def call(env)
COMMON_TMP = Tempfile.new('unicorn_tmp') unless defined?(COMMON_TMP)
+ HEAVY_WORKERS = 2
HEAVY_CFG = <<-EOS
-worker_processes 4
+worker_processes #{HEAVY_WORKERS}
timeout 30
logger Logger.new('#{COMMON_TMP.path}')
before_fork do |server, worker|
@@ -606,6 +607,7 @@ def test_unicorn_config_listen_augments_cli
def test_weird_config_settings
File.open("config.ru", "wb") { |fp| fp.syswrite(HI) }
ucfg = Tempfile.new('unicorn_test_config')
+ proc_total = HEAVY_WORKERS + 1 # + 1 for master
ucfg.syswrite(HEAVY_CFG)
pid = xfork do
redirect_test_io do
@@ -616,9 +618,9 @@ def test_weird_config_settings
results = retry_hit(["http://#{@addr}:#{@port}/"])
assert_equal String, results[0].class
wait_master_ready(COMMON_TMP.path)
- wait_workers_ready(COMMON_TMP.path, 4)
+ wait_workers_ready(COMMON_TMP.path, HEAVY_WORKERS)
bf = File.readlines(COMMON_TMP.path).grep(/\bbefore_fork: worker=/)
- assert_equal 4, bf.size
+ assert_equal HEAVY_WORKERS, bf.size
rotate = Tempfile.new('unicorn_rotate')
File.rename(COMMON_TMP.path, rotate.path)
@@ -630,20 +632,20 @@ def test_weird_config_settings
tries = DEFAULT_TRIES
log = File.readlines(rotate.path)
while (tries -= 1) > 0 &&
- log.grep(/reopening logs\.\.\./).size < 5
+ log.grep(/reopening logs\.\.\./).size < proc_total
sleep DEFAULT_RES
log = File.readlines(rotate.path)
end
- assert_equal 5, log.grep(/reopening logs\.\.\./).size
+ assert_equal proc_total, log.grep(/reopening logs\.\.\./).size
assert_equal 0, log.grep(/done reopening logs/).size
tries = DEFAULT_TRIES
log = File.readlines(COMMON_TMP.path)
- while (tries -= 1) > 0 && log.grep(/done reopening logs/).size < 5
+ while (tries -= 1) > 0 && log.grep(/done reopening logs/).size < proc_total
sleep DEFAULT_RES
log = File.readlines(COMMON_TMP.path)
end
- assert_equal 5, log.grep(/done reopening logs/).size
+ assert_equal proc_total, log.grep(/done reopening logs/).size
assert_equal 0, log.grep(/reopening logs\.\.\./).size
Process.kill(:QUIT, pid)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] test_helper: remove unused `chunked_spawn'
2020-01-26 5:33 [PATCH 0/3] minor test golfing to make worktree smaller Eric Wong
2020-01-26 5:33 ` [PATCH 1/3] test/exec/test_exec: bring worker_processes down to 2 Eric Wong
@ 2020-01-26 5:33 ` Eric Wong
2020-01-26 5:33 ` [PATCH 3/3] test_upload: use spawn to simplify redirects Eric Wong
2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2020-01-26 5:33 UTC (permalink / raw)
To: unicorn-public
It was added nearly 11 years ago in commit 6945342a1f0a4caa
("Transfer-Encoding: chunked streaming input support") but
never used.
---
test/test_helper.rb | 26 --------------------------
1 file changed, 26 deletions(-)
diff --git a/test/test_helper.rb b/test/test_helper.rb
index c21f75d..94a5b1b 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -265,32 +265,6 @@ def wait_for_death(pid)
raise "PID:#{pid} never died!"
end
-# executes +cmd+ and chunks its STDOUT
-def chunked_spawn(stdout, *cmd)
- fork {
- crd, cwr = IO.pipe
- crd.binmode
- cwr.binmode
- crd.sync = cwr.sync = true
-
- pid = fork {
- STDOUT.reopen(cwr)
- crd.close
- cwr.close
- exec(*cmd)
- }
- cwr.close
- begin
- buf = crd.readpartial(16384)
- stdout.write("#{'%x' % buf.size}\r\n#{buf}")
- rescue EOFError
- stdout.write("0\r\n")
- pid, status = Process.waitpid(pid)
- exit status.exitstatus
- end while true
- }
-end
-
def reset_sig_handlers
%w(WINCH QUIT INT TERM USR1 USR2 HUP TTIN TTOU CHLD).each do |sig|
trap(sig, "DEFAULT")
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] test_upload: use spawn to simplify redirects
2020-01-26 5:33 [PATCH 0/3] minor test golfing to make worktree smaller Eric Wong
2020-01-26 5:33 ` [PATCH 1/3] test/exec/test_exec: bring worker_processes down to 2 Eric Wong
2020-01-26 5:33 ` [PATCH 2/3] test_helper: remove unused `chunked_spawn' Eric Wong
@ 2020-01-26 5:33 ` Eric Wong
2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2020-01-26 5:33 UTC (permalink / raw)
To: unicorn-public
We can start using Ruby 1.9 APIs, nowadays (right?)
---
test/unit/test_upload.rb | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/test/unit/test_upload.rb b/test/unit/test_upload.rb
index 5de02e4..8d90e50 100644
--- a/test/unit/test_upload.rb
+++ b/test/unit/test_upload.rb
@@ -236,15 +236,10 @@ def test_chunked_upload_via_curl
resp = Tempfile.new('resp')
resp.sync = true
- rd, wr = IO.pipe
- wr.sync = rd.sync = true
- pid = fork {
- STDIN.reopen(rd)
- rd.close
- wr.close
- STDOUT.reopen(resp)
- exec cmd
- }
+ rd, wr = IO.pipe.each do |io|
+ io.sync = io.close_on_exec = true
+ end
+ pid = spawn(*cmd, { 0 => rd, 1 => resp })
rd.close
tmp.rewind
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-01-26 5:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-26 5:33 [PATCH 0/3] minor test golfing to make worktree smaller Eric Wong
2020-01-26 5:33 ` [PATCH 1/3] test/exec/test_exec: bring worker_processes down to 2 Eric Wong
2020-01-26 5:33 ` [PATCH 2/3] test_helper: remove unused `chunked_spawn' Eric Wong
2020-01-26 5:33 ` [PATCH 3/3] test_upload: use spawn to simplify redirects Eric Wong
Code repositories for project(s) associated with this public inbox
https://yhbt.net/unicorn.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).