remove old test provider from e2e tests

This commit is contained in:
James Bardin 2020-11-20 14:54:33 -05:00
parent eee581ae54
commit e4c72015a3
4 changed files with 19 additions and 17 deletions

View File

@ -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(`

View File

@ -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" {
}

View File

@ -1,6 +1,10 @@
provider "test" {
terraform {
required_providers {
simple = {
source = "hashicorp/test"
}
}
}
resource "test_resource_signal" "test" {
resource "simple_resource" "test" {
}

View File

@ -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()