Skip to content
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

Expose multi-CV feature downstream #85

Conversation

jeremylenz
Copy link
Contributor

This removes allow_multiple_content_views from UpstreamOnlySettings, allowing it to be exposed downstream.

I didn't remove the UpstreamOnlySettings feature entirely, because I thought it might be handy to have in the future? thoughts welcome.

@evgeni
Copy link
Member

evgeni commented Sep 28, 2024

Stubbing constants is weird (in Ruby?). You'd need stub_const from either rspec-mocks or minitest-stub-const for that, I think.

@jeremylenz
Copy link
Contributor Author

Originally I was just setting them in the test, but that felt weird too. What's the non-weird way?

@ShimShtein
Copy link
Contributor

I think it would be better to redesign the UpstreamOnlySettings module to be a proper class:

class UpstreamOnlySettings
  def self.include?(key)
    new.include?
  def include?(key)
    SETTINGS.include?(key.to_s)
  end
end

Then it would be easier to stub the class:

UpstreamOnlySettings.any_instance.stubs(:include?).returns(false)

@jeremylenz jeremylenz force-pushed the multi-cv-feature-flag-activate branch from 0ed46ea to d029292 Compare September 30, 2024 17:06
@jeremylenz
Copy link
Contributor Author

@ShimShtein good idea! updated.

I'm relying on CI to see if my tests are good, looks like someone needs to click a button for me

@jeremylenz
Copy link
Contributor Author

@ShimShtein how's it looking now?

@jeremylenz jeremylenz force-pushed the multi-cv-feature-flag-activate branch from 4176408 to 83df9a5 Compare October 7, 2024 20:09
@jeremylenz
Copy link
Contributor Author

guess I was trying to be a Pythonista...

updated

@jeremylenz jeremylenz force-pushed the multi-cv-feature-flag-activate branch from 83df9a5 to 5a0e475 Compare October 7, 2024 20:13
@ShimShtein
Copy link
Contributor

LGTM. Let's wait for the tests

@jeremylenz
Copy link
Contributor Author

I can't run tests locally, I am getting errors like

ERROR:  relation "permissions" does not exist (PG::UndefinedTable)
LINE 8:  WHERE a.attrelid = '"permissions"'::regclass

I'm guessing it's Zeitwerk-related somehow?...

@jeremylenz
Copy link
Contributor Author

@ShimShtein
Copy link
Contributor

@jeremylenz Currently I see only unmet expectations failures in the report: https://github.com/RedHatSatellite/foreman_theme_satellite/actions/runs/11223216416/job/31283723243?pr=85#step:21:36

Do you see something else?

@jeremylenz
Copy link
Contributor Author

that's what I see too.

@jeremylenz jeremylenz force-pushed the multi-cv-feature-flag-activate branch from 5a0e475 to 82e750c Compare October 28, 2024 17:01
@jeremylenz
Copy link
Contributor Author

I was finally able to update my dev box and see why the tests were failing. Should be passing now.

@jeremylenz jeremylenz requested a review from ShimShtein November 1, 2024 15:10
@jeremylenz
Copy link
Contributor Author

🍏

Comment on lines +30 to +44
UpstreamOnlySettings.expects(:include?).with('test_setting').returns(true)
assert_nil Setting['test_setting']
Copy link
Member

Choose a reason for hiding this comment

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

You never add test_setting to UpstreamOnlySettings::SETTINGS, so this test is not testing what it says to be testing.
Wouldn't you need to first declare that setting with a default value, then add it to UpstreamOnlySettings and then assert the result is nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't

UpstreamOnlySettings::SETTINGS << 'test_setting'

due to

FrozenError: can't modify frozen Array: []

But I did add the setting definition in the test.
(and did confirm it does fail when I comment out the

UpstreamOnlySettings.expects(:include?).with('test_setting').returns(true)

)

does that look okay?

@jeremylenz jeremylenz force-pushed the multi-cv-feature-flag-activate branch from 82e750c to 1e34872 Compare November 4, 2024 15:15
@jeremylenz
Copy link
Contributor Author

Side note: I went thru some confusing test failures because Minitest is retrying the test. The retries aren't the actual failure:

[MinitestRetry] retry 'test_0002_hides upstream-only settings' count: 1,  msg: FrozenError: can't modify frozen Array: []
    /home/vagrant/foreman_theme_satellite/test/unit/setting_registry_branding_test.rb:42:in `block (2 levels) in <class:SettingRegistryBrandingTest>'
[MinitestRetry] retry 'test_0002_hides upstream-only settings' count: 2,  msg: Foreman::Exception: ERF42-8739 [Foreman::Exception]: Setting 'test_setting' is already defined, please avoid collisions

I can't find where the retries are configured 🤔

@jeremylenz jeremylenz force-pushed the multi-cv-feature-flag-activate branch from 1e34872 to e6a3ee5 Compare November 4, 2024 15:30
@jeremylenz
Copy link
Contributor Author

@evgeni how's it look now?

Setting['allow_multiple_content_views']
UpstreamOnlySettings.expects(:include?).with('test_setting').returns(true)
Rails.logger.expects(:debug).with('Setting \'test_setting\' is not available in Satellite; ignoring')
Setting['test_setting']
Copy link
Contributor

Choose a reason for hiding this comment

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

You are not defining the test_setting in settings here. Are you relying on the test execution order?

Also not related to this specific PR: why do we have two classes in a single file? Can we separate them please?

Copy link
Member

Choose a reason for hiding this comment

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

I think this relies on the fact that Setting[something] always queries the Settings registry and triggers the warning code, even if the setting is not actually defined. (The test worked also before the setting definition in the previous test that I asked for)

@ShimShtein ShimShtein merged commit d37ea62 into RedHatSatellite:develop Nov 7, 2024
21 checks passed
@ShimShtein
Copy link
Contributor

Merged. Thanks @jeremylenz !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants