support arch in downloadURL

pull/10774/head
Ilya Zuyev 2021-03-19 13:55:11 -07:00
parent 7e45721c82
commit 275f743e9f
5 changed files with 17 additions and 11 deletions

View File

@ -23,6 +23,7 @@ import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"runtime"
"testing" "testing"
retryablehttp "github.com/hashicorp/go-retryablehttp" retryablehttp "github.com/hashicorp/go-retryablehttp"
@ -56,7 +57,7 @@ func TestReleasesJSON(t *testing.T) {
fmt.Printf("Checking release: %s\n", r.Name) fmt.Printf("Checking release: %s\n", r.Name)
for platform, sha := range r.Checksums { for platform, sha := range r.Checksums {
fmt.Printf("Checking SHA for %s.\n", platform) fmt.Printf("Checking SHA for %s.\n", platform)
actualSha, err := getSHAFromURL(util.GetBinaryDownloadURL(r.Name, platform)) actualSha, err := getSHAFromURL(util.GetBinaryDownloadURL(r.Name, platform, runtime.GOARCH))
if err != nil { if err != nil {
t.Errorf("Error calculating SHA for %s-%s. Error: %v", r.Name, platform, err) t.Errorf("Error calculating SHA for %s-%s. Error: %v", r.Name, platform, err)
continue continue

View File

@ -29,7 +29,7 @@ import (
) )
const ( const (
downloadURL = "https://storage.googleapis.com/minikube/releases/%s/minikube-%s-amd64%s" downloadURL = "https://storage.googleapis.com/minikube/releases/%s/minikube-%s-%s%s"
) )
// CalculateSizeInMB returns the number of MB in the human readable string // CalculateSizeInMB returns the number of MB in the human readable string
@ -62,13 +62,13 @@ func ConvertUnsignedBytesToMB(byteSize uint64) int64 {
return int64(byteSize / units.MiB) return int64(byteSize / units.MiB)
} }
// GetBinaryDownloadURL returns a suitable URL for the platform // GetBinaryDownloadURL returns a suitable URL for the platform and arch
func GetBinaryDownloadURL(version, platform string) string { func GetBinaryDownloadURL(version, platform, arch string) string {
switch platform { switch platform {
case "windows": case "windows":
return fmt.Sprintf(downloadURL, version, platform, ".exe") return fmt.Sprintf(downloadURL, version, platform, arch, ".exe")
default: default:
return fmt.Sprintf(downloadURL, version, platform, "") return fmt.Sprintf(downloadURL, version, platform, arch, "")
} }
} }

View File

@ -20,6 +20,7 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"os/user" "os/user"
"runtime"
"syscall" "syscall"
"testing" "testing"
@ -38,7 +39,7 @@ func TestGetBinaryDownloadURL(t *testing.T) {
} }
for _, tt := range testData { for _, tt := range testData {
url := GetBinaryDownloadURL(tt.version, tt.platform) url := GetBinaryDownloadURL(tt.version, tt.platform, runtime.GOARCH)
if url != tt.expectedURL { if url != tt.expectedURL {
t.Fatalf("Expected '%s' but got '%s'", tt.expectedURL, url) t.Fatalf("Expected '%s' but got '%s'", tt.expectedURL, url)
} }

View File

@ -43,7 +43,7 @@ func installRelease(version string) (f *os.File, err error) {
} }
tf.Close() tf.Close()
url := pkgutil.GetBinaryDownloadURL(version, runtime.GOOS) url := pkgutil.GetBinaryDownloadURL(version, runtime.GOOS, runtime.GOARCH)
if err := retry.Expo(func() error { return getter.GetFile(tf.Name(), url) }, 3*time.Second, Minutes(3)); err != nil { if err := retry.Expo(func() error { return getter.GetFile(tf.Name(), url) }, 3*time.Second, Minutes(3)); err != nil {
return tf, err return tf, err
@ -79,9 +79,13 @@ func TestRunningBinaryUpgrade(t *testing.T) {
// Should be a version from the last 6 months // Should be a version from the last 6 months
legacyVersion := "v1.6.2" legacyVersion := "v1.6.2"
if KicDriver() { if KicDriver() {
if arm64Platform() {
legacyVersion = "v1.17.0"
} else {
// v1.8.0 would be selected, but: https://github.com/kubernetes/minikube/issues/8740 // v1.8.0 would be selected, but: https://github.com/kubernetes/minikube/issues/8740
legacyVersion = "v1.9.0" legacyVersion = "v1.9.0"
} }
}
tf, err := installRelease(legacyVersion) tf, err := installRelease(legacyVersion)
if err != nil { if err != nil {

View File

@ -48,7 +48,7 @@ func TestStress(t *testing.T) {
} }
oldPath := fmt.Sprintf("../../out/minikube-%s", *upgradeFrom) oldPath := fmt.Sprintf("../../out/minikube-%s", *upgradeFrom)
url := util.GetBinaryDownloadURL(*upgradeFrom, runtime.GOOS) url := util.GetBinaryDownloadURL(*upgradeFrom, runtime.GOOS, runtime.GOARCH)
t.Logf("Downloading minikube %s from %s", *upgradeFrom, url) t.Logf("Downloading minikube %s from %s", *upgradeFrom, url)
err = getter.GetFile(oldPath, url) err = getter.GetFile(oldPath, url)
if err != nil { if err != nil {