foreman_wreckingball 4.0.0 → 6.0.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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/Rakefile +2 -2
  4. data/app/controllers/foreman_wreckingball/hosts_controller.rb +30 -13
  5. data/app/helpers/{concerns/foreman_wreckingball/hosts_helper_extensions.rb → foreman_wreckingball/hosts_helper.rb} +1 -1
  6. data/app/helpers/foreman_wreckingball/hypervisors_helper.rb +2 -1
  7. data/app/helpers/foreman_wreckingball/statuses_helper.rb +9 -7
  8. data/app/jobs/update_hosts_vmware_facets.rb +3 -2
  9. data/app/lib/actions/foreman_wreckingball/bulk_remediate.rb +4 -1
  10. data/app/lib/actions/foreman_wreckingball/host/remediate_hardware_version.rb +3 -1
  11. data/app/lib/actions/foreman_wreckingball/host/remediate_spectre_v2.rb +3 -1
  12. data/app/lib/actions/foreman_wreckingball/host/remediate_vmware_operatingsystem.rb +14 -10
  13. data/app/lib/actions/foreman_wreckingball/vmware/schedule_vmware_sync.rb +1 -1
  14. data/app/lib/actions/foreman_wreckingball/vmware/sync_compute_resource.rb +2 -2
  15. data/app/lib/fog_extensions/foreman_wreckingball/vsphere/host.rb +2 -0
  16. data/app/lib/fog_extensions/foreman_wreckingball/vsphere/mock.rb +3 -1
  17. data/app/lib/fog_extensions/foreman_wreckingball/vsphere/real.rb +7 -2
  18. data/app/lib/fog_extensions/foreman_wreckingball/vsphere/server.rb +2 -0
  19. data/app/lib/vsphere_os_identifiers/data.yaml +7 -0
  20. data/app/models/concerns/foreman_wreckingball/compute_resource_extensions.rb +11 -5
  21. data/app/models/concerns/foreman_wreckingball/host_extensions.rb +9 -4
  22. data/app/models/concerns/foreman_wreckingball/vmware_facet_host_extensions.rb +42 -11
  23. data/app/models/concerns/foreman_wreckingball/vmware_hypervisor_facet_host_extensions.rb +6 -2
  24. data/app/models/foreman_wreckingball/cpu_hot_add_status.rb +1 -1
  25. data/app/models/foreman_wreckingball/hardware_version_status.rb +1 -1
  26. data/app/models/foreman_wreckingball/operatingsystem_status.rb +2 -0
  27. data/app/models/foreman_wreckingball/spectre_v2_status.rb +2 -2
  28. data/app/models/foreman_wreckingball/vmware_cluster.rb +14 -13
  29. data/app/models/foreman_wreckingball/vmware_facet.rb +18 -12
  30. data/app/models/foreman_wreckingball/vmware_hypervisor_facet.rb +3 -1
  31. data/app/services/foreman_wreckingball/vmware_cluster_importer.rb +7 -4
  32. data/app/services/foreman_wreckingball/vmware_hypervisor_importer.rb +44 -41
  33. data/app/views/foreman_wreckingball/hosts/_hosts.json.rabl +2 -2
  34. data/app/views/foreman_wreckingball/hosts/status_hosts.json.rabl +4 -4
  35. data/config/environments/production.rb +1 -1
  36. data/config/routes.rb +3 -2
  37. data/db/migrate/20181021111543_add_indexes_to_vmware_hypervisor_facets.rb +1 -1
  38. data/db/migrate/20240201094513_fix_wreckingball_settings_category_to_dsl.rb +13 -0
  39. data/lib/foreman_wreckingball/engine.rb +79 -87
  40. data/lib/foreman_wreckingball/scheduled_jobs.rb +1 -1
  41. data/lib/foreman_wreckingball/version.rb +1 -1
  42. data/lib/tasks/foreman_vmware_checks_tasks.rake +1 -21
  43. data/test/actions/foreman_wreckingball/bulk_remediate_test.rb +0 -1
  44. data/test/actions/foreman_wreckingball/host/refresh_vmware_facet_test.rb +6 -7
  45. data/test/actions/foreman_wreckingball/host/remediate_hardware_version_test.rb +6 -7
  46. data/test/actions/foreman_wreckingball/host/remediate_spectre_v2_test.rb +6 -7
  47. data/test/actions/foreman_wreckingball/host/remediate_vmware_operatingsystem_test.rb +8 -9
  48. data/test/actions/foreman_wreckingball/vmware/sync_compute_resource_test.rb +2 -2
  49. data/test/controllers/compute_resources_controller_test.rb +2 -2
  50. data/test/controllers/foreman_wreckingball/hosts_controller_test.rb +19 -18
  51. data/test/factories/foreman_wreckingball_factories.rb +10 -10
  52. data/test/integration/hosts_status_dashboard_test.rb +0 -4
  53. data/test/integration/hosts_status_managed_hosts_test.rb +4 -5
  54. data/test/models/compute_resources/vmware_test.rb +1 -1
  55. data/test/models/foreman_wreckingball/cpu_hot_add_status_test.rb +2 -2
  56. data/test/models/foreman_wreckingball/hardware_version_status_test.rb +3 -4
  57. data/test/models/foreman_wreckingball/operatingsystem_status_test.rb +5 -5
  58. data/test/models/foreman_wreckingball/spectre_v2_status_test.rb +4 -4
  59. data/test/models/foreman_wreckingball/tools_status_test.rb +2 -2
  60. data/test/models/foreman_wreckingball/vmware_facet_test.rb +10 -10
  61. data/test/models/foreman_wreckingball/vmware_hypervisor_facet_test.rb +4 -4
  62. data/test/models/host_test.rb +54 -52
  63. data/test/test_plugin_helper.rb +1 -1
  64. data/test/unit/foreman_wreckingball/access_permissions_test.rb +18 -0
  65. data/test/unit/foreman_wreckingball/vmware_cluster_importer_test.rb +6 -6
  66. data/test/unit/foreman_wreckingball/vmware_hypervisor_importer_test.rb +4 -4
  67. metadata +56 -40
  68. data/app/models/setting/wreckingball.rb +0 -26
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanWreckingball
4
- VERSION = '4.0.0'
4
+ VERSION = '6.0.0'
5
5
  end
