-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add an apply matcher #115
base: master
Are you sure you want to change the base?
Add an apply matcher #115
Conversation
@trevor-vaughan I'd like to get your opinion on this since AFAIK you're a significant user of Beaker. My goal with this was to provide proper debugging of failures. By using a matcher it shouldn't show a track trace anymore (which is kind of pointless anyway) but instead the actual output. Also where it failed. I also wanted a hook to show more output, but I think the |
This is an interesting idea.
I'll take a look as soon as I can.
…On Fri, Oct 28, 2022 at 7:52 AM Ewoud Kohl van Wijngaarden < ***@***.***> wrote:
@trevor-vaughan <https://github.com/trevor-vaughan> I'd like to get your
opinion on this since AFAIK you're a significant user of Beaker.
My goal with this was to provide proper debugging of failures. By using a
matcher it shouldn't show a track trace anymore (which is kind of pointless
anyway) but instead the actual output. Also where it failed.
I also wanted a hook to show more output, but I think the failure_context
may be a bit too well hidden. Not sure what a good way is.
—
Reply to this email directly, view it on GitHub
<#115 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABGAOSJSJJRD73ZH7TXNEETWFO5BFANCNFSM6AAAAAAROLBAFA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
** ⬆⬇⬆⬇⬅➡⬅➡BA **
|
70c362a
to
e6be805
Compare
This allows users to specify code as: describe 'motd class' do subject { 'include motd' } # Just run it once it { is_expected.to apply } # The same, but run it twice it { is_expected.to apply.idempotently } end This gives the full output of puppet apply, rather than just the last 10 lines. It also tells the user if it failed on the first or second run. Additionally, users can define a failure_context method to run an additional command and output it. The main motivation for this is when puppet apply doesn't provide any useful output on the failure. For example, when a service fails to start Puppet does provide the journal output, but sometimes it only logs errors to its own files (looking at you Apache). This command is only executed if the Puppet run failed to apply. describe 'motd class' do subject { 'include motd' } def failure_context 'cat /etc/motd' end it { is_expected.to apply.idempotently } end
e6be805
to
e298601
Compare
Tests now fail because Puppet is not installed. I'll deal with that later. It at least shows how it should be used now. |
@ekohl Took a deeper look at how we're using things and here's my feedback:
let(:manifest) { whatever }
let(:hieradata) {{ whatever }}
hosts.each do |host|
it 'should apply' do
set_hieradata_on(host, hieradata)
apply_manifest_on(host, manifest)
end
it 'should be idempotent' do
apply_manifest_on(host, manifest, catch_changes: true)
end
end |
I like this concept. I vote for putting an experimental warning on it and shipping it to get some real world usage. |
This allows users to specify code as:
This gives the full output of puppet apply, rather than just the last 10 lines. It also tells the user if it failed on the first or second run.
Additionally, users can define a
failure_context
method to run an additional command and output it. The main motivation for this is when puppet apply doesn't provide any useful output on the failure. For example, when a service fails to start Puppet does provide the journal output, but sometimes it only logs errors to its own files (looking at you Apache). This command is only executed if the Puppet run failed to apply.I'm submitting this for feedback now. I have some additional work with example groups so you can make it even easier.