Travis
This commit is contained in:
parent
cb4cefdfad
commit
ca1c71ea68
|
@ -4,6 +4,32 @@ require 'stud/temporary'
|
||||||
require 'java'
|
require 'java'
|
||||||
require 'securerandom'
|
require 'securerandom'
|
||||||
|
|
||||||
|
RSpec.configure do |c|
|
||||||
|
|
||||||
|
def start_service(name)
|
||||||
|
cmd = "sudo /etc/init.d/#{name}* stop"
|
||||||
|
|
||||||
|
`which systemctl`
|
||||||
|
if $?.success?
|
||||||
|
cmd = "sudo systemctl start #{name}"
|
||||||
|
end
|
||||||
|
|
||||||
|
`#{cmd}`
|
||||||
|
end
|
||||||
|
|
||||||
|
def stop_service(name)
|
||||||
|
cmd = "sudo /etc/init.d/#{name}* stop"
|
||||||
|
|
||||||
|
`which systemctl`
|
||||||
|
if $?.success?
|
||||||
|
cmd = "sudo systemctl stop #{name}"
|
||||||
|
end
|
||||||
|
|
||||||
|
`#{cmd}`
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
RSpec.shared_context 'rspec setup' do
|
RSpec.shared_context 'rspec setup' do
|
||||||
it 'ensure jar is available' do
|
it 'ensure jar is available' do
|
||||||
expect(ENV[jdbc_jar_env]).not_to be_nil, "#{jdbc_jar_env} not defined, required to run tests"
|
expect(ENV[jdbc_jar_env]).not_to be_nil, "#{jdbc_jar_env} not defined, required to run tests"
|
||||||
|
@ -124,28 +150,21 @@ RSpec.shared_context 'when outputting messages' do
|
||||||
# Check that everything is fine right now
|
# Check that everything is fine right now
|
||||||
expect { p.multi_receive([event]) }.not_to raise_error
|
expect { p.multi_receive([event]) }.not_to raise_error
|
||||||
|
|
||||||
start_stop_cmd = 'sudo /etc/init.d/%<service>s* %<action>s'
|
stop_service(systemd_database_service)
|
||||||
|
|
||||||
`which systemctl`
|
|
||||||
if $?.success?
|
|
||||||
start_stop_cmd = 'sudo systemctl %<action>s %<service>s'
|
|
||||||
end
|
|
||||||
|
|
||||||
cmd = start_stop_cmd % { action: 'stop', service: systemd_database_service }
|
|
||||||
`#{cmd}`
|
|
||||||
|
|
||||||
# Start a thread to restart the service after the fact.
|
# Start a thread to restart the service after the fact.
|
||||||
t = Thread.new(systemd_database_service) { |start_stop_cmd, systemd_database_service|
|
t = Thread.new(systemd_database_service) { |systemd_database_service|
|
||||||
sleep 20
|
sleep 20
|
||||||
|
|
||||||
cmd = start_stop_cmd % { action: 'start', service: systemd_database_service }
|
start_service(systemd_database_service)
|
||||||
`#{cmd}`
|
|
||||||
}
|
}
|
||||||
t.run
|
|
||||||
|
|
||||||
|
t.run
|
||||||
|
|
||||||
expect(logger).to receive(:warn).at_least(:once).with(/JDBC - Exception. Retrying/, Hash)
|
expect(logger).to receive(:warn).at_least(:once).with(/JDBC - Exception. Retrying/, Hash)
|
||||||
expect { p.multi_receive([event]) }.to_not raise_error
|
expect { p.multi_receive([event]) }.to_not raise_error
|
||||||
|
|
||||||
|
# Wait for the thread to finish
|
||||||
t.join
|
t.join
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user