@@ -6,7 +6,7 @@ require 'rake/testtask'
6
6
  namespace :foreman_wreckingball do
7
7
  namespace :vmware do
8
8
  desc 'Synchonize VMware compute resource data'
9
- task :sync => ['environment', 'dynflow:client'] do
9
+ task sync: ['environment', 'dynflow:client'] do
10
10
  User.as_anonymous_admin do
11
11
  ::ForemanTasks.sync_task(::Actions::ForemanWreckingball::Vmware::ScheduleVmwareSync)
12
12
  end
@@ -26,24 +26,4 @@ namespace :test do
26
26
  end
27
27
  end
28
28
 
29
- namespace :foreman_wreckingball do
30
- task :rubocop do
31
- begin
32
- require 'rubocop/rake_task'
33
- RuboCop::RakeTask.new(:rubocop_foreman_wreckingball) do |task|
34
- task.patterns = ["#{ForemanWreckingball::Engine.root}/app/**/*.rb",
35
- "#{ForemanWreckingball::Engine.root}/lib/**/*.rb",
36
- "#{ForemanWreckingball::Engine.root}/test/**/*.rb"]
37
- end
38
- rescue StandardError
39
- puts 'Rubocop not loaded.'
40
- end
41
-
42
- Rake::Task['rubocop_foreman_wreckingball'].invoke
43
- end
44
- end
45
-
46
29
  Rake::Task[:test].enhance ['test:foreman_wreckingball']
47
-
48
- load 'tasks/jenkins.rake'
49
- Rake::Task['jenkins:unit'].enhance ['test:foreman_wreckingball', 'foreman_wreckingball:rubocop'] if Rake::Task.task_defined?(:'jenkins:unit')
@@ -12,7 +12,6 @@ module Actions
12
12
  let(:action) { create_action(action_class) }
13
13
 
14
14
  setup do
15
- Setting::Wreckingball.load_defaults
16
15
  FactoryBot.create_list(:host, 2, :managed, :with_wreckingball_statuses)
17
16
  end
18
17
 
@@ -13,17 +13,16 @@ module Actions
13
13
 
14
14
  setup do
15
15
  ::Fog.mock!
16
- ::ForemanWreckingball.fog_vsphere_namespace::Mock.any_instance.stubs(:get_vm_ref).returns(vm)
17
- ::ForemanWreckingball.fog_vsphere_namespace::Server.any_instance.stubs(:ready?).returns(false)
16
+ Fog::Vsphere::Compute::Mock.any_instance.stubs(:get_vm_ref).returns(vm)
17
+ Fog::Vsphere::Compute::Server.any_instance.stubs(:ready?).returns(false)
18
18
  ::ForemanWreckingball::SpectreV2Status.any_instance.stubs(:recent_hw_version?).returns(true)
19
19
  # this is not stubbed correctly in fog-vsphere
20
- ::ForemanWreckingball.fog_vsphere_namespace::Server.any_instance.stubs(:cpuHotAddEnabled).returns(false)
21
- Setting::Wreckingball.load_defaults
20
+ Fog::Vsphere::Compute::Server.any_instance.stubs(:cpuHotAddEnabled).returns(false)
22
21
  end
