WIP integration test for deploy

This commit is contained in:
Shreyas Goenka 2022-12-01 16:16:55 +01:00
parent e1669b0352
commit 79c26a4ac2
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 78 additions and 0 deletions

78
internal/deployer_test.go Normal file
View File

@ -0,0 +1,78 @@
package internal
// import (
// "context"
// "fmt"
// "math/rand"
// "os"
// "path/filepath"
// "sync"
// "testing"
// "time"
// "github.com/databricks/bricks/bundle/deployer"
// "github.com/databricks/databricks-sdk-go"
// "github.com/hashicorp/go-version"
// "github.com/hashicorp/hc-install/product"
// "github.com/hashicorp/hc-install/releases"
// "github.com/stretchr/testify/assert"
// "github.com/stretchr/testify/require"
// )
// func setupTerraformBinary(t *testing.T) (string, error) {
// installer := releases.ExactVersion{
// Product: product.Terraform,
// Version: version.Must(version.NewVersion("1.2.4")),
// }
// execPath, err := installer.Install(context.TODO())
// if err != nil {
// return "", err
// }
// t.Cleanup(func() {
// installer.Remove(context.TODO())
// })
// return execPath, nil
// }
// func createLocalTestProjectWithTfConfig(t *testing.T, id string) {
// localRoot := createLocalTestProject(t)
// err := os.MkdirAll(filepath.Join(localRoot, ".databricks/bundle"), os.ModeDir)
// require.NoError(t, err)
// os.WriteFile(filepath.Join(localRoot, ".databricks/bundle/main.tf"), []byte(
// fmt.Sprintf(`
// `)
// ), os.ModePerm)
// }
// func TestAccDeploy(t *testing.T) {
// t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV"))
// ctx := context.TODO()
// wsc := databricks.Must(databricks.NewWorkspaceClient())
// localProjectRoot := createLocalTestProject(t)
// remoteProjectRoot := createRemoteTestProject(t, "deploy-acc-", wsc)
// tfExecPath, err := setupTerraformBinary(t)
// assert.NoError(t, err)
// numConcurrentDeployers := 4
// deployErrs := make([]error, numConcurrentDeployers)
// deployers := make([]*deployer.Deployer, numConcurrentDeployers)
// for i := 0; i < numConcurrentDeployers; i++ {
// deployers[i], err = deployer.Create(ctx, "development", localProjectRoot, remoteProjectRoot, wsc)
// require.NoError(t, err)
// }
// var wg sync.WaitGroup
// for i := 0; i < numConcurrentDeployers; i++ {
// wg.Add(1)
// currentIndex := i
// go func() {
// defer wg.Done()
// time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
// deployErrs[currentIndex] = deployers[currentIndex].Lock(ctx)
// }()
// }
// wg.Wait()
// }