diff --git a/vhdbuilder/packer/test/linux-vhd-content-test.sh b/vhdbuilder/packer/test/linux-vhd-content-test.sh index 7593df2d85e..48aaf8c64a0 100644 --- a/vhdbuilder/packer/test/linux-vhd-content-test.sh +++ b/vhdbuilder/packer/test/linux-vhd-content-test.sh @@ -216,7 +216,7 @@ testPackagesInstalled() { echo $test "[INFO] File ${downloadedPackage} exists and has the correct size ${fileSizeDownloaded} bytes" # Validate whether package exists in Azure China cloud if [[ $downloadURL == https://acs-mirror.azureedge.net/* ]]; then - mcURL="${downloadURL/https:\/\/acs-mirror.azureedge.net/https:\/\/kubernetesartifacts.blob.core.chinacloudapi.cn}" + mcURL="${downloadURL/https:\/\/acs-mirror.azureedge.net/https:\/\/mirror.azk8s.cn}" echo "Validating: $mcURL" isExist=$(curl -sLI "$mcURL" | grep -i "404 The specified blob does not exist." | awk '{print $2}') if [[ "$isExist" == "404" ]]; then @@ -224,7 +224,7 @@ testPackagesInstalled() { continue fi - fileSizeInMC=$(curl -sLI $mcURL | grep -i Content-Length | tail -n1 | awk '{print $2}' | tr -d '\r') + fileSizeInMC=$(wget -S $mcURL --start-pos=500G 2>&1 | grep -i Content-Length | tail -n1 | awk '{print $2}' | tr -d '\r') if [[ "$fileSizeInMC" != "$fileSizeDownloaded" ]]; then err "$mcURL is valid but the file size is different. Expected file size: ${fileSizeDownloaded} - downloaded file size: ${fileSizeInMC}" continue diff --git a/vhdbuilder/packer/test/windows-files-check.ps1 b/vhdbuilder/packer/test/windows-files-check.ps1 index 25dd097d16f..1ee8db658a5 100644 --- a/vhdbuilder/packer/test/windows-files-check.ps1 +++ b/vhdbuilder/packer/test/windows-files-check.ps1 @@ -197,9 +197,14 @@ function Test-CompareSingleDir { } if ($URL.StartsWith("https://acs-mirror.azureedge.net/")) { - $mcURL = $URL.replace("https://acs-mirror.azureedge.net/", "https://kubernetesartifacts.blob.core.chinacloudapi.cn/") - - $mooncakeFileSize = (Invoke-WebRequest $mcURL -UseBasicParsing -Method Head).Headers.'Content-Length' + $mcURL = $URL.replace("https://acs-mirror.azureedge.net/", "https://mirror.azk8s.cn/") + + $webRequest = [System.Net.HttpWebRequest]::Create($mcURL) + # Set the 'Range' header using the AddRange method + $webRequest.AddRange(0, 1023) + # Get the response + $response = $webRequest.GetResponse() + $mooncakeFileSize = $response.Headers["Content-Range"] -split "/" | Select-Object -Last 1 if ($globalFileSize -ne $mooncakeFileSize) { $MisMatchFiles[$URL]=$mcURL diff --git a/vhdbuilder/packer/test/windows-vhd-content-test.ps1 b/vhdbuilder/packer/test/windows-vhd-content-test.ps1 index 83f68858a8d..c826b440040 100644 --- a/vhdbuilder/packer/test/windows-vhd-content-test.ps1 +++ b/vhdbuilder/packer/test/windows-vhd-content-test.ps1 @@ -167,12 +167,18 @@ function Test-FilesToCacheOnVHD if ( $URL.StartsWith("https://acs-mirror.azureedge.net/")) { - $mcURL = $URL.replace("https://acs-mirror.azureedge.net/", "https://kubernetesartifacts.blob.core.chinacloudapi.cn/") + $mcURL = $URL.replace("https://acs-mirror.azureedge.net/", "https://mirror.azk8s.cn/") try { # It's too slow to download the file from the China Cloud. So we only compare the file size. $localFileSize = (Get-Item $dest).length - $remoteFileSize = (Invoke-WebRequest $mcURL -UseBasicParsing -Method Head).Headers.'Content-Length' + + $webRequest = [System.Net.HttpWebRequest]::Create($mcURL) + # Set the 'Range' header using the AddRange method + $webRequest.AddRange(0, 1023) + # Get the response + $response = $webRequest.GetResponse() + $remoteFileSize = $response.Headers["Content-Range"] -split "/" | Select-Object -Last 1 if ($localFileSize -ne $remoteFileSize) { $isIgnore = $False