23
22
  teardown { ::Fog.unmock! }
24
23
 
25
24
  let(:compute_resource) do
26
- cr = FactoryBot.create(:compute_resource, :vmware, :with_taxonomy, :uuid => 'Solutions')
25
+ cr = FactoryBot.create(:compute_resource, :vmware, :with_taxonomy, uuid: 'Solutions')
27
26
  ComputeResource.find(cr.id)
28
27
  end
29
28
 
@@ -35,7 +34,7 @@ module Actions
35
34
  compute_resource: compute_resource,
36
35
  uuid: uuid
37
36
  ).tap do |host|
38
- host.vmware_facet.update_attribute(:guest_id, 'asianux4_64Guest')
37
+ host.vmware_facet.update_attribute(:guest_id, 'asianux4_64Guest') # rubocop:disable Rails/SkipsModelValidations
39
38
  end
40
39
  end
41
40
 
@@ -45,7 +44,7 @@ module Actions
45
44
  action.stubs(:action_subject).returns(host)
46
45
  action.input.update(
47
46
  host: {
48
- id: host.id
47
+ id: host.id,
49
48
  }
50
49
  )
51
50
  end
@@ -10,16 +10,15 @@ module Actions
10
10
  setup do
11
11
  ::Fog.mock!
12
12
  # this is not stubbed correctly in fog-vsphere
13
- ::ForemanWreckingball.fog_vsphere_namespace::Server.any_instance.stubs(:cpuHotAddEnabled).returns(false)
14
- ::ForemanWreckingball.fog_vsphere_namespace::Server.any_instance.stubs(:hardware_version).returns('vmx-13')
13
+ Fog::Vsphere::Compute::Server.any_instance.stubs(:cpuHotAddEnabled).returns(false)
14
+ Fog::Vsphere::Compute::Server.any_instance.stubs(:hardware_version).returns('vmx-13')
15
15
  ::ForemanWreckingball::SpectreV2Status.any_instance.stubs(:recent_hw_version?).returns(true)
16
16
  ::PowerManager::Virt.any_instance.stubs(:ready?).returns(true)
17
- Setting::Wreckingball.load_defaults
18
17
  end
19
18
  teardown { ::Fog.unmock! }
20
19
 
21
20
  let(:compute_resource) do
22
- cr = FactoryBot.create(:compute_resource, :vmware, :with_taxonomy, :uuid => 'Solutions')
21
+ cr = FactoryBot.create(:compute_resource, :vmware, :with_taxonomy, uuid: 'Solutions')
23
22
  ComputeResource.find(cr.id)
24
23
  end
25
24
  let(:uuid) { '5032c8a5-9c5e-ba7a-3804-832a03e16381' }
@@ -41,7 +40,7 @@ module Actions
41
40
  action.stubs(:action_subject).returns(host)
42
41
  action.input.update(
43
42
  host: {
44
- id: host.id
43
+ id: host.id,
45
44
  }
46
45
  )
47
46
  end
@@ -53,8 +52,8 @@ module Actions
53
52
 
54
53
  test "it remediates the host's hardware version" do
55
54
  assert_equal :success, runned_action.state
56
- assert_equal true, runned_action.output.fetch('state')
57
- assert_equal true, runned_action.output.fetch('initially_powered_on')
55
+ assert runned_action.output.fetch('state')
56
+ assert runned_action.output.fetch('initially_powered_on')
58
57
  assert_equal 'vmx-13', host.reload.vmware_facet.hardware_version
59
58
  end
60
59
  end
@@ -10,16 +10,15 @@ module Actions
10
10
  setup do
11
11
  ::Fog.mock!
12
12
  # this is not stubbed correctly in fog-vsphere
13
- ::ForemanWreckingball.fog_vsphere_namespace::Server.any_instance.stubs(:cpuHotAddEnabled).returns(false)
14
- ::ForemanWreckingball.fog_vsphere_namespace::Server.any_instance.stubs(:hardware_version).returns('vmx-13')
13
+ Fog::Vsphere::Compute::Server.any_instance.stubs(:cpuHotAddEnabled).returns(false)
14
+ Fog::Vsphere::Compute::Server.any_instance.stubs(:hardware_version).returns('vmx-13')
15
15
  ::ForemanWreckingball::SpectreV2Status.any_instance.stubs(:recent_hw_version?).returns(true)
16
16
  ::PowerManager::Virt.any_instance.stubs(:ready?).returns(true)
17
- Setting::Wreckingball.load_defaults
18
17
  end
19
18
  teardown { ::Fog.unmock! }
20
19
 
21
20
  let(:compute_resource) do
