From d049958b137e1532239f13bb848d01baac96962d Mon Sep 17 00:00:00 2001 From: Dustin Long Date: Tue, 30 Mar 2021 12:49:25 -0400 Subject: [PATCH] fix(pull): Pull uses network resolver. Fixes integration test. --- cmd/pull.go | 2 +- lib/datasets.go | 7 +++++-- lib/integration_test.go | 6 ++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/pull.go b/cmd/pull.go index 3f5511317..49997124d 100644 --- a/cmd/pull.go +++ b/cmd/pull.go @@ -80,7 +80,7 @@ func (o *PullOptions) Run(args []string) error { Remote: o.Remote, } - res, err := o.inst.Dataset().Pull(ctx, p) + res, err := o.inst.WithSource("network").Dataset().Pull(ctx, p) if err != nil { return err } diff --git a/lib/datasets.go b/lib/datasets.go index 253553c6e..450fef639 100644 --- a/lib/datasets.go +++ b/lib/datasets.go @@ -1492,18 +1492,21 @@ func (datasetImpl) Remove(scope scope, p *RemoveParams) (*RemoveResponse, error) // a network connection func (datasetImpl) Pull(scope scope, p *PullParams) (*dataset.Dataset, error) { res := &dataset.Dataset{} + // TODO(dustmop): source has moved to the scope, and passing it to ParseAndResolveRef + // does nothing. Remove it from here and from the third parameter of that func source := p.Remote if source == "" { source = "network" } - ref, source, err := scope.ParseAndResolveRef(scope.Context(), p.Ref, source) + ref, location, err := scope.ParseAndResolveRef(scope.Context(), p.Ref, source) if err != nil { log.Debugf("resolving reference: %s", err) return nil, err } + log.Infof("pulling dataset from location: %s", location) - ds, err := scope.RemoteClient().PullDataset(scope.Context(), &ref, source) + ds, err := scope.RemoteClient().PullDataset(scope.Context(), &ref, location) if err != nil { log.Debugf("pulling dataset: %s", err) return nil, err diff --git a/lib/integration_test.go b/lib/integration_test.go index b16820662..ec10d2d00 100644 --- a/lib/integration_test.go +++ b/lib/integration_test.go @@ -20,8 +20,6 @@ import ( ) func TestTwoActorRegistryIntegration(t *testing.T) { - t.Skip("TODO(dustmop): meaning of source changed, this needs to be fixed") - tr := NewNetworkIntegrationTestRunner(t, "integration_two_actor_registry") defer tr.Cleanup() @@ -70,7 +68,7 @@ func TestTwoActorRegistryIntegration(t *testing.T) { PushToRegistry(tr.Ctx, t, nasim, ref.Alias()) // 7. hinshun logsyncs with the registry for world bank dataset, sees multiple versions - _, err = hinshun.Dataset().Pull(tr.Ctx, &PullParams{LogsOnly: true, Ref: ref.String()}) + _, err = hinshun.WithSource("network").Dataset().Pull(tr.Ctx, &PullParams{LogsOnly: true, Ref: ref.String()}) if err != nil { t.Errorf("cloning logs: %s", err) } @@ -437,7 +435,7 @@ func SearchFor(ctx context.Context, t *testing.T, inst *Instance, term string) [ func Pull(ctx context.Context, t *testing.T, inst *Instance, refstr string) *dataset.Dataset { t.Helper() - res, err := inst.Dataset().Pull(ctx, &PullParams{Ref: refstr}) + res, err := inst.WithSource("network").Dataset().Pull(ctx, &PullParams{Ref: refstr}) if err != nil { t.Fatalf("cloning dataset %s: %s", refstr, err) }