You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spec/unit/puppet/provider/dsc_base_provider/dsc_base_provider_spec.rb
+38Lines changed: 38 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -794,6 +794,44 @@
794
794
end
795
795
end
796
796
797
+
context'when the invocation script errors with a collision'do
798
+
it'writes a notice via context and applies successfully on retry'do
799
+
expect(ps_manager).toreceive(:execute).and_return({stdout: '{"errormessage": "The Invoke-DscResource cmdlet is in progress and must return before Invoke-DscResource can be invoked"}'})
800
+
expect(context).toreceive(:notice).with(/Invoke-DscResource collision detected: Please stagger the timing of your Puppet runs as this can lead to unexpected behaviour./).once
801
+
expect(context).toreceive(:notice).with('Sleeping for 60 seconds.').twice
802
+
expect(context).toreceive(:notice).with(/Retrying: attempt [1-2] of 5/).twice
803
+
expect(ps_manager).toreceive(:execute).and_return({stdout: '{"errormessage": "The Invoke-DscResource cmdlet is in progress and must return before Invoke-DscResource can be invoked"}'})
804
+
expect(context).toreceive(:notice).with('Attempt 1 of 5 failed.')
it'writes a error via context and fails to apply when all retry attempts used'do
811
+
expect(ps_manager).toreceive(:execute).and_return({stdout: '{"errormessage": "The Invoke-DscResource cmdlet is in progress and must return before Invoke-DscResource can be invoked"}'})
812
+
.exactly(5).times
813
+
expect(context).toreceive(:notice).with(/Invoke-DscResource collision detected: Please stagger the timing of your Puppet runs as this can lead to unexpected behaviour./).once
814
+
expect(context).toreceive(:notice).with('Sleeping for 60 seconds.').exactly(5).times
815
+
expect(context).toreceive(:notice).with(/Retrying: attempt [1-6] of 5/).exactly(5).times
816
+
expect(ps_manager).toreceive(:execute).and_return({stdout: '{"errormessage": "The Invoke-DscResource cmdlet is in progress and must return before Invoke-DscResource can be invoked"}'})
817
+
expect(context).toreceive(:notice).with(/Attempt [1-6] of 5 failed/).exactly(5).times
818
+
expect(context).toreceive(:err).with(/The Invoke-DscResource cmdlet is in progress and must return before Invoke-DscResource can be invoked/)
819
+
allow(provider).toreceive(:sleep)
820
+
expect(result).tobe_nil
821
+
end
822
+
823
+
it'writes an error via context and fails to apply when encountering an unexpected error'do
824
+
expect(ps_manager).toreceive(:execute).and_return({stdout: '{"errormessage": "The Invoke-DscResource cmdlet is in progress and must return before Invoke-DscResource can be invoked"}'})
825
+
expect(context).toreceive(:notice).with(/Invoke-DscResource collision detected: Please stagger the timing of your Puppet runs as this can lead to unexpected behaviour./).once
826
+
expect(context).toreceive(:notice).with('Sleeping for 60 seconds.').once
827
+
expect(context).toreceive(:notice).with(/Retrying: attempt 1 of 5/).once
0 commit comments