22
- cr = FactoryBot.create(:compute_resource, :vmware, :with_taxonomy, :uuid => 'Solutions')
21
+ cr = FactoryBot.create(:compute_resource, :vmware, :with_taxonomy, uuid: 'Solutions')
23
22
  ComputeResource.find(cr.id)
24
23
  end
25
24
  let(:uuid) { '5032c8a5-9c5e-ba7a-3804-832a03e16381' }
@@ -41,7 +40,7 @@ module Actions
41
40
  action.stubs(:action_subject).returns(host)
42
41
  action.input.update(
43
42
  host: {
44
- id: host.id
43
+ id: host.id,
45
44
  }
46
45
  )
47
46
  end
@@ -53,8 +52,8 @@ module Actions
53
52
 
54
53
  test "it remediates the host's spectre v2 status" do
55
54
  assert_equal :success, runned_action.state
56
- assert_equal true, runned_action.output.fetch('state')
57
- assert_equal true, runned_action.output.fetch('initially_powered_on')
55
+ assert runned_action.output.fetch('state')
56
+ assert runned_action.output.fetch('initially_powered_on')
58
57
  end
59
58
  end
60
59
  end
@@ -10,15 +10,14 @@ module Actions
10
10
  setup do
11
11
  ::Fog.mock!
12
12
  # this is not stubbed correctly in fog-vsphere
13
- ::ForemanWreckingball.fog_vsphere_namespace::Server.any_instance.stubs(:cpuHotAddEnabled).returns(false)
13
+ Fog::Vsphere::Compute::Server.any_instance.stubs(:cpuHotAddEnabled).returns(false)
14
14
  ::ForemanWreckingball::SpectreV2Status.any_instance.stubs(:recent_hw_version?).returns(true)
15
15
  ::PowerManager::Virt.any_instance.stubs(:ready?).returns(true)
16
- Setting::Wreckingball.load_defaults
17
16
  end
18
17
  teardown { ::Fog.unmock! }
19
18
 
20
19
  let(:compute_resource) do
21
- cr = FactoryBot.create(:compute_resource, :vmware, :with_taxonomy, :uuid => 'Solutions')
20
+ cr = FactoryBot.create(:compute_resource, :vmware, :with_taxonomy, uuid: 'Solutions')
22
21
  ComputeResource.find(cr.id)
23
22
  end
24
23
  let(:uuid) { '5032c8a5-9c5e-ba7a-3804-832a03e16381' }
@@ -27,7 +26,7 @@ module Actions
27
26
  let(:operatingsystem) do
28
27
  FactoryBot.create(
29
28
  :operatingsystem,
30
- architectures: [architectures(:x86_64)],
29
+ architectures: [architectures(:x86_64)], # rubocop:disable Naming/VariableNumber
31
30
  major: 6,
32
31
  minor: 1,
33
32
  type: 'Redhat',
@@ -40,12 +39,12 @@ module Actions
40
39
  :host,
41
40
  :managed,
42
41
  :with_vmware_facet,
43
- architecture: architectures(:x86_64),
42
+ architecture: architectures(:x86_64), # rubocop:disable Naming/VariableNumber
44
43
  operatingsystem: operatingsystem,
45
44
  compute_resource: compute_resource,
46
45
  uuid: uuid
47
46
  ).tap do |host|
48
- host.vmware_facet.update_attribute(:guest_id, 'asianux4_64Guest')
47
+ host.vmware_facet.update_attribute(:guest_id, 'asianux4_64Guest') # rubocop:disable Rails/SkipsModelValidations
49
48
  end
50
49
  end
51
50
 
@@ -55,7 +54,7 @@ module Actions
55
54
  action.stubs(:action_subject).returns(host)
56
55
  action.input.update(
57
56
  host: {
58
- id: host.id
57
+ id: host.id,
59
58
  }
60
59
  )
61
60
  end
@@ -69,8 +68,8 @@ module Actions
69
68
  assert_equal :success, runned_action.state
70
69
  assert_equal 'asianux4_64Guest', runned_action.output.fetch('old_operatingsystem_id')
71
70
  assert_equal 'rhel6_64Guest', runned_action.output.fetch('new_operatingsytem_id')
72
- assert_equal true, runned_action.output.fetch('state')
73
- assert_equal true, runned_action.output.fetch('initially_powered_on')
71
+ assert runned_action.output.fetch('state')
72
+ assert runned_action.output.fetch('initially_powered_on')
74
73
  assert_equal 'rhel6_64Guest', host.reload.vmware_facet.guest_id
75
74
  end
76
75
  end
@@ -27,7 +27,7 @@ module Actions
27
27
  action.stubs(:action_subject).returns(compute_resource)
28
28
  action.input.update(
29
29
  compute_resource: {
30
- id: compute_resource.id
30
+ id: compute_resource.id,
31
31
  }
32
32
  )
