Sha256: 4e1282fc14f34c3fcd9c0278533f6738f4a10b3ace42ee978d969dfef1280320

Contents?: true

Size: 1.83 KB

Versions: 68

Compression:

Stored size: 1.83 KB

Contents

require 'test_plugin_helper'
require 'foreman_tasks/test_helpers'

class InsightsClientStatusAgingTest < ActiveSupport::TestCase
  include ForemanTasks::TestHelpers::WithInThreadExecutor

  setup do
    User.current = User.find_by(login: 'secret_admin')

    @host1 = FactoryBot.create(:host)
    @host2 = FactoryBot.create(:host)
    @host3 = FactoryBot.create(:host)
    @host4 = FactoryBot.create(:host)

    @hosts = [@host1, @host2, @host3, @host4]
  end

  test 'stale statuses should change' do
    InsightsClientReportStatus.find_or_initialize_by(host_id: @host1.id).update(status: InsightsClientReportStatus::REPORTING, reported_at: Time.now - InsightsClientReportStatus::REPORT_INTERVAL + 1.day)
    InsightsClientReportStatus.find_or_initialize_by(host_id: @host2.id).update(status: InsightsClientReportStatus::NO_REPORT, reported_at: Time.now - InsightsClientReportStatus::REPORT_INTERVAL + 1.day)
    InsightsClientReportStatus.find_or_initialize_by(host_id: @host3.id).update(status: InsightsClientReportStatus::REPORTING, reported_at: Time.now - InsightsClientReportStatus::REPORT_INTERVAL - 1.day)
    InsightsClientReportStatus.find_or_initialize_by(host_id: @host4.id).update(status: InsightsClientReportStatus::NO_REPORT, reported_at: Time.now - InsightsClientReportStatus::REPORT_INTERVAL - 1.day)

    ForemanTasks.sync_task(InsightsCloud::Async::InsightsClientStatusAging)

    @hosts.each(&:reload)

    assert_equal InsightsClientReportStatus::REPORTING, @host1.get_status(InsightsClientReportStatus).status
    assert_equal InsightsClientReportStatus::NO_REPORT, @host2.get_status(InsightsClientReportStatus).status
    assert_equal InsightsClientReportStatus::NO_REPORT, @host3.get_status(InsightsClientReportStatus).status
    assert_equal InsightsClientReportStatus::NO_REPORT, @host4.get_status(InsightsClientReportStatus).status
  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
foreman_rh_cloud-8.0.49 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-8.0.48 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-8.0.47 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-8.0.46 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-6.0.45 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-5.0.46 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-5.0.45 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-7.0.46 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-5.0.44 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-7.0.45 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-6.0.44 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-5.0.43 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-4.0.36 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-3.0.33 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-6.0.42.2 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-6.0.42.1 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-6.0.43 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-5.0.42 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-6.0.42 test/jobs/insights_client_status_aging_test.rb
foreman_rh_cloud-5.0.41 test/jobs/insights_client_status_aging_test.rb