hawkular-client 2.8.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -4
- data/.travis/start_hawkular_services.sh +21 -0
- data/.travis/wait_for_services.rb +26 -10
- data/CHANGES.rdoc +26 -0
- data/README.rdoc +12 -1
- data/docker-compose.yml +4 -2
- data/hawkularclient.gemspec +2 -0
- data/lib/hawkular/alerts/alerts_api.rb +22 -1
- data/lib/hawkular/base_client.rb +29 -24
- data/lib/hawkular/client_utils.rb +42 -0
- data/lib/hawkular/env_config.rb +15 -0
- data/lib/hawkular/hawkular_client.rb +33 -25
- data/lib/hawkular/inventory/entities.rb +9 -0
- data/lib/hawkular/inventory/inventory_api.rb +13 -3
- data/lib/hawkular/logger.rb +14 -0
- data/lib/hawkular/metrics/metric_api.rb +24 -8
- data/lib/hawkular/operations/operations_api.rb +57 -25
- data/lib/hawkular/tokens/tokens_api.rb +4 -1
- data/lib/hawkular/version.rb +1 -1
- data/lib/hawkularclient.rb +8 -0
- data/spec/integration/alerts_spec.rb +50 -27
- data/spec/integration/env_config_spec.rb +39 -0
- data/spec/integration/hawkular_client_spec.rb +10 -7
- data/spec/integration/inventory_spec.rb +36 -3
- data/spec/integration/logger_spec.rb +36 -0
- data/spec/integration/metric_spec.rb +62 -3
- data/spec/integration/operations_spec.rb +112 -63
- data/spec/integration/tokens_spec.rb +6 -6
- data/spec/spec_helper.rb +20 -6
- data/spec/unit/base_spec.rb +25 -3
- data/spec/unit/canonical_path_spec.rb +2 -1
- data/spec/unit/client_spec.rb +2 -1
- data/spec/unit/deprecations_spec.rb +19 -0
- data/spec/vcr_cassettes/Alert/Alerts/Templates/Should_add_tags_to_existing_alert.yml +210 -0
- data/spec/vcr_cassettes/Alert/Alerts/Templates/Should_remove_tags_from_existing_alert.yml +257 -0
- data/spec/vcr_cassettes/Alert/Triggers/Templates/Should_get_the_action_definitions.yml +59 -22
- data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_have_a_consistent_behaviour_when_creating_an_already_existing_resource.yml +714 -0
- data/spec/vcr_cassettes/Inventory/NonSecure/inventory_0_17/Templates/Should_return_data_from_get_entity.yml +230 -0
- data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/All_Tags_for_metrics/Should_fetch_all_metrics_with_some_tags.yml +1251 -0
- data/spec/vcr_cassettes/Metrics/NonSecure/metrics_services/Templates/Tags_Metrics/setup_client.yml +3 -3
- data/spec/vcr_cassettes/Operation/NonSecure/Helpers/Templates/agent_properties.yml +124 -0
- data/spec/vcr_cassettes/Operation/NonSecure/Helpers/Templates/get_feed.yml +7 -7
- data/spec/vcr_cassettes/Operation/NonSecure/Operation/Add_JDBC_driver_should_add_the_driver.json +4 -4
- data/spec/vcr_cassettes/Operation/NonSecure/Operation/Add_deployment_should_be_doable.json +4 -4
- data/spec/vcr_cassettes/Operation/NonSecure/Operation/Disable_should_be_performed_and_eventually_respond_with_success.json +4 -4
- data/spec/vcr_cassettes/Operation/NonSecure/Operation/Remove_JDBC_driver_should_be_performed_and_eventually_respond_with_success.json +3 -3
- data/spec/vcr_cassettes/Operation/NonSecure/Operation/Restart_can_be_run_multiple_times_in_parallel.json +5 -5
- data/spec/vcr_cassettes/Operation/NonSecure/Operation/Restart_should_be_performed_and_eventually_respond_with_success.json +4 -4
- data/spec/vcr_cassettes/Operation/NonSecure/Operation/Update_collection_intervals_should_be_performed_and_eventually_respond_with_success.json +23 -0
- metadata +57 -7
- data/lib/hawkular/hawkular_client_utils.rb +0 -41
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
require 'hawkular/env_config'
|
4
|
+
|
5
|
+
describe Hawkular::EnvConfig do
|
6
|
+
subject(:config) { Hawkular::EnvConfig }
|
7
|
+
describe '.log_response?' do
|
8
|
+
it 'is true if defined' do
|
9
|
+
swap_env('HAWKULARCLIENT_LOG_RESPONSE', 'true') do
|
10
|
+
expect(config.log_response?).to be_truthy
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'is false if null' do
|
15
|
+
swap_env('HAWKULARCLIENT_LOG_RESPONSE', nil) do
|
16
|
+
expect(config.log_response?).to be_falsey
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.rest_timeout' do
|
22
|
+
it 'returns the value for the environment' do
|
23
|
+
swap_env('HAWKULARCLIENT_REST_TIMEOUT', '20') do
|
24
|
+
expect(config.rest_timeout).to eq '20'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def swap_env(name, value)
|
32
|
+
old_value = ENV[name]
|
33
|
+
ENV[name] = value
|
34
|
+
|
35
|
+
yield
|
36
|
+
ensure
|
37
|
+
ENV[name] = old_value
|
38
|
+
end
|
39
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative '../vcr/vcr_setup'
|
2
|
+
require_relative '../spec_helper'
|
3
|
+
|
3
4
|
require 'securerandom'
|
4
5
|
|
5
6
|
# examples that tests the main client which delegates all the calls to Hawkular component clients
|
@@ -16,6 +17,8 @@ module Hawkular::Client::RSpec
|
|
16
17
|
mock_inventory_client '0.17.2.Final'
|
17
18
|
mock_metrics_version
|
18
19
|
@hawkular_client = Hawkular::Client.new(entrypoint: HOST, credentials: @creds, options: { tenant: 'hawkular' })
|
20
|
+
@hawkular_client.inventory
|
21
|
+
@hawkular_client.metrics
|
19
22
|
end
|
20
23
|
@state = {
|
21
24
|
hostname: 'localhost.localdomain',
|
@@ -30,7 +33,7 @@ module Hawkular::Client::RSpec
|
|
30
33
|
password: 'password'
|
31
34
|
}
|
32
35
|
expect do
|
33
|
-
Hawkular::Client.new(entrypoint: HOST, credentials: @creds)
|
36
|
+
Hawkular::Client.new(entrypoint: HOST, credentials: @creds).inventory_list_feeds
|
34
37
|
end.to raise_error(Hawkular::BaseClient::HawkularException, 'Unauthorized')
|
35
38
|
end
|
36
39
|
end
|
@@ -83,9 +86,9 @@ module Hawkular::Client::RSpec
|
|
83
86
|
before(:all) do
|
84
87
|
::RSpec::Mocks.with_temporary_scope do
|
85
88
|
mock_inventory_client '0.17.2.Final'
|
86
|
-
@client = Hawkular::Inventory::
|
87
|
-
|
88
|
-
|
89
|
+
@client = Hawkular::Inventory::Client.create(entrypoint: HOST,
|
90
|
+
credentials: @creds,
|
91
|
+
options: { tenant: 'hawkular' })
|
89
92
|
end
|
90
93
|
end
|
91
94
|
|
@@ -249,7 +252,7 @@ module Hawkular::Client::RSpec
|
|
249
252
|
}
|
250
253
|
|
251
254
|
actual_data = {}
|
252
|
-
client = Hawkular::Operations::
|
255
|
+
client = Hawkular::Operations::Client.new(entrypoint: HOST, credentials: @creds)
|
253
256
|
client.invoke_generic_operation(redeploy) do |on|
|
254
257
|
on.success do |data|
|
255
258
|
actual_data[:data] = data
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative '../vcr/vcr_setup'
|
2
|
+
require_relative '../spec_helper'
|
3
|
+
|
3
4
|
require 'securerandom'
|
4
5
|
|
5
6
|
module Hawkular::Inventory::RSpec
|
@@ -71,7 +72,7 @@ module Hawkular::Inventory::RSpec
|
|
71
72
|
VCR.eject_cassette
|
72
73
|
record("Inventory/#{security_context}/Connection", @creds, cassette_name) do
|
73
74
|
expect do
|
74
|
-
Hawkular::Inventory::
|
75
|
+
Hawkular::Inventory::Client.create(entrypoint: entrypoint, credentials: @creds)
|
75
76
|
end.to raise_error(Hawkular::BaseClient::HawkularException, 'Unauthorized')
|
76
77
|
end
|
77
78
|
end
|
@@ -522,6 +523,34 @@ module Hawkular::Inventory::RSpec
|
|
522
523
|
expect(r2.properties).not_to be_empty
|
523
524
|
end
|
524
525
|
|
526
|
+
it 'Should have a consistent behaviour when creating an already existing resource' do
|
527
|
+
new_feed_id = "#{security_context}_feed_may_exist"
|
528
|
+
@client.create_feed new_feed_id
|
529
|
+
ret = @client.create_resource_type new_feed_id, 'rt-123', 'ResourceType'
|
530
|
+
type_path = ret.path
|
531
|
+
|
532
|
+
r1 = @client.create_resource type_path, 'r999', 'My Resource', 'version' => 1.0
|
533
|
+
r2 = @client.create_resource type_path, 'r999', 'My Resource', 'version' => 1.0
|
534
|
+
|
535
|
+
r3 = @client.create_resource_under_resource type_path, r1.path, 'r1000', 'My Resource', 'version' => 1.0
|
536
|
+
r4 = @client.create_resource_under_resource type_path, r1.path, 'r1000', 'My Resource', 'version' => 1.0
|
537
|
+
|
538
|
+
expect(r1).to eq(r2)
|
539
|
+
expect(r3).to eq(r4)
|
540
|
+
end
|
541
|
+
|
542
|
+
it 'Should return data from get_entity' do
|
543
|
+
new_feed_id = 'feed_may_exist'
|
544
|
+
@client.create_feed new_feed_id
|
545
|
+
ret = @client.create_resource_type new_feed_id, 'dummy-resource-type', 'ResourceType'
|
546
|
+
type_path = ret.path
|
547
|
+
entity = @client.get_entity(type_path)
|
548
|
+
|
549
|
+
expect(entity['path']).to eq(type_path)
|
550
|
+
expect(entity['name']).to eq('ResourceType')
|
551
|
+
expect(entity['id']).to eq('dummy-resource-type')
|
552
|
+
end
|
553
|
+
|
525
554
|
it 'Should not find an unknown resource' do
|
526
555
|
new_feed_id = 'feed_may_exist'
|
527
556
|
path = Hawkular::Inventory::CanonicalPath.new(
|
@@ -591,6 +620,10 @@ module Hawkular::Inventory::RSpec
|
|
591
620
|
# create 3 resources
|
592
621
|
@client.create_resource type_path, id_1, 'My Resource 1', 'version' => 1.0
|
593
622
|
@client.create_resource type_path, id_2, 'My Resource 2', 'version' => 1.1
|
623
|
+
# Wait for id_1 and id_2 before stop listening.
|
624
|
+
wait_while do
|
625
|
+
!hash_include_all(new_resource_events, [id_1, id_2])
|
626
|
+
end
|
594
627
|
resources_closable.close
|
595
628
|
@client.create_resource type_path, id_3, 'My Resource 3', 'version' => 1.2
|
596
629
|
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require 'hawkular/logger'
|
3
|
+
|
4
|
+
describe Hawkular::Logger do
|
5
|
+
let(:file) { Tempfile.new('hawkular_spec') }
|
6
|
+
subject(:logger) { described_class.new(file) }
|
7
|
+
|
8
|
+
describe '#log' do
|
9
|
+
before { allow(Hawkular::EnvConfig).to receive(:log_response?) { true } }
|
10
|
+
|
11
|
+
it 'logs the message to a file' do
|
12
|
+
logger.log('this is a message')
|
13
|
+
file.flush
|
14
|
+
|
15
|
+
expect(File.read(file)).to include 'this is a message'
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'does not log anything if the config does not allow it' do
|
19
|
+
allow(Hawkular::EnvConfig).to receive(:log_response?) { false }
|
20
|
+
|
21
|
+
logger.log('this is a message')
|
22
|
+
file.flush
|
23
|
+
|
24
|
+
expect(File.read(file)).to be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
%w(debug info warn error fatal).each do |priority|
|
28
|
+
it "allows to log with #{priority} priority" do
|
29
|
+
logger.log('this is a message', priority)
|
30
|
+
file.flush
|
31
|
+
|
32
|
+
expect(File.read(file)).to include priority.upcase
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative '../vcr/vcr_setup'
|
2
|
+
require_relative '../spec_helper'
|
3
|
+
|
3
4
|
require 'securerandom'
|
4
5
|
|
5
6
|
SKIP_SECURE_CONTEXT = ENV['SKIP_SECURE_CONTEXT'] || '1'
|
@@ -751,7 +752,7 @@ security_contexts.each do |security_context|
|
|
751
752
|
|
752
753
|
describe 'All Tags for metrics', run_for: [services_context] do
|
753
754
|
before(:each) do
|
754
|
-
@tenant =
|
755
|
+
@tenant = SecureRandom.uuid
|
755
756
|
options = setup_options.merge(tenant: @tenant)
|
756
757
|
record("Metrics/#{security_context}/#{metrics_context}",
|
757
758
|
options,
|
@@ -760,6 +761,64 @@ security_contexts.each do |security_context|
|
|
760
761
|
end
|
761
762
|
end
|
762
763
|
|
764
|
+
it 'Should fetch all metrics with some tags', :skip_auto_vcr do
|
765
|
+
id1 = SecureRandom.uuid
|
766
|
+
id2 = SecureRandom.uuid
|
767
|
+
id3 = SecureRandom.uuid
|
768
|
+
id4 = SecureRandom.uuid
|
769
|
+
|
770
|
+
bindings = { id1: id1, id2: id2, id3: id3, id4: id4 }
|
771
|
+
tag = { miq_metric: true }
|
772
|
+
example = proc do
|
773
|
+
create_metric_using_md @client.gauges, id1, tag
|
774
|
+
create_metric_using_md @client.gauges, id2, tag
|
775
|
+
create_metric_using_md @client.gauges, id3, tag
|
776
|
+
create_metric_using_md @client.gauges, id4, tag
|
777
|
+
|
778
|
+
create_metric_using_md @client.avail, id1, tag
|
779
|
+
create_metric_using_md @client.avail, id2, tag
|
780
|
+
create_metric_using_md @client.avail, id3, tag
|
781
|
+
create_metric_using_md @client.avail, id4, tag
|
782
|
+
|
783
|
+
create_metric_using_md @client.counters, id1, tag
|
784
|
+
create_metric_using_md @client.counters, id2, tag
|
785
|
+
create_metric_using_md @client.counters, id3, tag
|
786
|
+
create_metric_using_md @client.counters, id4, tag
|
787
|
+
|
788
|
+
@client.push_data(
|
789
|
+
counters: [
|
790
|
+
{ id: id1, data: [{ value: 1 }] },
|
791
|
+
{ id: id2, data: [{ value: 2 }] },
|
792
|
+
{ id: id3, data: [{ value: 3 }] }
|
793
|
+
],
|
794
|
+
availabilities: [
|
795
|
+
{ id: id1, data: [{ value: 'up' }] },
|
796
|
+
{ id: id2, data: [{ value: 'down' }] },
|
797
|
+
{ id: id3, data: [{ value: 'up' }] },
|
798
|
+
{ id: id4, data: [{ value: 'up', timestamp: 10_000 },
|
799
|
+
{ value: 'down', timestamp: 100_000 },
|
800
|
+
{ value: 'admin', timestamp: 1_000_000 }] }
|
801
|
+
],
|
802
|
+
gauges: [
|
803
|
+
{ id: id1, data: [{ value: 1.1 }] },
|
804
|
+
{ id: id2, data: [{ value: 2.2 }] },
|
805
|
+
{ id: id3, data: [{ value: 3.3 }] }
|
806
|
+
]
|
807
|
+
)
|
808
|
+
data = @client.data_by_tags(tag, buckets: 1)
|
809
|
+
|
810
|
+
expect(data.size).to eql(3)
|
811
|
+
expect(data['gauge'].size).to eql(4)
|
812
|
+
expect(data['availability'].size).to eql(4)
|
813
|
+
expect(data['counter'].size).to eql(4)
|
814
|
+
end
|
815
|
+
|
816
|
+
record("Metrics/#{security_context}/#{metrics_context}",
|
817
|
+
vcr_bindings.merge(bindings),
|
818
|
+
cassette_name,
|
819
|
+
example: example)
|
820
|
+
end
|
821
|
+
|
763
822
|
it 'Should fetch all metric tags for metrics definitions' do
|
764
823
|
tags_m1 = {
|
765
824
|
tag1: 'value1',
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative '../vcr/vcr_setup'
|
2
|
+
require_relative '../spec_helper'
|
3
|
+
|
3
4
|
require 'securerandom'
|
4
5
|
|
5
6
|
include Hawkular::Inventory
|
@@ -11,6 +12,7 @@ SKIP_SECURE_CONTEXT = ENV['SKIP_SECURE_CONTEXT'] || '1'
|
|
11
12
|
module Hawkular::Operations::RSpec
|
12
13
|
NON_SECURE_CONTEXT = :NonSecure
|
13
14
|
SECURE_CONTEXT = :Secure
|
15
|
+
|
14
16
|
[NON_SECURE_CONTEXT, SECURE_CONTEXT].each do |security_context|
|
15
17
|
next if security_context == SECURE_CONTEXT && SKIP_SECURE_CONTEXT == '1'
|
16
18
|
if security_context == NON_SECURE_CONTEXT && ENV['SKIP_NON_SECURE_CONTEXT'] == '1'
|
@@ -47,7 +49,7 @@ module Hawkular::Operations::RSpec
|
|
47
49
|
end
|
48
50
|
|
49
51
|
let(:client) do
|
50
|
-
|
52
|
+
Client.new(options)
|
51
53
|
end
|
52
54
|
|
53
55
|
before(:all) do
|
@@ -73,7 +75,7 @@ module Hawkular::Operations::RSpec
|
|
73
75
|
it 'should be established via entrypoint' do
|
74
76
|
ep = host_with_scheme(host, security_context == SECURE_CONTEXT)
|
75
77
|
|
76
|
-
client =
|
78
|
+
client = Client.new(options.merge entrypoint: ep, host: nil)
|
77
79
|
ws = client.ws
|
78
80
|
expect(ws).not_to be nil
|
79
81
|
expect(ws.open?).to be true
|
@@ -126,7 +128,7 @@ module Hawkular::Operations::RSpec
|
|
126
128
|
|
127
129
|
it 'should bail with no host' do
|
128
130
|
expect do
|
129
|
-
|
131
|
+
Client.new(options.merge host: nil)
|
130
132
|
end.to raise_error(StandardError, 'no parameter ":host" or ":entrypoint" given')
|
131
133
|
end
|
132
134
|
end
|
@@ -141,7 +143,7 @@ module Hawkular::Operations::RSpec
|
|
141
143
|
record("Operation/#{security_context}/Helpers", nil, 'get_tenant') do
|
142
144
|
::RSpec::Mocks.with_temporary_scope do
|
143
145
|
mock_inventory_client
|
144
|
-
@inventory_client =
|
146
|
+
@inventory_client = ::Hawkular::Inventory::Client.create(
|
145
147
|
options.merge entrypoint: host_with_scheme(host, security_context == SECURE_CONTEXT))
|
146
148
|
end
|
147
149
|
inventory_client = @inventory_client
|
@@ -150,6 +152,15 @@ module Hawkular::Operations::RSpec
|
|
150
152
|
record("Operation/#{security_context}/Helpers", { tenant_id: @tenant_id }, 'get_feed') do
|
151
153
|
@feed_id = inventory_client.list_feeds[0]
|
152
154
|
end
|
155
|
+
record("Operation/#{security_context}/Helpers", { tenant_id: @tenant_id, feed_id: @feed_id },
|
156
|
+
'agent_properties') do
|
157
|
+
@wf_server_resource_id = 'Local~~'
|
158
|
+
wf_path = CanonicalPath.new(tenant_id: @tenant_id,
|
159
|
+
feed_id: @feed_id,
|
160
|
+
resource_ids: [@wf_server_resource_id])
|
161
|
+
wf_agent_path = path_for_installed_agent(wf_path)
|
162
|
+
@agent_immutable = immutable(inventory_client, wf_agent_path)
|
163
|
+
end
|
153
164
|
end
|
154
165
|
@bindings = { random_uuid: @random_uuid, tenant_id: @tenant_id, feed_id: @feed_id }
|
155
166
|
record_websocket("Operation/#{security_context}/Operation",
|
@@ -158,13 +169,12 @@ module Hawkular::Operations::RSpec
|
|
158
169
|
example)
|
159
170
|
end
|
160
171
|
|
161
|
-
it 'Add JDBC driver should add the driver' do
|
162
|
-
wf_server_resource_id = 'Local~~'
|
172
|
+
it 'Add JDBC driver should add the driver' do # Unless it runs in a container
|
163
173
|
driver_name = 'CreatedByRubyDriver' + @not_so_random_uuid
|
164
174
|
driver_bits = IO.binread("#{File.dirname(__FILE__)}/../resources/driver.jar")
|
165
175
|
wf_path = CanonicalPath.new(tenant_id: @tenant_id,
|
166
176
|
feed_id: @feed_id,
|
167
|
-
resource_ids: [wf_server_resource_id]).to_s
|
177
|
+
resource_ids: [@wf_server_resource_id]).to_s
|
168
178
|
|
169
179
|
actual_data = {}
|
170
180
|
|
@@ -178,26 +188,27 @@ module Hawkular::Operations::RSpec
|
|
178
188
|
actual_data[:data] = data
|
179
189
|
end
|
180
190
|
on.failure do |error|
|
181
|
-
actual_data[:data] =
|
182
|
-
puts 'error callback was called, reason: ' + error.to_s
|
191
|
+
actual_data[:data] = error
|
192
|
+
puts 'error callback was called, reason: ' + error.to_s unless @agent_immutable
|
183
193
|
end
|
184
194
|
end
|
185
195
|
actual_data = wait_for actual_data
|
186
|
-
expect(actual_data['status']).to eq('OK')
|
187
|
-
expect(actual_data['message']).to start_with('Added JDBC Driver')
|
188
|
-
expect(actual_data['driverName']).to eq(driver_name)
|
196
|
+
expect(actual_data['status']).to eq('OK') unless @agent_immutable
|
197
|
+
expect(actual_data['message']).to start_with('Added JDBC Driver') unless @agent_immutable
|
198
|
+
expect(actual_data['driverName']).to eq(driver_name) unless @agent_immutable
|
199
|
+
expect(actual_data).to include('Command not allowed because the agent is immutable') if @agent_immutable
|
189
200
|
end
|
190
201
|
|
191
202
|
it 'Restart should be performed and eventually respond with success' do
|
192
203
|
wf_server_resource_id = 'Local~~'
|
193
|
-
|
204
|
+
status_war_resource_id = 'Local~%2Fdeployment%3Dhawkular-status.war'
|
194
205
|
path = CanonicalPath.new(tenant_id: @tenant_id,
|
195
206
|
feed_id: @feed_id,
|
196
|
-
resource_ids: [wf_server_resource_id,
|
207
|
+
resource_ids: [wf_server_resource_id, status_war_resource_id])
|
197
208
|
|
198
209
|
restart = {
|
199
210
|
resource_path: path.to_s,
|
200
|
-
deployment_name: 'hawkular-
|
211
|
+
deployment_name: 'hawkular-status.war'
|
201
212
|
}
|
202
213
|
|
203
214
|
actual_data = {}
|
@@ -244,14 +255,14 @@ module Hawkular::Operations::RSpec
|
|
244
255
|
|
245
256
|
it 'Disable should be performed and eventually respond with success' do
|
246
257
|
wf_server_resource_id = 'Local~~'
|
247
|
-
|
258
|
+
status_war_resource_id = 'Local~%2Fdeployment%3Dhawkular-status.war'
|
248
259
|
path = CanonicalPath.new(tenant_id: @tenant_id,
|
249
260
|
feed_id: @feed_id,
|
250
|
-
resource_ids: [wf_server_resource_id,
|
261
|
+
resource_ids: [wf_server_resource_id, status_war_resource_id])
|
251
262
|
|
252
263
|
disable = {
|
253
264
|
resource_path: path.to_s,
|
254
|
-
deployment_name: 'hawkular-
|
265
|
+
deployment_name: 'hawkular-status.war'
|
255
266
|
}
|
256
267
|
actual_data = {}
|
257
268
|
client.disable_deployment(disable) do |on|
|
@@ -259,13 +270,14 @@ module Hawkular::Operations::RSpec
|
|
259
270
|
actual_data[:data] = data
|
260
271
|
end
|
261
272
|
on.failure do |error|
|
262
|
-
actual_data[:data] =
|
263
|
-
puts 'error callback was called, reason: ' + error.to_s
|
273
|
+
actual_data[:data] = error
|
274
|
+
puts 'error callback was called, reason: ' + error.to_s unless @agent_immutable
|
264
275
|
end
|
265
276
|
end
|
266
277
|
actual_data = wait_for actual_data
|
267
|
-
expect(actual_data['status']).to eq('OK')
|
268
|
-
expect(actual_data['message']).to start_with('Performed [Disable Deployment] on')
|
278
|
+
expect(actual_data['status']).to eq('OK') unless @agent_immutable
|
279
|
+
expect(actual_data['message']).to start_with('Performed [Disable Deployment] on') unless @agent_immutable
|
280
|
+
expect(actual_data).to include('Command not allowed because the agent is immutable') if @agent_immutable
|
269
281
|
end
|
270
282
|
|
271
283
|
it 'Add non-XA datasource should be doable' do
|
@@ -300,16 +312,17 @@ module Hawkular::Operations::RSpec
|
|
300
312
|
actual_data[:data] = data
|
301
313
|
end
|
302
314
|
on.failure do |error|
|
303
|
-
actual_data[:data] =
|
304
|
-
puts 'error callback was called, reason: ' + error.to_s
|
315
|
+
actual_data[:data] = error
|
316
|
+
puts 'error callback was called, reason: ' + error.to_s unless @agent_immutable
|
305
317
|
end
|
306
318
|
end
|
307
319
|
actual_data = wait_for actual_data
|
308
|
-
expect(actual_data['status']).to eq('OK')
|
309
|
-
expect(actual_data['message']).to start_with('Added Datasource')
|
310
|
-
expect(actual_data['xaDatasource']).to be_falsey
|
311
|
-
expect(actual_data['datasourceName']).to eq(payload[:datasourceName])
|
312
|
-
expect(actual_data['resourcePath']).to eq(payload[:resourcePath])
|
320
|
+
expect(actual_data['status']).to eq('OK') unless @agent_immutable
|
321
|
+
expect(actual_data['message']).to start_with('Added Datasource') unless @agent_immutable
|
322
|
+
expect(actual_data['xaDatasource']).to be_falsey unless @agent_immutable
|
323
|
+
expect(actual_data['datasourceName']).to eq(payload[:datasourceName]) unless @agent_immutable
|
324
|
+
expect(actual_data['resourcePath']).to eq(payload[:resourcePath]) unless @agent_immutable
|
325
|
+
expect(actual_data).to include('Command not allowed because the agent is immutable') if @agent_immutable
|
313
326
|
end
|
314
327
|
|
315
328
|
it 'Add XA datasource should be doable' do
|
@@ -344,16 +357,17 @@ module Hawkular::Operations::RSpec
|
|
344
357
|
actual_data[:data] = data
|
345
358
|
end
|
346
359
|
on.failure do |error|
|
347
|
-
actual_data[:data] =
|
348
|
-
puts 'error callback was called, reason: ' + error.to_s
|
360
|
+
actual_data[:data] = error
|
361
|
+
puts 'error callback was called, reason: ' + error.to_s unless @agent_immutable
|
349
362
|
end
|
350
363
|
end
|
351
364
|
actual_data = wait_for actual_data
|
352
|
-
expect(actual_data['status']).to eq('OK')
|
353
|
-
expect(actual_data['message']).to start_with('Added Datasource')
|
354
|
-
expect(actual_data['xaDatasource']).to be_truthy
|
355
|
-
expect(actual_data['datasourceName']).to eq(payload[:datasourceName])
|
356
|
-
expect(actual_data['resourcePath']).to eq(payload[:resourcePath])
|
365
|
+
expect(actual_data['status']).to eq('OK') unless @agent_immutable
|
366
|
+
expect(actual_data['message']).to start_with('Added Datasource') unless @agent_immutable
|
367
|
+
expect(actual_data['xaDatasource']).to be_truthy unless @agent_immutable
|
368
|
+
expect(actual_data['datasourceName']).to eq(payload[:datasourceName]) unless @agent_immutable
|
369
|
+
expect(actual_data['resourcePath']).to eq(payload[:resourcePath]) unless @agent_immutable
|
370
|
+
expect(actual_data).to include('Command not allowed because the agent is immutable') if @agent_immutable
|
357
371
|
end
|
358
372
|
|
359
373
|
it 'should not be possible to perform on closed client' do
|
@@ -371,18 +385,18 @@ module Hawkular::Operations::RSpec
|
|
371
385
|
|
372
386
|
it 'Restart can be run multiple times in parallel' do
|
373
387
|
wf_server_resource_id = 'Local~~'
|
374
|
-
|
388
|
+
status_war_resource_id = 'Local~%2Fdeployment%3Dhawkular-status.war'
|
375
389
|
console_war_resource_id = 'Local~%2Fdeployment%3Dhawkular-wildfly-agent-download.war'
|
376
390
|
path1 = CanonicalPath.new(tenant_id: @tenant_id,
|
377
391
|
feed_id: @feed_id,
|
378
|
-
resource_ids: [wf_server_resource_id,
|
392
|
+
resource_ids: [wf_server_resource_id, status_war_resource_id])
|
379
393
|
path2 = CanonicalPath.new(tenant_id: @tenant_id,
|
380
394
|
feed_id: @feed_id,
|
381
395
|
resource_ids: [wf_server_resource_id, console_war_resource_id])
|
382
396
|
|
383
397
|
restart1 = {
|
384
398
|
resource_path: path1.to_s,
|
385
|
-
deployment_name: 'hawkular-
|
399
|
+
deployment_name: 'hawkular-status.war'
|
386
400
|
}
|
387
401
|
|
388
402
|
restart2 = {
|
@@ -427,15 +441,16 @@ module Hawkular::Operations::RSpec
|
|
427
441
|
actual_data[:data] = data
|
428
442
|
end
|
429
443
|
on.failure do |error|
|
430
|
-
actual_data[:data] =
|
431
|
-
puts 'error callback was called, reason: ' + error.to_s
|
444
|
+
actual_data[:data] = error
|
445
|
+
puts 'error callback was called, reason: ' + error.to_s unless @agent_immutable
|
432
446
|
end
|
433
447
|
end
|
434
448
|
actual_data = wait_for actual_data
|
435
|
-
expect(actual_data['status']).to eq('OK')
|
436
|
-
expect(actual_data['message']).to start_with('Performed [Deploy] on')
|
437
|
-
expect(actual_data['destinationFileName']).to eq(app_name)
|
438
|
-
expect(actual_data['resourcePath']).to eq(wf_path)
|
449
|
+
expect(actual_data['status']).to eq('OK') unless @agent_immutable
|
450
|
+
expect(actual_data['message']).to start_with('Performed [Deploy] on') unless @agent_immutable
|
451
|
+
expect(actual_data['destinationFileName']).to eq(app_name) unless @agent_immutable
|
452
|
+
expect(actual_data['resourcePath']).to eq(wf_path) unless @agent_immutable
|
453
|
+
expect(actual_data).to include('Command not allowed because the agent is immutable') if @agent_immutable
|
439
454
|
end
|
440
455
|
|
441
456
|
it 'Undeploy deployment should be performed and eventually respond with success' do
|
@@ -454,13 +469,14 @@ module Hawkular::Operations::RSpec
|
|
454
469
|
actual_data[:data] = data
|
455
470
|
end
|
456
471
|
on.failure do |error|
|
457
|
-
actual_data[:data] =
|
458
|
-
puts 'error callback was called, reason: ' + error.to_s
|
472
|
+
actual_data[:data] = error
|
473
|
+
puts 'error callback was called, reason: ' + error.to_s unless @agent_immutable
|
459
474
|
end
|
460
475
|
end
|
461
476
|
actual_data = wait_for actual_data
|
462
|
-
expect(actual_data['status']).to eq('OK')
|
463
|
-
expect(actual_data['message']).to start_with('Performed [Undeploy] on')
|
477
|
+
expect(actual_data['status']).to eq('OK') unless @agent_immutable
|
478
|
+
expect(actual_data['message']).to start_with('Performed [Undeploy] on') unless @agent_immutable
|
479
|
+
expect(actual_data).to include('Command not allowed because the agent is immutable') if @agent_immutable
|
464
480
|
end
|
465
481
|
|
466
482
|
it 'Remove datasource should be performed and eventually respond with success' do
|
@@ -480,23 +496,24 @@ module Hawkular::Operations::RSpec
|
|
480
496
|
actual_data[:data] = data
|
481
497
|
end
|
482
498
|
on.failure do |error|
|
483
|
-
actual_data[:data] =
|
484
|
-
puts 'error callback was called, reason: ' + error.to_s
|
499
|
+
actual_data[:data] = error
|
500
|
+
puts 'error callback was called, reason: ' + error.to_s unless @agent_immutable
|
485
501
|
end
|
486
502
|
end
|
487
503
|
actual_data = wait_for actual_data
|
488
|
-
expect(actual_data['status']).to eq('OK')
|
489
|
-
expect(actual_data['message']).to start_with('Performed [Remove] on')
|
490
|
-
expect(actual_data['serverRefreshIndicator']).to eq('RELOAD-REQUIRED')
|
504
|
+
expect(actual_data['status']).to eq('OK') unless @agent_immutable
|
505
|
+
expect(actual_data['message']).to start_with('Performed [Remove] on') unless @agent_immutable
|
506
|
+
expect(actual_data['serverRefreshIndicator']).to eq('RELOAD-REQUIRED') unless @agent_immutable
|
507
|
+
expect(actual_data).to include('Command not allowed because the agent is immutable') if @agent_immutable
|
491
508
|
end
|
492
509
|
|
493
510
|
it 'Remove JDBC driver should be performed and eventually respond with success' do
|
494
|
-
|
511
|
+
# Unless it runs in a container
|
495
512
|
driver_resource_id = 'Local~%2Fsubsystem%3Ddatasources%2Fjdbc-driver%3DCreatedByRubyDriver'
|
496
513
|
driver_resource_id << @not_so_random_uuid
|
497
514
|
path = CanonicalPath.new(tenant_id: @tenant_id,
|
498
515
|
feed_id: @feed_id,
|
499
|
-
resource_ids: [wf_server_resource_id, driver_resource_id]).to_s
|
516
|
+
resource_ids: [@wf_server_resource_id, driver_resource_id]).to_s
|
500
517
|
|
501
518
|
actual_data = {}
|
502
519
|
client.invoke_specific_operation({ resourcePath: path }, 'RemoveJdbcDriver') do |on|
|
@@ -504,14 +521,16 @@ module Hawkular::Operations::RSpec
|
|
504
521
|
actual_data[:data] = data
|
505
522
|
end
|
506
523
|
on.failure do |error|
|
507
|
-
actual_data[:data] =
|
508
|
-
puts 'error callback was called, reason: ' + error.to_s
|
524
|
+
actual_data[:data] = error
|
525
|
+
puts 'error callback was called, reason: ' + error.to_s unless @agent_immutable
|
509
526
|
end
|
510
527
|
end
|
511
528
|
actual_data = wait_for actual_data
|
512
|
-
expect(actual_data['status']).to eq('OK')
|
513
|
-
expect(actual_data['resourcePath']).to eq(path)
|
514
|
-
expect(actual_data['message']).to start_with(
|
529
|
+
expect(actual_data['status']).to eq('OK') unless @agent_immutable
|
530
|
+
expect(actual_data['resourcePath']).to eq(path) unless @agent_immutable
|
531
|
+
expect(actual_data['message']).to start_with(
|
532
|
+
'Performed [Remove] on a [JDBC Driver]') unless @agent_immutable
|
533
|
+
expect(actual_data).to include('Command not allowed because the agent is immutable') if @agent_immutable
|
515
534
|
end
|
516
535
|
|
517
536
|
xit 'Export JDR should retrieve the zip file with the report' do
|
@@ -536,6 +555,36 @@ module Hawkular::Operations::RSpec
|
|
536
555
|
expect(actual_data['message']).to start_with('Performed [Export JDR] on')
|
537
556
|
expect(actual_data['fileName']).to start_with('jdr_')
|
538
557
|
end
|
558
|
+
|
559
|
+
it 'Update collection intervals should be performed and eventually respond with success' do
|
560
|
+
wf_server_resource_id = 'Local~~'
|
561
|
+
wf_agent_id = 'Local~%2Fsubsystem%3Dhawkular-wildfly-agent'
|
562
|
+
path = CanonicalPath.new(tenant_id: @tenant_id,
|
563
|
+
feed_id: @feed_id,
|
564
|
+
resource_ids: [wf_server_resource_id, wf_agent_id])
|
565
|
+
|
566
|
+
hash = {
|
567
|
+
resourcePath: path.to_s,
|
568
|
+
metricTypes: { 'WildFly Memory Metrics~Heap Max' => 77, 'Unknown~Metric' => 666 },
|
569
|
+
availTypes: { 'Server Availability~Server Availability' => 77, 'Unknown~Avail' => 666 }
|
570
|
+
}
|
571
|
+
|
572
|
+
actual_data = {}
|
573
|
+
client.update_collection_intervals(hash) do |on|
|
574
|
+
on.success do |data|
|
575
|
+
actual_data[:data] = data
|
576
|
+
end
|
577
|
+
on.failure do |error|
|
578
|
+
actual_data[:data] = error
|
579
|
+
puts 'error callback was called, reason: ' + error.to_s unless @agent_immutable
|
580
|
+
end
|
581
|
+
end
|
582
|
+
actual_data = wait_for actual_data
|
583
|
+
expect(actual_data['status']).to eq('OK') unless @agent_immutable
|
584
|
+
expect(
|
585
|
+
actual_data['message']).to start_with('Performed [Update Collection Intervals] on') unless @agent_immutable
|
586
|
+
expect(actual_data).to include('Command not allowed because the agent is immutable') if @agent_immutable
|
587
|
+
end
|
539
588
|
end
|
540
589
|
end
|
541
590
|
end
|