33
33
  end
@@ -41,7 +41,7 @@ module Actions
41
41
  test 'syncs a compute resource' do
42
42
  assert ::ForemanWreckingball::VmwareCluster.count.zero?
43
43
  assert_equal :success, runned_action.state
44
- refute ::ForemanWreckingball::VmwareCluster.count.zero?
44
+ assert_not ::ForemanWreckingball::VmwareCluster.count.zero?
45
45
  end
46
46
  end
47
47
  end
@@ -11,9 +11,9 @@ class ComputeResourcesControllerTest < ActionController::TestCase
11
11
  skip if Gem::Version.new(Foreman::Version.new.to_s) < Gem::Version.new('1.19.0')
12
12
  FactoryBot.create_list(:vmware_hypervisor_facet, 5, vmware_cluster: vmware_cluster)
13
13
 
14
- get :show, params: { :id => compute_resource.to_param }, session: set_session_user
14
+ get :show, params: { id: compute_resource.to_param }, session: set_session_user
15
15
  assert_response :success
16
- assert @response.body.match(/Hypervisors/)
16
+ assert_includes @response.body, 'Hypervisors'
17
17
  end
18
18
  end
19
19
  end
@@ -6,10 +6,6 @@ module ForemanWreckingball
6
6
  class HostsControllerTest < ActionController::TestCase
7
7
  let(:fake_task) { OpenStruct.new(id: 123) }
8
8
 
9
- setup do
10
- Setting::Wreckingball.load_defaults
11
- end
12
-
13
9
  describe '#status_dashboard' do
14
10
  context 'when there are no hosts with wreckingball statuses' do
15
11
  test 'shows an empty status page' do
@@ -47,8 +43,8 @@ module ForemanWreckingball
47
43
  let(:search) { "owner = current_user or (owner_type = Usergroup and owner_id = #{user.usergroups.first.id}) or hostgroup_id = #{hostgroup.id} or name ~ #{host_name_prefix}" }
48
44
  let(:filter) do
49
45
  FactoryBot.create(:filter,
50
- search: search,
51
- permissions: Permission.where(name: 'view_hosts'))
46
+ search: search,
47
+ permissions: Permission.where(name: 'view_hosts'))
52
48
  end
53
49
  let(:role) { FactoryBot.create(:role) }
54
50
  let(:user) { FactoryBot.create(:user, :with_mail, :with_usergroup, admin: false, roles: [role]) }
@@ -131,7 +127,7 @@ module ForemanWreckingball
131
127
 
132
128
  test 'should filter host with vm' do
133
129
  get :status_managed_hosts_dashboard, session: set_session_user
134
- refute_includes assigns[:missing_hosts], @managed_host
130
+ assert_not_includes assigns[:missing_hosts], @managed_host
135
131
  end
136
132
  end
137
133
 
@@ -140,8 +136,9 @@ module ForemanWreckingball
140
136
  FactoryBot.create_list(:vmware_hardware_version_status, 3, :with_ok_status)
141
137
  FactoryBot.create_list(:vmware_hardware_version_status, 4, :with_out_of_date_status)
142
138
 
143
- get :status_hosts, params: { status: ::ForemanWreckingball::HardwareVersionStatus.host_association },
144
- session: set_session_user, xhr: true
139
+ get :status_hosts,
140
+ params: { status: ::ForemanWreckingball::HardwareVersionStatus.host_association },
141
+ session: set_session_user, xhr: true
145
142
 
146
143
  assert_response :ok
147
144
  json = JSON.parse(response.body)
@@ -154,8 +151,9 @@ module ForemanWreckingball
154
151
  ok_status = FactoryBot.create(:vmware_hardware_version_status, :with_ok_status)
155
152
  out_of_date_status = FactoryBot.create(:vmware_hardware_version_status, :with_out_of_date_status)
156
153
 
157
- get :status_hosts, params: { status: ::ForemanWreckingball::HardwareVersionStatus.host_association },
158
- session: set_session_user, xhr: true
154
+ get :status_hosts,
155
+ params: { status: ::ForemanWreckingball::HardwareVersionStatus.host_association },
156
+ session: set_session_user, xhr: true
159
157
 
160
158
  assert_response :ok
161
159
 
@@ -164,15 +162,16 @@ module ForemanWreckingball
164
162
  hosts_names = data.map { |host| host['name'] }
165
163
  assert_equal 1, data.size
166
164
  assert_includes hosts_names, out_of_date_status.host.name
167
- refute_includes hosts_names, ok_status.host.name
165
+ assert_not_includes hosts_names, ok_status.host.name
168
166
  end
169
167
 
170
168
  test 'returns hosts for spectre v2 status' do
171
169
  FactoryBot.create_list(:vmware_spectre_v2_status, 1, :with_enabled)
