Documentation ¶
Index ¶
- func GetProviderAttachEnv(runningProviders []*ProviderAttach) string
- func RandomString() string
- func ReportUpgradeCoverage(t *testing.T)
- type ConvertedProgram
- type Diff
- type DiffValidation
- type Diffs
- type E2eOption
- type Option
- func WithBaselineVersion(v string) Option
- func WithConfig(key, value string) Option
- func WithDiffValidation(valid DiffValidation) Option
- func WithE2eOptions(opts ...E2eOption) Option
- func WithExtraBaselineDependencies(deps map[string]string) Option
- func WithProvider(start StartProvider) Option
- func WithProviderName(name string) Option
- func WithResourceProviderServer(s pulumirpc.ResourceProviderServer) Option
- func WithSkipSdk(language string, reasonArgs ...any) Option
- func WithSkippedUpgradeTestMode(m UpgradeTestMode, reason string) Option
- func WithUpdateStep(opts ...UpdateStepOption) Option
- type ProviderAttach
- type ProviderTest
- func (pt *ProviderTest) Configure(opts ...Option) *ProviderTest
- func (pt *ProviderTest) ConvertProgram(t *testing.T, language string) (*ConvertedProgram, error)
- func (pt *ProviderTest) GetConfig() auto.ConfigMap
- func (pt *ProviderTest) Run(t *testing.T)
- func (pt *ProviderTest) RunE2e(t *testing.T, runFullTest bool, options ...E2eOption)
- func (pt *ProviderTest) RunSdk(t *testing.T, language string)
- func (pt *ProviderTest) VerifyUpgrade(t *testing.T, mode UpgradeTestMode)
- func (pt *ProviderTest) VerifyUpgradeSnapshot(t *testing.T)
- type StartProvider
- type UpdateStep
- type UpdateStepOption
- type UpgradeTestMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetProviderAttachEnv ¶
func GetProviderAttachEnv(runningProviders []*ProviderAttach) string
func RandomString ¶
func RandomString() string
func ReportUpgradeCoverage ¶
This is a temporary helper method to assess upgrade resource coverage until better methods for tracking coverage are built. Run with -test.v to see the data logged. This finds all recorded GRPC states and traverses them to find the union of all resources used. It does not take into account if the corresponding tests are skipped or passing.
Types ¶
type ConvertedProgram ¶
type ConvertedProgram struct { Language string Dir string UpdateSteps []UpdateStep }
func (*ConvertedProgram) RestorePackages ¶
func (convertedProgram *ConvertedProgram) RestorePackages(t *testing.T, ctx context.Context)
type Diff ¶ added in v0.0.3
type Diff struct { URN resource.URN HasChanges bool // Non-empty Replaces indicates that the plan is a resource replacement and not a simple // in-place update. Replaces []string Diffs []string DeleteBeforeReplace bool }
The structure is mapped directly from Pulumi gRPC DiffResponse structure in the provider protocol and is currently unstable / subject to change.
https://github.com/pulumi/pulumi/blob/master/proto/pulumi/provider.proto#L225
Need to verify if this is representative of the actual Pulumi plans, since it only considers the decisions made by the provider, not the engine. For example, unclear if replaceOnChanges option https://www.pulumi.com/docs/concepts/options/replaceonchanges/ would surface here.
Even with the above caveats, it is reasonable to rely on this for the purposes of testing the provider itself.
type DiffValidation ¶ added in v0.0.3
func NoChanges ¶ added in v0.0.3
func NoChanges() DiffValidation
func NoReplacements ¶ added in v0.0.3
func NoReplacements() DiffValidation
type E2eOption ¶
type E2eOption func(*integration.ProgramTestOptions)
type Option ¶
type Option func(*ProviderTest)
func WithBaselineVersion ¶
func WithConfig ¶
func WithDiffValidation ¶ added in v0.0.3
func WithDiffValidation(valid DiffValidation) Option
func WithE2eOptions ¶
func WithExtraBaselineDependencies ¶ added in v0.0.2
When testing upgrades, this option specifies additional baseline dependency versions. For example, when testing pulumi-eks, WithBaselineVersion("1.0.4") will define the baseline version of eks provider itself, where WithExtraBaselineDependencies(map[string]string{"aws": "5.42.0"}) will pin the aws dependency.
func WithProvider ¶
func WithProvider(start StartProvider) Option
WithProvider adds a provider to be started and attached for the test run.
func WithProviderName ¶
func WithResourceProviderServer ¶
func WithResourceProviderServer(s pulumirpc.ResourceProviderServer) Option
TODO[pulumi/providertest#9] make this redundant.
func WithSkipSdk ¶
func WithSkippedUpgradeTestMode ¶
func WithSkippedUpgradeTestMode(m UpgradeTestMode, reason string) Option
func WithUpdateStep ¶
func WithUpdateStep(opts ...UpdateStepOption) Option
WithUpdateStep adds a step to the test will be applied before then executing an update.
type ProviderAttach ¶
type ProviderAttach struct { // Name of the provider e.g. "aws" Name string // Port the provider is listening on Port int }
func StartProviders ¶
func StartProviders(ctx context.Context, providerStartups ...StartProvider) ([]*ProviderAttach, error)
type ProviderTest ¶
type ProviderTest struct {
// contains filtered or unexported fields
}
func NewProviderTest ¶
func NewProviderTest(dir string, opts ...Option) *ProviderTest
NewProviderTest creates a new provider test with the initial directory to be tested.
func (*ProviderTest) Configure ¶
func (pt *ProviderTest) Configure(opts ...Option) *ProviderTest
func (*ProviderTest) ConvertProgram ¶
func (pt *ProviderTest) ConvertProgram(t *testing.T, language string) (*ConvertedProgram, error)
func (*ProviderTest) GetConfig ¶
func (pt *ProviderTest) GetConfig() auto.ConfigMap
func (*ProviderTest) Run ¶
func (pt *ProviderTest) Run(t *testing.T)
Run starts executing the configured tests
func (*ProviderTest) RunE2e ¶
func (pt *ProviderTest) RunE2e(t *testing.T, runFullTest bool, options ...E2eOption)
func (*ProviderTest) VerifyUpgrade ¶
func (pt *ProviderTest) VerifyUpgrade(t *testing.T, mode UpgradeTestMode)
Verifies that upgrading the provider does not generate any unexpected replacements.
Specifically check that for a given Pulumi program located in dir, users can run pulumi up on a baseline provider version, then upgrade the provider to the new version under test, run pulumi up again and observe an empty diff.
func (*ProviderTest) VerifyUpgradeSnapshot ¶
func (pt *ProviderTest) VerifyUpgradeSnapshot(t *testing.T)
type StartProvider ¶
type StartProvider func(ctx context.Context) (*ProviderAttach, error)
StartProvider is a function that starts a provider and returns the name and port it is listening on. When the test is complete, the context will be cancelled and the provider should exit.
type UpdateStep ¶
type UpdateStep struct {
// contains filtered or unexported fields
}
type UpdateStepOption ¶
type UpdateStepOption func(*UpdateStep)
func UpdateStepClean ¶
func UpdateStepClean() UpdateStepOption
UpdateStepClean will remove files from the directory which were removed in this step compared to the previous step's directory.
func UpdateStepDir ¶
func UpdateStepDir(dir string) UpdateStepOption
UpdateStepDir fetches files from the dir before performing the update. If dir is a relative path, it will be resolved relative to the original test directory.
type UpgradeTestMode ¶
type UpgradeTestMode int
Enumerates various available modes to test provider upgrades. The modes differ in speed vs precision tradeoffs.
const ( // The least precise but fastest mode. Tests are performed in-memory using pre-recorded // snapshots of baseline provider behavior. No cloud credentals are required, no // subprocesses are launched, fully debuggable. UpgradeTestMode_Quick UpgradeTestMode = iota // The medium precision/speed mode. Imports Pulumi statefile recorded on a baseline version, // and performs pulumi preview, asserting that the preview results in an empty diff. Cloud // credentials are required, but no infra is actually provisioned, making it quicker to // verify slow-to-provision resources such as databases. UpgradeTestMode_PreviewOnly // Full fidelity, slow mode. No pre-recorded snapshots are required. Do a complete pulumi up // on the baseline version, followed by a complete pulumi up on the version under test, and // assert that there are no observable updates or replacements. UpgradeTestMode_Full )
func UpgradeTestModes ¶
func UpgradeTestModes() []UpgradeTestMode
func (UpgradeTestMode) String ¶
func (m UpgradeTestMode) String() string