foreman_rh_cloud 7.0.48 → 8.0.46
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +1 -1
- data/lib/foreman_inventory_upload/generators/tags.rb +3 -5
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb +7 -27
- data/package.json +1 -1
- data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +11 -3
- data/test/factories/inventory_upload_factories.rb +15 -2
- data/test/jobs/connector_playbook_execution_reporter_task_test.rb +37 -120
- data/test/test_plugin_helper.rb +6 -0
- data/test/unit/slice_generator_test.rb +14 -9
- data/test/unit/tags_generator_test.rb +21 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8db662f6cd6809ba5dd5b183ec76330b4a1d4eb6db931136c8e34dcdf53c796c
|
4
|
+
data.tar.gz: e410219ca7fcbd0555d157f05123cc7c7618b29531157de42a3e3413d9d96eb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 601501b2ec41be00150bbc9797ad9fe7c93a92aea619ca1781ef3df88224e3f6fb04b2c16e2c2e974832ef67926794108d3c8f2c7654d52056e25a218887cd55
|
7
|
+
data.tar.gz: 6a7ca4b57eb655c5d4c3a880f0deac4af3f86c6a4b71ddd4ff02b7adc4aa9bf5c0cb2a70731f5472ce763b841a75f755835e0674d489c6b5d51759ee9d1c85f3
|
@@ -113,7 +113,7 @@ module ForemanInventoryUpload
|
|
113
113
|
bash_hostname = `uname -n`.chomp
|
114
114
|
foreman_hostname = ForemanRhCloud.foreman_host&.name
|
115
115
|
if bash_hostname == foreman_hostname
|
116
|
-
fqdn(
|
116
|
+
fqdn(foreman_hostname)
|
117
117
|
elsif Setting[:obfuscate_inventory_hostnames]
|
118
118
|
obfuscate_fqdn(bash_hostname)
|
119
119
|
else
|
@@ -45,11 +45,9 @@ module ForemanInventoryUpload
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def content_data
|
48
|
-
[
|
49
|
-
|
50
|
-
|
51
|
-
] +
|
52
|
-
(@host.activation_keys || []).map { |item| ['activation_key', item.name] }
|
48
|
+
(@host.lifecycle_environments.uniq || []).map { |item| ['lifecycle_environment', item.name] } +
|
49
|
+
(@host.activation_keys || []).map { |item| ['activation_key', item.name] } +
|
50
|
+
(@host.content_views || []).map { |item| ['content_view', item.name] }
|
53
51
|
end
|
54
52
|
|
55
53
|
def satellite_server_data
|
@@ -43,17 +43,7 @@ module InsightsCloud
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def done?(current_status = invocation_status)
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def job_finished?
|
50
|
-
job_invocation.finished?
|
51
|
-
end
|
52
|
-
|
53
|
-
def all_hosts_finished?(current_status)
|
54
|
-
current_status[:hosts_state].values.all? do |status|
|
55
|
-
ActiveModel::Type::Boolean.new.cast(status['report_done'] == true)
|
56
|
-
end
|
46
|
+
job_invocation.finished? || current_status.map { |_host_id, task_status| task_status['report_done'] }.all?
|
57
47
|
end
|
58
48
|
|
59
49
|
# noop, we don't want to do anything when the polling task starts
|
@@ -105,11 +95,7 @@ module InsightsCloud
|
|
105
95
|
end
|
106
96
|
|
107
97
|
def host_status(host)
|
108
|
-
external_task&.dig('invocation_status',
|
109
|
-
end
|
110
|
-
|
111
|
-
def task_done_state
|
112
|
-
ActiveModel::Type::Boolean.new.cast(external_task&.dig('invocation_status', :task_state, :task_done_reported))
|
98
|
+
external_task&.dig('invocation_status', host)
|
113
99
|
end
|
114
100
|
|
115
101
|
def sequence(host)
|
@@ -125,15 +111,13 @@ module InsightsCloud
|
|
125
111
|
end
|
126
112
|
|
127
113
|
def invocation_status
|
128
|
-
|
114
|
+
Hash[job_invocation.targeting.hosts.map do |host|
|
129
115
|
next unless host.insights&.uuid
|
130
116
|
[
|
131
117
|
host.insights.uuid,
|
132
118
|
task_status(job_invocation.sub_task_for_host(host), host.insights.uuid),
|
133
119
|
]
|
134
120
|
end.compact]
|
135
|
-
|
136
|
-
{task_state: {task_done_reported: task_done_state}, hosts_state: hosts_state}
|
137
121
|
end
|
138
122
|
|
139
123
|
def task_status(host_task, host_name)
|
@@ -144,7 +128,7 @@ module InsightsCloud
|
|
144
128
|
{
|
145
129
|
'state' => host_task.state,
|
146
130
|
'output' => host_task.main_action.live_output.map { |line| line['output'] }.join("\n"),
|
147
|
-
'exit_status' =>
|
131
|
+
'exit_status' => host_task.main_action.exit_status,
|
148
132
|
'sequence' => sequence(host_name),
|
149
133
|
'report_done' => host_done?(host_name),
|
150
134
|
}
|
@@ -154,9 +138,9 @@ module InsightsCloud
|
|
154
138
|
generator = InsightsCloud::Generators::PlaybookProgressGenerator.new(correlation_id)
|
155
139
|
all_hosts_success = true
|
156
140
|
|
157
|
-
invocation_status
|
141
|
+
invocation_status.each do |host_name, status|
|
158
142
|
# skip host if the host already reported that it's finished
|
159
|
-
next if
|
143
|
+
next if status['report_done']
|
160
144
|
|
161
145
|
unless status['state'] == 'unknown'
|
162
146
|
sequence = status['sequence']
|
@@ -170,11 +154,7 @@ module InsightsCloud
|
|
170
154
|
all_hosts_success &&= status['exit_status'] == 0
|
171
155
|
end
|
172
156
|
end
|
173
|
-
|
174
|
-
if (job_finished? || all_hosts_finished?(invocation_status))
|
175
|
-
generator.job_finished_message(all_hosts_success)
|
176
|
-
invocation_status[:task_state][:task_done_reported] = true
|
177
|
-
end
|
157
|
+
generator.job_finished_message(all_hosts_success) if done?(invocation_status)
|
178
158
|
|
179
159
|
send_report(generator.generate)
|
180
160
|
end
|
data/package.json
CHANGED
@@ -110,7 +110,7 @@ module InsightsCloud::Api
|
|
110
110
|
User.current = User.find_by(login: 'secret_admin')
|
111
111
|
|
112
112
|
@env = FactoryBot.create(:katello_k_t_environment)
|
113
|
-
|
113
|
+
@env2 = FactoryBot.create(:katello_k_t_environment, organization: @env.organization)
|
114
114
|
|
115
115
|
@host = FactoryBot.create(
|
116
116
|
:host,
|
@@ -118,8 +118,16 @@ module InsightsCloud::Api
|
|
118
118
|
:with_content,
|
119
119
|
:with_hostgroup,
|
120
120
|
:with_parameter,
|
121
|
-
|
122
|
-
|
121
|
+
content_view_environments: [
|
122
|
+
FactoryBot.create(
|
123
|
+
:katello_content_view_environment,
|
124
|
+
content_view: FactoryBot.create(:katello_content_view, organization: @env.organization),
|
125
|
+
lifecycle_environment: @env),
|
126
|
+
FactoryBot.create(
|
127
|
+
:katello_content_view_environment,
|
128
|
+
content_view: FactoryBot.create(:katello_content_view, organization: @env.organization),
|
129
|
+
lifecycle_environment: @env2),
|
130
|
+
],
|
123
131
|
organization: @env.organization
|
124
132
|
)
|
125
133
|
|
@@ -33,6 +33,13 @@ FactoryBot.define do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
FactoryBot.define do
|
37
|
+
factory :katello_content_view_environment, :class => Katello::ContentViewEnvironment do
|
38
|
+
sequence(:name) { |n| "name#{n}" }
|
39
|
+
sequence(:label) { |n| "label#{n}" }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
36
43
|
FactoryBot.define do
|
37
44
|
factory :katello_k_t_environment, :aliases => [:katello_environment], :class => Katello::KTEnvironment do
|
38
45
|
sequence(:name) { |n| "Environment#{n}" }
|
@@ -93,6 +100,7 @@ FactoryBot.modify do
|
|
93
100
|
content_view { nil }
|
94
101
|
lifecycle_environment { nil }
|
95
102
|
content_source { nil }
|
103
|
+
content_view_environments { [] }
|
96
104
|
end
|
97
105
|
|
98
106
|
trait :with_content do
|
@@ -100,9 +108,14 @@ FactoryBot.modify do
|
|
100
108
|
|
101
109
|
after(:build) do |host, evaluator|
|
102
110
|
if host.content_facet
|
103
|
-
|
104
|
-
|
111
|
+
if evaluator.content_view && evaluator.lifecycle_environment
|
112
|
+
host.content_facet.assign_single_environment(
|
113
|
+
content_view_id: evaluator.content_view.id,
|
114
|
+
lifecycle_environment_id: evaluator.lifecycle_environment.id
|
115
|
+
)
|
116
|
+
end
|
105
117
|
host.content_facet.content_source = evaluator.content_source if evaluator.content_source
|
118
|
+
host.content_facet.content_view_environments = evaluator.content_view_environments unless evaluator.content_view_environments.empty?
|
106
119
|
end
|
107
120
|
end
|
108
121
|
end
|
@@ -29,11 +29,7 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
|
|
29
29
|
end
|
30
30
|
|
31
31
|
test 'It reports finish playbook messages' do
|
32
|
-
|
33
|
-
host1_task.state = 'stopped'
|
34
|
-
host1_task.save!
|
35
|
-
|
36
|
-
TestConnectorPlaybookExecutionReporterTask.any_instance.stubs(:job_finished?).returns(true)
|
32
|
+
TestConnectorPlaybookExecutionReporterTask.any_instance.stubs(:done?).returns(true)
|
37
33
|
|
38
34
|
actual = ForemanTasks.sync_task(TestConnectorPlaybookExecutionReporterTask, @job_invocation)
|
39
35
|
|
@@ -43,13 +39,6 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
|
|
43
39
|
assert_not_nil actual_report
|
44
40
|
actual_jsonl = read_jsonl(actual_report)
|
45
41
|
|
46
|
-
assert_equal true, actual.output['task']['invocation_status']['task_state']['task_done_reported']
|
47
|
-
assert_equal 0, actual.output['task']['invocation_status']['hosts_state']['TEST_UUID1']['exit_status']
|
48
|
-
assert_equal 0, actual.output['task']['invocation_status']['hosts_state']['TEST_UUID2']['exit_status']
|
49
|
-
|
50
|
-
assert_equal true, @job_invocation.finished?
|
51
|
-
assert_equal 'stopped', @job_invocation.sub_task_for_host(Host.where(name: 'host1').first)['state']
|
52
|
-
|
53
42
|
assert_not_nil actual_report_finished = actual_jsonl.find { |l| l['type'] == 'playbook_run_completed' }
|
54
43
|
assert_equal 'TEST_CORRELATION', actual_report_finished['correlation_id']
|
55
44
|
assert_equal 'success', actual_report_finished['status']
|
@@ -60,127 +49,57 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
|
|
60
49
|
end
|
61
50
|
|
62
51
|
test 'It reports single progress message for done host' do
|
63
|
-
|
64
|
-
def send_report(report)
|
65
|
-
host1_task = @job_invocation.sub_task_for_host(Host.where(name: 'host1').first)
|
66
|
-
host1_task.state = 'stopped'
|
67
|
-
host1_task.save!
|
68
|
-
|
69
|
-
output[:saved_reports] = (output[:saved_reports] || []) << report
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
ArrangeTestHost.instance_variable_set(:@connector_feature_id, nil)
|
74
|
-
host1_task = @job_invocation.sub_task_for_host(Host.where(name: 'host1').first)
|
75
|
-
host1_task.state = 'running'
|
76
|
-
host1_task.save!
|
77
|
-
|
78
|
-
ArrangeTestHost.any_instance.stubs(:job_finished?).returns(false, true)
|
52
|
+
TestConnectorPlaybookExecutionReporterTask.any_instance.stubs(:done?).returns(false, true)
|
79
53
|
|
80
|
-
actual = ForemanTasks.sync_task(
|
81
|
-
|
82
|
-
actual_report1 = actual.output[:saved_reports].first.to_s
|
83
|
-
actual_report2 = actual.output[:saved_reports].second.to_s
|
84
|
-
|
85
|
-
assert_equal 2, actual.output[:saved_reports].size
|
86
|
-
assert_not_nil actual_report1
|
87
|
-
assert_not_nil actual_report2
|
88
|
-
|
89
|
-
actual_json1 = read_jsonl(actual_report1)
|
90
|
-
actual_json2 = read_jsonl(actual_report2)
|
91
|
-
|
92
|
-
assert_equal true, actual.output['task']['invocation_status']['task_state']['task_done_reported']
|
93
|
-
assert_equal 0, actual.output['task']['invocation_status']['hosts_state']['TEST_UUID1']['exit_status']
|
94
|
-
|
95
|
-
assert_equal 'stopped', @job_invocation.sub_task_for_host(Host.where(name: 'host1').first)['state']
|
96
|
-
|
97
|
-
assert_not_nil actual_report_updated = actual_json1.find { |l| l['type'] == 'playbook_run_update' && l['host'] == 'TEST_UUID1' }
|
98
|
-
assert_equal 'TEST_CORRELATION', actual_report_updated['correlation_id']
|
99
|
-
assert_equal 'TEST_UUID1', actual_report_updated['host']
|
100
|
-
assert_equal 0, actual_report_updated['sequence']
|
101
|
-
assert_equal 6, actual_report_updated.size
|
54
|
+
actual = ForemanTasks.sync_task(TestConnectorPlaybookExecutionReporterTask, @job_invocation)
|
102
55
|
|
103
|
-
|
104
|
-
assert_equal 'TEST_CORRELATION', actual_report_updated['correlation_id']
|
105
|
-
assert_equal 'TEST_UUID1', actual_report_updated['host']
|
106
|
-
assert_equal 1, actual_report_updated['sequence']
|
107
|
-
assert_equal 6, actual_report_updated.size
|
56
|
+
actual_report = actual.output[:saved_reports].first.to_s
|
108
57
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
assert_equal 'success', actual_host_finished['status']
|
113
|
-
assert_equal 7, actual_host_finished.size
|
58
|
+
assert_equal 1, actual.output[:saved_reports].size
|
59
|
+
assert_not_nil actual_report
|
60
|
+
actual_jsonl = read_jsonl(actual_report)
|
114
61
|
|
115
|
-
|
116
|
-
|
117
|
-
assert_equal
|
118
|
-
assert_equal
|
62
|
+
actual_host_updates = actual_jsonl
|
63
|
+
.select { |l| l['type'] == 'playbook_run_update' && l['host'] == @host1.insights.uuid }
|
64
|
+
assert_equal 1, actual_host_updates.size
|
65
|
+
assert_equal 0, actual_host_updates.first['sequence']
|
119
66
|
end
|
120
67
|
|
121
68
|
test 'It reports two progress messages for in progress host' do
|
122
|
-
|
123
|
-
def send_report(report)
|
124
|
-
iteration_number = output[:iteration_number].to_i
|
125
|
-
|
126
|
-
if iteration_number == 1
|
127
|
-
host1_task = job_invocation.sub_task_for_host(Host.where(name: 'host1').first)
|
128
|
-
host1_task.state = 'stopped'
|
129
|
-
host1_task.save!
|
130
|
-
end
|
131
|
-
|
132
|
-
output[:iteration_number] = iteration_number + 1
|
133
|
-
output[:saved_reports] = (output[:saved_reports] || []) << report
|
134
|
-
end
|
135
|
-
end
|
69
|
+
TestConnectorPlaybookExecutionReporterTask.any_instance.stubs(:done?).returns(false, false, true)
|
136
70
|
|
137
|
-
|
138
|
-
host1_task = @job_invocation.sub_task_for_host(Host.where(name: 'host1').first)
|
71
|
+
host1_task = @job_invocation.template_invocations.joins(:host).where(hosts: {name: @host1.name}).first.run_host_job_task
|
139
72
|
host1_task.state = 'running'
|
140
73
|
host1_task.save!
|
141
74
|
|
142
|
-
|
143
|
-
|
144
|
-
actual = ForemanTasks.sync_task(ArrangeTestHostTwo, @job_invocation)
|
145
|
-
|
146
|
-
actual_report1 = actual.output[:saved_reports].first.to_s
|
147
|
-
actual_report2 = actual.output[:saved_reports].second.to_s
|
148
|
-
actual_report3 = actual.output[:saved_reports].third.to_s
|
75
|
+
actual = ForemanTasks.sync_task(TestConnectorPlaybookExecutionReporterTask, @job_invocation)
|
149
76
|
|
150
|
-
assert_equal
|
151
|
-
assert_not_nil actual_report1
|
152
|
-
assert_not_nil actual_report2
|
153
|
-
assert_not_nil actual_report3
|
77
|
+
assert_equal 2, actual.output[:saved_reports].size
|
154
78
|
|
155
|
-
|
156
|
-
|
157
|
-
actual_json3 = read_jsonl(actual_report3)
|
79
|
+
first_report = actual.output[:saved_reports].first.to_s
|
80
|
+
actual_jsonl = read_jsonl(first_report)
|
158
81
|
|
159
|
-
|
160
|
-
|
82
|
+
actual_host_updates = actual_jsonl
|
83
|
+
.select { |l| l['type'] == 'playbook_run_update' && l['host'] == @host1.insights.uuid }
|
84
|
+
assert_equal 1, actual_host_updates.size
|
85
|
+
assert_equal 0, actual_host_updates.first['sequence']
|
161
86
|
|
162
|
-
|
163
|
-
|
164
|
-
assert_equal
|
165
|
-
assert_equal 0,
|
166
|
-
assert_equal 6, actual_report_updated.size
|
87
|
+
actual_host_updates = actual_jsonl
|
88
|
+
.select { |l| l['type'] == 'playbook_run_update' && l['host'] == @host2.insights.uuid }
|
89
|
+
assert_equal 1, actual_host_updates.size
|
90
|
+
assert_equal 0, actual_host_updates.first['sequence']
|
167
91
|
|
168
|
-
|
169
|
-
|
170
|
-
assert_equal 'TEST_UUID1', actual_report_updated['host']
|
171
|
-
assert_equal 1, actual_report_updated['sequence']
|
172
|
-
assert_equal 6, actual_report_updated.size
|
92
|
+
second_report = actual.output[:saved_reports].last.to_s
|
93
|
+
actual_jsonl = read_jsonl(second_report)
|
173
94
|
|
174
|
-
|
175
|
-
|
176
|
-
assert_equal
|
177
|
-
assert_equal
|
178
|
-
assert_equal 7, actual_host_finished.size
|
95
|
+
actual_host_updates = actual_jsonl
|
96
|
+
.select { |l| l['type'] == 'playbook_run_update' && l['host'] == @host1.insights.uuid }
|
97
|
+
assert_equal 1, actual_host_updates.size
|
98
|
+
assert_equal 1, actual_host_updates.first['sequence']
|
179
99
|
|
180
|
-
|
181
|
-
|
182
|
-
assert_equal
|
183
|
-
assert_equal 4, actual_report_finished.size
|
100
|
+
actual_host_updates = actual_jsonl
|
101
|
+
.select { |l| l['type'] == 'playbook_run_update' && l['host'] == @host2.insights.uuid }
|
102
|
+
assert_equal 0, actual_host_updates.size
|
184
103
|
end
|
185
104
|
|
186
105
|
private
|
@@ -245,12 +164,10 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
|
|
245
164
|
:value => '1'
|
246
165
|
)
|
247
166
|
|
248
|
-
@host1 = FactoryBot.create(:host, :with_insights_hits)
|
249
|
-
@host1.name = 'host1' # overriding name since there is an issue with Factorybot and setting the name correctly, same for 2nd host
|
167
|
+
@host1 = FactoryBot.create(:host, :with_insights_hits, name: 'host1')
|
250
168
|
@host1.insights.uuid = 'TEST_UUID1'
|
251
169
|
@host1.insights.save!
|
252
|
-
@host2 = FactoryBot.create(:host, :with_insights_hits)
|
253
|
-
@host2.name = 'host2'
|
170
|
+
@host2 = FactoryBot.create(:host, :with_insights_hits, name: 'host2')
|
254
171
|
@host2.insights.uuid = 'TEST_UUID2'
|
255
172
|
@host2.insights.save!
|
256
173
|
|
@@ -273,7 +190,7 @@ class ConnectorPlaybookExecutionReporterTaskTest < ActiveSupport::TestCase
|
|
273
190
|
{ 'timestamp' => (Time.now - (5 - i)).to_f, 'output' => "#{i}\n" }
|
274
191
|
end
|
275
192
|
Support::DummyDynflowAction.any_instance.stubs(:live_output).returns(fake_output)
|
276
|
-
Support::DummyDynflowAction.any_instance.stubs(:exit_status).returns(
|
193
|
+
Support::DummyDynflowAction.any_instance.stubs(:exit_status).returns(0)
|
277
194
|
|
278
195
|
job_invocation
|
279
196
|
end
|
data/test/test_plugin_helper.rb
CHANGED
@@ -8,6 +8,12 @@ FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories
|
|
8
8
|
# FactoryBot.definition_file_paths << "#{Katello::Engine.root}/test/factories"
|
9
9
|
FactoryBot.reload
|
10
10
|
|
11
|
+
begin
|
12
|
+
require 'pry-rescue/minitest'
|
13
|
+
rescue LoadError
|
14
|
+
# if the extension is not loaded - please continue, no harm done.
|
15
|
+
end
|
16
|
+
|
11
17
|
module FolderIsolation
|
12
18
|
extend ActiveSupport::Concern
|
13
19
|
|
@@ -30,7 +30,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
30
30
|
subscription: FactoryBot.create(:katello_subscription, organization_id: env.organization.id)
|
31
31
|
)
|
32
32
|
@host.interfaces.first.identifier = 'test_nic1'
|
33
|
-
@host.save!
|
33
|
+
@host.interfaces.first.save!
|
34
34
|
|
35
35
|
ForemanInventoryUpload::Generators::Queries.instance_variable_set(:@fact_names, nil)
|
36
36
|
end
|
@@ -300,6 +300,11 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
300
300
|
|
301
301
|
test 'generates a report with satellite facts' do
|
302
302
|
hostgroup = FactoryBot.create(:hostgroup, name: 'Special"name')
|
303
|
+
# Don't try to update CP in tests
|
304
|
+
Katello::Resources::Candlepin::Consumer.stubs(:update)
|
305
|
+
# Don't try update facts for the host
|
306
|
+
Katello::Host::SubscriptionFacet.stubs(:update_facts)
|
307
|
+
|
303
308
|
@host.hostgroup = hostgroup
|
304
309
|
@host.save!
|
305
310
|
|
@@ -326,7 +331,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
326
331
|
actual_host = actual['hosts'].first
|
327
332
|
assert_tag('satellite-id', actual_host, 'satellite_instance_id')
|
328
333
|
assert_tag(@host.organization_id.to_s, actual_host, 'organization_id')
|
329
|
-
assert_tag(@host.
|
334
|
+
assert_tag(@host.content_views.first.name, actual_host, 'content_view')
|
330
335
|
assert_tag(@host.location.name, actual_host, 'location')
|
331
336
|
assert_tag(@host.organization.name, actual_host, 'organization')
|
332
337
|
assert_tag(@host.hostgroup.name, actual_host, 'hostgroup')
|
@@ -348,13 +353,13 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
348
353
|
:host,
|
349
354
|
:with_subscription,
|
350
355
|
:with_content,
|
351
|
-
content_view: @host.
|
352
|
-
lifecycle_environment: @host.
|
356
|
+
content_view: @host.content_views.first,
|
357
|
+
lifecycle_environment: @host.lifecycle_environments.first,
|
353
358
|
organization: @host.organization
|
354
359
|
)
|
355
360
|
|
356
361
|
@host.subscription_facet.hypervisor_host = hypervisor_host
|
357
|
-
@host.save!
|
362
|
+
@host.subscription_facet.save!
|
358
363
|
|
359
364
|
batch = Host.where(id: @host.id).in_batches.first
|
360
365
|
generator = create_generator(batch)
|
@@ -497,8 +502,8 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
497
502
|
:host,
|
498
503
|
:with_subscription,
|
499
504
|
:with_content,
|
500
|
-
content_view: @host.
|
501
|
-
lifecycle_environment: @host.
|
505
|
+
content_view: @host.content_views.first,
|
506
|
+
lifecycle_environment: @host.lifecycle_environments.first,
|
502
507
|
organization: new_org
|
503
508
|
)
|
504
509
|
|
@@ -644,8 +649,8 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
644
649
|
:host,
|
645
650
|
:with_subscription,
|
646
651
|
:with_content,
|
647
|
-
content_view: @host.
|
648
|
-
lifecycle_environment: @host.
|
652
|
+
content_view: @host.content_views.first,
|
653
|
+
lifecycle_environment: @host.lifecycle_environments.first,
|
649
654
|
organization: @host.organization,
|
650
655
|
installed_packages: [installed_package]
|
651
656
|
)
|
@@ -7,7 +7,7 @@ class TagsGeneratorTest < ActiveSupport::TestCase
|
|
7
7
|
User.current = User.find_by(login: 'secret_admin')
|
8
8
|
|
9
9
|
env = FactoryBot.create(:katello_k_t_environment)
|
10
|
-
|
10
|
+
env2 = FactoryBot.create(:katello_k_t_environment, organization: env.organization)
|
11
11
|
|
12
12
|
@location1 = FactoryBot.create(:location)
|
13
13
|
@location2 = FactoryBot.create(:location, parent: @location1)
|
@@ -20,15 +20,27 @@ class TagsGeneratorTest < ActiveSupport::TestCase
|
|
20
20
|
:redhat,
|
21
21
|
:with_subscription,
|
22
22
|
:with_content,
|
23
|
-
content_view: cv.first,
|
24
|
-
lifecycle_environment: env,
|
25
23
|
organization: env.organization,
|
26
24
|
location: @location2,
|
27
|
-
hostgroup: @hostgroup2
|
25
|
+
hostgroup: @hostgroup2,
|
26
|
+
content_view_environments: [
|
27
|
+
FactoryBot.create(
|
28
|
+
:katello_content_view_environment,
|
29
|
+
content_view: FactoryBot.create(:katello_content_view, organization: env.organization),
|
30
|
+
lifecycle_environment: env),
|
31
|
+
FactoryBot.create(
|
32
|
+
:katello_content_view_environment,
|
33
|
+
content_view: FactoryBot.create(:katello_content_view, organization: env.organization),
|
34
|
+
lifecycle_environment: env2),
|
35
|
+
]
|
28
36
|
)
|
29
37
|
|
30
38
|
@host.organization.pools << FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
|
31
39
|
@host.interfaces.first.identifier = 'test_nic1'
|
40
|
+
# Don't try to update CP in tests
|
41
|
+
Katello::Resources::Candlepin::Consumer.stubs(:update)
|
42
|
+
# Don't try update facts for the host
|
43
|
+
Katello::Host::SubscriptionFacet.stubs(:update_facts)
|
32
44
|
@host.save!
|
33
45
|
end
|
34
46
|
|
@@ -46,8 +58,10 @@ class TagsGeneratorTest < ActiveSupport::TestCase
|
|
46
58
|
assert_nil actual['host collection']
|
47
59
|
|
48
60
|
assert_equal @host.organization.name, actual['organization'].first.last
|
49
|
-
assert_equal @host.
|
50
|
-
assert_equal @host.
|
61
|
+
assert_equal @host.lifecycle_environments.pluck(:name).min, actual['lifecycle_environment'].map(&:second).min
|
62
|
+
assert_equal @host.lifecycle_environments.pluck(:name).max, actual['lifecycle_environment'].map(&:second).max
|
63
|
+
assert_equal @host.content_views.pluck(:name).min, actual['content_view'].map(&:second).min
|
64
|
+
assert_equal @host.content_views.pluck(:name).max, actual['content_view'].map(&:second).max
|
51
65
|
assert_equal Foreman.instance_id, actual['satellite_instance_id'].first.last
|
52
66
|
assert_equal @host.organization_id.to_s, actual['organization_id'].first.last
|
53
67
|
end
|
@@ -55,7 +69,7 @@ class TagsGeneratorTest < ActiveSupport::TestCase
|
|
55
69
|
test 'filters tags with empty values' do
|
56
70
|
generator = create_generator
|
57
71
|
|
58
|
-
@host.stubs(:
|
72
|
+
@host.stubs(:content_views).returns([])
|
59
73
|
|
60
74
|
actual = generator.generate.group_by { |key, value| key }
|
61
75
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_rh_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.0.46
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Foreman Red Hat Cloud team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: katello
|