New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #22933 - fix functional test case for reboot all hosts #413
Conversation
Issues: #22933 |
I still see 8 failures here. FYI you need to remove this line because of this change in core: theforeman/foreman#5318 diff --git a/test/integration/discovered_hosts_test.rb b/test/integration/discovered_hosts_test.rb
index edcf4f7..0e47e50 100644
--- a/test/integration/discovered_hosts_test.rb
+++ b/test/integration/discovered_hosts_test.rb
@@ -5,8 +5,6 @@ class DiscoveredHostsTest < IntegrationTestWithJavascript
let(:discovered_host) { FactoryBot.create(:discovered_host, :with_facts) }
let(:discovered_hosts) { Host::Discovered.all }
- extend Minitest::OptionalRetry
-
setup do
assert discovered_notification_blueprint
discovered_host.save! |
Here is what I see locally atm:
|
562b508
to
6b0327e
Compare
test/unit/host_discovered_test.rb
Outdated
@@ -155,7 +155,7 @@ class HostDiscoveredTest < ActiveSupport::TestCase | |||
test "should refresh existing discovered" do | |||
interface = mock() | |||
interface.stubs(:host).returns(Host.create(:name => "xyz", :type => "Host::Discovered")) | |||
::Nic::Managed.stubs(:where).with(:mac => @facts['discovery_bootif'].downcase, :primary => true).returns([interface]) | |||
::Nic::Managed.stubs(:where).with(:mac => @facts['discovery_bootif'].downcase, :primary => true).returns([interface]).never | |||
host = discover_host_from_facts(@facts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lzap not sure if this helps, can you please look into this?
@mmoll thanks is there a trick to trigger them other than manually via Jenkins Web UI ? :-D @rahulbajaj0509 still failing lemme look |
@rahulbajaj0509 ok so the problem is that the test is clunky, no idea why it regressed but here is better version of doing the same - we want to basically make sure that if there is an existing discovered host, new one is not created. Here is new version much better, also tests NIC and fact: diff --git a/test/unit/host_discovered_test.rb b/test/unit/host_discovered_test.rb
index 5597fe9..89bad06 100644
--- a/test/unit/host_discovered_test.rb
+++ b/test/unit/host_discovered_test.rb
@@ -152,12 +152,20 @@ class HostDiscoveredTest < ActiveSupport::TestCase
assert_equal 'e41f13cc3658',host.name
end
- test "should refresh existing discovered" do
- interface = mock()
- interface.stubs(:host).returns(Host.create(:name => "xyz", :type => "Host::Discovered"))
- ::Nic::Managed.stubs(:where).with(:mac => @facts['discovery_bootif'].downcase, :primary => true).returns([interface]).never
- host = discover_host_from_facts(@facts)
- assert_equal 'xyz', host.name
+ test "should refresh facts and NICs of an existing discovered host" do
+ host1 = discover_host_from_facts(@facts)
+ assert_equal 'mace41f13cc3658', host1.name
+ assert_equal 'IBM System x -[7870K4G]-', host1.facts["productname"]
+ assert_equal 1, Host::Discovered.where(:name => 'mace41f13cc3658').count
+ assert_equal '10.35.27.3', host1.ip
+
+ @facts["ipaddress_eth0"] = "1.2.3.4"
+ @facts["productname"] = "Dishwasher DW400"
+ host2 = discover_host_from_facts(@facts)
+ assert_equal 'mace41f13cc3658', host2.name
+ assert_equal 'Dishwasher DW400', host2.facts["productname"]
+ assert_equal '1.2.3.4', host2.ip
+ assert_equal 1, Host::Discovered.where(:name => 'mace41f13cc3658').count
end
test "should raise when hostname fact cannot be found" do For easy copypaste here it is:
Ping me after you rebase so I can quickly test and merge! Thanks. |
6b0327e
to
705761d
Compare
Merged, all green locally! |
No description provided.