Skip to content

Commit 176a982

Browse files
authored
Merge pull request #260 from OsamaSayegh/discourse-bench-fix
Discourse bench fix
2 parents f277f05 + f0f2ac5 commit 176a982

File tree

2 files changed

+19
-35
lines changed

2 files changed

+19
-35
lines changed

app/jobs/remote_server_job.rb

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class RemoteServerJob < ActiveJob::Base
1818

1919
PG_COMMIT = "#{SCRIPTS_PATH}/pg/master.sh"
2020

21+
RUBY_COMMIT_DISCOURSE = "#{SCRIPTS_PATH}/ruby/discourse/trunk.sh"
22+
2123
# Use keyword arguments once Rails 4.2.1 has been released.
2224
def perform(initiator_key, benchmark_group, options = {})
2325
Net::SSH.start(
@@ -78,19 +80,9 @@ def ruby_release_discourse(ssh, ruby_version, options)
7880
end
7981

8082
def ruby_commit_discourse(ssh, commit_hash, options)
81-
execute_ssh_commands(ssh,
82-
[
83-
'docker pull rubybench/ruby_trunk_discourse',
84-
'docker run --name discourse_redis -d redis:2.8.19',
85-
'docker run --name discourse_postgres -d postgres:9.3.5',
86-
"docker run --rm --link discourse_postgres:postgres
87-
--link discourse_redis:redis -e \"RUBY_COMMIT_HASH=#{commit_hash}\"
88-
-e \"API_NAME=#{secrets.api_name}\"
89-
-e \"API_PASSWORD=#{secrets.api_password}\"
90-
rubybench/ruby_trunk_discourse".squish,
91-
'docker stop discourse_postgres discourse_redis',
92-
'docker rm -v discourse_postgres discourse_redis'
93-
]
83+
ssh_exec!(
84+
ssh,
85+
"#{RUBY_COMMIT_DISCOURSE} #{commit_hash} #{secrets.api_name} #{secrets.api_password}"
9486
)
9587
end
9688

test/jobs/remote_server_job_test.rb

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ class RemoteServerJobTest < ActiveJob::TestCase
99
end
1010

1111
test '#perform ruby_commit' do
12-
@ssh.expects(:exec!).with(
13-
"tsp #{RemoteServerJob::RUBY_COMMIT} #{@ruby} #{@memory} #{@optcarrot} #{@liquid} #{@commit_hash} #{@api_name} #{@api_password} #{@patterns}"
14-
)
15-
16-
RemoteServerJob.new.perform(
17-
@commit_hash, 'ruby_commit', include_patterns: @patterns
18-
)
12+
begin
13+
@liquid = false
14+
@ssh.expects(:exec!).with(
15+
"tsp #{RemoteServerJob::RUBY_COMMIT} #{@ruby} #{@memory} #{@optcarrot} #{@liquid} #{@commit_hash} #{@api_name} #{@api_password} #{@patterns}"
16+
)
17+
18+
RemoteServerJob.new.perform(
19+
@commit_hash, 'ruby_commit', include_patterns: @patterns
20+
)
21+
ensure
22+
@liquid = true
23+
end
1924
end
2025

2126
test '#perform ruby_releases' do
@@ -51,21 +56,8 @@ class RemoteServerJobTest < ActiveJob::TestCase
5156
end
5257

5358
test '#perform ruby_commit_discourse' do
54-
[
55-
'tsp docker pull rubybench/ruby_trunk_discourse',
56-
'tsp docker run --name discourse_redis -d redis:2.8.19',
57-
'tsp docker run --name discourse_postgres -d postgres:9.3.5',
58-
"tsp docker run --rm --link discourse_postgres:postgres
59-
--link discourse_redis:redis -e \"RUBY_COMMIT_HASH=commit_hash\"
60-
-e \"API_NAME=#{@api_name}\"
61-
-e \"API_PASSWORD=#{@api_password}\"
62-
rubybench/ruby_trunk_discourse".squish,
63-
'tsp docker stop discourse_postgres discourse_redis',
64-
'tsp docker rm -v discourse_postgres discourse_redis'
65-
].each do |command|
66-
67-
@ssh.expects(:exec!).with(command)
68-
end
59+
command = "tsp #{RemoteServerJob::RUBY_COMMIT_DISCOURSE} commit_hash #{@api_name} #{@api_password}"
60+
@ssh.expects(:exec!).with(command)
6961

7062
RemoteServerJob.new.perform('commit_hash', 'ruby_commit_discourse')
7163
end

0 commit comments

Comments
 (0)