hawkular-client 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.gitignore +2 -1
- data/.rubocop.yml +19 -6
- data/CHANGES.rdoc +13 -3
- data/README.rdoc +9 -3
- data/hawkularclient.gemspec +8 -4
- data/lib/alerts/alerts_api.rb +202 -32
- data/lib/hawkular.rb +35 -67
- data/lib/hawkular_all.rb +2 -0
- data/lib/inventory/inventory_api.rb +459 -130
- data/lib/metrics/metric_api.rb +14 -9
- data/lib/operations/operations_api.rb +247 -0
- data/lib/tokens/tokens_api.rb +33 -0
- data/lib/version.rb +1 -1
- data/spec/integration/alerts_spec.rb +272 -20
- data/spec/integration/hello-world-definitions.json +46 -0
- data/spec/integration/inventory_spec.rb +253 -89
- data/spec/integration/metric_spec.rb +36 -0
- data/spec/integration/operations_spec.rb +420 -0
- data/spec/integration/tokens_spec.rb +45 -0
- data/spec/resources/driver.jar +0 -0
- data/spec/resources/sample.war +0 -0
- data/spec/spec_helper.rb +30 -6
- data/spec/unit/base_spec.rb +22 -1
- data/spec/unit/canonical_path_spec.rb +92 -0
- data/spec/vcr/vcr_setup.rb +3 -4
- data/spec/vcr_cassettes/Alert/EndToEnd/Should_create_and_fire_a_trigger.yml +1187 -0
- data/spec/vcr_cassettes/Alert/Events/Should_list_events.yml +101 -0
- data/spec/vcr_cassettes/Alert/Events/Should_list_events_using_criteria.yml +79 -0
- data/spec/vcr_cassettes/Alert/Events/Should_not_list_events_using_criteria.yml +49 -0
- data/spec/vcr_cassettes/Alert/Triggers/Should_bulk_load_triggers.yml +225 -0
- data/spec/vcr_cassettes/Alert/Triggers/Should_create_a_basic_trigger_with_action.yml +355 -0
- data/spec/vcr_cassettes/Alert/Triggers/Should_create_an_action.yml +134 -0
- data/spec/vcr_cassettes/Alert/Triggers/Should_create_an_action_for_webhooks.yml +220 -0
- data/spec/vcr_cassettes/Alert/Triggers/Should_get_the_action_definitions.yml +218 -0
- data/spec/vcr_cassettes/Alert/Triggers/Should_not_create_an_action_for_unknown_plugin.yml +46 -0
- data/spec/vcr_cassettes/Alert/Triggers/Should_not_create_an_action_for_unknown_properties.yml +134 -0
- data/spec/vcr_cassettes/Counter_metrics/Should_get_metrics_with_limit_and_order.yml +270 -0
- data/spec/vcr_cassettes/Inventory/Client_should_listen_on_various_inventory_events.json +47 -0
- data/spec/vcr_cassettes/Inventory/Client_should_listen_on_various_inventory_events.yml +191 -0
- data/spec/vcr_cassettes/Inventory/Helpers/generate_some_events_for_websocket.yml +507 -0
- data/spec/vcr_cassettes/Inventory/Should_List_datasources_with_no_props.yml +74 -69
- data/spec/vcr_cassettes/Inventory/{Should_list_types_without_feed.yml → Should_create_a_feed.yml} +29 -32
- data/spec/vcr_cassettes/Inventory/Should_create_a_feed_again.yml +211 -0
- data/spec/vcr_cassettes/Inventory/Should_create_a_resource_.yml +355 -0
- data/spec/vcr_cassettes/Inventory/Should_create_a_resource_with_metric.yml +786 -0
- data/spec/vcr_cassettes/Inventory/Should_create_a_resourcetype.yml +205 -0
- data/spec/vcr_cassettes/Inventory/Should_create_and_delete_feed.yml +201 -0
- data/spec/vcr_cassettes/Inventory/Should_create_and_get_a_resource.yml +419 -0
- data/spec/vcr_cassettes/Inventory/Should_list_URLs.yml +39 -27
- data/spec/vcr_cassettes/Inventory/Should_list_WildFlys.yml +37 -29
- data/spec/vcr_cassettes/Inventory/Should_list_WildFlys_with_props.yml +53 -45
- data/spec/vcr_cassettes/Inventory/Should_list_all_the_resource_types.yml +177 -0
- data/spec/vcr_cassettes/Inventory/Should_list_children_of_WildFly.yml +230 -56
- data/spec/vcr_cassettes/Inventory/Should_list_feeds.yml +27 -24
- data/spec/vcr_cassettes/Inventory/Should_list_heap_metrics_for_WildFlys.yml +586 -119
- data/spec/vcr_cassettes/Inventory/Should_list_metrics_for_WildFlys.yml +220 -59
- data/spec/vcr_cassettes/Inventory/Should_list_metrics_of_given_metric_type.yml +613 -0
- data/spec/vcr_cassettes/Inventory/Should_list_metrics_of_given_resource_type.yml +333 -0
- data/spec/vcr_cassettes/Inventory/Should_list_recursive_children_of_WildFly.yml +2064 -0
- data/spec/vcr_cassettes/Inventory/Should_list_relationships_of_WildFly.yml +460 -0
- data/spec/vcr_cassettes/Inventory/Should_list_types_with_bad_feed.yml +26 -25
- data/spec/vcr_cassettes/Inventory/Should_list_types_with_feed.yml +102 -36
- data/spec/vcr_cassettes/Inventory/Should_not_find_an_unknown_resource.yml +54 -0
- data/spec/vcr_cassettes/Inventory/Tenants/Should_Get_Tenant_For_Explicit_Credentials.yml +50 -0
- data/spec/vcr_cassettes/Inventory/Tenants/Should_Get_Tenant_For_Implicit_Credentials.yml +50 -0
- data/spec/vcr_cassettes/Operation/Helpers/get_tenant.yml +50 -0
- data/spec/vcr_cassettes/Operation/Operation/Add_JDBC_driver_should_add_the_driver.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Add_datasource_should_be_doable.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Add_deployment_should_be_doable.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Redeploy_can_be_run_multiple_times_in_parallel.json +40 -0
- data/spec/vcr_cassettes/Operation/Operation/Redeploy_should_be_performed_and_eventually_respond_with_success.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Redeploy_should_not_be_performed_if_resource_path_is_wrong.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Remove_JDBC_driver_should_be_performed_and_eventually_respond_with_success.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Remove_datasource_should_be_performed_and_eventually_respond_with_success.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Remove_deployment_should_be_performed_and_eventually_respond_with_success.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/Undeploy_should_be_performed_and_eventually_respond_with_success.json +26 -0
- data/spec/vcr_cassettes/Operation/Operation/should_not_be_possible_to_perform_on_closed_client.json +12 -0
- data/spec/vcr_cassettes/Operation/Websocket_connection/should_be_established.json +9 -0
- data/spec/vcr_cassettes/Tokens/Should_be_able_to_create_a_new_token_for_an_actual_user.yml +57 -0
- data/spec/vcr_cassettes/Tokens/Should_be_able_to_list_the_available_tokens.yml +49 -0
- data/spec/vcr_cassettes/Tokens/Should_get_a_401_when_attempting_to_create_a_token_with_a_wrong_password.yml +56 -0
- data/spec/vcr_cassettes/Tokens/Should_get_a_401_when_attempting_to_create_a_token_without_a_password.yml +55 -0
- metadata +175 -11
- data/lib/metrics/version.rb +0 -7
@@ -198,6 +198,42 @@ describe 'Counter metrics' do
|
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
201
|
+
it 'Should get metrics with limit and order' do
|
202
|
+
@client = setup_client(username: 'jdoe', password: 'password')
|
203
|
+
id = '33c6a285-495a-4442-a818-974b03408a6f'
|
204
|
+
now = 1_458_666_669_263
|
205
|
+
|
206
|
+
VCR.use_cassette('Counter_metrics/Should get metrics with limit and order',
|
207
|
+
erb: { id: id, ends: now - t4h, starts: now - (2 * t4h),
|
208
|
+
minus20: now - 20, minus30: now - 30, minus10: now - 10,
|
209
|
+
now: now }, record: :none
|
210
|
+
) do
|
211
|
+
# create counter
|
212
|
+
@client.counters.create(id: id)
|
213
|
+
|
214
|
+
# push 3 values with timestamps
|
215
|
+
@client.counters.push_data(id, [{ value: 1, timestamp: now - 30 },
|
216
|
+
{ value: 2, timestamp: now - 20 },
|
217
|
+
{ value: 3, timestamp: now - 10 }])
|
218
|
+
|
219
|
+
data = @client.counters.get_data(id)
|
220
|
+
expect(data.size).to be 3
|
221
|
+
|
222
|
+
# push one value without timestamp (which means now)
|
223
|
+
@client.counters.push_data(id, value: 4)
|
224
|
+
data = @client.counters.get_data(id)
|
225
|
+
expect(data.size).to be 4
|
226
|
+
|
227
|
+
# retrieve values with limit
|
228
|
+
data = @client.counters.get_data(id, limit: 1)
|
229
|
+
expect(data.size).to be 1
|
230
|
+
|
231
|
+
# retrieve values from past
|
232
|
+
data = @client.counters.get_data(id, starts: now - (2 * t4h), ends: now - t4h)
|
233
|
+
expect(data.empty?).to be true
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
201
237
|
it 'Should push metric data to non-existing counter' do
|
202
238
|
id = SecureRandom.uuid
|
203
239
|
|
@@ -0,0 +1,420 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../vcr/vcr_setup"
|
2
|
+
require "#{File.dirname(__FILE__)}/../spec_helper"
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
include Hawkular::Inventory
|
6
|
+
include Hawkular::Operations
|
7
|
+
|
8
|
+
# examples for operations, it uses the websocket communication
|
9
|
+
module Hawkular::Operations::RSpec
|
10
|
+
HOST = 'localhost:8080'
|
11
|
+
describe 'Operation/Websocket connection', vcr: { decode_compressed_response: true } do
|
12
|
+
let(:example) do |e|
|
13
|
+
e
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should be established' do
|
17
|
+
VCR::WebSocket.configure do |c|
|
18
|
+
c.hook_uris = [HOST]
|
19
|
+
end
|
20
|
+
|
21
|
+
VCR::WebSocket.record(example, self) do
|
22
|
+
client = OperationsClient.new(host: HOST,
|
23
|
+
wait_time: 0,
|
24
|
+
credentials: {
|
25
|
+
username: 'jdoe',
|
26
|
+
password: 'password'
|
27
|
+
})
|
28
|
+
ws = client.ws
|
29
|
+
expect(ws).not_to be nil
|
30
|
+
expect(ws.open?).to be true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'Operation/Operation', :websocket, vcr: { decode_compressed_response: true } do
|
36
|
+
let(:example) do |e|
|
37
|
+
e
|
38
|
+
end
|
39
|
+
|
40
|
+
before(:all) do
|
41
|
+
# TODO: erb substitution
|
42
|
+
VCR.use_cassette('Operation/Helpers/get_tenant', decode_compressed_response: true) do
|
43
|
+
@creds = { username: 'jdoe', password: 'password' }
|
44
|
+
inventory_client = InventoryClient.create(credentials: @creds)
|
45
|
+
@tenant_id = inventory_client.get_tenant
|
46
|
+
# @feed_id = inventory_client.list_feeds[0]
|
47
|
+
@feed_id = '41df9f9c-72a6-457b-a0ee-ee1740846254'
|
48
|
+
# @random_uuid = SecureRandom.uuid comment this out once the erb support is there
|
49
|
+
@random_uuid = 'random'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
before(:each) do |ex|
|
54
|
+
unless ex.metadata[:skip_open]
|
55
|
+
@client = OperationsClient.new(credentials: @creds,
|
56
|
+
wait_time: 0)
|
57
|
+
@ws = @client.ws
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
around(:each) do |ex|
|
62
|
+
if ex.metadata[:websocket]
|
63
|
+
VCR::WebSocket.configure do |c|
|
64
|
+
c.hook_uris = [HOST]
|
65
|
+
end
|
66
|
+
VCR::WebSocket.record(ex, self) do
|
67
|
+
ex.run
|
68
|
+
end
|
69
|
+
else
|
70
|
+
ex.run
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
after(:each) do |ex|
|
75
|
+
unless ex.metadata[:skip_close]
|
76
|
+
@client.close_connection!
|
77
|
+
@client = nil
|
78
|
+
@ws = nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'Add JDBC driver should add the driver' do
|
83
|
+
wf_server_resource_id = 'Local~~'
|
84
|
+
driver_name = 'CreatedByRubyDriver' + @random_uuid
|
85
|
+
driver_bits = IO.binread("#{File.dirname(__FILE__)}/../resources/driver.jar")
|
86
|
+
wf_path = CanonicalPath.new(tenant_id: @tenant_id,
|
87
|
+
feed_id: @feed_id,
|
88
|
+
resource_ids: [wf_server_resource_id]).to_s
|
89
|
+
|
90
|
+
actual_data = {}
|
91
|
+
@client.add_jdbc_driver(resource_path: wf_path,
|
92
|
+
driver_jar_name: 'driver.jar',
|
93
|
+
driver_name: driver_name,
|
94
|
+
module_name: 'foo.bar.' + @random_uuid, # jboss module
|
95
|
+
driver_class: 'com.mysql.jdbc.Driver',
|
96
|
+
binary_content: driver_bits) do |on|
|
97
|
+
on.success do |data|
|
98
|
+
actual_data[:data] = data
|
99
|
+
end
|
100
|
+
on.failure do |error|
|
101
|
+
actual_data[:data] = {}
|
102
|
+
puts 'error callback was called, reason: ' + error.to_s
|
103
|
+
end
|
104
|
+
end
|
105
|
+
actual_data = wait_for actual_data
|
106
|
+
expect(actual_data['status']).to eq('OK')
|
107
|
+
expect(actual_data['message']).to start_with('Added JDBC Driver')
|
108
|
+
expect(actual_data['driverName']).to eq(driver_name)
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'Redeploy should be performed and eventually respond with success' do
|
112
|
+
wf_server_resource_id = 'Local~~'
|
113
|
+
alerts_war_resource_id = 'Local~%2Fdeployment%3Dhawkular-alerts-actions-email.war'
|
114
|
+
path = CanonicalPath.new(tenant_id: @tenant_id,
|
115
|
+
feed_id: @feed_id,
|
116
|
+
resource_ids: [wf_server_resource_id, alerts_war_resource_id])
|
117
|
+
|
118
|
+
redeploy = {
|
119
|
+
operationName: 'Redeploy',
|
120
|
+
resourcePath: path.to_s
|
121
|
+
}
|
122
|
+
|
123
|
+
actual_data = {}
|
124
|
+
@client.invoke_generic_operation(redeploy) do |on|
|
125
|
+
on.success do |data|
|
126
|
+
actual_data[:data] = data
|
127
|
+
end
|
128
|
+
on.failure do |error|
|
129
|
+
actual_data[:data] = {}
|
130
|
+
puts 'error callback was called, reason: ' + error.to_s
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# expectations don't work from callbacks so waiting for the results via blocking helper `wait_for`
|
135
|
+
actual_data = wait_for actual_data
|
136
|
+
expect(actual_data['status']).to eq('OK')
|
137
|
+
expect(actual_data['resourcePath']).to eq(path.to_s)
|
138
|
+
expect(actual_data['message']).to start_with('Performed [Redeploy] on')
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'Redeploy should not be performed if resource path is wrong' do
|
142
|
+
wf_server_resource_id = 'Local~~'
|
143
|
+
wrong_war_resource_id = 'Local~%2Fdeployment%3Dnon-existent.war'
|
144
|
+
path = CanonicalPath.new(tenant_id: @tenant_id,
|
145
|
+
feed_id: @feed_id,
|
146
|
+
resource_ids: [wf_server_resource_id, wrong_war_resource_id])
|
147
|
+
|
148
|
+
redeploy = {
|
149
|
+
operationName: 'Redeploy',
|
150
|
+
resourcePath: path.to_s
|
151
|
+
}
|
152
|
+
actual_data = {}
|
153
|
+
@client.invoke_generic_operation(redeploy) do |on|
|
154
|
+
on.success do |_|
|
155
|
+
actual_data[:data] = { error: 'the operation should have failed' }
|
156
|
+
end
|
157
|
+
on.failure do |error|
|
158
|
+
actual_data[:data] = { error: error }
|
159
|
+
end
|
160
|
+
end
|
161
|
+
actual_data = wait_for actual_data
|
162
|
+
expect(actual_data[:error]).to start_with('Could not perform [Redeploy] on')
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'Undeploy should be performed and eventually respond with success' do
|
166
|
+
wf_server_resource_id = 'Local~~'
|
167
|
+
alerts_war_resource_id = 'Local~%2Fdeployment%3Dhawkular-alerts-actions-email.war'
|
168
|
+
path = CanonicalPath.new(tenant_id: @tenant_id,
|
169
|
+
feed_id: @feed_id,
|
170
|
+
resource_ids: [wf_server_resource_id, alerts_war_resource_id])
|
171
|
+
|
172
|
+
undeploy = {
|
173
|
+
operationName: 'Undeploy',
|
174
|
+
resourcePath: path.to_s
|
175
|
+
}
|
176
|
+
actual_data = {}
|
177
|
+
@client.invoke_generic_operation(undeploy) do |on|
|
178
|
+
on.success do |data|
|
179
|
+
actual_data[:data] = data
|
180
|
+
end
|
181
|
+
on.failure do |error|
|
182
|
+
actual_data[:data] = {}
|
183
|
+
puts 'error callback was called, reason: ' + error.to_s
|
184
|
+
end
|
185
|
+
end
|
186
|
+
actual_data = wait_for actual_data
|
187
|
+
expect(actual_data['status']).to eq('OK')
|
188
|
+
expect(actual_data['message']).to start_with('Performed [Undeploy] on')
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'Add datasource should be doable' do
|
192
|
+
wf_server_resource_id = 'Local~~'
|
193
|
+
wf_path = CanonicalPath.new(tenant_id: @tenant_id,
|
194
|
+
feed_id: @feed_id,
|
195
|
+
resource_ids: [wf_server_resource_id]).to_s
|
196
|
+
payload = {
|
197
|
+
# compulsory fields
|
198
|
+
resourcePath: wf_path,
|
199
|
+
xaDatasource: false,
|
200
|
+
datasourceName: 'CreatedByRubyDS' + @random_uuid,
|
201
|
+
jndiName: 'java:jboss/datasources/CreatedByRubyDS' + @random_uuid,
|
202
|
+
driverName: 'h2',
|
203
|
+
# this is probably a bug (driver class should be already defined in driver)
|
204
|
+
driverClass: 'org.h2.Driver',
|
205
|
+
connectionUrl: 'dbc:h2:mem:ruby;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE',
|
206
|
+
|
207
|
+
# optional
|
208
|
+
datasourceProperties: {
|
209
|
+
someKey: 'someValue'
|
210
|
+
},
|
211
|
+
userName: 'sa',
|
212
|
+
password: 'sa',
|
213
|
+
securityDomain: 'other'
|
214
|
+
# xaDataSourceClass: 'clazz' for xa DS
|
215
|
+
}
|
216
|
+
|
217
|
+
actual_data = {}
|
218
|
+
@client.add_datasource(payload) do |on|
|
219
|
+
on.success do |data|
|
220
|
+
actual_data[:data] = data
|
221
|
+
end
|
222
|
+
on.failure do |error|
|
223
|
+
actual_data[:data] = { 'status' => 'ERROR' }
|
224
|
+
puts 'error callback was called, reason: ' + error.to_s
|
225
|
+
end
|
226
|
+
end
|
227
|
+
actual_data = wait_for actual_data
|
228
|
+
expect(actual_data['status']).to eq('OK')
|
229
|
+
expect(actual_data['message']).to start_with('Added Datasource')
|
230
|
+
expect(actual_data['xaDatasource']).to be_falsey
|
231
|
+
expect(actual_data['datasourceName']).to eq(payload[:datasourceName])
|
232
|
+
expect(actual_data['resourcePath']).to eq(payload[:resourcePath])
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'should not be possible to perform on closed client', skip_open: true, skip_close: true do
|
236
|
+
@client.close_connection! unless @client.nil?
|
237
|
+
|
238
|
+
# open the connection
|
239
|
+
operations_client = OperationsClient.new(credentials: @creds)
|
240
|
+
|
241
|
+
redeploy = {
|
242
|
+
operationName: 'Redeploy',
|
243
|
+
resourcePath: '/t;t1/f;whatever/r;something'
|
244
|
+
}
|
245
|
+
|
246
|
+
# close the connection
|
247
|
+
operations_client.close_connection!
|
248
|
+
expect do
|
249
|
+
operations_client.invoke_generic_operation(redeploy)
|
250
|
+
end.to raise_error(RuntimeError, /Handshake with server has not been done./)
|
251
|
+
end
|
252
|
+
|
253
|
+
it 'Redeploy can be run multiple times in parallel' do
|
254
|
+
wf_server_resource_id = 'Local~~'
|
255
|
+
alerts_war_resource_id = 'Local~%2Fdeployment%3Dhawkular-alerts-actions-email.war'
|
256
|
+
console_war_resource_id = 'Local~%2Fdeployment%3Dhawkular-console.war'
|
257
|
+
path1 = CanonicalPath.new(tenant_id: @tenant_id,
|
258
|
+
feed_id: @feed_id,
|
259
|
+
resource_ids: [wf_server_resource_id, alerts_war_resource_id])
|
260
|
+
path2 = CanonicalPath.new(tenant_id: @tenant_id,
|
261
|
+
feed_id: @feed_id,
|
262
|
+
resource_ids: [wf_server_resource_id, console_war_resource_id])
|
263
|
+
|
264
|
+
redeploy1 = {
|
265
|
+
operationName: 'Redeploy',
|
266
|
+
resourcePath: path1.to_s
|
267
|
+
}
|
268
|
+
|
269
|
+
redeploy2 = {
|
270
|
+
operationName: 'Redeploy',
|
271
|
+
resourcePath: path2.to_s
|
272
|
+
}
|
273
|
+
|
274
|
+
# run the first operation w/o registering the callback
|
275
|
+
@client.invoke_generic_operation(redeploy1)
|
276
|
+
|
277
|
+
actual_data = {}
|
278
|
+
# run the 2nd operation with 2 callback blocks (the happy path and the less happy path)
|
279
|
+
@client.invoke_generic_operation(redeploy2) do |on|
|
280
|
+
on.success do |data|
|
281
|
+
actual_data[:data] = data
|
282
|
+
end
|
283
|
+
on.failure do |error|
|
284
|
+
actual_data[:data] = {}
|
285
|
+
puts 'error callback was called, reason: ' + error.to_s
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
actual_data = wait_for actual_data
|
290
|
+
expect(actual_data['status']).to eq('OK')
|
291
|
+
expect(actual_data['resourcePath']).to eq(path2.to_s)
|
292
|
+
expect(actual_data['message']).to start_with('Performed [Redeploy] on')
|
293
|
+
end
|
294
|
+
|
295
|
+
it 'Add deployment should be doable' do
|
296
|
+
wf_server_resource_id = 'Local~~'
|
297
|
+
app_name = 'sample.war'
|
298
|
+
war_file = IO.binread("#{File.dirname(__FILE__)}/../resources/#{app_name}")
|
299
|
+
wf_path = CanonicalPath.new(tenant_id: @tenant_id,
|
300
|
+
feed_id: @feed_id,
|
301
|
+
resource_ids: [wf_server_resource_id]).to_s
|
302
|
+
|
303
|
+
actual_data = {}
|
304
|
+
@client.add_deployment(resource_path: wf_path,
|
305
|
+
destination_file_name: app_name,
|
306
|
+
binary_content: war_file) do |on|
|
307
|
+
on.success do |data|
|
308
|
+
actual_data[:data] = data
|
309
|
+
end
|
310
|
+
on.failure do |error|
|
311
|
+
actual_data[:data] = {}
|
312
|
+
puts 'error callback was called, reason: ' + error.to_s
|
313
|
+
end
|
314
|
+
end
|
315
|
+
actual_data = wait_for actual_data
|
316
|
+
expect(actual_data['status']).to eq('OK')
|
317
|
+
expect(actual_data['message']).to start_with('Performed [Deploy] on')
|
318
|
+
expect(actual_data['destinationFileName']).to eq(app_name)
|
319
|
+
expect(actual_data['resourcePath']).to eq(wf_path)
|
320
|
+
end
|
321
|
+
|
322
|
+
it 'Remove deployment should be performed and eventually respond with success' do
|
323
|
+
wf_server_resource_id = 'Local~~'
|
324
|
+
sample_app_resource_id = 'Local~%2Fdeployment=sample.war'
|
325
|
+
path = CanonicalPath.new(tenant_id: @tenant_id,
|
326
|
+
feed_id: @feed_id,
|
327
|
+
resource_ids: [wf_server_resource_id, sample_app_resource_id])
|
328
|
+
remove_deployment = {
|
329
|
+
operationName: 'Remove',
|
330
|
+
resourcePath: path.to_s
|
331
|
+
}
|
332
|
+
actual_data = {}
|
333
|
+
@client.invoke_generic_operation(remove_deployment) do |on|
|
334
|
+
on.success do |data|
|
335
|
+
actual_data[:data] = data
|
336
|
+
end
|
337
|
+
on.failure do |error|
|
338
|
+
actual_data[:data] = { 'status' => 'ERROR' }
|
339
|
+
puts 'error callback was called, reason: ' + error.to_s
|
340
|
+
end
|
341
|
+
end
|
342
|
+
actual_data = wait_for actual_data
|
343
|
+
expect(actual_data['status']).to eq('OK')
|
344
|
+
expect(actual_data['message']).to start_with('Performed [Remove] on')
|
345
|
+
end
|
346
|
+
|
347
|
+
it 'Remove datasource should be performed and eventually respond with success' do
|
348
|
+
wf_server_resource_id = 'Local~~'
|
349
|
+
datasource_resource_id = 'Local~%2Fsubsystem%3Ddatasources%2Fdata-source%3DCreatedByRubyDS' + @random_uuid
|
350
|
+
path = CanonicalPath.new(tenant_id: @tenant_id,
|
351
|
+
feed_id: @feed_id,
|
352
|
+
resource_ids: [wf_server_resource_id, datasource_resource_id])
|
353
|
+
|
354
|
+
operation = {
|
355
|
+
resourcePath: path.to_s
|
356
|
+
}
|
357
|
+
|
358
|
+
actual_data = {}
|
359
|
+
@client.invoke_specific_operation(operation, 'RemoveDatasource') do |on|
|
360
|
+
on.success do |data|
|
361
|
+
actual_data[:data] = data
|
362
|
+
end
|
363
|
+
on.failure do |error|
|
364
|
+
actual_data[:data] = {}
|
365
|
+
puts 'error callback was called, reason: ' + error.to_s
|
366
|
+
end
|
367
|
+
end
|
368
|
+
actual_data = wait_for actual_data
|
369
|
+
expect(actual_data['status']).to eq('OK')
|
370
|
+
expect(actual_data['message']).to start_with('Performed [Remove] on')
|
371
|
+
expect(actual_data['serverRefreshIndicator']).to eq('RELOAD-REQUIRED')
|
372
|
+
end
|
373
|
+
|
374
|
+
it 'Remove JDBC driver should be performed and eventually respond with success' do
|
375
|
+
wf_server_resource_id = 'Local~~'
|
376
|
+
driver_resource_id = 'Local~%2Fsubsystem%3Ddatasources%2Fjdbc-driver%3DCreatedByRubyDriver' + @random_uuid
|
377
|
+
path = CanonicalPath.new(tenant_id: @tenant_id,
|
378
|
+
feed_id: @feed_id,
|
379
|
+
resource_ids: [wf_server_resource_id, driver_resource_id]).to_s
|
380
|
+
|
381
|
+
actual_data = {}
|
382
|
+
@client.invoke_specific_operation({ resourcePath: path }, 'RemoveJdbcDriver') do |on|
|
383
|
+
on.success do |data|
|
384
|
+
actual_data[:data] = data
|
385
|
+
end
|
386
|
+
on.failure do |error|
|
387
|
+
actual_data[:data] = {}
|
388
|
+
puts 'error callback was called, reason: ' + error.to_s
|
389
|
+
end
|
390
|
+
end
|
391
|
+
actual_data = wait_for actual_data
|
392
|
+
expect(actual_data['status']).to eq('OK')
|
393
|
+
expect(actual_data['resourcePath']).to eq(path)
|
394
|
+
expect(actual_data['message']).to start_with('Performed [Remove] on a [JDBC Driver]')
|
395
|
+
end
|
396
|
+
|
397
|
+
xit 'Export JDR should retrieve the zip file with the report' do
|
398
|
+
wf_server_resource_id = 'Local~~'
|
399
|
+
path = CanonicalPath.new(tenant_id: @tenant_id,
|
400
|
+
feed_id: @feed_id,
|
401
|
+
resource_ids: [wf_server_resource_id]).to_s
|
402
|
+
|
403
|
+
actual_data = {}
|
404
|
+
@client.export_jdr(path) do |on|
|
405
|
+
on.success do |data|
|
406
|
+
actual_data[:data] = data
|
407
|
+
end
|
408
|
+
on.failure do |error|
|
409
|
+
actual_data[:data] = {}
|
410
|
+
puts 'error callback was called, reason: ' + error.to_s
|
411
|
+
end
|
412
|
+
end
|
413
|
+
actual_data = wait_for actual_data
|
414
|
+
expect(actual_data['status']).to eq('OK')
|
415
|
+
expect(actual_data['resourcePath']).to eq(path)
|
416
|
+
expect(actual_data['message']).to start_with('Performed [Export JDR] on')
|
417
|
+
expect(actual_data['fileName']).to start_with('jdr_')
|
418
|
+
end
|
419
|
+
end
|
420
|
+
end
|