Fixes #38173 - Permit use of arrays for multiple timesources
I'm unclear how best to test this.
My site offers multiple on site NTP servers on different names depending on location. This permits them to bring hosts down for maintenance without significant interruption.
You can add the parameter to foreman/app/services/foreman/template_snapshot_service.rb
I'm not seeing where this has an existing test for when it is of type String. I'd expect for coverage and sanity it should check both String and Array types to make sure each kind works as expected.
Testwise, I'm not sure switching to is_a(String) seems to be on the safemode list?
I'm unclear how best to test this.
In https://github.com/theforeman/foreman/pull/10605#pullrequestreview-3009592626 I described where we provide parameters. Then it runs through the snapshots and is validated.
In that PR I already felt the need for a "plain" (all defaults) host and then introduce another host with non-default values. Perhaps that's something you could look at, given how this code is non-trivial.
For this specific case I'd be tempted to not store the full snapshot but have a dedicated test with asserts. https://github.com/theforeman/foreman/commit/d7e1c39909cf365dcddf3b8ffff7b2c15c88377a can be another inspiration for that. You can see that in test/unit/foreman/templates we already have some template testing infrastructure.
I've tried to add in test conditions. Per my usual behavior, RAILS_ENV=test bundle exec rails snapshots:generate provides a series of errors that make no sense to me.
RAILS_ENV=test bundle exec rails snapshots:generate
rails aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "settings" does not exist
LINE 1: SELECT "settings".* FROM "settings"
^
/data/app/registries/setting_registry.rb:183:in `load_values'
/data/app/registries/setting_registry.rb:161:in `load'
/data/lib/tasks/snapshots.rake:34:in `block (3 levels) in <main>'
/data/lib/tasks/snapshots.rake:33:in `block (2 levels) in <main>'
/data/bin/rails:9:in `<top (required)>'
/data/bin/spring:12:in `require'
/data/bin/spring:12:in `<top (required)>'
Caused by:
PG::UndefinedTable: ERROR: relation "settings" does not exist
LINE 1: SELECT "settings".* FROM "settings"
^
/data/app/registries/setting_registry.rb:183:in `load_values'
/data/app/registries/setting_registry.rb:161:in `load'
/data/lib/tasks/snapshots.rake:34:in `block (3 levels) in <main>'
/data/lib/tasks/snapshots.rake:33:in `block (2 levels) in <main>'
/data/bin/rails:9:in `<top (required)>'
/data/bin/spring:12:in `require'
/data/bin/spring:12:in `<top (required)>'
Tasks: TOP => snapshots:generate
(See full trace by running task with --trace)
db:create and db:migrate are similarly erroring out.
Patch rebased.
The only one of these I actually use is anaconda.
I've attempted the other installer tweaks based on their online documentation.
The template generation is producing an error on the ntp-server parameter test I added to RHEL. I have no idea how to fix that...
I've tried to fix the testing again...
Merged suggested change, squashed, and rebased off develop.
I'll rework the other if blocks.
I'm unsure if I've got something overall rational for junos since there is the server and boot-server bits and I've no experience with that product.
hmmm
Safemode doesn't allow to access 'constant' on Array
Oh that's annoying. Perhaps you can fake it and use host_param().respond_to?(:join) to determine if it's an array.
Took a stab at fixing with the check for join.
I am staring at the error and not seeing I've done wrongly in the CI...