172
170
  FactoryBot.create_list(:vmware_spectre_v2_status, 2, :with_missing)
173
171
 
174
- get :status_hosts, params: { status: ::ForemanWreckingball::SpectreV2Status.host_association },
175
- session: set_session_user, xhr: true
172
+ get :status_hosts,
173
+ params: { status: ::ForemanWreckingball::SpectreV2Status.host_association },
174
+ session: set_session_user, xhr: true
176
175
 
177
176
  data = JSON.parse(response.body)['data']
178
177
  assert_equal 2, data.size
@@ -187,14 +186,16 @@ module ForemanWreckingball
187
186
  end
188
187
 
189
188
  test 'should show all hosts' do
190
- get :status_hosts, params: { status: ::ForemanWreckingball::SpectreV2Status.host_association },
191
- session: set_session_user, xhr: true
189
+ get :status_hosts,
190
+ params: { status: ::ForemanWreckingball::SpectreV2Status.host_association },
191
+ session: set_session_user, xhr: true
192
192
  assert_equal 4, JSON.parse(response.body)['data'].count
193
193
  end
194
194
 
195
195
  test 'should show only owned hosts' do
196
- get :status_hosts, params: { status: ::ForemanWreckingball::SpectreV2Status.host_association, owned_only: true },
197
- session: set_session_user, xhr: true
196
+ get :status_hosts,
197
+ params: { status: ::ForemanWreckingball::SpectreV2Status.host_association, owned_only: true },
198
+ session: set_session_user, xhr: true
198
199
  assert_equal 2, JSON.parse(response.body)['data'].count
199
200
  end
200
201
  end
@@ -3,8 +3,8 @@
3
3
  FactoryBot.define do
4
4
  factory :vmware_facet, class: 'ForemanWreckingball::VmwareFacet' do
5
5
  vmware_cluster
6
- tools_state { 2 } #:toolsOk
7
- power_state { 1 } #:poweredOn
6
+ tools_state { 2 } # :toolsOk
7
+ power_state { 1 } # :poweredOn
8
8
  cpus { 2 }
9
9
  corespersocket { 1 }
10
10
  memory_mb { 8192 }
@@ -32,7 +32,7 @@ FactoryBot.define do
32
32
  'cpuid.NX',
33
33
  'cpuid.RDTSCP',
34
34
  'cpuid.LM',
35
- 'cpuid.Intel'
35
+ 'cpuid.Intel',
36
36
  ]
37
37
  end
38
38
  host
@@ -127,14 +127,14 @@ FactoryBot.define do
127
127
  'vpmc.numFixedCtrs',
128
128
  'vpmc.numGenCtrs',
129
129
  'vpmc.version',
130
- 'vt.realmode'
130
+ 'vt.realmode',
131
131
  ]
132
132
  end
133
133
  end
134
134
 
135
135
  factory :vmware_cluster, class: 'ForemanWreckingball::VmwareCluster' do
136
136
  sequence(:name) { |n| "Cluster #{n}" }
137
- association :compute_resource, factory: [:compute_resource, :vmware]
137
+ association :compute_resource, factory: %i[compute_resource vmware]
138
138
 
139
139
  trait(:with_hosts) do
140
140
  after(:create) do |vmware_cluster|
@@ -156,25 +156,25 @@ FactoryBot.define do
156
156
  end
157
157
 
158
158
  factory :vmware_tools_status, class: 'ForemanWreckingball::ToolsStatus' do
159
- association :host, factory: [:host, :with_vmware_facet]
159
+ association :host, factory: %i[host with_vmware_facet]
160
160
  reported_at { Time.now.utc }
161
161
  after(:build) { |status| status.status = status.to_status }
162
162
  end
163
163
 
164
164
  factory :vmware_operatingsystem_status, class: 'ForemanWreckingball::OperatingsystemStatus' do
165
- association :host, factory: [:host, :with_vmware_facet]
165
+ association :host, factory: %i[host with_vmware_facet]
166
166
  reported_at { Time.now.utc }
167
167
  after(:build) { |status| status.status = status.to_status }
168
168
  end
169
169
 
170
170
  factory :vmware_cpu_hot_add_status, class: 'ForemanWreckingball::CpuHotAddStatus' do
171
- association :host, factory: [:host, :with_vmware_facet]
171
+ association :host, factory: %i[host with_vmware_facet]
172
172
  reported_at { Time.now.utc }
173
173
  after(:build) { |status| status.status = status.to_status }
174
174
  end
175
175
 
176
176
  factory :vmware_spectre_v2_status, class: 'ForemanWreckingball::SpectreV2Status' do
177
- association :host, factory: [:host, :with_vmware_facet]
177
+ association :host, factory: %i[host with_vmware_facet]
178
178
  reported_at { Time.now.utc }
179
179
  after(:build) { |status| status.status = status.to_status }
180
180
 
@@ -188,7 +188,7 @@ FactoryBot.define do
188
188
  end
189
189
 
190
190
  factory :vmware_hardware_version_status, class: 'ForemanWreckingball::HardwareVersionStatus' do
191
- association :host, factory: [:host, :with_vmware_facet]
191
+ association :host, factory: %i[host with_vmware_facet]
192
192
  reported_at { Time.now.utc }
193
193
  after(:build) { |status| status.status = status.to_status }
194
194
 
@@ -3,10 +3,6 @@
3
3
  require 'integration_test_plugin_helper'
4
4
 
5
5
  class HostsStatusDashboardTest < ActionDispatch::IntegrationTest
6
- setup do
7
- Setting::Wreckingball.load_defaults
8
- end
9
-
10
6
  test 'shows different vmware host statuses' do
11
7
  FactoryBot.create_list(:host, 10)
12
8
  FactoryBot.create_list(:vmware_tools_status, 1)
@@ -4,7 +4,6 @@ require 'integration_test_plugin_helper'
4
4
 
5
5
  class HostsStatusManagedHostsTest < ActionDispatch::IntegrationTest
6
6
  setup do
7
- Setting::Wreckingball.load_defaults
8
7
  Fog.mock!
9
8
  end
10
9
 
@@ -33,7 +32,7 @@ class HostsStatusManagedHostsTest < ActionDispatch::IntegrationTest
33
32
 
34
33
  list = page.find('#missing_vms')
35
34
  assert_includes list.text, missing_host.name
36
- refute_includes list.text, managed_host.name
35
+ assert_not_includes list.text, managed_host.name
37
36
  end
38
37
 
39
38
  test 'shows hosts associated to wrong compute resource' do
@@ -62,7 +61,7 @@ class HostsStatusManagedHostsTest < ActionDispatch::IntegrationTest
62
61
  visit status_managed_hosts_dashboard_hosts_path
63
62
 
64
63
  list = page.find('#wrong_hosts')
65
- refute_includes list.text, correct_host.name
64
+ assert_not_includes list.text, correct_host.name
66
65
  assert_includes list.text, incorrect_host.name
67
66
  end
68
67
 
@@ -98,8 +97,8 @@ class HostsStatusManagedHostsTest < ActionDispatch::IntegrationTest
98
97
  visit status_managed_hosts_dashboard_hosts_path
99
98
 
100
99
  list = page.find('#more_than_one_hosts')
101
- refute_includes list.text, managed1_host.name
100
+ assert_not_includes list.text, managed1_host.name
102
101
  assert_includes list.text, managed2_host.name
103
- refute_includes list.text, managed3_host.name
102
+ assert_not_includes list.text, managed3_host.name
104
103
  end
105
104
  end
@@ -5,7 +5,7 @@ require 'test_plugin_helper'
5
5
  class VmwareTest < ActiveSupport::TestCase
6
6
  setup { Fog.mock! }
7
7
  teardown { Fog.unmock! }
8
- let(:compute_resource) { FactoryBot.build(:vmware_cr, :uuid => 'Solutions') }
8
+ let(:compute_resource) { FactoryBot.build(:vmware_cr, uuid: 'Solutions') }
9
9
 
10
10
  test '#hypervisors returns hosts by cluster' do
11
11
  hosts = compute_resource.hypervisors(cluster_id: 'Solutionscluster').map(&:name)
@@ -51,11 +51,11 @@ module ForemanWreckingball
51
51
  end
52
52
 
53
53
  test 'status is not relevant' do
54
- refute status.relevant?
54
+ assert_not status.relevant?
55
55
  end
56
56
 
57
57
  test 'no performance degration is indicated' do
58
- refute status.performance_degration?
58
+ assert_not status.performance_degration?
59
59
  end
60
60
  end
61
61
 
@@ -6,7 +6,6 @@ module ForemanWreckingball
6
6
  class HardwareVersionStatusTest < ActiveSupport::TestCase
7
7
  setup do
8
8
  User.current = users(:admin)
9
- Setting::Wreckingball.load_defaults
10
9
  end
11
10
 
12
11
  should belong_to(:host)
@@ -27,14 +26,14 @@ module ForemanWreckingball
27
26
 
28
27
  test '#relevant is only for hosts with a vmware facet' do
29
28
  h = FactoryBot.build(:host, :managed)
30
- refute ForemanWreckingball::ToolsStatus.new(host: h).relevant?
29
+ assert_not ForemanWreckingball::ToolsStatus.new(host: h).relevant?
31
30
  assert status.relevant?
32
31
  end
33
32
 
