check shas of new archs
parent
a0d7457e36
commit
be711f1d7f
|
@ -21,7 +21,6 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"runtime"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
retryablehttp "github.com/hashicorp/go-retryablehttp"
|
retryablehttp "github.com/hashicorp/go-retryablehttp"
|
||||||
|
@ -46,30 +45,28 @@ func getSHAFromURL(url string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestReleasesJSON checks if all *GA* releases
|
// TestReleasesJSON checks if all *GA* releases
|
||||||
// enlisted in https://storage.googleapis.com/minikube/releases.json
|
// enlisted in https://storage.googleapis.com/minikube/releases-v2.json
|
||||||
// are available to download and have correct hashsum
|
// are available to download and have correct hashsum
|
||||||
func TestReleasesJSON(t *testing.T) {
|
func TestReleasesJSON(t *testing.T) {
|
||||||
releases, err := notify.AllVersionsFromURL(notify.GithubMinikubeReleasesURL)
|
releases, err := notify.AllVersionsFromURL(notify.GithubMinikubeReleasesURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error getting releases.json: %v", err)
|
t.Fatalf("Error getting releases.json: %v", err)
|
||||||
}
|
}
|
||||||
checkReleases(t, releases)
|
checkReleasesV2(t, releases)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestBetaReleasesJSON checks if all *BETA* releases
|
// TestBetaReleasesJSON checks if all *BETA* releases
|
||||||
// enlisted in https://storage.googleapis.com/minikube/releases-beta.json
|
// enlisted in https://storage.googleapis.com/minikube/releases-beta-v2.json
|
||||||
// are available to download and have correct hashsum
|
// are available to download and have correct hashsum
|
||||||
func TestBetaReleasesJSON(t *testing.T) {
|
func TestBetaReleasesJSON(t *testing.T) {
|
||||||
releases, err := notify.AllVersionsFromURL(notify.GithubMinikubeBetaReleasesURL)
|
releases, err := notify.AllVersionsFromURL(notify.GithubMinikubeBetaReleasesURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error getting releases-bets.json: %v", err)
|
t.Fatalf("Error getting releases-bets.json: %v", err)
|
||||||
}
|
}
|
||||||
checkReleases(t, releases)
|
checkReleasesV2(t, releases)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkReleases(t *testing.T, rs notify.Releases) {
|
func checkReleasesV1(t *testing.T, r notify.Release) {
|
||||||
for _, r := range rs.Releases {
|
|
||||||
fmt.Printf("Checking release: %s\n", r.Name)
|
|
||||||
checksums := map[string]string{
|
checksums := map[string]string{
|
||||||
"darwin": r.Checksums.Darwin,
|
"darwin": r.Checksums.Darwin,
|
||||||
"linux": r.Checksums.Linux,
|
"linux": r.Checksums.Linux,
|
||||||
|
@ -77,7 +74,7 @@ func checkReleases(t *testing.T, rs notify.Releases) {
|
||||||
}
|
}
|
||||||
for platform, sha := range checksums {
|
for platform, sha := range 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, runtime.GOARCH))
|
actualSha, err := getSHAFromURL(util.GetBinaryDownloadURL(r.Name, platform, "amd64"))
|
||||||
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
|
||||||
|
@ -87,5 +84,45 @@ func checkReleases(t *testing.T, rs notify.Releases) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getSHAMap(c notify.Checksums) map[string]map[string]string {
|
||||||
|
return map[string]map[string]string{
|
||||||
|
"darwin": {
|
||||||
|
"amd64": c.AMD64.Darwin,
|
||||||
|
"arm64": c.ARM64.Darwin,
|
||||||
|
},
|
||||||
|
"linux": {
|
||||||
|
"amd64": c.AMD64.Linux,
|
||||||
|
"arm": c.ARM.Linux,
|
||||||
|
"arm64": c.ARM64.Linux,
|
||||||
|
"ppc64le": c.PPC64LE.Linux,
|
||||||
|
"s390x": c.S390X.Linux,
|
||||||
|
},
|
||||||
|
"windows": {
|
||||||
|
"amd64": c.AMD64.Windows,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkReleasesV2(t *testing.T, rs notify.Releases) {
|
||||||
|
for _, r := range rs.Releases {
|
||||||
|
fmt.Printf("Checking release: %s\n", r.Name)
|
||||||
|
checkReleasesV1(t, r)
|
||||||
|
release := getSHAMap(r.Checksums)
|
||||||
|
for os, archs := range release {
|
||||||
|
for arch, sha := range archs {
|
||||||
|
fmt.Printf("Checking SHA for %s-%s.\n", os, arch)
|
||||||
|
actualSha, err := getSHAFromURL(util.GetBinaryDownloadURL(r.Name, os, arch))
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Error calculating SHA for %s-%s-%s. Error: %v", r.Name, os, arch, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if actualSha != sha {
|
||||||
|
t.Errorf("ERROR: SHA does not match for version %s, os %s, arch %s. Expected %s, got %s.", r.Name, os, arch, sha, actualSha)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ type operatingSystems struct {
|
||||||
Windows string `json:"windows,omitempty"`
|
Windows string `json:"windows,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type checksums struct {
|
type Checksums struct {
|
||||||
AMD64 *operatingSystems `json:"amd64,omitempty"`
|
AMD64 *operatingSystems `json:"amd64,omitempty"`
|
||||||
ARM *operatingSystems `json:"arm,omitempty"`
|
ARM *operatingSystems `json:"arm,omitempty"`
|
||||||
ARM64 *operatingSystems `json:"arm64,omitempty"`
|
ARM64 *operatingSystems `json:"arm64,omitempty"`
|
||||||
|
@ -146,7 +146,7 @@ type checksums struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Release struct {
|
type Release struct {
|
||||||
Checksums checksums `json:"checksums"`
|
Checksums Checksums `json:"checksums"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue