pulumi/pkg/engine/lifecycletest
Will Jones 1da0555b6a
Enable `pulumi:pulumi:getResource` to hydrate `Read` resources (#18070)
*Components* provide a means for Pulumi users to logically group and
abstract sets of resources. While authors of Pulumi programs can define
"local" components using e.g. the `ComponentResource` class of the
NodeJS or Python SDK, these can only be consumed by programs written in
the same language. Components implemented by provider `Construct`
implementations, however (often called "remote" components), can be
consumed by any appropriate client SDK, just like any other Pulumi
resource.

Despite their implementation involving gRPC protocol communications,
remote components offer many of the same features as local components.
For instance, just as it is possible for a local component's outputs to
contain references to its child resources, so may a remote component
return references to resources instantiated in its `Construct`
implementation. On the wire, these are serialized using resource URNs
and IDs. These values are then "hydrated" into fully fledged resource
values by the calling client SDK.

Hydration is powered by the `pulumi:pulumi:getResource` function. This
is an invoke offered by the so-called *built-in* provider, alongside
other core Pulumi concerns such as stack references. Under the hood,
`getResource` is implemented by looking up URNs in a table of resources
being managed by the executing program, and returning the appropriate
state to the caller.

Presently, this lookup only takes into account resources managed by
Pulumi (that is, *resource registrations*). It does not take into
account *reads* such as those caused by e.g. a `.get` call in a NodeJS
SDK. Consequently, if a `Construct` implementation performs a `.get` and
returns a reference to the read resource as an output, later hydrations
of that reference will fail. This is the cause of #17515.

This change fixes this by augmenting the built-in provider with a map of
read resources, which is updated as a deployment progresses just as the
list of registered resources being used already is. When a lookup in the
registrations map fails, the read map is tried, with an error being
raised only if that also fails. A pair of lifecycle tests are added to
verify that the behaviour works as intended.

Fixes #17515
2024-12-22 20:13:43 +00:00
..
framework Factor out the lifecycle testing framework (#17584) 2024-10-28 11:58:59 +00:00
fuzzing Generate more accurate reproductions when fuzzing (#17737) 2024-11-15 09:16:46 +00:00
testdata Enable `pulumi:pulumi:getResource` to hydrate `Read` resources (#18070) 2024-12-22 20:13:43 +00:00
README.md Support generating random fixtures in lifecycle tests (#17627) 2024-10-31 15:16:38 +00:00
alias_test.go Normalize URNs in `DeletedWith` references (#17666) 2024-11-05 13:27:11 +00:00
analyzer_test.go Factor out the lifecycle testing framework (#17584) 2024-10-28 11:58:59 +00:00
autonaming_test.go Add a lifecycle test for autonaming (#17995) 2024-12-12 16:00:00 +00:00
components_test.go Enable `pulumi:pulumi:getResource` to hydrate `Read` resources (#18070) 2024-12-22 20:13:43 +00:00
continue_on_error_test.go Factor out the lifecycle testing framework (#17584) 2024-10-28 11:58:59 +00:00
delete_before_replace_test.go Factor out the lifecycle testing framework (#17584) 2024-10-28 11:58:59 +00:00
fuzz_test.go Add Go tests for fuzzing the engine (#17717) 2024-11-08 13:11:03 +00:00
golang_sdk_test.go Factor out the lifecycle testing framework (#17584) 2024-10-28 11:58:59 +00:00
import_test.go Test import uses the expected provider version (#17993) 2024-12-10 17:05:43 +00:00
loader_test.go Bump gRPC dependencies and migrate `grpc.Dial` (#17701) 2024-11-06 18:36:10 +00:00
parameterized_test.go Factor out the lifecycle testing framework (#17584) 2024-10-28 11:58:59 +00:00
pending_delete_test.go Factor out the lifecycle testing framework (#17584) 2024-10-28 11:58:59 +00:00
pending_replace_test.go Factor out the lifecycle testing framework (#17584) 2024-10-28 11:58:59 +00:00
provider_test.go Add GetRequiredPackages to the language host (#17894) 2024-12-02 20:24:23 +00:00
pulumi_test.go Bulk out tests for hydrating registered resources (#18069) 2024-12-19 10:32:46 +00:00
refresh_legacy_diff_test.go Update golangci-lint (#17972) 2024-12-10 11:50:38 +00:00
refresh_test.go Update golangci-lint (#17972) 2024-12-10 11:50:38 +00:00
resource_reference_test.go Factor out the lifecycle testing framework (#17584) 2024-10-28 11:58:59 +00:00
retain_on_delete_test.go Factor out the lifecycle testing framework (#17584) 2024-10-28 11:58:59 +00:00
source_query_test.go Factor out the lifecycle testing framework (#17584) 2024-10-28 11:58:59 +00:00
step_generator_test.go Factor out the lifecycle testing framework (#17584) 2024-10-28 11:58:59 +00:00
target_test.go Support renaming providers in targeted operations (#17746) 2024-11-13 16:54:16 +00:00
transformation_test.go Factor out the lifecycle testing framework (#17584) 2024-10-28 11:58:59 +00:00
update_plan_test.go Add GetRequiredPackages to the language host (#17894) 2024-12-02 20:24:23 +00:00

README.md

(lifecycle-tests)=

Lifecycle tests

Lifecycle tests exercise the Pulumi engine and serve as a specification for the behaviours and interactions of the various features that define the lifecycle of a Pulumi program. This includes, but is not limited to:

  • The operation(s) being executed (up, preview, etc.) and the options passed to that operation (--target, --target-dependents, etc.).
  • The programs being executed -- their resources, invocations, and the various options that might be associated with them (parent, retainOnDelete, etc.).
  • The state of the program before and after operations are executed.

How and when to use