Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose debug-env.json wrappers through qa package #529

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions internal/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/config"
"github.com/databricks/databricks-sdk-go/internal/env"
"github.com/databricks/databricks-sdk-go/qa"
"github.com/databricks/databricks-sdk-go/service/compute"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestAccDefaultCredentials(t *testing.T) {
t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV"))
t.Log(qa.GetEnvOrSkipTest(t, "CLOUD_ENV"))
w := databricks.Must(databricks.NewWorkspaceClient())
if w.Config.IsAccountClient() {
t.SkipNow()
Expand All @@ -35,7 +36,7 @@ func TestAccDefaultCredentials(t *testing.T) {

func TestAccExplicitDatabricksCfg(t *testing.T) {
w := databricks.Must(databricks.NewWorkspaceClient(&databricks.Config{
Profile: GetEnvOrSkipTest(t, "DATABRICKS_CONFIG_PROFILE"),
Profile: qa.GetEnvOrSkipTest(t, "DATABRICKS_CONFIG_PROFILE"),
}))
if w.Config.IsAccountClient() {
t.SkipNow()
Expand All @@ -62,17 +63,17 @@ func TestAccExplicitAzureCliAuth(t *testing.T) {
"az",
"login",
"--service-principal",
"--user", GetEnvOrSkipTest(t, "ARM_CLIENT_ID"),
"--password", GetEnvOrSkipTest(t, "ARM_CLIENT_SECRET"),
"--tenant", GetEnvOrSkipTest(t, "ARM_TENANT_ID"),
"--user", qa.GetEnvOrSkipTest(t, "ARM_CLIENT_ID"),
"--password", qa.GetEnvOrSkipTest(t, "ARM_CLIENT_SECRET"),
"--tenant", qa.GetEnvOrSkipTest(t, "ARM_TENANT_ID"),
)
out, err := cmd.Output()
if err != nil {
t.Fatalf("error running az: %s (%s)", err, out)
}

w := databricks.Must(databricks.NewWorkspaceClient(&databricks.Config{
AzureResourceID: GetEnvOrSkipTest(t, "DATABRICKS_AZURE_RESOURCE_ID"),
AzureResourceID: qa.GetEnvOrSkipTest(t, "DATABRICKS_AZURE_RESOURCE_ID"),
Credentials: config.AzureCliCredentials{},
}))
ctx := context.Background()
Expand All @@ -89,10 +90,10 @@ func TestAccExplicitAzureCliAuth(t *testing.T) {

func TestAccExplicitAzureSpnAuth(t *testing.T) {
w := databricks.Must(databricks.NewWorkspaceClient(&databricks.Config{
AzureTenantID: GetEnvOrSkipTest(t, "ARM_TENANT_ID"),
AzureClientID: GetEnvOrSkipTest(t, "ARM_CLIENT_ID"),
AzureClientSecret: GetEnvOrSkipTest(t, "ARM_CLIENT_SECRET"),
AzureResourceID: GetEnvOrSkipTest(t, "DATABRICKS_AZURE_RESOURCE_ID"),
AzureTenantID: qa.GetEnvOrSkipTest(t, "ARM_TENANT_ID"),
AzureClientID: qa.GetEnvOrSkipTest(t, "ARM_CLIENT_ID"),
AzureClientSecret: qa.GetEnvOrSkipTest(t, "ARM_CLIENT_SECRET"),
AzureResourceID: qa.GetEnvOrSkipTest(t, "DATABRICKS_AZURE_RESOURCE_ID"),
Credentials: config.AzureClientSecretCredentials{},
}))
ctx := context.Background()
Expand Down
21 changes: 11 additions & 10 deletions internal/billing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package internal
import (
"testing"

"github.com/databricks/databricks-sdk-go/qa"
"github.com/databricks/databricks-sdk-go/service/billing"
"github.com/databricks/databricks-sdk-go/service/provisioning"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestMwsAccUsageDownload(t *testing.T) {
ctx, a := accountTest(t)
ctx, a := qa.AccountTest(t)
if !a.Config.IsAws() {
t.SkipNow()
}
Expand All @@ -23,25 +24,25 @@ func TestMwsAccUsageDownload(t *testing.T) {
}

func TestMwsAccLogDelivery(t *testing.T) {
ctx, a := accountTest(t)
ctx, a := qa.AccountTest(t)
if !a.Config.IsAws() {
t.SkipNow()
}
creds, err := a.Credentials.Create(ctx, provisioning.CreateCredentialRequest{
CredentialsName: RandomName("sdk-"),
CredentialsName: qa.RandomName("sdk-"),
AwsCredentials: provisioning.CreateCredentialAwsCredentials{
StsRole: &provisioning.CreateCredentialStsRole{
RoleArn: GetEnvOrSkipTest(t, "TEST_LOGDELIVERY_ARN"),
RoleArn: qa.GetEnvOrSkipTest(t, "TEST_LOGDELIVERY_ARN"),
},
},
})
require.NoError(t, err)
defer a.Credentials.DeleteByCredentialsId(ctx, creds.CredentialsId)

bucket, err := a.Storage.Create(ctx, provisioning.CreateStorageConfigurationRequest{
StorageConfigurationName: RandomName("sdk-"),
StorageConfigurationName: qa.RandomName("sdk-"),
RootBucketInfo: provisioning.RootBucketInfo{
BucketName: RandomName("sdk-bucket-"),
BucketName: qa.RandomName("sdk-bucket-"),
},
})
require.NoError(t, err)
Expand All @@ -50,7 +51,7 @@ func TestMwsAccLogDelivery(t *testing.T) {
// TODO: OpenAPI: x-databricks-sdk-inline on schema
created, err := a.LogDelivery.Create(ctx, billing.WrappedCreateLogDeliveryConfiguration{
LogDeliveryConfiguration: &billing.CreateLogDeliveryConfigurationParams{
ConfigName: RandomName("sdk-go-"),
ConfigName: qa.RandomName("sdk-go-"),
CredentialsId: creds.CredentialsId,
StorageConfigurationId: bucket.StorageConfigurationId,
LogType: billing.LogTypeAuditLogs,
Expand Down Expand Up @@ -78,15 +79,15 @@ func TestMwsAccLogDelivery(t *testing.T) {
}

func TestMwsAccBudgets(t *testing.T) {
ctx, a := accountTest(t)
ctx, a := qa.AccountTest(t)
if !a.Config.IsAws() {
t.SkipNow()
}

// TODO: OpenAPI: x-databricks-sdk-inline on schema
created, err := a.Budgets.Create(ctx, billing.WrappedBudget{
Budget: billing.Budget{
Name: RandomName("go-sdk-"),
Name: qa.RandomName("go-sdk-"),
Filter: "tag.tagName = 'all'",
Period: "1 month",
StartDate: "2022-01-01",
Expand All @@ -105,7 +106,7 @@ func TestMwsAccBudgets(t *testing.T) {
err = a.Budgets.Update(ctx, billing.WrappedBudget{
BudgetId: created.Budget.BudgetId,
Budget: billing.Budget{
Name: RandomName("go-sdk-updated-"),
Name: qa.RandomName("go-sdk-updated-"),
Filter: "tag.tagName = 'all'",
Period: "1 month",
StartDate: "2022-01-01",
Expand Down
Loading