CHEF-3833 Added delay for InSpec parallel status reporter (#6993)

* Added delay in status reporter for inspec-parallel for clear reporting

Signed-off-by: Nik08 <nikita.mathur@progress.com>

* Made chef-licensing warning silent between parallel runs

Signed-off-by: Nik08 <nikita.mathur@progress.com>

* Code review changes for setting output config

Signed-off-by: Nik08 <nikita.mathur@progress.com>

* As a safe measure added logic to reset output stream

Signed-off-by: Nik08 <nikita.mathur@progress.com>

---------

Signed-off-by: Nik08 <nikita.mathur@progress.com>
This commit is contained in:
Nikita Mathur 2024-05-08 18:56:53 +05:30 committed by GitHub
parent 9ab6a463d0
commit c83733bf9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View file

@ -22,7 +22,10 @@ module InspecPlugins
def run
initiate_background_run if run_in_background # running a process as daemon changes parent process pid
original_stdout_stream = ChefLicensing::Config.output
until invocations.empty? && @child_tracker.empty?
# Changing output to STDERR to avoid the output interruption between runs
ChefLicensing::Config.output = STDERR
while should_start_more_jobs?
if Inspec.locally_windows?
spawn_another_process
@ -35,6 +38,8 @@ module InspecPlugins
cleanup_child_processes
sleep 0.1
end
# Reset output to the original STDOUT stream as a safe measure.
ChefLicensing::Config.output = original_stdout_stream
# Requires renaming operations on windows only
# Do Rename and delete operations after all child processes have exited successfully

View file

@ -44,6 +44,7 @@ module InspecPlugins::Parallelism
status_by_pid[pid][:last_control] = title
status_by_pid[pid][:last_status] = status
sleep 0.5
paint
end