@@ -163,7 +163,7 @@ func testAccept(t *testing.T, inprocessMode bool, singleTest string) int {
163163 }
164164
165165 // Download terraform and provider and create config.
166- RunCommand (t , []string {"python3" , filepath .Join (cwd , "install_terraform.py" ), "--targetdir" , terraformDir }, "." )
166+ RunCommand (t , []string {"python3" , filepath .Join (cwd , "install_terraform.py" ), "--targetdir" , terraformDir }, "." , [] string {} )
167167
168168 wheelPath := buildDatabricksBundlesWheel (t , buildDir )
169169 if wheelPath != "" {
@@ -234,6 +234,12 @@ func testAccept(t *testing.T, inprocessMode bool, singleTest string) int {
234234 }
235235 }
236236
237+ if cloudEnv != "" && UseVersion == "" {
238+ // Create linux release artifacts, to be used by the cloud-only ssh tunnel tests
239+ releasesDir := CreateReleaseArtifacts (t , cwd , "linux" )
240+ t .Setenv ("CLI_RELEASES_DIR" , releasesDir )
241+ }
242+
237243 testDefaultWarehouseId := os .Getenv ("TEST_DEFAULT_WAREHOUSE_ID" )
238244 if testDefaultWarehouseId != "" {
239245 repls .Set (testDefaultWarehouseId , "[TEST_DEFAULT_WAREHOUSE_ID]" )
@@ -892,10 +898,62 @@ func BuildCLI(t *testing.T, buildDir, coverDir string) string {
892898 args = append (args , "-buildvcs=false" )
893899 }
894900
895- RunCommand (t , args , ".." )
901+ RunCommand (t , args , ".." , [] string {} )
896902 return execPath
897903}
898904
905+ // CreateReleaseArtifacts builds release artifacts for the given OS using amd64 and arm64 architectures,
906+ // archives them into zip files, and returns the directory containing the release artifacts.
907+ func CreateReleaseArtifacts (t * testing.T , cwd , osName string ) string {
908+ releasesDir := filepath .Join (cwd , "build" , "releases" )
909+ require .NoError (t , os .MkdirAll (releasesDir , os .ModePerm ))
910+ arches := []string {"amd64" , "arm64" }
911+ for _ , arch := range arches {
912+ CreateReleaseArtifact (t , cwd , releasesDir , osName , arch )
913+ }
914+ return releasesDir
915+ }
916+
917+ func CreateReleaseArtifact (t * testing.T , cwd , releasesDir , osName , arch string ) {
918+ tempBuildDir := filepath .Join (releasesDir , "tmp_" + arch )
919+ require .NoError (t , os .MkdirAll (tempBuildDir , os .ModePerm ))
920+ defer os .RemoveAll (tempBuildDir )
921+
922+ execPath := filepath .Join (tempBuildDir , "databricks" )
923+ args := []string {"go" , "build" , "-o" , execPath }
924+ RunCommand (t , args , ".." , []string {"GOOS=" + osName , "GOARCH=" + arch })
925+
926+ zipName := fmt .Sprintf ("databricks_cli_%s_%s.zip" , osName , arch )
927+ zipPath := filepath .Join (releasesDir , zipName )
928+
929+ zipFile , err := os .Create (zipPath )
930+ require .NoError (t , err )
931+ defer zipFile .Close ()
932+
933+ zipWriter := zip .NewWriter (zipFile )
934+ defer zipWriter .Close ()
935+
936+ info , err := os .Stat (execPath )
937+ require .NoError (t , err )
938+
939+ header , err := zip .FileInfoHeader (info )
940+ require .NoError (t , err )
941+ header .Name = "databricks"
942+ header .Method = zip .Deflate
943+
944+ writer , err := zipWriter .CreateHeader (header )
945+ require .NoError (t , err )
946+
947+ binaryFile , err := os .Open (execPath )
948+ require .NoError (t , err )
949+ defer binaryFile .Close ()
950+
951+ _ , err = io .Copy (writer , binaryFile )
952+ require .NoError (t , err )
953+
954+ t .Logf ("Created %s %s release: %s" , osName , arch , zipPath )
955+ }
956+
899957// DownloadCLI downloads a released CLI binary archive for the given version,
900958// extracts the executable, and returns its path.
901959func DownloadCLI (t * testing.T , buildDir , version string ) string {
@@ -1116,10 +1174,11 @@ func getUVDefaultCacheDir(t *testing.T) string {
11161174 }
11171175}
11181176
1119- func RunCommand (t * testing.T , args []string , dir string ) {
1177+ func RunCommand (t * testing.T , args []string , dir string , env [] string ) {
11201178 start := time .Now ()
11211179 cmd := exec .Command (args [0 ], args [1 :]... )
11221180 cmd .Dir = dir
1181+ cmd .Env = append (os .Environ (), env ... )
11231182 out , err := cmd .CombinedOutput ()
11241183 elapsed := time .Since (start )
11251184 t .Logf ("%s took %s" , args , elapsed )
@@ -1241,7 +1300,7 @@ func buildDatabricksBundlesWheel(t *testing.T, buildDir string) string {
12411300 // so we prepare here by keeping only one.
12421301 _ = prepareWheelBuildDirectory (t , buildDir )
12431302
1244- RunCommand (t , []string {"uv" , "build" , "--no-cache" , "-q" , "--wheel" , "--out-dir" , buildDir }, "../python" )
1303+ RunCommand (t , []string {"uv" , "build" , "--no-cache" , "-q" , "--wheel" , "--out-dir" , buildDir }, "../python" , [] string {} )
12451304
12461305 latestWheel := prepareWheelBuildDirectory (t , buildDir )
12471306 if latestWheel == "" {
@@ -1369,7 +1428,7 @@ func BuildYamlfmt(t *testing.T) {
13691428 args := []string {
13701429 "make" , "-s" , "tools/yamlfmt" + exeSuffix ,
13711430 }
1372- RunCommand (t , args , ".." )
1431+ RunCommand (t , args , ".." , [] string {} )
13731432}
13741433
13751434func loadUserReplacements (t * testing.T , repls * testdiff.ReplacementsContext , tmpDir string ) {
0 commit comments