Skip to content

Commit 3a94ffa

Browse files
committed
roachtest: allow local runs of azure backup roachtest
Previously the azure backup roachtest could only in the nightlies, and not by developers on their machines. This patch removes the clunky credentials auth path the test used to use. Now, the test auths to the bucket via an IAM policy that the developer needs to set up following the internal azure roachprod tutorial. Epic: none Release note: none
1 parent 9c4252b commit 3a94ffa

File tree

3 files changed

+0
-61
lines changed

3 files changed

+0
-61
lines changed

pkg/cmd/roachtest/tests/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ go_library(
354354
"@com_github_prometheus_common//model",
355355
"@com_github_stretchr_testify//assert",
356356
"@com_github_stretchr_testify//require",
357-
"@in_gopkg_yaml_v3//:yaml_v3",
358357
"@org_golang_google_protobuf//proto",
359358
"@org_golang_x_exp//maps",
360359
"@org_golang_x_oauth2//clientcredentials",

pkg/cmd/roachtest/tests/backup.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ const (
6565
AssumeRoleGCSCredentials = "GOOGLE_CREDENTIALS_ASSUME_ROLE"
6666
AssumeRoleGCSServiceAccount = "GOOGLE_SERVICE_ACCOUNT"
6767

68-
AzureClientIDEnvVar = "AZURE_CLIENT_ID"
69-
AzureClientSecretEnvVar = "AZURE_CLIENT_SECRET"
70-
AzureTenantIDEnvVar = "AZURE_TENANT_ID"
71-
7268
// rows2TiB is the number of rows to import to load 2TB of data (when
7369
// replicated).
7470
rows2TiB = 65_104_166

pkg/cmd/roachtest/tests/backup_fixtures.go

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
gosql "database/sql"
1111
"fmt"
1212
"net/url"
13-
"os"
1413
"path"
1514
"time"
1615

@@ -34,21 +33,8 @@ import (
3433
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
3534
"github.com/cockroachdb/errors"
3635
"github.com/stretchr/testify/require"
37-
"gopkg.in/yaml.v3"
3836
)
3937

40-
// At the moment, Azure VMs do not have managed identities set up yet.
41-
// Therefore, in order to use implicit authentication, we need to put a
42-
// credentials file on each VM and point the
43-
// `COCKROACH_AZURE_APPLICATION_CREDENTIALS_FILE` environment variable at the
44-
// file.
45-
// Currently, the only set of credentials that have write access to the storage
46-
// buckets are the Teamcity credentials, so the Azure fixture roachtests cannot
47-
// be run locally until those managed identities are set up.
48-
// TODO (kev-cao): Once managed identities are set up, we can remove this file
49-
// and rely on the managed identity to authenticate with Azure Blob Storage.
50-
const azureCredentialsFilePath = "/home/ubuntu/azure-credentials.yaml"
51-
5238
// Maps a fixture database name to the expected number of tables in the
5339
// database, useful for verifying that the fingerprint of the fixture is as
5440
// expected.
@@ -197,9 +183,6 @@ func (bd *backupDriver) prepareCluster(ctx context.Context) {
197183
"cloudstorage.s3.client_retry_token_bucket.enabled": "false",
198184
"cloudstorage.azure.try.timeout": "0s",
199185
},
200-
install.EnvOption{
201-
fmt.Sprintf("COCKROACH_AZURE_APPLICATION_CREDENTIALS_FILE=%s", azureCredentialsFilePath),
202-
},
203186
))
204187
}
205188

@@ -653,7 +636,6 @@ func registerBackupFixtures(r registry.Registry) {
653636
Suites: bf.suites,
654637
Skip: bf.skip,
655638
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
656-
require.NoError(t, maybePutAzureCredentialsFile(ctx, c, azureCredentialsFilePath))
657639
registry := GetFixtureRegistry(ctx, t, c.Cloud())
658640

659641
handle, err := registry.Create(ctx, bf.fixture.Name, t.L())
@@ -689,44 +671,6 @@ func registerBackupFixtures(r registry.Registry) {
689671
}
690672
}
691673

692-
func maybePutAzureCredentialsFile(ctx context.Context, c cluster.Cluster, path string) error {
693-
if c.Cloud() != spec.Azure {
694-
return nil
695-
}
696-
697-
type azureCreds struct {
698-
TenantID string `yaml:"azure_tenant_id"`
699-
ClientID string `yaml:"azure_client_id"`
700-
ClientSecret string `yaml:"azure_client_secret"`
701-
}
702-
703-
azureEnvVars := []string{AzureTenantIDEnvVar, AzureClientIDEnvVar, AzureClientSecretEnvVar}
704-
azureEnvValues := make(map[string]string)
705-
for _, envVar := range azureEnvVars {
706-
val := os.Getenv(envVar)
707-
if val == "" {
708-
return errors.Newf("environment variable %s is not set", envVar)
709-
}
710-
azureEnvValues[envVar] = val
711-
}
712-
713-
creds := azureCreds{
714-
TenantID: azureEnvValues[AzureTenantIDEnvVar],
715-
ClientID: azureEnvValues[AzureClientIDEnvVar],
716-
ClientSecret: azureEnvValues[AzureClientSecretEnvVar],
717-
}
718-
719-
credsYaml, err := yaml.Marshal(creds)
720-
if err != nil {
721-
return errors.Wrapf(err, "failed to marshal Azure credentials to YAML")
722-
}
723-
724-
return errors.Wrap(
725-
c.PutString(ctx, string(credsYaml), path, 0700),
726-
"failed to put Azure credentials file in cluster",
727-
)
728-
}
729-
730674
func registerBlobFixtureGC(r registry.Registry) {
731675
r.Add(registry.TestSpec{
732676
Name: "blobfixture/gc",

0 commit comments

Comments
 (0)