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

DRAFT: #33446 with alternate test style #229

Closed
wants to merge 2 commits into from

Conversation

wbclark
Copy link
Collaborator

@wbclark wbclark commented Sep 29, 2021

Continuing work from #227

This change implements the WORKER_TTL setting which lets Pulp decide
how long to wait for a worker to respond before considering it gone
and cleaning up it's database and re-assiging work.
@wbclark wbclark changed the title Wclark 33446 updated Fixes #33446 - Allow configuring pulpcore worker timeout Sep 29, 2021
@wbclark
Copy link
Collaborator Author

wbclark commented Sep 29, 2021

NOTE: I updated the parameter documentation to be clearer for users, and also tried a new style for the tests which should make it easier for developers to interpret test output.

@wbclark wbclark force-pushed the wclark-33446-updated branch from e05de29 to 9c7c41e Compare September 29, 2021 23:31
its(:stdout) { is_expected.to match(/^USE_NEW_WORKER_TYPE = True/) }
its(:exit_status) { is_expected.to eq 0 }
describe "Pulpcore Settings" do
let(:settings) { command("PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager diffsettings") }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As written, this works and should give a more descriptive output in the case of test failures (I will break a test shortly to confirm).

That said, I want to make sure really I understand correctly how this behaves -- would the block argument here get evaluated in the let block, or does it later get evaluated three times when calling settings.exit_status, settings.stdout, etc, causing inefficient code execution?

What I'm trying to do may or may not still be possible with describe command("PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager diffsettings") do instead. I am not sure if its(:stdout) "will a string work here?" do would function as I intend it do.

From looking at a lot of rspec examples, expect(...) seems to be preferred to it { is_expected.to ... } which is why I decided to try this. That said, maybe it is proper rspec style in general but not right for serverspec specifically.

Copy link
Member

Choose a reason for hiding this comment

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

I like the new grouping of things, and I think let should be evaluated once.

As for expect vs is_expected.to -- we use the later everywhere, so I'd prefer to keep that for consistency (and if change, change globally).

Copy link
Member

Choose a reason for hiding this comment

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

What you can do is:

describe 'Pulpcore settings' do
  subject { command("PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager diffsettings") }

  its(:exit_status) { is_expected.to eq 0 }
end

This is effectively the same as what was there before.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I recall trying something like this in the past which failed:

describe "Pulpcore settings" do
  subject { command("PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager diffsettings") }

  its(:exit_status) "exits without error" { is_expected.to eq 0 }
end

I will try again to confirm

Copy link
Collaborator Author

@wbclark wbclark Oct 4, 2021

Choose a reason for hiding this comment

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

The issue was

Failure/Error: __send__(method, file)

SyntaxError:
  /home/wclark/Projects/puppet-pulpcore/spec/acceptance/basic_spec.rb:80: syntax error, unexpected string literal, expecting `end'
      its(:exit_status) "retrieves pulpcore settings" ...

So it accepts an optional string argument before the block argument, but its(:symbol) can receive only the block.

Copy link
Collaborator Author

@wbclark wbclark left a comment

Choose a reason for hiding this comment

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

Thinking about this some more, what I really want to do is deliver a version of this PR which delivers the feature as needed, adhering to the current test style though it may be flawed.

I thought the tests would work in this style, and indeed they do, but I'm simply not confident enough yet with it to rule out drawbacks.

Therefore I will rename this PR and mark it as a draft, and shortly open another version that delivers the same functionality with the current style tests.

@wbclark wbclark marked this pull request as draft September 30, 2021 06:19
@wbclark wbclark changed the title Fixes #33446 - Allow configuring pulpcore worker timeout DRAFT: #33446 with alternate test style Sep 30, 2021
@wbclark
Copy link
Collaborator Author

wbclark commented Sep 30, 2021

OK, the real version of this is #230

Comment on lines +136 to +137
# The number of seconds before a pulpcore worker should be considered lost. If undefined, pulpcore will use its default setting which is 30 seconds as of
# pulpcore version 3.14. You should not need to modify this setting unless the application reports workers timing out while they are busy completing tasks.
Copy link
Member

Choose a reason for hiding this comment

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

Reading "You should not need to modify this setting unless the application reports workers timing out while they are busy completing tasks." one could think "Yeah, let's set it to 9000 then!", which is also not what we want the users to do.

For worker_count we say " Modifying this parameter should be done incrementally with benchmarking at each step to determine an optimal value for your deployment.", should something similar be added here?

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.

I still think this direction is wrong. We should not try to document what the value is but rather how to find out what the default is. Remember that this module is not exposed to the user directly so I don't see the value. In my experience it only brings work in trying to keep two values in sync.

If documentation is an issue, we should take it up with upstream. For example, we could investigate deploying a man page for the pulp settings, generated in packaging so it's guaranteed to be in sync.

@ehelms
Copy link
Member

ehelms commented Oct 11, 2021

Does this need a rebase just for the testing part or to be closed @wbclark ?

@wbclark
Copy link
Collaborator Author

wbclark commented Oct 11, 2021

Closing for now, I couldn't make the tests work quite how I wanted them to while adhering to the established style of the project.

@wbclark wbclark closed this Oct 11, 2021
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.

5 participants