From b1b076f6007b29473cc81395523771674960de8d Mon Sep 17 00:00:00 2001 From: Daniel Moran Date: Thu, 17 Jun 2021 09:18:55 -0400 Subject: [PATCH] refactor: delete old backup/restore CLI commands, replace with dependency on new CLI repo (#21703) --- backup/backup.go | 244 ------------ cmd/influx/backup.go | 110 ------ cmd/influx/main.go | 2 - cmd/influx/restore.go | 145 -------- cmd/influxd/launcher/backup_restore_test.go | 18 +- cmd/influxd/launcher/launcher_helpers.go | 72 ++-- cmd/influxd/launcher/launcher_test.go | 6 +- cmd/influxd/launcher/storage_test.go | 2 +- cmd/influxd/upgrade/upgrade_test.go | 5 +- go.mod | 13 +- go.sum | 53 ++- http/backup_service.go | 86 ----- http/client.go | 9 +- http/query_handler.go | 10 +- http/restore_service.go | 108 ------ .../cmd/fluxtest-harness-influxdb/test.go | 2 +- restore/restore.go | 347 ------------------ tests/pipeline_helpers.go | 4 +- tsdb/engine/tsm1/batch_integer_test.go | 7 +- tsdb/engine/tsm1/batch_string_test.go | 7 +- tsdb/engine/tsm1/bool_test.go | 7 +- tsdb/engine/tsm1/float_test.go | 8 +- tsdb/engine/tsm1/int_test.go | 7 +- tsdb/engine/tsm1/string_test.go | 7 +- 24 files changed, 139 insertions(+), 1140 deletions(-) delete mode 100644 cmd/influx/backup.go delete mode 100644 cmd/influx/restore.go delete mode 100644 restore/restore.go diff --git a/backup/backup.go b/backup/backup.go index 239f684a73..94cc4a9b58 100644 --- a/backup/backup.go +++ b/backup/backup.go @@ -1,24 +1,13 @@ package backup import ( - "compress/gzip" "context" "encoding/json" - "fmt" "io" - "io/ioutil" - "os" - "path/filepath" - "time" - - "github.com/influxdata/influxdb/v2/kit/platform" - "github.com/influxdata/influxdb/v2/kit/platform/errors" "github.com/influxdata/influxdb/v2" - "github.com/influxdata/influxdb/v2/bolt" "github.com/influxdata/influxdb/v2/tenant" "github.com/influxdata/influxdb/v2/v1/services/meta" - "go.uber.org/zap" ) type BucketManifestWriter struct { @@ -152,236 +141,3 @@ func shardOwnersToManifest(shardOwners []meta.ShardOwner) []influxdb.ShardOwner return r } - -type Request struct { - // Organization to backup. - // If not set, all orgs will be included. - OrgID platform.ID - Org string - - // Bucket to backup. - // If not set, all buckets within the org filter will be included. - BucketID platform.ID - Bucket string - - // Path to the directory where backup files should be written. - Path string -} - -type backupRunner struct { - baseName string - backupSvc influxdb.BackupService - tenantService influxdb.TenantService - metaClient *meta.Client - log *zap.Logger -} - -func RunBackup(ctx context.Context, req Request, svc influxdb.BackupService, log *zap.Logger) error { - if err := os.MkdirAll(req.Path, 0777); err != nil { - return err - } - - var manifest influxdb.Manifest - runner := backupRunner{ - baseName: time.Now().UTC().Format(influxdb.BackupFilenamePattern), - backupSvc: svc, - log: log, - } - - manifest.KV.FileName = fmt.Sprintf("%s.bolt", runner.baseName) - kvPath := filepath.Join(req.Path, manifest.KV.FileName) - if err := runner.backupKV(ctx, kvPath); err != nil { - return err - } - - fi, err := os.Stat(kvPath) - if err != nil { - return fmt.Errorf("failed to inspect local KV backup at %q: %w", kvPath, err) - } - manifest.KV.Size = fi.Size() - - // Inspect the backed-up KV data so we can iterate through orgs & buckets. - kvStore := bolt.NewKVStore(runner.log, kvPath) - if err := kvStore.Open(ctx); err != nil { - return err - } - defer kvStore.Close() - - runner.tenantService = tenant.NewService(tenant.NewStore(kvStore)) - runner.metaClient = meta.NewClient(meta.NewConfig(), kvStore) - if err := runner.metaClient.Open(); err != nil { - return err - } - defer runner.metaClient.Close() - - manifest.Files, err = runner.findShards(ctx, req) - if err != nil { - return err - } - - for i := range manifest.Files { - if err := runner.backupShard(ctx, &manifest.Files[i], req); err != nil { - return err - } - } - - manifestPath := filepath.Join(req.Path, fmt.Sprintf("%s.manifest", runner.baseName)) - if err := runner.writeManifest(manifest, manifestPath); err != nil { - return fmt.Errorf("failed to write backup manfiest to %q: %w", manifestPath, err) - } - - log.Info("Backup complete", zap.String("path", req.Path)) - return nil -} - -func (r *backupRunner) backupKV(ctx context.Context, path string) error { - r.log.Info("Backing up KV store", zap.String("path", path)) - f, err := os.Create(path) - if err != nil { - return fmt.Errorf("failed to open local KV backup file at %q: %w", path, err) - } - - // Stream bolt file from server, sync, and ensure file closes correctly. - if err := r.backupSvc.BackupKVStore(ctx, f); err != nil { - _ = f.Close() - return fmt.Errorf("failed to download KV backup: %w", err) - } - if err := f.Sync(); err != nil { - _ = f.Close() - return fmt.Errorf("failed to flush KV backup to local disk: %w", err) - } - if err := f.Close(); err != nil { - return fmt.Errorf("failed to close local KV backup at %q: %w", path, err) - } - - return nil -} - -func (r *backupRunner) findShards(ctx context.Context, req Request) ([]influxdb.ManifestEntry, error) { - filter := influxdb.OrganizationFilter{} - if req.OrgID.Valid() { - filter.ID = &req.OrgID - } - if req.Org != "" { - filter.Name = &req.Org - } - - orgs, _, err := r.tenantService.FindOrganizations(ctx, filter) - if err != nil { - return nil, fmt.Errorf("failed to find matching organizations: %w", err) - } - - var entries []influxdb.ManifestEntry - for _, org := range orgs { - r.log.Info("Backing up organization", zap.String("id", org.ID.String()), zap.String("name", org.Name)) - oentries, err := r.findOrgShards(ctx, org, req) - if err != nil { - return nil, err - } - entries = append(entries, oentries...) - } - - return entries, nil -} - -func (r *backupRunner) findOrgShards(ctx context.Context, org *influxdb.Organization, req Request) ([]influxdb.ManifestEntry, error) { - filter := influxdb.BucketFilter{OrganizationID: &org.ID} - if req.BucketID.Valid() { - filter.ID = &req.BucketID - } - if req.Bucket != "" { - filter.Name = &req.Bucket - } - buckets, _, err := r.tenantService.FindBuckets(ctx, filter) - if err != nil { - return nil, fmt.Errorf("failed to find matching buckets: %w", err) - } - - var entries []influxdb.ManifestEntry - for _, bucket := range buckets { - r.log.Info("Backing up bucket", zap.String("id", bucket.ID.String()), zap.String("name", bucket.Name)) - - // Lookup matching database from the bucket. - dbi := r.metaClient.Database(bucket.ID.String()) - if dbi == nil { - return nil, fmt.Errorf("bucket database not found: %s", bucket.ID.String()) - } - - // Collect info for each shard in the DB. - for _, rpi := range dbi.RetentionPolicies { - for _, sg := range rpi.ShardGroups { - if sg.Deleted() { - continue - } - - for _, sh := range sg.Shards { - entries = append(entries, influxdb.ManifestEntry{ - OrganizationID: org.ID.String(), - OrganizationName: org.Name, - BucketID: bucket.ID.String(), - BucketName: bucket.Name, - ShardID: sh.ID, - }) - } - } - } - } - - return entries, nil -} - -func (r *backupRunner) backupShard(ctx context.Context, shardInfo *influxdb.ManifestEntry, req Request) error { - shardInfo.FileName = fmt.Sprintf("%s.s%d.tar.gz", r.baseName, shardInfo.ShardID) - path := filepath.Join(req.Path, shardInfo.FileName) - r.log.Info("Backing up shard", zap.Uint64("id", shardInfo.ShardID), zap.String("path", path)) - - f, err := os.Create(path) - if err != nil { - return fmt.Errorf("failed to open local shard backup at %q: %w", path, err) - } - gw := gzip.NewWriter(f) - - // Stream file from server, sync, and ensure file closes correctly. - if err := r.backupSvc.BackupShard(ctx, gw, shardInfo.ShardID, time.Time{}); err != nil { - _ = gw.Close() - _ = f.Close() - - if errors.ErrorCode(err) == errors.ENotFound { - r.log.Warn("Shard removed during backup", zap.Uint64("id", shardInfo.ShardID)) - return nil - } - return fmt.Errorf("failed to download shard backup: %w", err) - } - if err := gw.Close(); err != nil { - _ = f.Close() - return fmt.Errorf("failed to flush GZIP footer to local shard backup: %w", err) - } - if err := f.Sync(); err != nil { - _ = f.Close() - return fmt.Errorf("failed to flush shard backup to local disk: %w", err) - } - if err := f.Close(); err != nil { - return fmt.Errorf("failed to close local shard backup at %q: %w", path, err) - } - - // Use downloaded file's info to fill in remaining pieces of manifest. - fi, err := os.Stat(path) - if err != nil { - return fmt.Errorf("failed to inspect local shard backup at %q: %w", path, err) - } - shardInfo.Size = fi.Size() - shardInfo.LastModified = fi.ModTime().UTC() - - return nil -} - -func (r *backupRunner) writeManifest(manifest influxdb.Manifest, path string) error { - r.log.Info("Writing manifest", zap.String("path", path)) - - buf, err := json.MarshalIndent(manifest, "", " ") - if err != nil { - return err - } - buf = append(buf, '\n') - return ioutil.WriteFile(path, buf, 0600) -} diff --git a/cmd/influx/backup.go b/cmd/influx/backup.go deleted file mode 100644 index 9e294d996d..0000000000 --- a/cmd/influx/backup.go +++ /dev/null @@ -1,110 +0,0 @@ -package main - -import ( - "context" - "fmt" - - "github.com/influxdata/influxdb/v2/kit/platform" - - "github.com/influxdata/influxdb/v2/backup" - "github.com/influxdata/influxdb/v2/http" - influxlogger "github.com/influxdata/influxdb/v2/logger" - "github.com/spf13/cobra" -) - -func cmdBackup(f *globalFlags, opts genericCLIOpts) *cobra.Command { - return newCmdBackupBuilder(f, opts).cmdBackup() -} - -type cmdBackupBuilder struct { - genericCLIOpts - *globalFlags - - bucketID string - bucketName string - org organization - path string -} - -func newCmdBackupBuilder(f *globalFlags, opts genericCLIOpts) *cmdBackupBuilder { - return &cmdBackupBuilder{ - genericCLIOpts: opts, - globalFlags: f, - } -} - -func (b *cmdBackupBuilder) cmdBackup() *cobra.Command { - cmd := b.newCmd("backup", b.backupRunE) - b.org.register(b.viper, cmd, true) - cmd.Flags().StringVar(&b.bucketID, "bucket-id", "", "The ID of the bucket to backup") - cmd.Flags().StringVarP(&b.bucketName, "bucket", "b", "", "The name of the bucket to backup") - cmd.Use = "backup [flags] path" - cmd.Args = func(cmd *cobra.Command, args []string) error { - if len(args) == 0 { - return fmt.Errorf("must specify output path") - } else if len(args) > 1 { - return fmt.Errorf("too many args specified") - } - b.path = args[0] - return nil - } - cmd.Short = "Backup database" - cmd.Long = ` -Backs up InfluxDB to a directory. - -Examples: - # backup all data - influx backup /path/to/backup -` - return cmd -} - -func (b *cmdBackupBuilder) backupRunE(cmd *cobra.Command, _ []string) error { - // Create top level logger - logconf := influxlogger.NewConfig() - log, err := logconf.New(cmd.OutOrStdout()) - if err != nil { - return err - } - - ac := flags.config() - backupService := &http.BackupService{ - Addr: ac.Host, - Token: ac.Token, - InsecureSkipVerify: flags.skipVerify, - } - - var orgID platform.ID - if b.org.id != "" { - if err := orgID.DecodeFromString(b.org.id); err != nil { - return err - } - } - - var bucketID platform.ID - if b.bucketID != "" { - if err := bucketID.DecodeFromString(b.bucketID); err != nil { - return err - } - } - - req := backup.Request{ - OrgID: orgID, - Org: b.org.name, - BucketID: bucketID, - Bucket: b.bucketName, - Path: b.path, - } - - if err := backup.RunBackup(context.Background(), req, backupService, log); err != nil { - return err - } - return nil -} - -func (b *cmdBackupBuilder) newCmd(use string, runE func(*cobra.Command, []string) error) *cobra.Command { - cmd := b.genericCLIOpts.newCmd(use, runE, true) - b.genericCLIOpts.registerPrintOptions(cmd) - b.globalFlags.registerFlags(b.viper, cmd) - return cmd -} diff --git a/cmd/influx/main.go b/cmd/influx/main.go index 1bdb2fa4b7..8988527e21 100644 --- a/cmd/influx/main.go +++ b/cmd/influx/main.go @@ -325,7 +325,6 @@ func influxCmd(opts ...genericCLIOptFn) *cobra.Command { builder := newInfluxCmdBuilder(opts...) return builder.cmd( cmdAuth, - cmdBackup, cmdBucket, cmdConfig, cmdDashboard, @@ -334,7 +333,6 @@ func influxCmd(opts ...genericCLIOptFn) *cobra.Command { cmdOrganization, cmdPing, cmdQuery, - cmdRestore, cmdSecret, cmdSetup, cmdStack, diff --git a/cmd/influx/restore.go b/cmd/influx/restore.go deleted file mode 100644 index 7ca396be6d..0000000000 --- a/cmd/influx/restore.go +++ /dev/null @@ -1,145 +0,0 @@ -package main - -import ( - "context" - "errors" - "fmt" - "os" - - "github.com/influxdata/influxdb/v2/kit/platform" - - "github.com/influxdata/influxdb/v2/http" - influxlogger "github.com/influxdata/influxdb/v2/logger" - "github.com/influxdata/influxdb/v2/restore" - "github.com/influxdata/influxdb/v2/tenant" - "github.com/spf13/cobra" -) - -func cmdRestore(f *globalFlags, opts genericCLIOpts) *cobra.Command { - return newCmdRestoreBuilder(f, opts).cmdRestore() -} - -type cmdRestoreBuilder struct { - genericCLIOpts - *globalFlags - - full bool - bucketID string - bucketName string - newBucketName string - newOrgName string - org organization - path string -} - -func newCmdRestoreBuilder(f *globalFlags, opts genericCLIOpts) *cmdRestoreBuilder { - return &cmdRestoreBuilder{ - genericCLIOpts: opts, - globalFlags: f, - } -} - -func (b *cmdRestoreBuilder) cmdRestore() *cobra.Command { - cmd := b.newCmd("restore", b.restoreRunE) - b.org.register(b.viper, cmd, true) - cmd.Flags().BoolVar(&b.full, "full", false, "Fully restore and replace all data on server") - cmd.Flags().StringVar(&b.bucketID, "bucket-id", "", "The ID of the bucket to restore") - cmd.Flags().StringVarP(&b.bucketName, "bucket", "b", "", "The name of the bucket to restore") - cmd.Flags().StringVar(&b.newBucketName, "new-bucket", "", "The name of the bucket to restore to") - cmd.Flags().StringVar(&b.newOrgName, "new-org", "", "The name of the organization to restore to") - cmd.Flags().StringVar(&b.path, "input", "", "Local backup data path") - cmd.Flags().MarkDeprecated("input", "pass backup data path as a positional argument instead") - cmd.Use = "restore [flags] path" - cmd.Args = func(cmd *cobra.Command, args []string) error { - // Legacy: path set by --input flag. - if b.path != "" { - if len(args) != 0 { - return errors.New("cannot specify backup directory using both --input and a positional argument") - } - return nil - } - - if len(args) == 0 { - return errors.New("must specify path to backup directory") - } else if len(args) > 1 { - return errors.New("only one backup directory can be specified at a time") - } - b.path = args[0] - return nil - } - cmd.Short = "Restores a backup directory to InfluxDB." - cmd.Long = ` -Restore influxdb. - -Examples: - # restore all data - influx restore /path/to/restore -` - return cmd -} - -func (b *cmdRestoreBuilder) restoreRunE(cmd *cobra.Command, args []string) (err error) { - // Create top level logger - logconf := influxlogger.NewConfig() - logger, err := logconf.New(os.Stdout) - if err != nil { - return err - } - - // Ensure org/bucket filters are set if a new org/bucket name is specified. - if b.newOrgName != "" && b.org.id == "" && b.org.name == "" { - return fmt.Errorf("must specify source org id or name when renaming restored org") - } else if b.newBucketName != "" && b.bucketID == "" && b.bucketName == "" { - return fmt.Errorf("must specify source bucket id or name when renaming restored bucket") - } - - ac := flags.config() - client, err := newHTTPClient() - if err != nil { - return err - } - - services := restore.Services{ - RestoreService: &http.RestoreService{ - Addr: ac.Host, - Token: ac.Token, - InsecureSkipVerify: flags.skipVerify, - }, - OrgService: &tenant.OrgClientService{Client: client}, - BucketService: &tenant.BucketClientService{Client: client}, - } - - var orgID platform.ID - if b.org.id != "" { - if err := orgID.DecodeFromString(b.org.id); err != nil { - return err - } - } - - var bucketID platform.ID - if b.bucketID != "" { - if err := bucketID.DecodeFromString(b.bucketID); err != nil { - return err - } - } - - request := restore.Request{ - OrgID: orgID, - Org: b.org.name, - NewOrgName: b.newOrgName, - BucketID: bucketID, - Bucket: b.bucketName, - NewBucketName: b.newBucketName, - Path: b.path, - Full: b.full, - } - - return restore.RunRestore(context.Background(), request, services, logger) -} - -func (b *cmdRestoreBuilder) newCmd(use string, runE func(*cobra.Command, []string) error) *cobra.Command { - cmd := b.genericCLIOpts.newCmd(use, runE, true) - b.genericCLIOpts.registerPrintOptions(cmd) - b.globalFlags.registerFlags(b.viper, cmd) - return cmd -} diff --git a/cmd/influxd/launcher/backup_restore_test.go b/cmd/influxd/launcher/backup_restore_test.go index 70aee46a41..4ce07f2b76 100644 --- a/cmd/influxd/launcher/backup_restore_test.go +++ b/cmd/influxd/launcher/backup_restore_test.go @@ -2,15 +2,15 @@ package launcher_test import ( "context" - "github.com/influxdata/influxdb/v2/kit/platform/errors" "io/ioutil" "os" "testing" + "github.com/influxdata/influx-cli/v2/clients/backup" + "github.com/influxdata/influx-cli/v2/clients/restore" "github.com/influxdata/influxdb/v2" - "github.com/influxdata/influxdb/v2/backup" "github.com/influxdata/influxdb/v2/cmd/influxd/launcher" - "github.com/influxdata/influxdb/v2/restore" + "github.com/influxdata/influxdb/v2/kit/platform/errors" "github.com/stretchr/testify/require" "go.uber.org/zap" ) @@ -30,7 +30,7 @@ func TestBackupRestore_Full(t *testing.T) { o.LogLevel = zap.InfoLevel }) l1.WritePointsOrFail(t, "m,k=v1 f=100i 946684800000000000\nm,k=v2 f=200i 946684800000000001") - l1.BackupOrFail(t, ctx, backup.Request{Path: backupDir}) + l1.BackupOrFail(t, ctx, backup.Params{Path: backupDir}) // Create a new bucket, write data into it (+ the old bucket), and take another backup. b1 := influxdb.Bucket{OrgID: l1.Org.ID, Name: "bucket2"} @@ -41,7 +41,7 @@ func TestBackupRestore_Full(t *testing.T) { Auth: l1.Auth, }, "m,k=v1 f=100i 946684800000000005\nm,k=v2 f=200i 946684800000000006") l1.WritePointsOrFail(t, "m,k=v1 f=100i 946684800000000002\nm,k=v2 f=200i 946684800000000003") - l1.BackupOrFail(t, ctx, backup.Request{Path: backupDir}) + l1.BackupOrFail(t, ctx, backup.Params{Path: backupDir}) // Shut down the server. l1.ShutdownOrFail(t, ctx) @@ -77,7 +77,7 @@ func TestBackupRestore_Full(t *testing.T) { }, "m,k=v5 f=100i 946684800000000005\nm,k=v7 f=200i 946684800000000006") // Perform a full restore from the previous backups. - l2.RestoreOrFail(t, ctx, restore.Request{Path: backupDir, Full: true}) + l2.RestoreOrFail(t, ctx, restore.Params{Path: backupDir, Full: true}) // Check that orgs and buckets were reset to match the original server's metadata. _, err = l2.OrgService(t).FindOrganizationByID(ctx, l2.Org.ID) @@ -124,7 +124,7 @@ func TestBackupRestore_Partial(t *testing.T) { o.LogLevel = zap.InfoLevel }) l1.WritePointsOrFail(t, "m,k=v1 f=100i 946684800000000000\nm,k=v2 f=200i 946684800000000001") - l1.BackupOrFail(t, ctx, backup.Request{Path: backupDir}) + l1.BackupOrFail(t, ctx, backup.Params{Path: backupDir}) // Create a new bucket, write data into it (+ the old bucket), and take another backup. b1 := influxdb.Bucket{OrgID: l1.Org.ID, Name: "bucket2"} @@ -135,7 +135,7 @@ func TestBackupRestore_Partial(t *testing.T) { Auth: l1.Auth, }, "m,k=v1 f=100i 946684800000000005\nm,k=v2 f=200i 946684800000000006") l1.WritePointsOrFail(t, "m,k=v1 f=100i 946684800000000002\nm,k=v2 f=200i 946684800000000003") - l1.BackupOrFail(t, ctx, backup.Request{Path: backupDir}) + l1.BackupOrFail(t, ctx, backup.Params{Path: backupDir}) // Shut down the server. l1.ShutdownOrFail(t, ctx) @@ -170,7 +170,7 @@ func TestBackupRestore_Partial(t *testing.T) { }, "m,k=v5 f=100i 946684800000000005\nm,k=v7 f=200i 946684800000000006") // Perform a partial restore from the previous backups. - l2.RestoreOrFail(t, ctx, restore.Request{Path: backupDir}) + l2.RestoreOrFail(t, ctx, restore.Params{Path: backupDir}) // Check that buckets from the 1st launcher were restored to the new server. rbkt1, err := l2.BucketService(t).FindBucket(ctx, influxdb.BucketFilter{Org: &l1.Org.Name, Name: &l1.Bucket.Name}) diff --git a/cmd/influxd/launcher/launcher_helpers.go b/cmd/influxd/launcher/launcher_helpers.go index d85744515d..dd2bffdddb 100644 --- a/cmd/influxd/launcher/launcher_helpers.go +++ b/cmd/influxd/launcher/launcher_helpers.go @@ -6,6 +6,7 @@ import ( "fmt" "io/ioutil" nethttp "net/http" + "net/url" "os" "path/filepath" "reflect" @@ -15,8 +16,11 @@ import ( "github.com/influxdata/flux" "github.com/influxdata/flux/lang" + "github.com/influxdata/influx-cli/v2/api" + "github.com/influxdata/influx-cli/v2/clients" + clibackup "github.com/influxdata/influx-cli/v2/clients/backup" + clirestore "github.com/influxdata/influx-cli/v2/clients/restore" "github.com/influxdata/influxdb/v2" - "github.com/influxdata/influxdb/v2/backup" "github.com/influxdata/influxdb/v2/bolt" influxdbcontext "github.com/influxdata/influxdb/v2/context" dashboardTransport "github.com/influxdata/influxdb/v2/dashboards/transport" @@ -27,7 +31,6 @@ import ( "github.com/influxdata/influxdb/v2/pkg/httpc" "github.com/influxdata/influxdb/v2/pkger" "github.com/influxdata/influxdb/v2/query" - "github.com/influxdata/influxdb/v2/restore" "github.com/influxdata/influxdb/v2/sqlite" "github.com/influxdata/influxdb/v2/task/taskmodel" "github.com/influxdata/influxdb/v2/tenant" @@ -53,6 +56,7 @@ type TestLauncher struct { Auth *influxdb.Authorization httpClient *httpc.Client + apiClient *api.APIClient // Flag to act as standard server: disk store, no-e2e testing flag realServer bool @@ -95,12 +99,15 @@ func NewTestLauncherServer() *TestLauncher { } // URL returns the URL to connect to the HTTP server. -func (tl *TestLauncher) URL() string { - transport := "http" - if tl.Launcher.tlsEnabled { - transport = "https" +func (tl *TestLauncher) URL() *url.URL { + u := url.URL{ + Host: fmt.Sprintf("127.0.0.1:%d", tl.Launcher.httpPort), + Scheme: "http", } - return fmt.Sprintf("%s://127.0.0.1:%d", transport, tl.Launcher.httpPort) + if tl.Launcher.tlsEnabled { + u.Scheme = "https" + } + return &u } type OptSetter = func(o *InfluxdOpts) @@ -354,33 +361,29 @@ func (tl *TestLauncher) QueryFlux(tb testing.TB, org *influxdb.Organization, tok return string(b[:len(b)-1]) } -func (tl *TestLauncher) BackupOrFail(tb testing.TB, ctx context.Context, req backup.Request) { +func (tl *TestLauncher) BackupOrFail(tb testing.TB, ctx context.Context, req clibackup.Params) { tb.Helper() require.NoError(tb, tl.Backup(tb, ctx, req)) } -func (tl *TestLauncher) Backup(tb testing.TB, ctx context.Context, req backup.Request) error { +func (tl *TestLauncher) Backup(tb testing.TB, ctx context.Context, req clibackup.Params) error { tb.Helper() - return backup.RunBackup(ctx, req, tl.BackupService(tb), tl.log) + return tl.BackupService(tb).Backup(ctx, &req) } -func (tl *TestLauncher) RestoreOrFail(tb testing.TB, ctx context.Context, req restore.Request) { +func (tl *TestLauncher) RestoreOrFail(tb testing.TB, ctx context.Context, req clirestore.Params) { tb.Helper() require.NoError(tb, tl.Restore(tb, ctx, req)) } -func (tl *TestLauncher) Restore(tb testing.TB, ctx context.Context, req restore.Request) error { +func (tl *TestLauncher) Restore(tb testing.TB, ctx context.Context, req clirestore.Params) error { tb.Helper() - return restore.RunRestore(ctx, req, restore.Services{ - RestoreService: tl.RestoreService(tb), - BucketService: tl.BucketService(tb), - OrgService: tl.OrgService(tb), - }, tl.log) + return tl.RestoreService(tb).Restore(ctx, &req) } // MustNewHTTPRequest returns a new nethttp.Request with base URL and auth attached. Fail on error. func (tl *TestLauncher) MustNewHTTPRequest(method, rawurl, body string) *nethttp.Request { - req, err := nethttp.NewRequest(method, tl.URL()+rawurl, strings.NewReader(body)) + req, err := nethttp.NewRequest(method, tl.URL().String()+rawurl, strings.NewReader(body)) if err != nil { panic(err) } @@ -391,7 +394,7 @@ func (tl *TestLauncher) MustNewHTTPRequest(method, rawurl, body string) *nethttp // NewHTTPRequest returns a new nethttp.Request with base URL and auth attached. func (tl *TestLauncher) NewHTTPRequest(method, rawurl, token string, body string) (*nethttp.Request, error) { - req, err := nethttp.NewRequest(method, tl.URL()+rawurl, strings.NewReader(body)) + req, err := nethttp.NewRequest(method, tl.URL().String()+rawurl, strings.NewReader(body)) if err != nil { return nil, err } @@ -412,11 +415,11 @@ func (tl *TestLauncher) NewHTTPRequestOrFail(tb testing.TB, method, rawurl, toke // Services func (tl *TestLauncher) FluxService() *http.FluxService { - return &http.FluxService{Addr: tl.URL(), Token: tl.Auth.Token} + return &http.FluxService{Addr: tl.URL().String(), Token: tl.Auth.Token} } func (tl *TestLauncher) FluxQueryService() *http.FluxQueryService { - return &http.FluxQueryService{Addr: tl.URL(), Token: tl.Auth.Token} + return &http.FluxQueryService{Addr: tl.URL().String(), Token: tl.Auth.Token} } func (tl *TestLauncher) BucketService(tb testing.TB) *tenant.BucketClientService { @@ -477,14 +480,15 @@ func (tl *TestLauncher) TaskService(tb testing.TB) taskmodel.TaskService { return &http.TaskService{Client: tl.HTTPClient(tb)} } -func (tl *TestLauncher) BackupService(tb testing.TB) influxdb.BackupService { +func (tl *TestLauncher) BackupService(tb testing.TB) *clibackup.Client { tb.Helper() - return &http.BackupService{Addr: tl.URL(), Token: tl.Auth.Token} + return &clibackup.Client{CLI: clients.CLI{}, BackupApi: tl.APIClient(tb).BackupApi} } -func (tl *TestLauncher) RestoreService(tb testing.TB) influxdb.RestoreService { +func (tl *TestLauncher) RestoreService(tb testing.TB) *clirestore.Client { tb.Helper() - return &http.RestoreService{Addr: tl.URL(), Token: tl.Auth.Token} + client := tl.APIClient(tb) + return &clirestore.Client{CLI: clients.CLI{}, RestoreApi: client.RestoreApi, OrganizationsApi: client.OrganizationsApi} } func (tl *TestLauncher) HTTPClient(tb testing.TB) *httpc.Client { @@ -495,7 +499,7 @@ func (tl *TestLauncher) HTTPClient(tb testing.TB) *httpc.Client { if tl.Auth != nil { token = tl.Auth.Token } - client, err := http.NewHTTPClient(tl.URL(), token, false) + client, err := http.NewHTTPClient(tl.URL().String(), token, false) if err != nil { tb.Fatal(err) } @@ -504,6 +508,22 @@ func (tl *TestLauncher) HTTPClient(tb testing.TB) *httpc.Client { return tl.httpClient } +func (tl *TestLauncher) APIClient(tb testing.TB) *api.APIClient { + tb.Helper() + + if tl.apiClient == nil { + params := api.ConfigParams{ + Host: tl.URL(), + } + if tl.Auth != nil { + params.Token = &tl.Auth.Token + } + tl.apiClient = api.NewAPIClient(api.NewAPIConfig(params)) + } + + return tl.apiClient +} + func (tl *TestLauncher) Metrics(tb testing.TB) (metrics map[string]*dto.MetricFamily) { req := tl.HTTPClient(tb). Get("/metrics"). diff --git a/cmd/influxd/launcher/launcher_test.go b/cmd/influxd/launcher/launcher_test.go index e3bb964abe..fa146a4a61 100644 --- a/cmd/influxd/launcher/launcher_test.go +++ b/cmd/influxd/launcher/launcher_test.go @@ -22,7 +22,7 @@ func TestLauncher_Setup(t *testing.T) { l.RunOrFail(t, ctx) defer l.ShutdownOrFail(t, ctx) - client, err := http.NewHTTPClient(l.URL(), "", false) + client, err := http.NewHTTPClient(l.URL().String(), "", false) if err != nil { t.Fatal(err) } @@ -52,7 +52,7 @@ func TestLauncher_SetupWithUsers(t *testing.T) { l := launcher.RunAndSetupNewLauncherOrFail(ctx, t) defer l.ShutdownOrFail(t, ctx) - r, err := nethttp.NewRequest("POST", l.URL()+"/api/v2/signin", nil) + r, err := nethttp.NewRequest("POST", l.URL().String()+"/api/v2/signin", nil) if err != nil { t.Fatal(err) } @@ -107,7 +107,7 @@ func TestLauncher_SetupWithUsers(t *testing.T) { t.Fatalf("unexpected status code: %d, body: %s, headers: %v", resp.StatusCode, body, resp.Header) } - r, err = nethttp.NewRequest("GET", l.URL()+"/api/v2/users", nil) + r, err = nethttp.NewRequest("GET", l.URL().String()+"/api/v2/users", nil) if err != nil { t.Fatal(err) } diff --git a/cmd/influxd/launcher/storage_test.go b/cmd/influxd/launcher/storage_test.go index 8c481ea4f5..02d7ff82ee 100644 --- a/cmd/influxd/launcher/storage_test.go +++ b/cmd/influxd/launcher/storage_test.go @@ -172,7 +172,7 @@ func TestLauncher_DeleteWithPredicate(t *testing.T) { // Execute single write against the server. s := http.DeleteService{ - Addr: l.URL(), + Addr: l.URL().String(), Token: l.Auth.Token, } if err := s.DeleteBucketRangePredicate(context.Background(), http.DeleteRequest{ diff --git a/cmd/influxd/upgrade/upgrade_test.go b/cmd/influxd/upgrade/upgrade_test.go index c349e02db1..6871387684 100644 --- a/cmd/influxd/upgrade/upgrade_test.go +++ b/cmd/influxd/upgrade/upgrade_test.go @@ -6,7 +6,6 @@ import ( "fmt" "io/ioutil" "net/http" - "net/url" "os" "path/filepath" "testing" @@ -345,8 +344,8 @@ func TestUpgradeRealDB(t *testing.T) { } func mustRunQuery(t *testing.T, tl *launcher.TestLauncher, db, rawQ, token string) string { - queryUrl, err := url.Parse(tl.URL() + "/query") - require.Nil(t, err) + queryUrl := *tl.URL() + queryUrl.Path = "/query" params := queryUrl.Query() params.Set("db", db) diff --git a/go.mod b/go.mod index 99d2a4f519..d3962de26f 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/editorconfig-checker/editorconfig-checker v0.0.0-20190819115812-1474bdeaf2a2 github.com/elazarl/go-bindata-assetfs v1.0.0 github.com/fatih/color v1.9.0 - github.com/fujiwara/shapeio v0.0.0-20170602072123-c073257dd745 + github.com/fujiwara/shapeio v1.0.0 github.com/getkin/kin-openapi v0.53.0 github.com/ghodss/yaml v1.0.0 github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 // indirect @@ -32,11 +32,11 @@ require ( github.com/go-stack/stack v1.8.0 github.com/gogo/protobuf v1.3.1 github.com/golang/gddo v0.0.0-20181116215533-9bd4a3295021 - github.com/golang/mock v1.4.4 + github.com/golang/mock v1.5.0 github.com/golang/protobuf v1.3.3 github.com/golang/snappy v0.0.1 github.com/google/btree v1.0.0 - github.com/google/go-cmp v0.5.4 + github.com/google/go-cmp v0.5.5 github.com/google/go-github v17.0.0+incompatible github.com/google/go-jsonnet v0.14.0 github.com/google/go-querystring v1.0.0 // indirect @@ -49,6 +49,7 @@ require ( github.com/influxdata/cron v0.0.0-20191203200038-ded12750aac6 github.com/influxdata/flux v0.118.1 github.com/influxdata/httprouter v1.3.1-0.20191122104820-ee83e2772f69 + github.com/influxdata/influx-cli/v2 v2.0.0-20210616152201-0ee555c6a73e github.com/influxdata/influxql v0.0.0-20180925231337-1cbfca8e56b6 github.com/influxdata/pkg-config v0.2.7 github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368 @@ -100,16 +101,16 @@ require ( golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad golang.org/x/net v0.0.0-20210119194325-5f4716e94777 golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d - golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 + golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c golang.org/x/text v0.3.5 golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba - golang.org/x/tools v0.0.0-20200721032237-77f530d86f9a + golang.org/x/tools v0.1.0 google.golang.org/api v0.17.0 gopkg.in/vmihailenco/msgpack.v2 v2.9.1 // indirect gopkg.in/yaml.v2 v2.3.0 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c - honnef.co/go/tools v0.0.1-2020.1.4 + honnef.co/go/tools v0.1.3 labix.org/v2/mgo v0.0.0-20140701140051-000000000287 // indirect ) diff --git a/go.sum b/go.sum index 06bc578778..cb0f39783e 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,8 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy cloud.google.com/go/storage v1.5.0 h1:RPUcBvDeYgQFMfQu1eBMq6piD1SXmLH+vK3qjewZPus= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/AlecAivazis/survey/v2 v2.2.9 h1:LWvJtUswz/W9/zVVXELrmlvdwWcKE60ZAw0FWV9vssk= +github.com/AlecAivazis/survey/v2 v2.2.9/go.mod h1:9DYvHgXtiXm6nCn+jXnOXLKbH+Yo9u8fAS/SduGdoPk= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest v0.9.3/go.mod h1:GsRuLYvwzLjjjRoWEIyMUaYq8GNUx2nRB378IPt/1p0= @@ -57,6 +59,7 @@ github.com/DATA-DOG/go-sqlmock v1.4.1 h1:ThlnYciV1iM/V0OSF/dtkqWb6xo5qITT1TJBG1M github.com/DATA-DOG/go-sqlmock v1.4.1/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/HdrHistogram/hdrhistogram-go v1.1.0 h1:6dpdDPTRoo78HxAJ6T1HfMiKSnqhgRRqzCuPshRkQ7I= github.com/HdrHistogram/hdrhistogram-go v1.1.0/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= +github.com/MakeNowJust/heredoc/v2 v2.0.1/go.mod h1:6/2Abh5s+hc3g9nbWLe9ObDIOhaRrqsyY9MWy+4JdRM= github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc= github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/sprig v2.16.0+incompatible h1:QZbMUPxRQ50EKAq3LFMnxddMu88/EUUG3qmxwtDmPsY= @@ -67,6 +70,8 @@ github.com/Microsoft/go-winio v0.4.11 h1:zoIOcVf0xPN1tnMVbTtEdI+P8OofVk3NObnwOQ6 github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= github.com/NYTimes/gziphandler v1.0.1 h1:iLrQrdwjDd52kHDA5op2UBJFjmOb9g+7scBan4RN8F0= github.com/NYTimes/gziphandler v1.0.1/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= +github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8 h1:xzYJEypr/85nBpB11F9br+3HUrpgb+fcm5iADzXXYEw= +github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -127,9 +132,12 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= +github.com/daixiang0/gci v0.2.8/go.mod h1:+4dZ7TISfSmqfAGv59ePaHfNzgGtIkHAhhdKggP1JAc= github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -175,8 +183,8 @@ github.com/foxcpp/go-mockdns v0.0.0-20201212160233-ede2f9158d15 h1:nLPjjvpUAODOR github.com/foxcpp/go-mockdns v0.0.0-20201212160233-ede2f9158d15/go.mod h1:tPg4cp4nseejPd+UKxtCVQ2hUxNTZ7qQZJa7CLriIeo= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fujiwara/shapeio v0.0.0-20170602072123-c073257dd745 h1:+tPNWeI7Uk5JKgSj4IYytZc0mdch+e3Yf8g1sGOg4hQ= -github.com/fujiwara/shapeio v0.0.0-20170602072123-c073257dd745/go.mod h1:/WpqsrSkjgwEG2Es2qnZXbXwHDVbawpdlXJIjJMmnZs= +github.com/fujiwara/shapeio v1.0.0 h1:xG5D9oNqCSUUbryZ/jQV3cqe1v2suEjwPIcEg1gKM8M= +github.com/fujiwara/shapeio v1.0.0/go.mod h1:LmEmu6L/8jetyj1oewewFb7bZCNRwE7wLCUNzDLaLVA= github.com/getkin/kin-openapi v0.53.0 h1:7WzP+MZRRe7YQz2Kc74Ley3dukJmXDvifVbElGmQfoA= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= @@ -205,6 +213,7 @@ github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/gocarina/gocsv v0.0.0-20210408192840-02d7211d929d/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI= github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84= github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -229,8 +238,8 @@ github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4er github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.5.0 h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g= +github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -249,8 +258,9 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-jsonnet v0.14.0 h1:as/sAfmjOHqY/OMBR4mv9I8ZY0/jNuqN3u44AicwxPs= @@ -321,6 +331,8 @@ github.com/hashicorp/vault/sdk v0.1.8 h1:pfF3KwA1yPlfpmcumNsFM4uo91WMasX5gTuIkIt github.com/hashicorp/vault/sdk v0.1.8/go.mod h1:tHZfc6St71twLizWNHvnnbiGFo1aq0eD2jGPLtP8kAU= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDGgJGQpNflI3+MJSBhsgT5PCtzBQ= +github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.0.0 h1:pO2K/gKgKaat5LdpAhxhluX2GPQMaI3W5FUz/I/UnWk= @@ -337,6 +349,8 @@ github.com/influxdata/flux v0.118.1 h1:Wa/h3+WCB1ngAE9j9BiykSMQ/RpCDFIzccccBd9kH github.com/influxdata/flux v0.118.1/go.mod h1:d0Asx5xusUbp2d32ikmXMAiBabs5EFzz4yp1ykgE60U= github.com/influxdata/httprouter v1.3.1-0.20191122104820-ee83e2772f69 h1:WQsmW0fXO4ZE/lFGIE84G6rIV5SJN3P3sjIXAP1a8eU= github.com/influxdata/httprouter v1.3.1-0.20191122104820-ee83e2772f69/go.mod h1:pwymjR6SrP3gD3pRj9RJwdl1j5s3doEEV8gS4X9qSzA= +github.com/influxdata/influx-cli/v2 v2.0.0-20210616152201-0ee555c6a73e h1:ytGdXUwL4HMERtBH+FqLABWcAfaxmx4lT2o5ScepM8M= +github.com/influxdata/influx-cli/v2 v2.0.0-20210616152201-0ee555c6a73e/go.mod h1:A+JS4qejFQBmcfJIrYHVGejDcEOlcMVbCz4up86lAQ8= github.com/influxdata/influxdb-client-go/v2 v2.3.1-0.20210518120617-5d1fff431040 h1:MBLCfcSsUyFPDJp6T7EoHp/Ph3Jkrm4EuUKLD2rUWHg= github.com/influxdata/influxdb-client-go/v2 v2.3.1-0.20210518120617-5d1fff431040/go.mod h1:vLNHdxTJkIf2mSLvGrpj8TCcISApPoXkaxP8g9uRlW8= github.com/influxdata/influxql v0.0.0-20180925231337-1cbfca8e56b6 h1:CFx+pP90q/qg3spoiZjf8donE4WpAdjeJfPOcoNqkWo= @@ -372,6 +386,8 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef h1:2jNeR4YUziVtswNP9sEFAI913cVrzH85T+8Q6LpYbT0= github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kevinburke/go-bindata v3.22.0+incompatible h1:/JmqEhIWQ7GRScV0WjX/0tqBrC5D21ALg0H0U/KZ/ts= github.com/kevinburke/go-bindata v3.22.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= @@ -381,6 +397,8 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.4 h1:5Myjjh3JY/NaAi4IsUbHADytDyl1VE1Y9PXDlL+P/VQ= +github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= @@ -426,6 +444,8 @@ github.com/mattn/go-tty v0.0.0-20180907095812-13ff1204f104 h1:d8RFOZ2IiFtFWBcKEH github.com/mattn/go-tty v0.0.0-20180907095812-13ff1204f104/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= +github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/miekg/dns v1.1.22 h1:Jm64b3bO9kP43ddLjL2EY3Io6bmy1qGb9Xxz6TqS6rc= github.com/miekg/dns v1.1.22/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/mileusna/useragent v0.0.0-20190129205925-3e331f0949a5 h1:pXqZHmHOz6LN+zbbUgqyGgAWRnnZEI40IzG3tMsXcSI= @@ -519,6 +539,7 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk= @@ -530,6 +551,7 @@ github.com/segmentio/kafka-go v0.1.0 h1:IXCHG+sXPNiIR5pC/vTEItZduPKu4cnpr85Ygxpx github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -564,6 +586,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -590,6 +613,8 @@ github.com/uber/jaeger-client-go v2.28.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMW github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg= github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= +github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= @@ -606,6 +631,7 @@ github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDf github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI= github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= @@ -638,6 +664,7 @@ golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -706,6 +733,7 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210119194325-5f4716e94777 h1:003p0dJM77cxMSyCPFphvZf/Y5/NXf5fzg6ufd1/Oew= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -720,8 +748,9 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -738,6 +767,7 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190530182044-ad28b68e88f1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -757,7 +787,9 @@ golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= @@ -814,8 +846,10 @@ golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200304024140-c4206d458c3f/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200721032237-77f530d86f9a h1:kVMPw4f6EVqYdfGQTedjrpw1dbE2PEMfw4jwXsNdn9s= golang.org/x/tools v0.0.0-20200721032237-77f530d86f9a/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20201118003311-bd56c0adb394/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -897,6 +931,7 @@ gopkg.in/vmihailenco/msgpack.v2 v2.9.1/go.mod h1:/3Dn1Npt9+MYyLpYYXjInO/5jvMLamn gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= @@ -911,8 +946,8 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.1.3 h1:qTakTkI6ni6LFD5sBwwsdSO+AQqbSIxOauHTTQKZ/7o= +honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= labix.org/v2/mgo v0.0.0-20140701140051-000000000287 h1:L0cnkNl4TfAXzvdrqsYEmxOHOCv2p5I3taaReO8BWFs= labix.org/v2/mgo v0.0.0-20140701140051-000000000287/go.mod h1:Lg7AYkt1uXJoR9oeSZ3W/8IXLdvOfIITgZnommstyz4= rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE= diff --git a/http/backup_service.go b/http/backup_service.go index 00c1d20890..b7802ecb3e 100644 --- a/http/backup_service.go +++ b/http/backup_service.go @@ -1,12 +1,10 @@ package http import ( - "context" "fmt" "io" "mime/multipart" "net/http" - "net/url" "strconv" "time" @@ -58,8 +56,6 @@ const ( backupKVStorePath = prefixBackup + "/kv" backupShardPath = prefixBackup + "/shards/:shardID" backupMetadataPath = prefixBackup + "/metadata" - - httpClientTimeout = time.Hour ) // NewBackupHandler creates a new handler at /api/v2/backup to receive backup requests. @@ -202,85 +198,3 @@ func (h *BackupHandler) handleBackupMetadata(w http.ResponseWriter, r *http.Requ return } } - -// BackupService is the client implementation of influxdb.BackupService. -type BackupService struct { - Addr string - Token string - InsecureSkipVerify bool -} - -func (s *BackupService) BackupKVStore(ctx context.Context, w io.Writer) error { - span, ctx := tracing.StartSpanFromContext(ctx) - defer span.Finish() - - u, err := NewURL(s.Addr, prefixBackup+"/kv") - if err != nil { - return err - } - - req, err := http.NewRequest(http.MethodGet, u.String(), nil) - if err != nil { - return err - } - SetToken(s.Token, req) - req = req.WithContext(ctx) - - hc := NewClient(u.Scheme, s.InsecureSkipVerify) - hc.Timeout = httpClientTimeout - resp, err := hc.Do(req) - if err != nil { - return err - } - defer resp.Body.Close() - - if err := CheckError(resp); err != nil { - return err - } - - if _, err := io.Copy(w, resp.Body); err != nil { - return err - } - return resp.Body.Close() -} - -func (s *BackupService) BackupShard(ctx context.Context, w io.Writer, shardID uint64, since time.Time) error { - span, ctx := tracing.StartSpanFromContext(ctx) - defer span.Finish() - - u, err := NewURL(s.Addr, fmt.Sprintf(prefixBackup+"/shards/%d", shardID)) - if err != nil { - return err - } - if !since.IsZero() { - u.RawQuery = (url.Values{"since": {since.UTC().Format(time.RFC3339)}}).Encode() - } - - req, err := http.NewRequest(http.MethodGet, u.String(), nil) - if err != nil { - return err - } - SetToken(s.Token, req) - req = req.WithContext(ctx) - - hc := NewClient(u.Scheme, s.InsecureSkipVerify) - hc.Timeout = httpClientTimeout - resp, err := hc.Do(req) - if err != nil { - return err - } - defer resp.Body.Close() - - if err := CheckError(resp); err != nil { - return err - } - - if _, err := io.Copy(w, resp.Body); err != nil { - return err - } - return resp.Body.Close() -} - -// LockKVStore & UnlockKVStore are not implemented for the client. -func (s *BackupService) LockKVStore() {} -func (s *BackupService) UnlockKVStore() {} diff --git a/http/client.go b/http/client.go index ffdc51973a..c8bdbe58d4 100644 --- a/http/client.go +++ b/http/client.go @@ -42,7 +42,6 @@ type Service struct { Token string InsecureSkipVerify bool - *BackupService *TaskService *NotificationRuleService *VariableService @@ -68,12 +67,8 @@ type Service struct { // in the behavior of the returned service. func NewService(httpClient *httpc.Client, addr, token string) (*Service, error) { return &Service{ - Addr: addr, - Token: token, - BackupService: &BackupService{ - Addr: addr, - Token: token, - }, + Addr: addr, + Token: token, TaskService: &TaskService{Client: httpClient}, NotificationRuleService: &NotificationRuleService{Client: httpClient}, VariableService: &VariableService{Client: httpClient}, diff --git a/http/query_handler.go b/http/query_handler.go index 0dadd8bee6..dad69d3ab3 100644 --- a/http/query_handler.go +++ b/http/query_handler.go @@ -520,14 +520,12 @@ func (s FluxQueryService) Check(ctx context.Context) check.Response { } // GetQueryResponse runs a flux query with common parameters and returns the response from the query service. -func GetQueryResponse(qr *QueryRequest, addr, org, token string, headers ...string) (*http.Response, error) { +func GetQueryResponse(qr *QueryRequest, addr *url.URL, org, token string, headers ...string) (*http.Response, error) { if len(headers)%2 != 0 { return nil, fmt.Errorf("headers must be key value pairs") } - u, err := NewURL(addr, prefixQuery) - if err != nil { - return nil, err - } + u := *addr + u.Path = prefixQuery params := url.Values{} params.Set(Org, org) u.RawQuery = params.Encode() @@ -568,7 +566,7 @@ func GetQueryResponseBody(res *http.Response) ([]byte, error) { } // SimpleQuery runs a flux query with common parameters and returns CSV results. -func SimpleQuery(addr, flux, org, token string, headers ...string) ([]byte, error) { +func SimpleQuery(addr *url.URL, flux, org, token string, headers ...string) ([]byte, error) { header := true qr := &QueryRequest{ Type: "flux", diff --git a/http/restore_service.go b/http/restore_service.go index 9402152bee..0d7ec87449 100644 --- a/http/restore_service.go +++ b/http/restore_service.go @@ -1,18 +1,14 @@ package http import ( - "bytes" "compress/gzip" - "context" "encoding/json" - "fmt" "io" "io/ioutil" "net/http" "strconv" "time" - "github.com/influxdata/influxdb/v2/kit/platform" "github.com/influxdata/influxdb/v2/kit/platform/errors" kithttp "github.com/influxdata/influxdb/v2/kit/transport/http" "github.com/influxdata/influxdb/v2/v1/services/meta" @@ -352,107 +348,3 @@ func (h *RestoreHandler) handleRestoreShard(w http.ResponseWriter, r *http.Reque return } } - -// RestoreService is the client implementation of influxdb.RestoreService. -type RestoreService struct { - Addr string - Token string - InsecureSkipVerify bool -} - -func (s *RestoreService) RestoreKVStore(ctx context.Context, r io.Reader) error { - span, ctx := tracing.StartSpanFromContext(ctx) - defer span.Finish() - - u, err := NewURL(s.Addr, restoreKVPath) - if err != nil { - return err - } - - req, err := http.NewRequest(http.MethodPost, u.String(), r) - if err != nil { - return err - } - SetToken(s.Token, req) - req = req.WithContext(ctx) - - hc := NewClient(u.Scheme, s.InsecureSkipVerify) - hc.Timeout = httpClientTimeout - resp, err := hc.Do(req) - if err != nil { - return err - } - defer resp.Body.Close() - - if err := CheckError(resp); err != nil { - return err - } - - return nil -} - -func (s *RestoreService) RestoreBucket(ctx context.Context, id platform.ID, dbi []byte) (map[uint64]uint64, error) { - span, ctx := tracing.StartSpanFromContext(ctx) - defer span.Finish() - - u, err := NewURL(s.Addr, prefixRestore+fmt.Sprintf("/buckets/%s", id.String())) - if err != nil { - return nil, err - } - - req, err := http.NewRequest(http.MethodPost, u.String(), bytes.NewReader(dbi)) - if err != nil { - return nil, err - } - SetToken(s.Token, req) - req = req.WithContext(ctx) - - hc := NewClient(u.Scheme, s.InsecureSkipVerify) - hc.Timeout = httpClientTimeout - resp, err := hc.Do(req) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - if err := CheckError(resp); err != nil { - return nil, err - } - - shardIDMap := make(map[uint64]uint64) - if err := json.NewDecoder(resp.Body).Decode(&shardIDMap); err != nil { - return nil, err - } - return shardIDMap, nil -} - -func (s *RestoreService) RestoreShard(ctx context.Context, shardID uint64, r io.Reader) error { - span, ctx := tracing.StartSpanFromContext(ctx) - defer span.Finish() - - u, err := NewURL(s.Addr, fmt.Sprintf(prefixRestore+"/shards/%d", shardID)) - if err != nil { - return err - } - - req, err := http.NewRequest(http.MethodPost, u.String(), r) - if err != nil { - return err - } - SetToken(s.Token, req) - req = req.WithContext(ctx) - - hc := NewClient(u.Scheme, s.InsecureSkipVerify) - hc.Timeout = httpClientTimeout - resp, err := hc.Do(req) - if err != nil { - return err - } - defer resp.Body.Close() - - if err := CheckError(resp); err != nil { - return err - } - - return nil -} diff --git a/internal/cmd/fluxtest-harness-influxdb/test.go b/internal/cmd/fluxtest-harness-influxdb/test.go index ff3545b25d..159421e755 100644 --- a/internal/cmd/fluxtest-harness-influxdb/test.go +++ b/internal/cmd/fluxtest-harness-influxdb/test.go @@ -121,7 +121,7 @@ func (t *testExecutor) Run(pkg *ast.Package) error { // TODO(nathanielc): When the executor is given access to the test name, // make the configName a function of the test name. configName := "flux-test" - err := createInfluxDBConfig(t.ctx, configName, t.l.URL(), t.l.Org.Name, t.l.Auth.Token) + err := createInfluxDBConfig(t.ctx, configName, t.l.URL().String(), t.l.Org.Name, t.l.Auth.Token) if err != nil { return err } diff --git a/restore/restore.go b/restore/restore.go deleted file mode 100644 index ee9bcc7eff..0000000000 --- a/restore/restore.go +++ /dev/null @@ -1,347 +0,0 @@ -package restore - -import ( - "compress/gzip" - "context" - "encoding/json" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "sort" - "strings" - - "github.com/influxdata/influxdb/v2/kit/platform" - "github.com/influxdata/influxdb/v2/kit/platform/errors" - - "github.com/influxdata/influxdb/v2" - "github.com/influxdata/influxdb/v2/bolt" - "github.com/influxdata/influxdb/v2/tenant" - "github.com/influxdata/influxdb/v2/v1/services/meta" - "go.uber.org/zap" -) - -type Request struct { - // Path to local backup data created using `influx backup` - Path string - - // Original ID/name of the organization to restore. - // If not set, all orgs will be restored. - OrgID platform.ID - Org string - - // New name to use for the restored organization. - // If not set, the org will be restored using its backed-up name. - NewOrgName string - - // Original ID/name of the bucket to restore. - // If not set, all buckets within the org filter will be restored. - BucketID platform.ID - Bucket string - - // New name to use for the restored bucket. - // If not set, the bucket will be restored using its backed-up name. - NewBucketName string - - // If true, replace all data on the server with the local backup. - // Otherwise only restore the requested org/bucket, leaving other data untouched. - Full bool -} - -type Services struct { - RestoreService influxdb.RestoreService - OrgService influxdb.OrganizationService - BucketService influxdb.BucketService -} - -type restoreRunner struct { - Services - - kvManifest *influxdb.ManifestKVEntry - shardManifests map[uint64]*influxdb.ManifestEntry - - tenantService influxdb.TenantService - metaClient *meta.Client - log *zap.Logger -} - -func RunRestore(ctx context.Context, req Request, svcs Services, log *zap.Logger) error { - runner := restoreRunner{ - Services: svcs, - log: log, - } - - if err := runner.loadManifests(req.Path); err != nil { - return err - } - - if req.Full { - return runner.fullRestore(ctx, req) - } - return runner.partialRestore(ctx, req) -} - -func (r *restoreRunner) loadManifests(path string) error { - // Read all manifest files from path, sort in descending time. - manifests, err := filepath.Glob(filepath.Join(path, "*.manifest")) - if err != nil { - return fmt.Errorf("failed to find backup manifests at %q: %w", path, err) - } else if len(manifests) == 0 { - return fmt.Errorf("no backup manifests found at %q", path) - } - sort.Sort(sort.Reverse(sort.StringSlice(manifests))) - - r.shardManifests = make(map[uint64]*influxdb.ManifestEntry) - for _, filename := range manifests { - // Skip file if it is a directory. - if fi, err := os.Stat(filename); err != nil { - return fmt.Errorf("failed to inspect local manifest at %q: %w", filename, err) - } else if fi.IsDir() { - continue - } - - // Read manifest file for backup. - var manifest influxdb.Manifest - if buf, err := ioutil.ReadFile(filename); err != nil { - return fmt.Errorf("failed to read local manifest at %q: %w", filename, err) - } else if err := json.Unmarshal(buf, &manifest); err != nil { - return fmt.Errorf("read manifest: %v", err) - } - - // Save latest KV entry (first in the sorted slice). - if r.kvManifest == nil { - r.kvManifest = &manifest.KV - } - - // Load most recent backup per shard. - for i := range manifest.Files { - sh := manifest.Files[i] - if _, err := os.Stat(filepath.Join(path, sh.FileName)); err != nil { - continue - } - - entry := r.shardManifests[sh.ShardID] - if entry == nil || sh.LastModified.After(entry.LastModified) { - r.shardManifests[sh.ShardID] = &sh - } - } - } - - return nil -} - -func (r *restoreRunner) fullRestore(ctx context.Context, req Request) error { - if err := r.restoreKV(ctx, req.Path); err != nil { - return err - } - - for _, m := range r.shardManifests { - if err := r.restoreShard(ctx, req.Path, m); err != nil { - return err - } - } - - r.log.Info("Full restore complete", zap.String("path", req.Path)) - return nil -} - -func (r *restoreRunner) partialRestore(ctx context.Context, req Request) error { - // Open meta store so we can iterate over metadata. - kvStore := bolt.NewKVStore(r.log, filepath.Join(req.Path, r.kvManifest.FileName)) - if err := kvStore.Open(ctx); err != nil { - return err - } - defer kvStore.Close() - - r.tenantService = tenant.NewService(tenant.NewStore(kvStore)) - r.metaClient = meta.NewClient(meta.NewConfig(), kvStore) - if err := r.metaClient.Open(); err != nil { - return err - } - defer r.metaClient.Close() - - if err := r.restoreOrganizations(ctx, req); err != nil { - return err - } - - r.log.Info("Partial restore complete", zap.String("path", req.Path)) - return nil -} - -func (r *restoreRunner) restoreKV(ctx context.Context, path string) error { - kvPath := filepath.Join(path, r.kvManifest.FileName) - r.log.Info("Restoring full metadata from local backup", zap.String("path", kvPath)) - - f, err := os.Open(kvPath) - if err != nil { - return fmt.Errorf("failed to open local KV backup at %q: %w", kvPath, err) - } - defer f.Close() - - if err := r.RestoreService.RestoreKVStore(ctx, f); err != nil { - return fmt.Errorf("failed to upload local KV backup at %q: %w", kvPath, err) - } - - r.log.Info("Full metadata restored", zap.String("path", kvPath)) - return nil -} - -func (r *restoreRunner) restoreShard(ctx context.Context, path string, manifest *influxdb.ManifestEntry) error { - shardPath := filepath.Join(path, manifest.FileName) - r.log.Info("Restoring shard from local backup", zap.Uint64("id", manifest.ShardID), zap.String("path", shardPath)) - - f, err := os.Open(shardPath) - if err != nil { - return fmt.Errorf("failed to open local shard backup at %q: %w", shardPath, err) - } - defer f.Close() - - gr, err := gzip.NewReader(f) - if err != nil { - return fmt.Errorf("failed to open gzip reader for local shard backup: %w", err) - } - defer gr.Close() - - if err := r.RestoreService.RestoreShard(ctx, manifest.ShardID, gr); err != nil { - return fmt.Errorf("failed to upload local shard backup at %q: %w", shardPath, err) - } - return nil -} - -func (r *restoreRunner) restoreOrganizations(ctx context.Context, req Request) error { - var filter influxdb.OrganizationFilter - if req.OrgID.Valid() { - filter.ID = &req.OrgID - } - if req.Org != "" { - filter.Name = &req.Org - } - - orgs, _, err := r.tenantService.FindOrganizations(ctx, filter) - if err != nil { - return err - } - - for _, org := range orgs { - if err := r.restoreOrganization(ctx, org, req); err != nil { - return err - } - } - - return nil -} - -func (r *restoreRunner) restoreOrganization(ctx context.Context, org *influxdb.Organization, req Request) error { - newOrg := *org - if req.NewOrgName != "" { - newOrg.Name = req.NewOrgName - } - r.log.Info( - "Restoring organization", - zap.String("backup_id", org.ID.String()), - zap.String("backup_name", org.Name), - zap.String("restored_name", newOrg.Name), - ) - - // Create organization on server if it doesn't already exist. - if o, err := r.OrgService.FindOrganization(ctx, influxdb.OrganizationFilter{Name: &newOrg.Name}); errors.ErrorCode(err) == errors.ENotFound { - if err := r.OrgService.CreateOrganization(ctx, &newOrg); err != nil { - return fmt.Errorf("failed to create organization %q: %w", newOrg.Name, err) - } - } else if err != nil { - return fmt.Errorf("failed to check existence of organization %q: %w", newOrg.Name, err) - } else { - newOrg.ID = o.ID - } - - filter := influxdb.BucketFilter{OrganizationID: &org.ID} - if req.BucketID.Valid() { - filter.ID = &req.BucketID - } - if req.Bucket != "" { - filter.Name = &req.Bucket - } - - buckets, _, err := r.tenantService.FindBuckets(ctx, filter) - if err != nil { - return err - } - - for _, bkt := range buckets { - // Skip internal buckets. - if strings.HasPrefix(bkt.Name, "_") { - continue - } - - bkt = bkt.Clone() - bkt.OrgID = newOrg.ID - - if err := r.restoreBucket(ctx, bkt, req); err != nil { - return err - } - } - - return nil -} - -func (r *restoreRunner) restoreBucket(ctx context.Context, bkt *influxdb.Bucket, req Request) error { - newBucket := *bkt - if req.NewBucketName != "" { - newBucket.Name = req.NewBucketName - } - r.log.Info( - "Restoring bucket", - zap.String("backup_id", bkt.ID.String()), - zap.String("backup_name", bkt.Name), - zap.String("restored_name", newBucket.Name), - ) - - // Lookup matching database from the meta store. - // Search using bucket ID from backup. - dbi := r.metaClient.Database(bkt.ID.String()) - if dbi == nil { - return fmt.Errorf("database for bucket %q not found in local backup", bkt.ID.String()) - } - - // Serialize to protobufs. - buf, err := dbi.MarshalBinary() - if err != nil { - return fmt.Errorf("failed to marshal database info for bucket %q: %w", bkt.ID.String(), err) - } - - // TODO: Only create if it doesn't already exist. - if err := r.BucketService.CreateBucket(ctx, &newBucket); err != nil { - return fmt.Errorf("failed to create bucket %q: %w", newBucket.Name, err) - } - - shardIDMap, err := r.RestoreService.RestoreBucket(ctx, newBucket.ID, buf) - if err != nil { - return fmt.Errorf("failed to restore bucket %q: %w", newBucket.Name, err) - } - - // Restore each shard for the bucket. - for _, m := range r.shardManifests { - if bkt.ID.String() != m.BucketID { - continue - } - - // Skip if shard metadata was not imported. - newID, ok := shardIDMap[m.ShardID] - if !ok { - r.log.Warn( - "Meta info not found, skipping shard", - zap.Uint64("shard_id", m.ShardID), - zap.String("bucket_id", newBucket.ID.String()), - zap.String("path", filepath.Join(req.Path, m.FileName)), - ) - continue - } - - m.ShardID = newID - if err := r.restoreShard(ctx, req.Path, m); err != nil { - return err - } - } - - return nil -} diff --git a/tests/pipeline_helpers.go b/tests/pipeline_helpers.go index 2d19a0b455..4b2ac73521 100644 --- a/tests/pipeline_helpers.go +++ b/tests/pipeline_helpers.go @@ -112,7 +112,7 @@ func (p *Pipeline) MustNewClient(org, bucket platform.ID, token string) *Client DocumentsNamespace: DefaultDocumentsNamespace, Token: token, } - svc, err := NewClient(p.Launcher.URL(), config) + svc, err := NewClient(p.Launcher.URL().String(), config) if err != nil { panic(err) } @@ -128,7 +128,7 @@ func (p *Pipeline) NewBrowserClient(org, bucket platform.ID, session *influxdb.S DocumentsNamespace: DefaultDocumentsNamespace, Session: session, } - return NewClient(p.Launcher.URL(), config) + return NewClient(p.Launcher.URL().String(), config) } // BrowserFor will create a user, session, and browser client. diff --git a/tsdb/engine/tsm1/batch_integer_test.go b/tsdb/engine/tsm1/batch_integer_test.go index e33feb7949..771255ce7f 100644 --- a/tsdb/engine/tsm1/batch_integer_test.go +++ b/tsdb/engine/tsm1/batch_integer_test.go @@ -910,9 +910,8 @@ func TestIntegerArrayDecodeAll_MinMax(t *testing.T) { func TestIntegerArrayDecodeAll_Quick(t *testing.T) { quick.Check(func(values []int64) bool { - exp := values if values == nil { - exp = []int64{} // is this really expected? + values = []int64{} // is this really expected? } // Write values to encoder. @@ -933,8 +932,8 @@ func TestIntegerArrayDecodeAll_Quick(t *testing.T) { t.Fatalf("unexpected decode error %q", err) } - if !cmp.Equal(got, exp) { - t.Fatalf("unexpected values: -got/+exp\n%s", cmp.Diff(got, exp)) + if !cmp.Equal(got, values) { + t.Fatalf("unexpected values: -got/+exp\n%s", cmp.Diff(got, values)) } return true diff --git a/tsdb/engine/tsm1/batch_string_test.go b/tsdb/engine/tsm1/batch_string_test.go index 325f3ca195..852f1bddd5 100644 --- a/tsdb/engine/tsm1/batch_string_test.go +++ b/tsdb/engine/tsm1/batch_string_test.go @@ -254,9 +254,8 @@ func TestStringArrayDecodeAll_Multi_Compressed(t *testing.T) { func TestStringArrayDecodeAll_Quick(t *testing.T) { quick.Check(func(values []string) bool { - exp := values if values == nil { - exp = []string{} + values = []string{} } // Write values to encoder. enc := NewStringEncoder(1024) @@ -276,8 +275,8 @@ func TestStringArrayDecodeAll_Quick(t *testing.T) { t.Fatalf("unexpected error creating string decoder: %v", err) } - if !cmp.Equal(got, exp) { - t.Fatalf("unexpected value: -got/+exp\n%s", cmp.Diff(got, exp)) + if !cmp.Equal(got, values) { + t.Fatalf("unexpected value: -got/+exp\n%s", cmp.Diff(got, values)) } return true diff --git a/tsdb/engine/tsm1/bool_test.go b/tsdb/engine/tsm1/bool_test.go index 88b5a1ede8..27db0130a1 100644 --- a/tsdb/engine/tsm1/bool_test.go +++ b/tsdb/engine/tsm1/bool_test.go @@ -80,9 +80,8 @@ func Test_BooleanEncoder_Multi_Compressed(t *testing.T) { func Test_BooleanEncoder_Quick(t *testing.T) { if err := quick.Check(func(values []bool) bool { - expected := values if values == nil { - expected = []bool{} + values = []bool{} } // Write values to encoder. enc := tsm1.NewBooleanEncoder(1024) @@ -105,8 +104,8 @@ func Test_BooleanEncoder_Quick(t *testing.T) { } // Verify that input and output values match. - if !reflect.DeepEqual(expected, got) { - t.Fatalf("mismatch:\n\nexp=%#v\n\ngot=%#v\n\n", expected, got) + if !reflect.DeepEqual(values, got) { + t.Fatalf("mismatch:\n\nexp=%#v\n\ngot=%#v\n\n", values, got) } return true diff --git a/tsdb/engine/tsm1/float_test.go b/tsdb/engine/tsm1/float_test.go index c0622afb95..cdbb5d2233 100644 --- a/tsdb/engine/tsm1/float_test.go +++ b/tsdb/engine/tsm1/float_test.go @@ -212,10 +212,8 @@ func TestFloatEncoder_Empty(t *testing.T) { func Test_FloatEncoder_Quick(t *testing.T) { quick.Check(func(values []float64) bool { - - expected := values if values == nil { - expected = []float64{} + values = []float64{} } // Write values to encoder. @@ -241,8 +239,8 @@ func Test_FloatEncoder_Quick(t *testing.T) { } // Verify that input and output values match. - if !reflect.DeepEqual(expected, got) { - t.Fatalf("mismatch:\n\nexp=%#v\n\ngot=%#v\n\n", expected, got) + if !reflect.DeepEqual(values, got) { + t.Fatalf("mismatch:\n\nexp=%#v\n\ngot=%#v\n\n", values, got) } return true diff --git a/tsdb/engine/tsm1/int_test.go b/tsdb/engine/tsm1/int_test.go index d91a54e432..7690feed33 100644 --- a/tsdb/engine/tsm1/int_test.go +++ b/tsdb/engine/tsm1/int_test.go @@ -516,9 +516,8 @@ func Test_IntegerEncoder_MinMax(t *testing.T) { func Test_IntegerEncoder_Quick(t *testing.T) { quick.Check(func(values []int64) bool { - expected := values if values == nil { - expected = []int64{} // is this really expected? + values = []int64{} // is this really expected? } // Write values to encoder. @@ -545,8 +544,8 @@ func Test_IntegerEncoder_Quick(t *testing.T) { } // Verify that input and output values match. - if !reflect.DeepEqual(expected, got) { - t.Fatalf("mismatch:\n\nexp=%#v\n\ngot=%#v\n\n", expected, got) + if !reflect.DeepEqual(values, got) { + t.Fatalf("mismatch:\n\nexp=%#v\n\ngot=%#v\n\n", values, got) } return true diff --git a/tsdb/engine/tsm1/string_test.go b/tsdb/engine/tsm1/string_test.go index 72765d322e..b355642729 100644 --- a/tsdb/engine/tsm1/string_test.go +++ b/tsdb/engine/tsm1/string_test.go @@ -92,9 +92,8 @@ func Test_StringEncoder_Multi_Compressed(t *testing.T) { func Test_StringEncoder_Quick(t *testing.T) { quick.Check(func(values []string) bool { - expected := values if values == nil { - expected = []string{} + values = []string{} } // Write values to encoder. enc := NewStringEncoder(1024) @@ -122,8 +121,8 @@ func Test_StringEncoder_Quick(t *testing.T) { } // Verify that input and output values match. - if !reflect.DeepEqual(expected, got) { - t.Fatalf("mismatch:\n\nexp=%#v\n\ngot=%#v\n\n", expected, got) + if !reflect.DeepEqual(values, got) { + t.Fatalf("mismatch:\n\nexp=%#v\n\ngot=%#v\n\n", values, got) } return true