-
Notifications
You must be signed in to change notification settings - Fork 196
/
Copy pathtest_all_connections.rb
33 lines (28 loc) · 1.05 KB
/
test_all_connections.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require 'looker-sdk'
# get API creds from environment variables
sdk = LookerSDK::Client.new(
:client_id => ENV['LOOKERSDK_CLIENT_ID'],
:client_secret => ENV['LOOKERSDK_CLIENT_SECRET'],
:api_endpoint => ENV['LOOKERSDK_BASE_URL']
)
def test_all_connections(looker)
all_connections = looker.all_connections(:fields => 'name, port, host, dialect(connection_tests, label)')
test_results = []
all_connections.each { | connection |
puts "Processing connection tests for \"#{connection[:name]}\""
begin
tests_to_run = connection[:dialect][:connection_tests].join(',')
testing = looker.test_connection(connection[:name], {}, tests: tests_to_run)
testing.each { | test |
if test[:status] != "success"
test_results << "Connection \"#{connection[:name]}\" (#{connection[:dialect][:label]}) has #{test[:status]}!"
end
}
rescue
test_results << "Uncaught error in testing connection \"#{connection[:name]}\""
end
}
puts "\n**********"
return test_results
end
puts test_all_connections(sdk)