Skip to content

Conversation

@sbernhard
Copy link
Contributor

No description provided.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you open a Redmine issue for this?

I'd also love to have some CI on GHA that uses a Windows runner to test if it works, but lack the specific knowledge (and time). Do you have any idea how hard that would be?

@sbernhard sbernhard changed the title Use syslog gem not in windows Fixes #38909 - Use syslog gem not in windows Nov 17, 2025
@sbernhard sbernhard force-pushed the syslog_not_for_win branch 16 times, most recently from 1b37d01 to 6f459ce Compare November 17, 2025 20:34
@sbernhard sbernhard force-pushed the syslog_not_for_win branch 4 times, most recently from 0acc281 to cf25385 Compare November 17, 2025 21:05
@maximiliankolb
Copy link

maximiliankolb commented Nov 26, 2025

@sbernhard Please create a Redmine issue & have a look at the failing tests. Please ping Ewoud after GHA are 🍏 for a final ACK.

edit: apologies; Redmine issue is open but GHA still fails. There must be another reason for that.

@sbernhard
Copy link
Contributor Author

@sbernhard Please create a Redmine issue & have a look at the failing tests. Please ping Ewoud after GHA are 🍏 for a final ACK.

edit: apologies; Redmine issue is open but GHA still fails. There must be another reason for that.

everything done.

@ekohl
Copy link
Member

ekohl commented Dec 28, 2025

@sbernhard the Redmine check is still failing: the commit must reference the issue.

@sbernhard
Copy link
Contributor Author

Fixed it. Thanks @ekohl

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at ruby/syslog@ffbfaa6 I wonder if it's really needed. I'd expect the gem (>= 0.2.0) to install on Windows and be a noop.

@sbernhard sbernhard force-pushed the syslog_not_for_win branch 2 times, most recently from 2aff80f to 91d8af2 Compare January 5, 2026 16:37
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By now this really evolved into just testing on Windows, which is still a good thing. Do you have any idea what is needed to actually make the tests work?

@ekohl
Copy link
Member

ekohl commented Jan 6, 2026

C:/hostedtoolcache/windows/Ruby/3.3.10/x64/lib/ruby/3.3.0/bundled_gems.rb:69:in `require': cannot load such file -- libvirt (LoadError)

I think this (and the krb5) related tests should be skipped. The modules themselves (both dns_libvirt and dhcp_libvirt) both correctly guard behind load_classes so it should be possible.

The biggest risk I see is that we silently disable the tests without knowing it, but I'm sure we can find a way around that.

@sbernhard
Copy link
Contributor Author

I think this (and the krb5) related tests should be skipped. The modules themselves (both dns_libvirt and dhcp_libvirt) both correctly guard behind load_classes so it should be possible.

I don't know how to skip the tests for these plugins. Can you please let me know more what you mean regarding load_classes??

@ekohl
Copy link
Member

ekohl commented Jan 12, 2026

Can you please let me know more what you mean regarding load_classes??

In normal operation the Smart Proxy loads things in some order:

The main file is interesting because it loads all the plugins that are built in, but there's also the smart_proxy_for_testing which does NOT do that. I'll admit the exact details here are not entirely clear to me since it's been a while. I think for plugins from gems we rely on Bundler to include them, but load order is a bit vague.

However, those plugins are only the plugin definitions. Taking DNS as an example: dns/dns only loads dns/configuration_loader and dns/dns_plugin. Zooming in on Proxy::Dns::ConfigurationLoader we see it defines the load_classes method which loads the real implementation.

It's in the Proxy::PluginInitializer that actually really initializes the plugin. This is not a trivial class because it uses dependency injection, but I still think it makes a lot of sense. It's initialize_plugins that does a bunch of steps that eventually calls load_classes.

It allows for loading plugin definitions but having the plugin itself disabled via configuration. This is more efficient (less memory used) but can also help if the actual implementation is unavailable (like Kerberos or libvirt bindings that aren't installed.

But in the end this is all what runtime does. Testing is different: it loads many things unconditionally. Taking the failing libvirt test: the test library loads test/**/*_test.rb which in turn loads [test/dhcp_libvirt/libvirt_dhcp_network_test.rb]https://github.com/theforeman/smart-proxy/blob/develop/test/dhcp_libvirt/libvirt_dhcp_network_test.rb) which has this line:

require 'dhcp_libvirt/libvirt_dhcp_network'

At runtime this class is only loaded if it's really needed:
def load_classes
require 'dhcp_libvirt/libvirt_dhcp_network'

That part is really loading the libvirt bindings:

require 'libvirt'
require 'libvirt_common/libvirt_network'

This is all a long intro into the loading mechanism. The real challenge is to modify the test suite so that it:

  • Will test libvirt bindings if available
  • Skip tests if bindings are unavailable
  • Not accidentally skip the tests unconditionally

I don't have a good answer on that right now.

My had a thought about looking at which bundler groups were available. I couldn't find a good API for that, but didn't dig very deep. You can probably be blunt and use:

begin
  Bundler.require(:libvirt)
rescue LoadError # or whatever it throws
  LIBVIRT_BUNDLER_GROUP_AVAILABLE = false
else
  LIBVIRT_BUNDLER_GROUP_AVAILABLE = true
  require 'dhcp_libvirt/libvirt_dhcp_network'
end

Then based on https://test-unit.github.io/test-unit/en/Test/Unit/TestCaseOmissionSupport.html I'd try enhancing each test_ method with:

def test_dump_xml
  omit_unless(LIBVIRT_BUNDLER_GROUP_AVAILABLE) do
    a_xml = '<xml></xml>'
    @network.expects(:xml_desc).returns(a_xml)
    assert_equal a_xml, @subject.dump_xml
  end
end

And perhaps there's a nicer way. https://test-unit.github.io/test-unit/en/Test/Unit/TestCase.html may be helpful in seeing if that's an option.

Looking at that particular setup I see that also refers to ::Libvirt so that will also fail. So I'd also see if the following works:

class LibvirtDHCPNetworkTest < Test::Unit::TestCase
  def setup
    omit_unless(LIBVIRT_BUNDLER_GROUP_AVAILABLE)

    # rest of the existing code here
  end
end

Perhaps I'm also thinking too complex and perhaps Test::Unit already has something built in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants