diff --git a/cmd/makemac/makemac.go b/cmd/makemac/makemac.go index e97631ce7..1acfadf88 100644 --- a/cmd/makemac/makemac.go +++ b/cmd/makemac/makemac.go @@ -642,8 +642,7 @@ func autoAdjust() { } }() - req, _ := http.NewRequest("GET", "https://farmer.golang.org/status/reverse.json", nil) - req = req.WithContext(ctx) + req, _ := http.NewRequestWithContext(ctx, "GET", "https://farmer.golang.org/status/reverse.json", nil) res, err := http.DefaultClient.Do(req) if err != nil { errors = append(errors, fmt.Sprintf("getting /status/reverse.json from coordinator: %v", err)) @@ -739,7 +738,7 @@ func (v Version) String() string { } // hostTypeToVersion determines the version of macOS from the host type. -// Sample host types would be: host-darwin-10_12 and host-darwin-arm64-11_0. +// Sample host types would be: host-darwin-10_15 and host-darwin-arm64-11_0. func hostTypeToVersion(hostType string) (*Version, error) { v := &Version{} var err error @@ -747,32 +746,37 @@ func hostTypeToVersion(hostType string) (*Version, error) { return nil, errors.New("unrecognized version") } htv := strings.TrimPrefix(hostType, "host-darwin-") - vs := strings.Split(htv, "-") - if len(vs) > 2 { - return nil, errors.New("unrecognized version") - } var majorMinor string - if len(vs) == 2 { + switch vs := strings.Split(htv, "-"); len(vs) { + case 2: if vs[0] != "amd64" && vs[0] != "arm64" { return nil, errors.New("unrecognized version") } v.Arch = vs[0] majorMinor = vs[1] - } else { + case 1: v.Arch = "amd64" majorMinor = vs[0] - } - mms := strings.Split(majorMinor, "_") - if len(mms) != 2 { + default: return nil, errors.New("unrecognized version") } - v.Major, err = strconv.Atoi(mms[0]) - if err != nil { - return nil, err - } - v.Minor, err = strconv.Atoi(mms[1]) - if err != nil { - return nil, err + switch mms := strings.Split(majorMinor, "_"); len(mms) { + case 1: + v.Major, err = strconv.Atoi(mms[0]) + if err != nil { + return nil, err + } + case 2: + v.Major, err = strconv.Atoi(mms[0]) + if err != nil { + return nil, err + } + v.Minor, err = strconv.Atoi(mms[1]) + if err != nil { + return nil, err + } + default: + return nil, errors.New("unrecognized version") } return v, nil } @@ -781,10 +785,10 @@ func hostTypeToVersion(hostType string) (*Version, error) { // or nil to not make anything. It gets the latest reverse buildlet // status from the coordinator. func wantedMacVersionNext(st *State, rstat *types.ReverseBuilderStatus) *Version { - // TODO: improve this logic now that the coordinator has a - // proper scheduler. Instead, don't create anything - // proactively until there's demand from it from the - // scheduler. (will need to add that to the coordinator's + // TODO(go.dev/issue/35698): improve this logic now that + // the coordinator has a proper scheduler. Instead, don't + // create anything proactively until there's demand from it + // from the scheduler. (will need to add that to the coordinator's // status JSON) And maybe add a streaming endpoint to the // coordinator so we don't need to poll every N seconds. Or // just poll every few seconds, perhaps at a lighter endpoint @@ -893,8 +897,7 @@ var ( ) func getLatestMacBuildlet(ctx context.Context) (bin []byte, err error) { - req, _ := http.NewRequest("HEAD", "https://storage.googleapis.com/go-builder-data/buildlet.darwin-amd64", nil) - req = req.WithContext(ctx) + req, _ := http.NewRequestWithContext(ctx, "HEAD", "https://storage.googleapis.com/go-builder-data/buildlet.darwin-amd64", nil) res, err := http.DefaultClient.Do(req) if err != nil { return nil, err @@ -917,8 +920,7 @@ func getLatestMacBuildlet(ctx context.Context) (bin []byte, err error) { buildletMu.Unlock() log.Printf("fetching buildlet from GCS...") - req, _ = http.NewRequest("GET", "https://storage.googleapis.com/go-builder-data/buildlet.darwin-amd64", nil) - req = req.WithContext(ctx) + req, _ = http.NewRequestWithContext(ctx, "GET", "https://storage.googleapis.com/go-builder-data/buildlet.darwin-amd64", nil) res, err = http.DefaultClient.Do(req) if err != nil { return nil, err diff --git a/cmd/makemac/makemac_test.go b/cmd/makemac/makemac_test.go index bae931822..28451f6e6 100644 --- a/cmd/makemac/makemac_test.go +++ b/cmd/makemac/makemac_test.go @@ -18,19 +18,19 @@ func TestHostTypeToVersion(t *testing.T) { }{ { desc: "valid original darwin host type", - hostType: "host-darwin-10_11", + hostType: "host-darwin-10_14", wantVersion: &Version{ Major: 10, - Minor: 11, + Minor: 14, Arch: "amd64", }, }, { desc: "valid original darwin host type", - hostType: "host-darwin-10_12", + hostType: "host-darwin-10_15", wantVersion: &Version{ Major: 10, - Minor: 12, + Minor: 15, Arch: "amd64", }, }, @@ -52,6 +52,15 @@ func TestHostTypeToVersion(t *testing.T) { Arch: "amd64", }, }, + { + desc: "valid newer darwin host AMD64", + hostType: "host-darwin-amd64-13", + wantVersion: &Version{ + Major: 13, + Minor: 0, + Arch: "amd64", + }, + }, } for _, tc := range testCases { t.Run(tc.desc, func(t *testing.T) { diff --git a/dashboard/builders.go b/dashboard/builders.go index 334a9cdb3..63c8b1e2a 100644 --- a/dashboard/builders.go +++ b/dashboard/builders.go @@ -468,19 +468,9 @@ var Hosts = map[string]*HostConfig{ IsReverse: true, ExpectNum: 5, }, - "host-darwin-10_12": &HostConfig{ - IsReverse: true, - ExpectNum: 2, - Notes: "MacStadium OS X 10.12 VM under VMWare ESXi", - env: []string{ - "GOROOT_BOOTSTRAP=/Users/gopher/go1.4", - }, - SSHUsername: "gopher", - HermeticReverse: true, // we destroy the VM when done & let cmd/makemac recreate - }, "host-darwin-10_14": &HostConfig{ IsReverse: true, - ExpectNum: 2, + ExpectNum: 3, Notes: "MacStadium macOS Mojave (10.14) VM under VMWare ESXi", env: []string{ "GOROOT_BOOTSTRAP=/Users/gopher/goboot", // Go 1.12.1 @@ -500,7 +490,7 @@ var Hosts = map[string]*HostConfig{ }, "host-darwin-amd64-11_0": &HostConfig{ IsReverse: true, - ExpectNum: 4, + ExpectNum: 5, Notes: "MacStadium macOS Big Sur (11.0) VM under VMWare ESXi", env: []string{ "GOROOT_BOOTSTRAP=/Users/gopher/goboot", // Go 1.13.4 @@ -2421,15 +2411,6 @@ func init() { }, KnownIssues: []int{51019}, }) - addBuilder(BuildConfig{ - Name: "darwin-amd64-10_12", - HostType: "host-darwin-10_12", - distTestAdjust: macTestPolicy, - buildsRepo: func(repo, branch, goBranch string) bool { - // macOS 10.12 not supported after Go 1.16 - return atMostGo1(goBranch, 16) && buildRepoByDefault(repo) - }, - }) addBuilder(BuildConfig{ Name: "darwin-amd64-10_14", HostType: "host-darwin-10_14", diff --git a/dashboard/builders_test.go b/dashboard/builders_test.go index 9509b96a8..36f5ac657 100644 --- a/dashboard/builders_test.go +++ b/dashboard/builders_test.go @@ -543,7 +543,6 @@ func TestBuilderConfig(t *testing.T) { {b("darwin-amd64-10_14", "exp"), onlyPost}, {b("darwin-amd64-10_15", "exp"), onlyPost}, // ... but not on most others: - {b("darwin-amd64-10_12", "exp"), none}, {b("freebsd-386-11_4", "exp"), none}, {b("freebsd-386-12_3", "exp"), none}, {b("freebsd-amd64-11_4", "exp"), none}, @@ -560,7 +559,6 @@ func TestBuilderConfig(t *testing.T) { {b("linux-amd64", "build"), both}, {b("linux-amd64-longtest", "build"), onlyPost}, {b("windows-amd64-2016", "build"), both}, - {b("darwin-amd64-10_12", "build"), none}, {b("darwin-amd64-10_14", "build"), none}, {b("darwin-amd64-10_15", "build"), onlyPost}, {b("openbsd-amd64-68", "build"), none}, @@ -582,14 +580,10 @@ func TestBuilderConfig(t *testing.T) { {b("android-amd64-emu", "build"), none}, // Only use latest macOS for subrepos, and only amd64: - {b("darwin-amd64-10_12@go1.16", "net"), onlyPost}, - {b("darwin-amd64-10_12", "net"), none}, {b("darwin-amd64-10_14", "net"), onlyPost}, {b("darwin-amd64-10_15", "go"), onlyPost}, {b("darwin-amd64-10_14", "go"), onlyPost}, - {b("darwin-amd64-10_12", "go"), none}, - {b("darwin-amd64-10_12@go1.16", "go"), onlyPost}, // plan9 only lived at master. We didn't support any past releases. // But it's off for now as it's always failing. @@ -739,7 +733,6 @@ func TestShouldRunDistTest(t *testing.T) { {"linux-amd64", "reboot", tryMode, true}, {"linux-amd64-race", "reboot", tryMode, false}, - {"darwin-amd64-10_12", "test:foo", postSubmit, false}, {"darwin-amd64-10_14", "test:foo", postSubmit, false}, {"darwin-amd64-10_14", "reboot", postSubmit, false}, {"darwin-amd64-10_14", "api", postSubmit, false}, @@ -944,9 +937,10 @@ func TestMiscCompileLinuxGOARM5(t *testing.T) { } } -// TestExpectedMacstadiumVMCount ensures that only 20 instances of macOS virtual machines -// are expected at MacStadium. -// TODO: remove once the scheduler allocates VMs based on demand https://golang.org/issue/35698 +// TestExpectedMacstadiumVMCount ensures that the right number of +// instances of macOS virtual machines are expected at MacStadium. +// +// TODO(go.dev/issue/35698): remove once the scheduler allocates VMs based on demand. func TestExpectedMacstadiumVMCount(t *testing.T) { got := 0 for host, config := range Hosts {