Skip to content

Commit e6913df

Browse files
author
Marko Bogdanović
authored
Merge pull request #243 from bmarkons/add-ssh-method
Add ssh method to support PG suite
2 parents 60654f2 + 5a4e6a0 commit e6913df

4 files changed

Lines changed: 28 additions & 0 deletions

File tree

app/jobs/remote_server_job.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class RemoteServerJob < ActiveJob::Base
1616

1717
BUNDLER_RELEASE = "#{SCRIPTS_PATH}/bundler/releases.sh"
1818

19+
PG_MASTER = "#{SCRIPTS_PATH}/pg/master.sh"
20+
1921
# Use keyword arguments once Rails 4.2.1 has been released.
2022
def perform(initiator_key, benchmark_group, options = {})
2123
Net::SSH.start(
@@ -123,6 +125,12 @@ def bundler_releases(ssh, version, options)
123125
ssh_exec!(ssh, "#{BUNDLER_RELEASE} #{version} #{secrets.api_name} #{secrets.api_password} #{patterns}")
124126
end
125127

128+
def pg_master(ssh, commit_hash, options)
129+
patterns = options[:include_patterns]
130+
131+
ssh_exec!(ssh, "#{PG_MASTER} #{commit_hash} #{secrets.api_name} #{secrets.api_password} #{patterns}")
132+
end
133+
126134
def execute_ssh_commands(ssh, commands)
127135
commands.each do |command|
128136
ssh_exec!(ssh, command)

app/services/benchmark_pool.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ def self.enqueue(repo_name, commit_sha, options = {})
88
RemoteServerJob.perform_later(commit_sha, 'rails_trunk', options)
99
when 'sequel'
1010
RemoteServerJob.perform_later(commit_sha, 'sequel_trunk', options)
11+
when 'ruby-pg'
12+
RemoteServerJob.perform_later(commit_sha, 'pg_master', options)
1113
else
1214
raise ArgumentError, "unknown repo: #{repo_name}"
1315
end

test/jobs/remote_server_job_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ class RemoteServerJobTest < ActiveJob::TestCase
120120
)
121121
end
122122

123+
test '#perform pg_master' do
124+
@ssh.expects(:exec!).with(
125+
"tsp #{RemoteServerJob::PG_MASTER} #{@commit_hash} #{@api_name} #{@api_password} #{@patterns}"
126+
)
127+
128+
RemoteServerJob.new.perform(
129+
@commit_hash, 'pg_master', include_patterns: @patterns
130+
)
131+
end
132+
123133
private
124134

125135
def set_script_arguments

test/services/benchmark_pool_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ class BenchmarkPoolTest < ActiveSupport::TestCase
2626

2727
assert_enqueued_jobs 1
2828
end
29+
30+
test '#enqueue for ruby-pg' do
31+
assert_enqueued_with(job: RemoteServerJob) do
32+
BenchmarkPool.enqueue('ruby-pg', 'abc')
33+
end
34+
35+
assert_enqueued_jobs 1
36+
end
2937
end

0 commit comments

Comments
 (0)