Repository: pulumi/pulumi-terraform-bridge
Pull request #1068 (2023-05-02 22:22:07)

Ensure replay tests use exact same server as prod code
We started making changes to provider_server.go to customize the translation of messages from protobuf layer talking the ResourceProvider Pulumi gRPC protocol to the resource.PropertyValue layer. In particular we updated Configure to signal to the engine that the bridged providers do not accept secrets. The tests did not reflect this due to a peculiarity - the tests were not using the same gRPC server. This is now fixed in the PR so the tests are representative of real use.

github-actions[bot]: Diff for [pulumi-azuread](https://github.com/pulumi-bot/pulumi-azuread/compare/d096379..88d20fd) with merge commit 1f696f27787aaa42b9f93446cd61348f660efd51
github-actions[bot]: Diff for [pulumi-random](https://github.com/pulumi-bot/pulumi-random/compare/327ab73..c487cf9) with merge commit 1f696f27787aaa42b9f93446cd61348f660efd51
github-actions[bot]: Diff for [pulumi-gcp](https://github.com/pulumi-bot/pulumi-gcp/compare/adce58d36..a8ada01b7) with merge commit 1f696f27787aaa42b9f93446cd61348f660efd51
github-actions[bot]: Diff for [pulumi-azuread](https://github.com/pulumi-bot/pulumi-azuread/compare/b9a1515..ba838e2) with merge commit df592093ea380fa98d48095c2c57a5dc5f35e178
github-actions[bot]: Diff for [pulumi-random](https://github.com/pulumi-bot/pulumi-random/compare/d1c6e44..a18eef7) with merge commit df592093ea380fa98d48095c2c57a5dc5f35e178
github-actions[bot]: Diff for [pulumi-azure](https://github.com/pulumi-bot/pulumi-azure/compare/b6d35613b..fb954f57f) with merge commit 1f696f27787aaa42b9f93446cd61348f660efd51

Patch:
diff --git a/pf/tfbridge/main.go b/pf/tfbridge/main.go
index 0e33b102..9cb0f1d3 100644
--- a/pf/tfbridge/main.go
+++ b/pf/tfbridge/main.go
@@ -162,7 +162,7 @@ func MakeMuxedServer(
 			case *schemashim.SchemaOnlyProvider:
 				m.Servers = append(m.Servers, muxer.Endpoint{
 					Server: func(host *rprovider.HostClient) (pulumirpc.ResourceProviderServer, error) {
-						return newProviderServer(ctx, host, ProviderInfo{
+						return NewProviderServer(ctx, host, ProviderInfo{
 							ProviderInfo: info,
 							NewProvider:  prov.PfProvider,
 						}, ProviderMetadata{PackageSchema: schema})
diff --git a/pf/tfbridge/provider.go b/pf/tfbridge/provider.go
index 4b78e71f..bea65d1b 100644
--- a/pf/tfbridge/provider.go
+++ b/pf/tfbridge/provider.go
@@ -148,7 +148,8 @@ func newProviderWithContext(ctx context.Context, info ProviderInfo,
 	}, nil
 }
 
-func newProviderServer(
+// Internal. The signature of this function can change between major releases. Exposed to facilitate testing.
+func NewProviderServer(
 	ctx context.Context,
 	logSink logutils.LogSink,
 	info ProviderInfo,
diff --git a/pf/tfbridge/serve.go b/pf/tfbridge/serve.go
index fd29317d..a3f8987a 100644
--- a/pf/tfbridge/serve.go
+++ b/pf/tfbridge/serve.go
@@ -23,6 +23,6 @@ import (
 
 func serve(ctx context.Context, pkg string, prov ProviderInfo, meta ProviderMetadata) error {
 	return rprovider.Main(pkg, func(host *rprovider.HostClient) (pulumirpc.ResourceProviderServer, error) {
-		return newProviderServer(ctx, host, prov, meta)
+		return NewProviderServer(ctx, host, prov, meta)
 	})
 }


Test patch:
diff --git a/pf/tests/provider_configure_test.go b/pf/tests/provider_configure_test.go
index 7e27b1ca..b6e98eb1 100644
--- a/pf/tests/provider_configure_test.go
+++ b/pf/tests/provider_configure_test.go
@@ -33,7 +33,6 @@ func TestConfigure(t *testing.T) {
       }
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     }
diff --git a/pf/tests/provider_read_test.go b/pf/tests/provider_read_test.go
index 2f1c674b..2cacb580 100644
--- a/pf/tests/provider_read_test.go
+++ b/pf/tests/provider_read_test.go
@@ -44,7 +44,6 @@ func TestReadFromRefresh(t *testing.T) {
 	    "acceptResources": true
 	  },
 	  "response": {
-	    "acceptSecrets": true,
 	    "supportsPreview": true,
 	    "acceptResources": true
 	  },
diff --git a/pf/tests/testdata/genrandom/random-delete-update.json b/pf/tests/testdata/genrandom/random-delete-update.json
index 2284dc36..b16282ba 100644
--- a/pf/tests/testdata/genrandom/random-delete-update.json
+++ b/pf/tests/testdata/genrandom/random-delete-update.json
@@ -53,7 +53,6 @@
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
diff --git a/pf/tests/testdata/genrandom/random-empty-preview.json b/pf/tests/testdata/genrandom/random-empty-preview.json
index ce8bceb4..402a36d9 100644
--- a/pf/tests/testdata/genrandom/random-empty-preview.json
+++ b/pf/tests/testdata/genrandom/random-empty-preview.json
@@ -53,7 +53,6 @@
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
diff --git a/pf/tests/testdata/genrandom/random-empty-update.json b/pf/tests/testdata/genrandom/random-empty-update.json
index e12f1a84..7ea9f8ad 100644
--- a/pf/tests/testdata/genrandom/random-empty-update.json
+++ b/pf/tests/testdata/genrandom/random-empty-update.json
@@ -53,7 +53,6 @@
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
diff --git a/pf/tests/testdata/genrandom/random-initial-preview.json b/pf/tests/testdata/genrandom/random-initial-preview.json
index 23ad2a4b..b43645a1 100644
--- a/pf/tests/testdata/genrandom/random-initial-preview.json
+++ b/pf/tests/testdata/genrandom/random-initial-preview.json
@@ -115,7 +115,6 @@
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
diff --git a/pf/tests/testdata/genrandom/random-initial-update.json b/pf/tests/testdata/genrandom/random-initial-update.json
index d3754320..3336e212 100644
--- a/pf/tests/testdata/genrandom/random-initial-update.json
+++ b/pf/tests/testdata/genrandom/random-initial-update.json
@@ -115,7 +115,6 @@
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
diff --git a/pf/tests/testdata/genrandom/random-replace-preview.json b/pf/tests/testdata/genrandom/random-replace-preview.json
index 48f1a575..60a1f694 100644
--- a/pf/tests/testdata/genrandom/random-replace-preview.json
+++ b/pf/tests/testdata/genrandom/random-replace-preview.json
@@ -53,7 +53,6 @@
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
diff --git a/pf/tests/testdata/genrandom/random-replace-update.json b/pf/tests/testdata/genrandom/random-replace-update.json
index 68749647..5a84df59 100644
--- a/pf/tests/testdata/genrandom/random-replace-update.json
+++ b/pf/tests/testdata/genrandom/random-replace-update.json
@@ -53,7 +53,6 @@
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
diff --git a/pf/tests/testdata/updateprogram.json b/pf/tests/testdata/updateprogram.json
index 09267947..0d7e2797 100644
--- a/pf/tests/testdata/updateprogram.json
+++ b/pf/tests/testdata/updateprogram.json
@@ -120,7 +120,6 @@
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
@@ -370,7 +369,6 @@
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
@@ -553,7 +551,6 @@
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
@@ -834,11 +831,9 @@
     "method": "/pulumirpc.ResourceProvider/Configure",
     "request": {
       "args": {},
-      "acceptSecrets": true,
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
@@ -1091,7 +1086,6 @@
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
@@ -1193,7 +1187,6 @@
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
@@ -1518,7 +1511,6 @@
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
@@ -1810,7 +1802,6 @@
       "acceptResources": true
     },
     "response": {
-      "acceptSecrets": true,
       "supportsPreview": true,
       "acceptResources": true
     },
diff --git a/pf/tests/util.go b/pf/tests/util.go
index 4259ec65..6973cce9 100644
--- a/pf/tests/util.go
+++ b/pf/tests/util.go
@@ -20,7 +20,6 @@ import (
 
 	"github.com/stretchr/testify/require"
 
-	"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
 	pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
 
 	"github.com/pulumi/pulumi-terraform-bridge/pf/tfbridge"
@@ -30,9 +29,9 @@ import (
 func newProviderServer(t *testing.T, info tfbridge.ProviderInfo) pulumirpc.ResourceProviderServer {
 	ctx := context.Background()
 	meta := genMetadata(t, info)
-	p, err := tfbridge.NewProvider(ctx, info, meta)
+	srv, err := tfbridge.NewProviderServer(ctx, nil, info, meta)
 	require.NoError(t, err)
-	return plugin.NewProviderServer(p)
+	return srv
 }
 
 func newMuxedProviderServer(t *testing.T, info tfbridge0.ProviderInfo) pulumirpc.ResourceProviderServer {