diff options
author | Neha Pansare <neha.pansare@progress.com> | 2022-10-12 16:34:41 +0530 |
---|---|---|
committer | Neha Pansare <neha.pansare@progress.com> | 2022-10-12 16:34:41 +0530 |
commit | d2d63e699603cb754ee2ad4ddf423dc5dc435aa9 (patch) | |
tree | 2a12d85f26e535b37030e539b74be048523529cf | |
parent | e4a028f619b22112b4eb206ccd7fb54ec4574f3c (diff) | |
download | chef-d2d63e699603cb754ee2ad4ddf423dc5dc435aa9.tar.gz |
Fix kitchen test failures:
1. Fix git installation failure on windows by removing any existing versions of git first before using the supermarket cookbook which tries to install it and fails due to existing version
2. Fix Errno::EBUSY: Device or resource busy @ rb_file_s_rename - (/etc/.chef-resolv20221011-713-1av4p28.conf, /etc/resolv.conf) by setting atomic_update to false
Signed-off-by: Neha Pansare <neha.pansare@progress.com>
-rw-r--r-- | kitchen-tests/cookbooks/end_to_end/recipes/linux.rb | 1 | ||||
-rw-r--r-- | kitchen-tests/cookbooks/end_to_end/recipes/windows.rb | 48 |
2 files changed, 49 insertions, 0 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/linux.rb b/kitchen-tests/cookbooks/end_to_end/recipes/linux.rb index 6adf3c362d..f302769840 100644 --- a/kitchen-tests/cookbooks/end_to_end/recipes/linux.rb +++ b/kitchen-tests/cookbooks/end_to_end/recipes/linux.rb @@ -42,6 +42,7 @@ include_recipe "ntp" unless fedora? # fedora 34+ doesn't have NTP resolver_config "/etc/resolv.conf" do nameservers [ "8.8.8.8", "8.8.4.4" ] search [ "chef.io" ] + atomic_update false # otherwise EBUSY for linux docker containers end users_from_databag = search("users", "*:*") diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb b/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb index 6e7ebf08a7..bd0c210894 100644 --- a/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb +++ b/kitchen-tests/cookbooks/end_to_end/recipes/windows.rb @@ -13,6 +13,54 @@ chef_sleep "2" execute "dir" +execute "Print git version" do + command "git --version & git --exec-path" + live_stream true +end + +# FIXME Uninstall git using powershell +# this is a temporary band-aid due to the fallback git version in +# https://github.com/sous-chefs/git defaulting to an older version of git +# than will be installed on the current image this runs in for GitHub Actions +powershell_script "uninstall_git" do + code <<-EOH + $possibleInstalledPaths = @("C:/Program Files/Git/", "C:/Program Files (x64)/Git/", "c:/git/") + $foundAnInstallation = $false + ### For all places where Git "could" be. + foreach ($installPath in $possibleInstalledPaths) + { + ### If the path where Git could exist + if (Test-Path($installPath)) + { + ## Some Git stuff might be running.. kill them. + Stop-Process -processname Bash -erroraction 'silentlycontinue' + Stop-Process -processname Putty* -erroraction 'silentlycontinue' + $foundAnInstallation = $true + Write-Host "Removing Git from " $installPath + ### Find if there's an uninstaller in the folder. + $uninstallers = Get-ChildItem $installPath"unins*.exe" + ### In reality, there should only be just one that matches. + foreach ($uninstaller in $uninstallers) + { + ### Invoke the uninstaller. + $uninstallerCommandLineOptions = "/SP- /VERYSILENT /SUPPRESSMSGBOXES /FORCECLOSEAPPLICATIONS" + Start-Process -Wait -FilePath $uninstaller -ArgumentList $uninstallerCommandLineOptions + } + ### Remove the folder if it didn't clean up properly. + if (Test-Path($installPath)) + { + Remove-Item -Recurse -Force $installPath + } + } + } + if (!($foundAnInstallation)) + { + Write-Host "No git installation found. Nothing to uninstall" + } + EOH + live_stream true +end + powershell_script "sleep 1 second" do code "Start-Sleep -s 1" live_stream true |