34
33
  test '#relevant is for hosts with a hardware version' do
35
34
  assert status.relevant?
36
35
  host.vmware_facet.hardware_version = nil
37
- refute status.relevant?
36
+ assert_not status.relevant?
38
37
  end
39
38
 
40
39
  describe 'status calculation' do
@@ -81,7 +80,7 @@ module ForemanWreckingball
81
80
 
82
81
  test 'is false when hw version is ancient' do
83
82
  status.host.vmware_facet.hardware_version = 'vmx-3'
84
- refute status.recent_hw_version?
83
+ assert_not status.recent_hw_version?
85
84
  end
86
85
  end
87
86
  end
@@ -13,7 +13,7 @@ module ForemanWreckingball
13
13
  let(:operatingsystem) do
14
14
  FactoryBot.create(
15
15
  :operatingsystem,
16
- architectures: [architectures(:x86_64)],
16
+ architectures: [architectures(:x86_64)], # rubocop:disable Naming/VariableNumber
17
17
  major: 6,
18
18
  minor: 1,
19
19
  type: 'Redhat',
@@ -25,7 +25,7 @@ module ForemanWreckingball
25
25
  :host,
26
26
  :managed,
27
27
  :with_vmware_facet,
28
- architecture: architectures(:x86_64),
28
+ architecture: architectures(:x86_64), # rubocop:disable Naming/VariableNumber
29
29
  operatingsystem: operatingsystem
30
30
  )
31
31
  end
@@ -38,7 +38,7 @@ module ForemanWreckingball
38
38
 
39
39
  test '#relevant is only for hosts with a vmware facet' do
40
40
  h = FactoryBot.build(:host, :managed)
41
- refute ForemanWreckingball::ToolsStatus.new(host: h).relevant?
41
+ assert_not ForemanWreckingball::ToolsStatus.new(host: h).relevant?
42
42
  assert status.relevant?
43
43
  end
44
44
 
@@ -81,12 +81,12 @@ module ForemanWreckingball
81
81
  describe '#os_matches_identifier?' do
82
82
  test 'when architecture does not match' do
83
83
  host.architecture = architectures(:sparc)
84
- refute status.os_matches_identifier?
84
+ assert_not status.os_matches_identifier?
85
85
  end
86
86
 
87
87
  test 'when operatingsystem does not match' do
88
88
  host.operatingsystem = operatingsystems(:ubuntu1210)
89
- refute status.os_matches_identifier?
89
+ assert_not status.os_matches_identifier?
90
90
  end
91
91
 
92
92
  test 'when architecture, osfamily, name and major match' do
@@ -26,14 +26,14 @@ module ForemanWreckingball
26
26
 
27
27
  test '#relevant is only for hosts with a vmware facet' do
28
28
  h = FactoryBot.build(:host, :managed)
29
- refute ForemanWreckingball::ToolsStatus.new(host: h).relevant?
29
+ assert_not ForemanWreckingball::ToolsStatus.new(host: h).relevant?
30
30
  assert status.relevant?
31
31
  end
32
32
 
33
33
  test '#relevant is for hosts with cpu features' do
34
34
  assert status.relevant?
35
35
  host.vmware_facet.cpu_features = []
36
- refute status.relevant?
36
+ assert_not status.relevant?
37
37
  end
38
38
 
39
39
  describe 'status calculation' do
@@ -84,14 +84,14 @@ module ForemanWreckingball
84
84
 
85
85
  test 'is false when hw version is ancient' do
86
86
  host.vmware_facet.hardware_version = 'vmx-3'
87
- refute status.recent_hw_version?
87
+ assert_not status.recent_hw_version?
88
88
  end
89
89
  end
90
90
 
91
91
  describe '#required_cpu_features_present?' do
92
92
  test 'is false when neither cpuid.IBRS, cpuid.IBPB nor cpuid.STIBP is present' do
93
93
  host.vmware_facet.cpu_features = ['cpuid.SSE42']
94
- refute status.required_cpu_features_present?
94
+ assert_not status.required_cpu_features_present?
95
95
  end
96
96
 
97
97
  test 'is true when cpuid.IBRS is present' do
@@ -23,12 +23,12 @@ module ForemanWreckingball
23
23
  assert status.relevant?
24
24
 
25
25
  host.build = true
26
- refute status.relevant?
26
+ assert_not status.relevant?
27
27
  end
28
28
 
29
29
  test '#relevant is only for hosts with a vmware facet' do
30
30
  h = FactoryBot.build(:host, :managed)
31
- refute ForemanWreckingball::ToolsStatus.new(host: h).relevant?
31
+ assert_not ForemanWreckingball::ToolsStatus.new(host: h).relevant?
32
32
  end
33
33
 
34
34
  describe 'status calculation' do