Hello, I happened to notice this repo today: <http...
# package-authoring
b
Hello, I happened to notice this repo today: https://github.com/pulumi/providertest. I would like to understand how it is intended to work. i.e. I see it generates a log of the grpc calls as well as a stack state file, but not quite sure how that works on the next run of the tests. For instance, does it just check that the sequence of grpc calls remains consistent?
Note: I did start to try it but there is a gotcha with go test timeouts that put me in a state where I had stranded resources that I had to clean up.
m
Ah! that repo is a bit experimental with some things we're trying to improve our internal testing of providers. I'd consider it rather alpha, (vs the programtest library described here: [Integration Testing for Pulumi Programs | Pulumi Docs](https://www.pulumi.com/docs/using-pulumi/testing/integration/)), but if you're interested in following along, the current state of the art from our perspective is in [providertest/pulumitest at main · pulumi/providertest](https://github.com/pulumi/providertest/tree/main/pulumitest)
b
Cool, I’’ll give this one a go (programtest). Just looking to build confidence that a provider release isn’t going to cause an outage.
Tried the programtest and got
Copy code
panic: proto: file "pulumi/plugin.proto" has a name conflict over pulumirpc.PluginDependency
See <https://protobuf.dev/reference/go/faq#namespace-conflict>
think I am going to stick to trying out the providertest as I was close to getting that working
So I got the providertest working and it is able to detect changes in generated resources. The one issue I am not quite sure how to solve after looking through all the repos that use this is, how do you make the test rebuild the provider and use that in the test. Right now I have to build the provider, install in path, then run the tests. I am assuming there has to be an easier way.
m
Unfortunately, I don't think there's any paved path for forcing the provider to rebuild as part of the test framework (worth filing an issue on that providertest repo though). With pulumitest, you can specify the path to the provider binary in the test: https://github.com/pulumi/providertest/tree/main/pulumitest#configuring-providers I'm not sure that any of the other variants support specifying a provider binary other than the one that's already on your path
b
I know this package is unannounced and isn’t really intended for general consumption yet so I appreciate you humoring my questions. This was my last attempt btw, seems something weird with the ResourceProviderServer that the pulumi-go-provider returns as the error here is
rpc error: code = Unimplemented desc = Check is not implemented
.
Copy code
package provider_test

import (
	"testing"

	"<http://github.com/pulumi/providertest|github.com/pulumi/providertest>"
	pp "<http://github.com/pulumi/pulumi-go-provider|github.com/pulumi/pulumi-go-provider>"
	pulumirpc "<http://github.com/pulumi/pulumi/sdk/v3/proto/go|github.com/pulumi/pulumi/sdk/v3/proto/go>"
	"<http://github.com/pulumi/pulumi-foo/provider/pkg/provider|github.com/pulumi/pulumi-foo/provider/pkg/provider>"
)

func TestUpgradeLocalCommand(t *testing.T) {
	t.Run("simple", func(t *testing.T) {
		test(t)
	})
}

func test(t *testing.T) {
	t.Parallel()

	test := providertest.NewProviderTest("testdata/simple",
		providertest.WithProviderName("foo"),
		providertest.WithResourceProviderServer(startProvider()),
		providertest.WithDiffValidation(providertest.NoChanges()),
	)

	test.Run(t)
}

func startProvider() pulumirpc.ResourceProviderServer {
	fooProvider := provider.NewProvider()
	server, err := pp.RawServer("foo", "0.0.1", fooProvider)
	if err != nil {
		panic(err)
	}
	return server
}
Anyway, I will leave it alone for now.