From e4c72015a3dc7fd6f48f6951a0dcaaa7ca04f692 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 20 Nov 2020 14:54:33 -0500 Subject: [PATCH] remove old test provider from e2e tests --- command/e2etest/provider_dev_test.go | 2 +- .../provider-dev-override.tf | 7 ++----- command/e2etest/testdata/test-provider/main.tf | 10 +++++++--- command/e2etest/unmanaged_test.go | 17 +++++++++-------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/command/e2etest/provider_dev_test.go b/command/e2etest/provider_dev_test.go index ba8f9c61c..9d7a0eaeb 100644 --- a/command/e2etest/provider_dev_test.go +++ b/command/e2etest/provider_dev_test.go @@ -33,7 +33,7 @@ func TestProviderDevOverrides(t *testing.T) { // such as if it stops being buildable into an independent executable. providerExeDir := filepath.Join(tf.WorkDir(), "pkgdir") providerExePrefix := filepath.Join(providerExeDir, "terraform-provider-test_") - providerExe := e2e.GoBuild("github.com/hashicorp/terraform/internal/legacy/builtin/bins/provider-test", providerExePrefix) + providerExe := e2e.GoBuild("github.com/hashicorp/terraform/internal/provider-simple/main", providerExePrefix) t.Logf("temporary provider executable is %s", providerExe) err := ioutil.WriteFile(filepath.Join(tf.WorkDir(), "dev.tfrc"), []byte(fmt.Sprintf(` diff --git a/command/e2etest/testdata/provider-dev-override/provider-dev-override.tf b/command/e2etest/testdata/provider-dev-override/provider-dev-override.tf index 195cb1a3b..9c629f722 100644 --- a/command/e2etest/testdata/provider-dev-override/provider-dev-override.tf +++ b/command/e2etest/testdata/provider-dev-override/provider-dev-override.tf @@ -1,14 +1,11 @@ terraform { required_providers { - test = { + simple = { source = "example.com/test/test" version = "2.0.0" } } } -provider "test" { -} - -data "test_data_source" "test" { +data "simple_resource" "test" { } diff --git a/command/e2etest/testdata/test-provider/main.tf b/command/e2etest/testdata/test-provider/main.tf index 864643ef6..a4de134c8 100644 --- a/command/e2etest/testdata/test-provider/main.tf +++ b/command/e2etest/testdata/test-provider/main.tf @@ -1,6 +1,10 @@ -provider "test" { - +terraform { + required_providers { + simple = { + source = "hashicorp/test" + } + } } -resource "test_resource_signal" "test" { +resource "simple_resource" "test" { } diff --git a/command/e2etest/unmanaged_test.go b/command/e2etest/unmanaged_test.go index 0dd262b3b..09eea5392 100644 --- a/command/e2etest/unmanaged_test.go +++ b/command/e2etest/unmanaged_test.go @@ -12,8 +12,8 @@ import ( "github.com/hashicorp/go-hclog" "github.com/hashicorp/go-plugin" "github.com/hashicorp/terraform/e2e" - "github.com/hashicorp/terraform/internal/legacy/builtin/providers/test" - grpcplugin "github.com/hashicorp/terraform/internal/legacy/helper/plugin" + "github.com/hashicorp/terraform/internal/grpcwrap" + simple "github.com/hashicorp/terraform/internal/provider-simple" proto "github.com/hashicorp/terraform/internal/tfplugin5" tfplugin "github.com/hashicorp/terraform/plugin" ) @@ -42,7 +42,7 @@ type reattachConfigAddr struct { type providerServer struct { sync.Mutex - *grpcplugin.GRPCProviderServer + proto.ProviderServer planResourceChangeCalled bool applyResourceChangeCalled bool } @@ -52,7 +52,7 @@ func (p *providerServer) PlanResourceChange(ctx context.Context, req *proto.Plan defer p.Unlock() p.planResourceChangeCalled = true - return p.GRPCProviderServer.PlanResourceChange(ctx, req) + return p.ProviderServer.PlanResourceChange(ctx, req) } func (p *providerServer) ApplyResourceChange(ctx context.Context, req *proto.ApplyResourceChange_Request) (*proto.ApplyResourceChange_Response, error) { @@ -60,7 +60,7 @@ func (p *providerServer) ApplyResourceChange(ctx context.Context, req *proto.App defer p.Unlock() p.applyResourceChangeCalled = true - return p.GRPCProviderServer.ApplyResourceChange(ctx, req) + return p.ProviderServer.ApplyResourceChange(ctx, req) } func (p *providerServer) PlanResourceChangeCalled() bool { @@ -99,7 +99,7 @@ func TestUnmanagedSeparatePlan(t *testing.T) { reattachCh := make(chan *plugin.ReattachConfig) closeCh := make(chan struct{}) provider := &providerServer{ - GRPCProviderServer: grpcplugin.NewGRPCProviderServerShim(test.Provider()), + ProviderServer: grpcwrap.New(simple.Provider()), } ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -140,6 +140,7 @@ func TestUnmanagedSeparatePlan(t *testing.T) { }, }, }) + tf.AddEnv("TF_REATTACH_PROVIDERS=" + string(reattachStr)) tf.AddEnv("PLUGIN_PROTOCOL_VERSION=5") @@ -164,7 +165,7 @@ func TestUnmanagedSeparatePlan(t *testing.T) { } if !provider.PlanResourceChangeCalled() { - t.Error("PlanResourceChange not called on in-process provider") + t.Error("PlanResourceChange not called on un-managed provider") } //// APPLY @@ -174,7 +175,7 @@ func TestUnmanagedSeparatePlan(t *testing.T) { } if !provider.ApplyResourceChangeCalled() { - t.Error("ApplyResourceChange not called on in-process provider") + t.Error("ApplyResourceChange not called on un-managed provider") } provider.ResetApplyResourceChangeCalled()