Skip to content

Commit

Permalink
Add support for ARM64 binaries on Linux and macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
alnr authored and rafiss committed Mar 2, 2023
1 parent 246d034 commit e5902a9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
6 changes: 3 additions & 3 deletions testserver/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# cockroach-go Testserver

The `testserver` package helps running cockroachDB binary with tests. It
automatically downloads the latest stable cockroach binary for your runtimeOS
(Linux-amd64 and Darwin-amd64 only for now), or attempts to run "cockroach" from your PATH.
automatically downloads the latest stable cockroach binary for your runtimeOS,
or attempts to run "cockroach" from your PATH.

### Example
To run the test server, call `NewTestServer(opts)` and with test server options.
Expand Down Expand Up @@ -63,4 +63,4 @@ NewTestServer()`.

### Test Server for Multi Tenants
The usage of test server as a tenant server is still under development. Please
check `testserver/tenant.go` for more information.
check `testserver/tenant.go` for more information.
13 changes: 9 additions & 4 deletions testserver/binaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const (
)

const (
linuxUrlpat = "https://binaries.cockroachdb.com/cockroach-v%s.linux-amd64.tgz"
macUrlpat = "https://binaries.cockroachdb.com/cockroach-v%s.darwin-10.9-amd64.tgz"
linuxUrlpat = "https://binaries.cockroachdb.com/cockroach-v%s.linux-%s.tgz"
macUrlpat = "https://binaries.cockroachdb.com/cockroach-v%s.darwin-%s-%s.tgz"
winUrlpat = "https://binaries.cockroachdb.com/cockroach-v%s.windows-6.2-amd64.zip"
sourceUrlPat = "https://binaries.cockroachdb.com/cockroach-v%s.src.tgz)"
)
Expand Down Expand Up @@ -266,9 +266,14 @@ func getLatestStableVersionInfo() (string, string, error) {
func getDownloadUrlForVersion(version string) string {
switch runtime.GOOS {
case "linux":
return fmt.Sprintf(linuxUrlpat, version)
return fmt.Sprintf(linuxUrlpat, version, runtime.GOARCH)
case "darwin":
return fmt.Sprintf(macUrlpat, version)
switch runtime.GOARCH {
case "arm64":
return fmt.Sprintf(macUrlpat, version, "11.0", runtime.GOARCH)
case "amd64":
return fmt.Sprintf(macUrlpat, version, "10.9", runtime.GOARCH)
}
case "windows":
return fmt.Sprintf(winUrlpat, version)
}
Expand Down
5 changes: 2 additions & 3 deletions testserver/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
// permissions and limitations under the License.

// Package testserver provides helpers to run a cockroach binary within tests.
// It automatically downloads the latest cockroach binary for your platform
// (Linux-amd64 and Darwin-amd64 only for now), or attempts to run "cockroach"
// from your PATH.
// It automatically downloads the latest cockroach binary for your platform,
// or attempts to run "cockroach" from your PATH.
//
// To use, run as follows:
//
Expand Down

0 comments on commit e5902a9

Please sign in to comment.