e2etest server was unsynchronized
This commit is contained in:
parent
a3c9b33b7b
commit
59110a2ca5
|
@ -6,6 +6,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/go-hclog"
|
"github.com/hashicorp/go-hclog"
|
||||||
|
@ -40,21 +41,54 @@ type reattachConfigAddr struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type providerServer struct {
|
type providerServer struct {
|
||||||
|
sync.Mutex
|
||||||
*grpcplugin.GRPCProviderServer
|
*grpcplugin.GRPCProviderServer
|
||||||
planResourceChangeCalled bool
|
planResourceChangeCalled bool
|
||||||
applyResourceChangeCalled bool
|
applyResourceChangeCalled bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *providerServer) PlanResourceChange(ctx context.Context, req *proto.PlanResourceChange_Request) (*proto.PlanResourceChange_Response, error) {
|
func (p *providerServer) PlanResourceChange(ctx context.Context, req *proto.PlanResourceChange_Request) (*proto.PlanResourceChange_Response, error) {
|
||||||
|
p.Lock()
|
||||||
|
defer p.Unlock()
|
||||||
|
|
||||||
p.planResourceChangeCalled = true
|
p.planResourceChangeCalled = true
|
||||||
return p.GRPCProviderServer.PlanResourceChange(ctx, req)
|
return p.GRPCProviderServer.PlanResourceChange(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *providerServer) ApplyResourceChange(ctx context.Context, req *proto.ApplyResourceChange_Request) (*proto.ApplyResourceChange_Response, error) {
|
func (p *providerServer) ApplyResourceChange(ctx context.Context, req *proto.ApplyResourceChange_Request) (*proto.ApplyResourceChange_Response, error) {
|
||||||
|
p.Lock()
|
||||||
|
defer p.Unlock()
|
||||||
|
|
||||||
p.applyResourceChangeCalled = true
|
p.applyResourceChangeCalled = true
|
||||||
return p.GRPCProviderServer.ApplyResourceChange(ctx, req)
|
return p.GRPCProviderServer.ApplyResourceChange(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *providerServer) PlanResourceChangeCalled() bool {
|
||||||
|
p.Lock()
|
||||||
|
defer p.Unlock()
|
||||||
|
|
||||||
|
return p.planResourceChangeCalled
|
||||||
|
}
|
||||||
|
func (p *providerServer) ResetPlanResourceChangeCalled() {
|
||||||
|
p.Lock()
|
||||||
|
defer p.Unlock()
|
||||||
|
|
||||||
|
p.planResourceChangeCalled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *providerServer) ApplyResourceChangeCalled() bool {
|
||||||
|
p.Lock()
|
||||||
|
defer p.Unlock()
|
||||||
|
|
||||||
|
return p.applyResourceChangeCalled
|
||||||
|
}
|
||||||
|
func (p *providerServer) ResetApplyResourceChangeCalled() {
|
||||||
|
p.Lock()
|
||||||
|
defer p.Unlock()
|
||||||
|
|
||||||
|
p.applyResourceChangeCalled = false
|
||||||
|
}
|
||||||
|
|
||||||
func TestUnmanagedSeparatePlan(t *testing.T) {
|
func TestUnmanagedSeparatePlan(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
@ -129,7 +163,7 @@ func TestUnmanagedSeparatePlan(t *testing.T) {
|
||||||
t.Fatalf("unexpected plan error: %s\nstderr:\n%s", err, stderr)
|
t.Fatalf("unexpected plan error: %s\nstderr:\n%s", err, stderr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !provider.planResourceChangeCalled {
|
if !provider.PlanResourceChangeCalled() {
|
||||||
t.Error("PlanResourceChange not called on in-process provider")
|
t.Error("PlanResourceChange not called on in-process provider")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,10 +173,10 @@ func TestUnmanagedSeparatePlan(t *testing.T) {
|
||||||
t.Fatalf("unexpected apply error: %s\nstderr:\n%s", err, stderr)
|
t.Fatalf("unexpected apply error: %s\nstderr:\n%s", err, stderr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !provider.applyResourceChangeCalled {
|
if !provider.ApplyResourceChangeCalled() {
|
||||||
t.Error("ApplyResourceChange not called on in-process provider")
|
t.Error("ApplyResourceChange not called on in-process provider")
|
||||||
}
|
}
|
||||||
provider.applyResourceChangeCalled = false
|
provider.ResetApplyResourceChangeCalled()
|
||||||
|
|
||||||
//// DESTROY
|
//// DESTROY
|
||||||
_, stderr, err = tf.Run("destroy", "-auto-approve")
|
_, stderr, err = tf.Run("destroy", "-auto-approve")
|
||||||
|
@ -150,7 +184,7 @@ func TestUnmanagedSeparatePlan(t *testing.T) {
|
||||||
t.Fatalf("unexpected destroy error: %s\nstderr:\n%s", err, stderr)
|
t.Fatalf("unexpected destroy error: %s\nstderr:\n%s", err, stderr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !provider.applyResourceChangeCalled {
|
if !provider.ApplyResourceChangeCalled() {
|
||||||
t.Error("ApplyResourceChange (destroy) not called on in-process provider")
|
t.Error("ApplyResourceChange (destroy) not called on in-process provider")
|
||||||
}
|
}
|
||||||
cancel()
|
cancel()
|
||||||
|
|
Loading…
Reference in New Issue