Skip to content

Commit b862ab4

Browse files
committed
Fix asynchronous tests
1 parent de523bd commit b862ab4

File tree

2 files changed

+15
-32
lines changed

2 files changed

+15
-32
lines changed

.github/workflows/main.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
env:
9393
OPTIONS: "COV=false LOG_LEVEL=info SKIP_DICHO=true SKIP_REAL_CASES=true SKIP_PERIODIC=true SKIP_SPLIT_CLUSTERING=true"
9494
TIMEOUT: 10m
95-
steps: &test_steps
95+
steps:
9696
- name: Checkout
9797
uses: actions/checkout@v4
9898
- name: Download Docker image
@@ -113,7 +113,20 @@ jobs:
113113
env:
114114
OPTIONS: "COV=false LOG_LEVEL=info TEST=test/lib/heuristics/dichotomous_test.rb"
115115
TIMEOUT: 20m
116-
steps: *test_steps
116+
steps: &test_steps
117+
- name: Checkout
118+
uses: actions/checkout@v4
119+
- name: Download Docker image
120+
uses: actions/download-artifact@v4
121+
with:
122+
name: docker-image
123+
path: /tmp
124+
- name: Load Docker image
125+
run: docker load --input /tmp/optimizer-api.tar
126+
- name: Launch Stack
127+
run: timeout 4m docker compose -f ./docker/docker-compose.test.yml up --wait
128+
- name: Starting tests
129+
run: timeout ${TIMEOUT} docker compose -f ./docker/docker-compose.test.yml exec api rake test TESTOPTS="${TESTOPTS}" ${OPTIONS}
117130

118131
test_real:
119132
needs: build

test/api/v01/helpers/request_helper.rb

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -155,39 +155,9 @@ def asynchronously(options = {start_worker: false})
155155
OptimizerWrapper.config[:solve][:synchronously] = false
156156
old_resque_inline = Resque.inline
157157
Resque.inline = false
158-
if options[:start_worker] && !ENV['DOCKER']
159-
pid_worker = Process.spawn({ 'COUNT' => '1', 'QUEUE' => 'DEFAULT' },
160-
'bundle exec rake resque:workers --trace', pgroup: true) # don't create another shell
161-
pgid_worker = Process.getpgid(pid_worker)
162-
while `ps -o pgid | grep #{pgid_worker}`.split(/\n/).size < 2
163-
puts "#{Time.now} Waiting for the worker to launch"
164-
sleep 0.1
165-
end
166-
puts "#{Time.now} Worker is started"
167-
sleep 0.1
168-
end
169158
yield
170159
ensure
171160
Resque.inline = old_resque_inline
172161
OptimizerWrapper.config[:solve][:synchronously] = old_config_solve_synchronously
173-
if options[:start_worker] && !ENV['DOCKER'] && pgid_worker
174-
# Kill all grandchildren
175-
worker_pids = `ps -o pgid,pid | grep #{pgid_worker}`.split(/\n/)
176-
worker_pids.collect!{ |i| i.split(' ')[-1].to_i }
177-
worker_pids.sort!
178-
worker_pids.reverse_each{ |pid|
179-
next if pid == pgid_worker
180-
181-
Process.kill('SIGKILL', pid)
182-
Process.detach(pid)
183-
}
184-
Process.kill('SIGTERM', -pgid_worker) # Kill the process group (this doesn't kill grandchildren)
185-
Process.waitpid(-pgid_worker, 0)
186-
while `ps -o pgid,pid | grep "#{worker_pids.join('\|')}"`.split(/\n/).any?
187-
puts "#{Time.now} Waiting the worker process group #{pgid_worker} to die\n"
188-
sleep 0.1
189-
end
190-
puts "#{Time.now} Worker is killed"
191-
end
192162
end
193163
end

0 commit comments

Comments
 (0)