2024-10-28 11:58:59 +00:00
|
|
|
// Copyright 2016-2024, Pulumi Corporation.
|
2023-07-13 14:05:50 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package lifecycletest
|
|
|
|
|
|
|
|
import (
|
2024-07-26 12:14:45 +00:00
|
|
|
"context"
|
2023-09-14 19:52:27 +00:00
|
|
|
"errors"
|
2023-07-13 14:05:50 +00:00
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/blang/semver"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2024-01-26 18:29:22 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2023-07-13 14:05:50 +00:00
|
|
|
|
2023-09-18 11:01:28 +00:00
|
|
|
"github.com/pulumi/pulumi/pkg/v3/display"
|
2023-11-21 15:16:13 +00:00
|
|
|
. "github.com/pulumi/pulumi/pkg/v3/engine" //nolint:revive
|
2024-10-28 11:58:59 +00:00
|
|
|
lt "github.com/pulumi/pulumi/pkg/v3/engine/lifecycletest/framework"
|
2023-07-13 14:05:50 +00:00
|
|
|
"github.com/pulumi/pulumi/pkg/v3/resource/deploy"
|
|
|
|
"github.com/pulumi/pulumi/pkg/v3/resource/deploy/deploytest"
|
2024-11-05 13:27:11 +00:00
|
|
|
"github.com/pulumi/pulumi/pkg/v3/resource/deploy/providers"
|
2023-07-13 14:05:50 +00:00
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
|
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/workspace"
|
2024-01-26 18:29:22 +00:00
|
|
|
pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
|
2023-07-13 14:05:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Resource is an abstract representation of a resource graph
|
|
|
|
type Resource struct {
|
|
|
|
t tokens.Type
|
|
|
|
name string
|
|
|
|
children []Resource
|
|
|
|
props resource.PropertyMap
|
|
|
|
aliasURNs []resource.URN
|
|
|
|
aliases []resource.Alias
|
|
|
|
dependencies []resource.URN
|
|
|
|
parent resource.URN
|
|
|
|
deleteBeforeReplace bool
|
|
|
|
|
|
|
|
aliasSpecs bool
|
|
|
|
grpcRequestHeaders map[string]string
|
|
|
|
}
|
|
|
|
|
2024-01-26 18:29:22 +00:00
|
|
|
// Ideally we'd get rid of this method, we probably shouldn't be talking in terms on `resource.Alias` in tests (they
|
|
|
|
// should be tested against the rpc protocol), and we should probably be using a stricter type in the engine.
|
|
|
|
func aliasesFromAliases(aliases []resource.Alias) []*pulumirpc.Alias {
|
|
|
|
result := make([]*pulumirpc.Alias, len(aliases))
|
|
|
|
for i, alias := range aliases {
|
|
|
|
if alias.URN != "" {
|
|
|
|
result[i] = &pulumirpc.Alias{
|
|
|
|
Alias: &pulumirpc.Alias_Urn{
|
|
|
|
Urn: string(alias.URN),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
spec := &pulumirpc.Alias_Spec{
|
|
|
|
Name: alias.Name,
|
|
|
|
Type: alias.Type,
|
|
|
|
Project: alias.Project,
|
|
|
|
Stack: alias.Stack,
|
|
|
|
}
|
|
|
|
|
|
|
|
if alias.Parent != "" {
|
|
|
|
spec.Parent = &pulumirpc.Alias_Spec_ParentUrn{
|
|
|
|
ParentUrn: string(alias.Parent),
|
|
|
|
}
|
|
|
|
} else if alias.NoParent {
|
|
|
|
spec.Parent = &pulumirpc.Alias_Spec_NoParent{
|
|
|
|
NoParent: alias.NoParent,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
result[i] = &pulumirpc.Alias{
|
|
|
|
Alias: &pulumirpc.Alias_Spec_{
|
|
|
|
Spec: spec,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeUrnAlias(urn string) *pulumirpc.Alias {
|
|
|
|
return &pulumirpc.Alias{
|
|
|
|
Alias: &pulumirpc.Alias_Urn{
|
|
|
|
Urn: urn,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeSpecAlias(name, typ, project, stack string) *pulumirpc.Alias {
|
|
|
|
return &pulumirpc.Alias{
|
|
|
|
Alias: &pulumirpc.Alias_Spec_{
|
|
|
|
Spec: &pulumirpc.Alias_Spec{
|
|
|
|
Name: name,
|
|
|
|
Type: typ,
|
|
|
|
Project: project,
|
|
|
|
Stack: stack,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeSpecAliasWithParent(name, typ, project, stack, parent string) *pulumirpc.Alias {
|
|
|
|
return &pulumirpc.Alias{
|
|
|
|
Alias: &pulumirpc.Alias_Spec_{
|
|
|
|
Spec: &pulumirpc.Alias_Spec{
|
|
|
|
Name: name,
|
|
|
|
Type: typ,
|
|
|
|
Project: project,
|
|
|
|
Stack: stack,
|
|
|
|
Parent: &pulumirpc.Alias_Spec_ParentUrn{
|
|
|
|
ParentUrn: parent,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeSpecAliasWithNoParent(name, typ, project, stack string, parent bool) *pulumirpc.Alias {
|
|
|
|
return &pulumirpc.Alias{
|
|
|
|
Alias: &pulumirpc.Alias_Spec_{
|
|
|
|
Spec: &pulumirpc.Alias_Spec{
|
|
|
|
Name: name,
|
|
|
|
Type: typ,
|
|
|
|
Project: project,
|
|
|
|
Stack: stack,
|
|
|
|
Parent: &pulumirpc.Alias_Spec_NoParent{
|
|
|
|
NoParent: parent,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-13 14:05:50 +00:00
|
|
|
func registerResources(t *testing.T, monitor *deploytest.ResourceMonitor, resources []Resource) error {
|
|
|
|
for _, r := range resources {
|
2023-08-31 18:26:04 +00:00
|
|
|
r := r
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err := monitor.RegisterResource(r.t, r.name, true, deploytest.ResourceOptions{
|
2023-07-13 14:05:50 +00:00
|
|
|
Parent: r.parent,
|
|
|
|
Dependencies: r.dependencies,
|
|
|
|
Inputs: r.props,
|
|
|
|
DeleteBeforeReplace: &r.deleteBeforeReplace,
|
|
|
|
AliasURNs: r.aliasURNs,
|
2024-01-26 18:29:22 +00:00
|
|
|
Aliases: aliasesFromAliases(r.aliases),
|
2023-07-13 14:05:50 +00:00
|
|
|
AliasSpecs: r.aliasSpecs,
|
|
|
|
GrpcRequestHeaders: r.grpcRequestHeaders,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
err = registerResources(t, monitor, r.children)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
type updateProgramWithResourceFunc func(*deploy.Snapshot, []Resource, []display.StepOp, bool, string) *deploy.Snapshot
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
func createUpdateProgramWithResourceFuncForAliasTests(
|
|
|
|
t *testing.T,
|
|
|
|
loaders []*deploytest.ProviderLoader,
|
|
|
|
) updateProgramWithResourceFunc {
|
|
|
|
t.Helper()
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
|
2023-07-13 14:05:50 +00:00
|
|
|
return func(
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
snap *deploy.Snapshot, resources []Resource, allowedOps []display.StepOp, expectFailure bool, name string,
|
2023-07-13 14:05:50 +00:00
|
|
|
) *deploy.Snapshot {
|
2023-09-28 21:50:18 +00:00
|
|
|
programF := deploytest.NewLanguageRuntimeF(func(_ plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
2023-07-13 14:05:50 +00:00
|
|
|
err := registerResources(t, monitor, resources)
|
|
|
|
return err
|
|
|
|
})
|
2023-09-28 21:50:18 +00:00
|
|
|
hostF := deploytest.NewPluginHostF(nil, nil, programF, loaders...)
|
2024-10-28 11:58:59 +00:00
|
|
|
p := <.TestPlan{
|
|
|
|
Options: lt.TestUpdateOptions{T: t, HostF: hostF},
|
|
|
|
Steps: []lt.TestStep{
|
2023-07-13 14:05:50 +00:00
|
|
|
{
|
|
|
|
Op: Update,
|
|
|
|
ExpectFailure: expectFailure,
|
|
|
|
Validate: func(project workspace.Project, target deploy.Target, entries JournalEntries,
|
2024-05-06 17:34:24 +00:00
|
|
|
events []Event, err error,
|
2023-10-11 14:44:09 +00:00
|
|
|
) error {
|
2023-07-13 14:05:50 +00:00
|
|
|
for _, event := range events {
|
|
|
|
if event.Type == ResourcePreEvent {
|
|
|
|
payload := event.Payload().(ResourcePreEventPayload)
|
2023-11-20 21:55:59 +00:00
|
|
|
if payload.Metadata.Type == "pulumi:providers:pkgA" {
|
|
|
|
continue
|
|
|
|
}
|
2023-07-13 14:05:50 +00:00
|
|
|
assert.Subset(t, allowedOps, []display.StepOp{payload.Metadata.Op})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, entry := range entries {
|
|
|
|
if entry.Step.Type() == "pulumi:providers:pkgA" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
switch entry.Kind {
|
|
|
|
case JournalEntrySuccess:
|
|
|
|
assert.Subset(t, allowedOps, []display.StepOp{entry.Step.Op()})
|
|
|
|
case JournalEntryFailure:
|
|
|
|
assert.Fail(t, "unexpected failure in journal")
|
|
|
|
case JournalEntryBegin:
|
|
|
|
case JournalEntryOutputs:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-11 14:44:09 +00:00
|
|
|
return err
|
2023-07-13 14:05:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
return p.RunWithName(t, snap, name)
|
2023-07-13 14:05:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAliases(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
loaders := []*deploytest.ProviderLoader{
|
|
|
|
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) {
|
|
|
|
return &deploytest.Provider{
|
|
|
|
// The `forcesReplacement` key forces replacement and all other keys can update in place
|
2024-07-26 12:14:45 +00:00
|
|
|
DiffF: func(_ context.Context, req plugin.DiffRequest) (plugin.DiffResult, error) {
|
2023-07-13 14:05:50 +00:00
|
|
|
replaceKeys := []resource.PropertyKey{}
|
2024-07-26 12:14:45 +00:00
|
|
|
old, hasOld := req.OldOutputs["forcesReplacement"]
|
|
|
|
new, hasNew := req.NewInputs["forcesReplacement"]
|
2023-07-13 14:05:50 +00:00
|
|
|
if hasOld && !hasNew || hasNew && !hasOld || hasOld && hasNew && old.Diff(new) != nil {
|
|
|
|
replaceKeys = append(replaceKeys, "forcesReplacement")
|
|
|
|
}
|
|
|
|
return plugin.DiffResult{ReplaceKeys: replaceKeys}, nil
|
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
|
|
|
|
updateProgramWithResource := createUpdateProgramWithResourceFuncForAliasTests(t, loaders)
|
|
|
|
|
|
|
|
snap := updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n1",
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "t1")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that rename produces Same
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n2",
|
|
|
|
aliases: []resource.Alias{{Name: "n1"}},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "t1-n2")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that rename produces Same with multiple aliases
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n3",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Name: "n2"},
|
|
|
|
{Name: "n1"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "t1-n3")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that rename produces Same with multiple aliases (reversed)
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n3",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{URN: "urn:pulumi:test::test::pkgA:index:t1::n2"},
|
|
|
|
{Name: "n1"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "t1-n3-full")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that aliasing back to original name is okay
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n1",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{URN: "urn:pulumi:test::test::pkgA:index:t1::n3"},
|
|
|
|
{Name: "n2"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "t1-n1-alias-back")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that removing aliases is okay (once old names are gone from all snapshots)
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n1",
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "t1-n1-remove-aliases")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that changing the type works
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "n1",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:t1"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "t2-n1")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that changing the type again works
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:othermod:t3",
|
|
|
|
name: "n1",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:t1"},
|
|
|
|
{Type: "pkgA:index:t2"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "t3-n1")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that order of aliases doesn't matter
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:othermod:t3",
|
|
|
|
name: "n1",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:t1"},
|
|
|
|
{Type: "pkgA:othermod:t3"},
|
|
|
|
{Type: "pkgA:index:t2"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "t3-n1-order")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that removing aliases is okay (once old names are gone from all snapshots)
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:othermod:t3",
|
|
|
|
name: "n1",
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "t3-remove-aliases")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that changing everything (including props) leads to update not delete and re-create
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t4",
|
|
|
|
name: "n2",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("x"): resource.NewNumberProperty(42),
|
|
|
|
},
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:othermod:t3", Name: "n1"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpUpdate}, false, "t4-n2")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that changing everything again (including props) leads to update not delete and re-create
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t5",
|
|
|
|
name: "n3",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("x"): resource.NewNumberProperty(1000),
|
|
|
|
},
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:t4", Name: "n2"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpUpdate}, false, "t5-n3")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that changing a forceNew property while also changing type and name leads to replacement not delete+create
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t6",
|
|
|
|
name: "n4",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("forcesReplacement"): resource.NewNumberProperty(1000),
|
|
|
|
},
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:t5", Name: "n3"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpReplace, deploy.OpCreateReplacement, deploy.OpDeleteReplaced}, false, "t6-n4")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that changing a forceNew property and deleteBeforeReplace while also changing type and name leads to
|
|
|
|
// replacement not delete+create
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t7",
|
|
|
|
name: "n5",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("forcesReplacement"): resource.NewNumberProperty(999),
|
|
|
|
},
|
|
|
|
deleteBeforeReplace: true,
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:t6", Name: "n4"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpReplace, deploy.OpCreateReplacement, deploy.OpDeleteReplaced}, false, "t7-n5")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Start again - this time with two resources with depends on relationship
|
|
|
|
snap = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n1",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("forcesReplacement"): resource.NewNumberProperty(1),
|
|
|
|
},
|
|
|
|
deleteBeforeReplace: true,
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "n2",
|
|
|
|
dependencies: []resource.URN{"urn:pulumi:test::test::pkgA:index:t1::n1"},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "t1-start-again")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1-new",
|
|
|
|
name: "n1-new",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("forcesReplacement"): resource.NewNumberProperty(2),
|
|
|
|
},
|
|
|
|
deleteBeforeReplace: true,
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:t1", Name: "n1"},
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2-new",
|
|
|
|
name: "n2-new",
|
|
|
|
dependencies: []resource.URN{"urn:pulumi:test::test::pkgA:index:t1-new::n1-new"},
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:t2", Name: "n2"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame, deploy.OpReplace, deploy.OpCreateReplacement, deploy.OpDeleteReplaced},
|
|
|
|
false, "t1-new-t2-new")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Start again - this time with two resources with parent relationship
|
|
|
|
snap = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n1",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("forcesReplacement"): resource.NewNumberProperty(1),
|
|
|
|
},
|
|
|
|
deleteBeforeReplace: true,
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "n2",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1::n1"),
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "t1-t2-start-again")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1-new",
|
|
|
|
name: "n1-new",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("forcesReplacement"): resource.NewNumberProperty(2),
|
|
|
|
},
|
|
|
|
deleteBeforeReplace: true,
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:t1", Name: "n1"},
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2-new",
|
|
|
|
name: "n2-new",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1-new::n1-new"),
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:t2", Name: "n2"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame, deploy.OpReplace, deploy.OpCreateReplacement, deploy.OpDeleteReplaced},
|
|
|
|
false, "t1-new-t2-new-parent")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// ensure failure when different resources use duplicate aliases
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n2",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Name: "n1"},
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "n3",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:t1", Name: "n1"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, true, "t1-fail-duplicate")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// ensure different resources can use different aliases
|
|
|
|
_ = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n1",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Name: "n1"},
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "n2",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "index:t1"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "different-aliases")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// ensure that aliases of parents of parents resolves correctly
|
|
|
|
// first create a chain of resources such that we have n1 -> n1-sub -> n1-sub-sub
|
|
|
|
snap = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n1",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "n1-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1::n1"),
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t3",
|
|
|
|
name: "n1-sub-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1$pkgA:index:t2::n1-sub"),
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "parents")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Now change n1's name and type
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1-new",
|
|
|
|
name: "n1-new",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:t1", Name: "n1"},
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "n1-new-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1-new::n1-new"),
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:t2", Name: "n1-sub"},
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t3",
|
|
|
|
name: "n1-new-sub-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1-new$pkgA:index:t2::n1-new-sub"),
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:t3", Name: "n1-sub-sub"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "n1-name-change")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Test catastrophic multiplication out of aliases doesn't crash out of memory
|
|
|
|
// first create a chain of resources such that we have n1 -> n1-sub -> n1-sub-sub
|
|
|
|
snap = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1-v0",
|
|
|
|
name: "n1",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2-v0",
|
|
|
|
name: "n1-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1-v0::n1"),
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t3",
|
|
|
|
name: "n1-sub-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1-v0$pkgA:index:t2-v0::n1-sub"),
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "multiplication")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Now change n1's name and type and n2's type, but also add a load of aliases and pre-multiply them out
|
|
|
|
// before sending to the engine
|
|
|
|
n1Aliases := make([]resource.Alias, 0)
|
|
|
|
n2Aliases := make([]resource.Alias, 0)
|
|
|
|
n3Aliases := make([]resource.Alias, 0)
|
|
|
|
for i := 0; i < 100; i++ {
|
|
|
|
n1Aliases = append(n1Aliases, resource.Alias{URN: resource.URN(
|
|
|
|
fmt.Sprintf("urn:pulumi:test::test::pkgA:index:t1-v%d::n1", i),
|
|
|
|
)})
|
|
|
|
|
|
|
|
for j := 0; j < 10; j++ {
|
|
|
|
n2Aliases = append(n2Aliases, resource.Alias{
|
|
|
|
URN: resource.URN(fmt.Sprintf("urn:pulumi:test::test::pkgA:index:t1-v%d$pkgA:index:t2-v%d::n1-sub", i, j)),
|
|
|
|
})
|
|
|
|
n3Aliases = append(n3Aliases, resource.Alias{
|
|
|
|
Name: "n1-sub-sub",
|
|
|
|
Type: fmt.Sprintf("pkgA:index:t1-v%d$pkgA:index:t2-v%d$pkgA:index:t3", i, j),
|
|
|
|
Stack: "test",
|
|
|
|
Project: "test",
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1-v100",
|
|
|
|
name: "n1-new",
|
|
|
|
aliases: n1Aliases,
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2-v10",
|
|
|
|
name: "n1-new-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1-v100::n1-new"),
|
|
|
|
aliases: n2Aliases,
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t3",
|
|
|
|
name: "n1-new-sub-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1-v100$pkgA:index:t2-v10::n1-new-sub"),
|
|
|
|
aliases: n3Aliases,
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "many-alaises")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
var err error
|
|
|
|
_, err = snap.NormalizeURNReferences()
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.NoError(t, err)
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Start again with a parent and child.
|
|
|
|
snap = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:parent",
|
|
|
|
name: "parent",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:child",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:parent::parent",
|
|
|
|
name: "child",
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "start-again-parent-child")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure renaming just the child produces Same
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:parent",
|
|
|
|
name: "parent",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:child",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:parent::parent",
|
|
|
|
name: "childnew",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Name: "child"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "child-same")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure changing just the child's type produces Same
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:parent",
|
|
|
|
name: "parent",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:child2",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:parent::parent",
|
|
|
|
name: "childnew",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Type: "pkgA:index:child"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "change-child-same")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Start again with multiple nested children.
|
|
|
|
snap = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "parent",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:t1::parent",
|
|
|
|
name: "sub",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:t1$pkgA:index:t1::sub",
|
|
|
|
name: "sub-sub",
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "nested-children")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure renaming the bottom child produces Same.
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "parent",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:t1::parent",
|
|
|
|
name: "sub",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:t1$pkgA:index:t1::sub",
|
|
|
|
name: "sub-sub-new",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Name: "sub-sub"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "rename-bottom-children")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Start again with two resources with no relationship.
|
|
|
|
snap = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "one",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "two",
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "no-relationship")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Now make "two" a child of "one" ensuring no changes.
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "one",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:t1::one",
|
|
|
|
name: "two",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{NoParent: true},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "make-children")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Now remove the parent relationship.
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "one",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "two",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Parent: "urn:pulumi:test::test::pkgA:index:t1::one"},
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "remove-parent-relationship")
|
2023-07-13 14:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestAliasesNodeJSBackCompat(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
loaders := []*deploytest.ProviderLoader{
|
|
|
|
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) {
|
|
|
|
return &deploytest.Provider{}, nil
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
|
|
|
|
updateProgramWithResource := createUpdateProgramWithResourceFuncForAliasTests(t, loaders)
|
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
aliasSpecs bool
|
|
|
|
grpcRequestHeaders map[string]string
|
|
|
|
noParentAlias resource.Alias
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "Old Node SDK",
|
|
|
|
grpcRequestHeaders: map[string]string{"pulumi-runtime": "nodejs"},
|
|
|
|
// Old Node.js SDKs set Parent to "" rather than setting NoParent to true,
|
|
|
|
noParentAlias: resource.Alias{Parent: ""},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "New Node SDK",
|
|
|
|
grpcRequestHeaders: map[string]string{"pulumi-runtime": "nodejs"},
|
|
|
|
// Indicate we're sending alias specs correctly.
|
|
|
|
aliasSpecs: true,
|
|
|
|
// Properly set NoParent to true.
|
|
|
|
noParentAlias: resource.Alias{NoParent: true},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Unknown SDK",
|
|
|
|
// Properly set NoParent to true.
|
|
|
|
noParentAlias: resource.Alias{NoParent: true},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
tt := tt
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
snap := updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "one",
|
|
|
|
aliasSpecs: tt.aliasSpecs,
|
|
|
|
grpcRequestHeaders: tt.grpcRequestHeaders,
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "two",
|
|
|
|
aliasSpecs: tt.aliasSpecs,
|
|
|
|
grpcRequestHeaders: tt.grpcRequestHeaders,
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "one-two")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Now make "two" a child of "one" ensuring no changes.
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "one",
|
|
|
|
aliasSpecs: tt.aliasSpecs,
|
|
|
|
grpcRequestHeaders: tt.grpcRequestHeaders,
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:t1::one",
|
|
|
|
name: "two",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
tt.noParentAlias,
|
|
|
|
},
|
|
|
|
aliasSpecs: tt.aliasSpecs,
|
|
|
|
grpcRequestHeaders: tt.grpcRequestHeaders,
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "make-two-child-of-one")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Now remove the parent relationship.
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "one",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "two",
|
|
|
|
aliases: []resource.Alias{
|
|
|
|
{Parent: "urn:pulumi:test::test::pkgA:index:t1::one"},
|
|
|
|
},
|
|
|
|
aliasSpecs: tt.aliasSpecs,
|
|
|
|
grpcRequestHeaders: tt.grpcRequestHeaders,
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "remove-relationship-of-two-to-one")
|
2023-07-13 14:05:50 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAliasURNs(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
loaders := []*deploytest.ProviderLoader{
|
|
|
|
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) {
|
|
|
|
return &deploytest.Provider{
|
|
|
|
// The `forcesReplacement` key forces replacement and all other keys can update in place
|
2024-07-26 12:14:45 +00:00
|
|
|
DiffF: func(_ context.Context, req plugin.DiffRequest) (plugin.DiffResult, error) {
|
2023-07-13 14:05:50 +00:00
|
|
|
replaceKeys := []resource.PropertyKey{}
|
2024-07-26 12:14:45 +00:00
|
|
|
old, hasOld := req.OldOutputs["forcesReplacement"]
|
|
|
|
new, hasNew := req.NewInputs["forcesReplacement"]
|
2023-07-13 14:05:50 +00:00
|
|
|
if hasOld && !hasNew || hasNew && !hasOld || hasOld && hasNew && old.Diff(new) != nil {
|
|
|
|
replaceKeys = append(replaceKeys, "forcesReplacement")
|
|
|
|
}
|
|
|
|
return plugin.DiffResult{ReplaceKeys: replaceKeys}, nil
|
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
|
|
|
|
updateProgramWithResource := createUpdateProgramWithResourceFuncForAliasTests(t, loaders)
|
|
|
|
|
|
|
|
snap := updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n1",
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "urn-t1-n1")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that rename produces Same
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n2",
|
|
|
|
aliasURNs: []resource.URN{"urn:pulumi:test::test::pkgA:index:t1::n1"},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-t1-n2")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that rename produces Same with multiple aliases
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n3",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n1",
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n2",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-t1-n3")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that rename produces Same with multiple aliases (reversed)
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n3",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n2",
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n1",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-t1-n3-rename")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that aliasing back to original name is okay
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n1",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n3",
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n2",
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n1",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-alias-original")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that removing aliases is okay (once old names are gone from all snapshots)
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n1",
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-remove-alias")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that changing the type works
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "n1",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n1",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-t2-n1")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that changing the type again works
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:othermod:t3",
|
|
|
|
name: "n1",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n1",
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t2::n1",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-change-type")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that order of aliases doesn't matter
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:othermod:t3",
|
|
|
|
name: "n1",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n1",
|
|
|
|
"urn:pulumi:test::test::pkgA:othermod:t3::n1",
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t2::n1",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-alias-order")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that removing aliases is okay (once old names are gone from all snapshots)
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:othermod:t3",
|
|
|
|
name: "n1",
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-remove-alias-2")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that changing everything (including props) leads to update not delete and re-create
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t4",
|
|
|
|
name: "n2",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("x"): resource.NewNumberProperty(42),
|
|
|
|
},
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:othermod:t3::n1",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpUpdate}, false, "urn-t4-n2")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that changing everything again (including props) leads to update not delete and re-create
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t5",
|
|
|
|
name: "n3",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("x"): resource.NewNumberProperty(1000),
|
|
|
|
},
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t4::n2",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpUpdate}, false, "urn-change-everything-again")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that changing a forceNew property while also changing type and name leads to replacement not delete+create
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t6",
|
|
|
|
name: "n4",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("forcesReplacement"): resource.NewNumberProperty(1000),
|
|
|
|
},
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t5::n3",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpReplace, deploy.OpCreateReplacement, deploy.OpDeleteReplaced}, false, "urn-t6-n4")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure that changing a forceNew property and deleteBeforeReplace while also changing type and name leads to
|
|
|
|
// replacement not delete+create
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t7",
|
|
|
|
name: "n5",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("forcesReplacement"): resource.NewNumberProperty(999),
|
|
|
|
},
|
|
|
|
deleteBeforeReplace: true,
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t6::n4",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpReplace, deploy.OpCreateReplacement, deploy.OpDeleteReplaced}, false, "urn-force-new")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Start again - this time with two resources with depends on relationship
|
|
|
|
snap = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n1",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("forcesReplacement"): resource.NewNumberProperty(1),
|
|
|
|
},
|
|
|
|
deleteBeforeReplace: true,
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "n2",
|
|
|
|
dependencies: []resource.URN{"urn:pulumi:test::test::pkgA:index:t1::n1"},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "urn-depends-relationship")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1-new",
|
|
|
|
name: "n1-new",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("forcesReplacement"): resource.NewNumberProperty(2),
|
|
|
|
},
|
|
|
|
deleteBeforeReplace: true,
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n1",
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2-new",
|
|
|
|
name: "n2-new",
|
|
|
|
dependencies: []resource.URN{"urn:pulumi:test::test::pkgA:index:t1-new::n1-new"},
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t2::n2",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame, deploy.OpReplace, deploy.OpCreateReplacement, deploy.OpDeleteReplaced},
|
|
|
|
false, "urn-depends-relationship-2")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Start again - this time with two resources with parent relationship
|
|
|
|
snap = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n1",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("forcesReplacement"): resource.NewNumberProperty(1),
|
|
|
|
},
|
|
|
|
deleteBeforeReplace: true,
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "n2",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1::n1"),
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "urn-parent-relationship")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1-new",
|
|
|
|
name: "n1-new",
|
|
|
|
props: resource.PropertyMap{
|
|
|
|
resource.PropertyKey("forcesReplacement"): resource.NewNumberProperty(2),
|
|
|
|
},
|
|
|
|
deleteBeforeReplace: true,
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n1",
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2-new",
|
|
|
|
name: "n2-new",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1-new::n1-new"),
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1$pkgA:index:t2::n2",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame, deploy.OpReplace, deploy.OpCreateReplacement, deploy.OpDeleteReplaced},
|
|
|
|
false, "urn-parent-relationship-2")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// ensure failure when different resources use duplicate aliases
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n2",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n1",
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "n3",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n1",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, true, "urn-fail-duplicate")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// ensure different resources can use different aliases
|
|
|
|
_ = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n1",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n1",
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "n2",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n2",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "urn-different-aliases")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// ensure that aliases of parents of parents resolves correctly
|
|
|
|
// first create a chain of resources such that we have n1 -> n1-sub -> n1-sub-sub
|
|
|
|
snap = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "n1",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "n1-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1::n1"),
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t3",
|
|
|
|
name: "n1-sub-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1$pkgA:index:t2::n1-sub"),
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "urn-parent-alias-resolution")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Now change n1's name and type
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1-new",
|
|
|
|
name: "n1-new",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1::n1",
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "n1-new-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1-new::n1-new"),
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1$pkgA:index:t2::n1-sub",
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t3",
|
|
|
|
name: "n1-new-sub-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1-new$pkgA:index:t2::n1-new-sub"),
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1$pkgA:index:t2$pkgA:index:t3::n1-sub-sub",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-n1-change-name-and-type")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Test catastrophic multiplication out of aliases doesn't crash out of memory
|
|
|
|
// first create a chain of resources such that we have n1 -> n1-sub -> n1-sub-sub
|
|
|
|
snap = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1-v0",
|
|
|
|
name: "n1",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2-v0",
|
|
|
|
name: "n1-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1-v0::n1"),
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t3",
|
|
|
|
name: "n1-sub-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1-v0$pkgA:index:t2-v0::n1-sub"),
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "urn-multiplication")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Now change n1's name and type and n2's type, but also add a load of aliases and pre-multiply them out
|
|
|
|
// before sending to the engine
|
|
|
|
n1Aliases := make([]resource.URN, 0)
|
|
|
|
n2Aliases := make([]resource.URN, 0)
|
|
|
|
n3Aliases := make([]resource.URN, 0)
|
|
|
|
for i := 0; i < 100; i++ {
|
|
|
|
n1Aliases = append(n1Aliases, resource.URN(
|
|
|
|
fmt.Sprintf("urn:pulumi:test::test::pkgA:index:t1-v%d::n1", i)))
|
|
|
|
|
|
|
|
for j := 0; j < 10; j++ {
|
|
|
|
n2Aliases = append(n2Aliases, resource.URN(
|
|
|
|
fmt.Sprintf("urn:pulumi:test::test::pkgA:index:t1-v%d$pkgA:index:t2-v%d::n1-sub", i, j)))
|
|
|
|
|
|
|
|
n3Aliases = append(n3Aliases, resource.URN(
|
|
|
|
fmt.Sprintf("urn:pulumi:test::test::pkgA:index:t1-v%d$pkgA:index:t2-v%d$pkgA:index:t3::n1-sub-sub", i, j)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1-v100",
|
|
|
|
name: "n1-new",
|
|
|
|
aliasURNs: n1Aliases,
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2-v10",
|
|
|
|
name: "n1-new-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1-v100::n1-new"),
|
|
|
|
aliasURNs: n2Aliases,
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t3",
|
|
|
|
name: "n1-new-sub-sub",
|
|
|
|
parent: resource.URN("urn:pulumi:test::test::pkgA:index:t1-v100$pkgA:index:t2-v10::n1-new-sub"),
|
|
|
|
aliasURNs: n3Aliases,
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-multiple-aliases")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
var err error
|
|
|
|
_, err = snap.NormalizeURNReferences()
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.NoError(t, err)
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Start again with a parent and child.
|
|
|
|
snap = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:parent",
|
|
|
|
name: "parent",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:child",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:parent::parent",
|
|
|
|
name: "child",
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "urn-parent-child")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure renaming just the child produces Same
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:parent",
|
|
|
|
name: "parent",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:child",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:parent::parent",
|
|
|
|
name: "childnew",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:parent$pkgA:index:child::child",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-rename-child")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure changing just the child's type produces Same
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:parent",
|
|
|
|
name: "parent",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:child2",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:parent::parent",
|
|
|
|
name: "childnew",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:parent$pkgA:index:child::childnew",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-change-child-type")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Start again with multiple nested children.
|
|
|
|
snap = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "parent",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:t1::parent",
|
|
|
|
name: "sub",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:t1$pkgA:index:t1::sub",
|
|
|
|
name: "sub-sub",
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "urn-nested-children")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Ensure renaming the bottom child produces Same.
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "parent",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:t1::parent",
|
|
|
|
name: "sub",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:t1$pkgA:index:t1::sub",
|
|
|
|
name: "sub-sub-new",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1$pkgA:index:t1$pkgA:index:t1::sub-sub",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-rename-bottom-child")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Start again with two resources with no relationship.
|
|
|
|
snap = updateProgramWithResource(nil, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "one",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "two",
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpCreate}, false, "urn-two-resources-no-relationship")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Now make "two" a child of "one" ensuring no changes.
|
|
|
|
snap = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "one",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
parent: "urn:pulumi:test::test::pkgA:index:t1::one",
|
|
|
|
name: "two",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t2::two",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-make-two-child-of-one")
|
2023-07-13 14:05:50 +00:00
|
|
|
|
|
|
|
// Now remove the parent relationship.
|
|
|
|
_ = updateProgramWithResource(snap, []Resource{{
|
|
|
|
t: "pkgA:index:t1",
|
|
|
|
name: "one",
|
|
|
|
}, {
|
|
|
|
t: "pkgA:index:t2",
|
|
|
|
name: "two",
|
|
|
|
aliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:index:t1$pkgA:index:t2::two",
|
|
|
|
},
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}}, []display.StepOp{deploy.OpSame}, false, "urn-remove-parent-relationship")
|
2023-07-13 14:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestDuplicatesDueToAliases(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
// This is a test for https://github.com/pulumi/pulumi/issues/11173
|
|
|
|
// to check that we don't allow resource aliases to refer to other resources.
|
|
|
|
// That is if you have A, then try and add B saying it's alias is A we should error that's a duplicate.
|
|
|
|
// We need to be careful that we handle this regardless of the order we send the RegisterResource requests for A and B.
|
|
|
|
|
|
|
|
loaders := []*deploytest.ProviderLoader{
|
|
|
|
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) {
|
|
|
|
return &deploytest.Provider{
|
2024-07-26 12:14:45 +00:00
|
|
|
CreateF: func(_ context.Context, req plugin.CreateRequest) (plugin.CreateResponse, error) {
|
|
|
|
return plugin.CreateResponse{
|
|
|
|
ID: "created-id",
|
|
|
|
Properties: req.Properties,
|
|
|
|
Status: resource.StatusOK,
|
|
|
|
}, nil
|
2023-07-13 14:05:50 +00:00
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}, deploytest.WithoutGrpc),
|
|
|
|
}
|
|
|
|
|
|
|
|
mode := 0
|
2023-09-28 21:50:18 +00:00
|
|
|
programF := deploytest.NewLanguageRuntimeF(func(info plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
2023-07-13 14:05:50 +00:00
|
|
|
switch mode {
|
|
|
|
case 0:
|
|
|
|
// Default case, just make resA
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err := monitor.RegisterResource(
|
2023-07-13 14:05:50 +00:00
|
|
|
"pkgA:m:typA",
|
|
|
|
"resA",
|
|
|
|
true,
|
|
|
|
deploytest.ResourceOptions{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
// First test case, try and create a new B that aliases to A. First make the A like normal...
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err := monitor.RegisterResource(
|
2023-07-13 14:05:50 +00:00
|
|
|
"pkgA:m:typA",
|
|
|
|
"resA",
|
|
|
|
true,
|
|
|
|
deploytest.ResourceOptions{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
// ... then make B with an alias, it should error
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err = monitor.RegisterResource(
|
2023-07-13 14:05:50 +00:00
|
|
|
"pkgA:m:typA",
|
|
|
|
"resB",
|
|
|
|
true,
|
|
|
|
deploytest.ResourceOptions{
|
2024-01-26 18:29:22 +00:00
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
makeSpecAlias("resA", "", "", ""),
|
|
|
|
},
|
2023-07-13 14:05:50 +00:00
|
|
|
})
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
// Second test case, try and create a new B that aliases to A. First make the B with an alias...
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err := monitor.RegisterResource(
|
2023-07-13 14:05:50 +00:00
|
|
|
"pkgA:m:typA",
|
|
|
|
"resB",
|
|
|
|
true,
|
|
|
|
deploytest.ResourceOptions{
|
2024-01-26 18:29:22 +00:00
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
makeSpecAlias("resA", "", "", ""),
|
|
|
|
},
|
2023-07-13 14:05:50 +00:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
// ... then try to make the A like normal. It should error that it's already been aliased away
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err = monitor.RegisterResource(
|
2023-07-13 14:05:50 +00:00
|
|
|
"pkgA:m:typA",
|
|
|
|
"resA",
|
|
|
|
true,
|
|
|
|
deploytest.ResourceOptions{})
|
|
|
|
assert.Error(t, err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
2023-09-28 21:50:18 +00:00
|
|
|
hostF := deploytest.NewPluginHostF(nil, nil, programF, loaders...)
|
2023-07-13 14:05:50 +00:00
|
|
|
|
2024-10-28 11:58:59 +00:00
|
|
|
p := <.TestPlan{
|
|
|
|
Options: lt.TestUpdateOptions{T: t, HostF: hostF},
|
2023-07-13 14:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
project := p.GetProject()
|
|
|
|
|
|
|
|
// Run an update to create the starting A resource
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err := lt.TestOp(Update).RunStep(project, p.GetTarget(t, nil), p.Options, false, p.BackendClient, nil, "0")
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.NoError(t, err)
|
2023-07-13 14:05:50 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Len(t, snap.Resources, 2)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA::resA"), snap.Resources[1].URN)
|
|
|
|
|
|
|
|
// Set mode to try and create A then a B that aliases to it, this should fail
|
|
|
|
mode = 1
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, snap), p.Options, false, p.BackendClient, nil, "1")
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.Error(t, err)
|
2023-07-13 14:05:50 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Len(t, snap.Resources, 2)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA::resA"), snap.Resources[1].URN)
|
|
|
|
|
|
|
|
// Set mode to try and create B first then a A, this should fail
|
|
|
|
mode = 2
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, snap), p.Options, false, p.BackendClient, nil, "2")
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.Error(t, err)
|
2023-07-13 14:05:50 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Len(t, snap.Resources, 2)
|
|
|
|
// Because we made the B first that's what should end up in the state file
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA::resB"), snap.Resources[1].URN)
|
|
|
|
}
|
|
|
|
|
2023-09-06 12:17:02 +00:00
|
|
|
func TestCorrectResourceChosen(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
// This is a test for https://github.com/pulumi/pulumi/issues/13848
|
|
|
|
// to check that a resource's URN is used first when looking for old resources in the state
|
|
|
|
// rather than aliases, and that we don't end up with a corrupt state after an update.
|
|
|
|
|
|
|
|
loaders := []*deploytest.ProviderLoader{
|
|
|
|
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) {
|
|
|
|
return &deploytest.Provider{
|
2024-07-26 12:14:45 +00:00
|
|
|
CreateF: func(_ context.Context, req plugin.CreateRequest) (plugin.CreateResponse, error) {
|
|
|
|
return plugin.CreateResponse{
|
|
|
|
ID: "created-id",
|
|
|
|
Properties: req.Properties,
|
|
|
|
Status: resource.StatusOK,
|
|
|
|
}, nil
|
2023-09-06 12:17:02 +00:00
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}, deploytest.WithoutGrpc),
|
|
|
|
}
|
|
|
|
|
|
|
|
mode := 0
|
2023-09-28 21:50:18 +00:00
|
|
|
programF := deploytest.NewLanguageRuntimeF(func(info plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
2023-09-06 12:17:02 +00:00
|
|
|
switch mode {
|
|
|
|
case 0:
|
|
|
|
// Default case, make "resA", "resB with resA as its parent", and "resB with no parent".
|
2024-04-19 11:08:56 +00:00
|
|
|
respA, err := monitor.RegisterResource(
|
2023-09-06 12:17:02 +00:00
|
|
|
"pkgA:m:typA",
|
|
|
|
"resA",
|
|
|
|
true,
|
|
|
|
deploytest.ResourceOptions{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err = monitor.RegisterResource(
|
2023-09-06 12:17:02 +00:00
|
|
|
"pkgA:m:typA",
|
|
|
|
"resB",
|
|
|
|
true,
|
2024-04-19 11:08:56 +00:00
|
|
|
deploytest.ResourceOptions{Parent: respA.URN})
|
2023-09-06 12:17:02 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err = monitor.RegisterResource(
|
2023-09-06 12:17:02 +00:00
|
|
|
"pkgA:m:typA",
|
|
|
|
"resB",
|
|
|
|
true,
|
|
|
|
deploytest.ResourceOptions{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
// Next case, make "resA" and "resB with no parent and alias to have resA as its parent".
|
2024-04-19 11:08:56 +00:00
|
|
|
respA, err := monitor.RegisterResource(
|
2023-09-06 12:17:02 +00:00
|
|
|
"pkgA:m:typA",
|
|
|
|
"resA",
|
|
|
|
true,
|
|
|
|
deploytest.ResourceOptions{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err = monitor.RegisterResource(
|
2023-09-06 12:17:02 +00:00
|
|
|
"pkgA:m:typA",
|
|
|
|
"resB",
|
|
|
|
true,
|
2024-01-26 18:29:22 +00:00
|
|
|
deploytest.ResourceOptions{
|
|
|
|
Aliases: []*pulumirpc.Alias{
|
2024-04-19 11:08:56 +00:00
|
|
|
makeSpecAliasWithParent("", "", "", "", string(respA.URN)),
|
2024-01-26 18:29:22 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
2023-09-06 12:17:02 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
2023-09-28 21:50:18 +00:00
|
|
|
hostF := deploytest.NewPluginHostF(nil, nil, programF, loaders...)
|
2023-09-06 12:17:02 +00:00
|
|
|
|
2024-10-28 11:58:59 +00:00
|
|
|
p := <.TestPlan{
|
|
|
|
Options: lt.TestUpdateOptions{T: t, HostF: hostF},
|
2023-09-06 12:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
project := p.GetProject()
|
|
|
|
|
|
|
|
// Run an update for initial state with "resA", "resB with resA as its parent", and "resB with no parent".
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err := lt.TestOp(Update).RunStep(project, p.GetTarget(t, nil), p.Options, false, p.BackendClient, nil, "0")
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.NoError(t, err)
|
2023-09-06 12:17:02 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Nil(t, snap.VerifyIntegrity())
|
|
|
|
assert.Len(t, snap.Resources, 4)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA::resA"), snap.Resources[1].URN)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA$pkgA:m:typA::resB"), snap.Resources[2].URN)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA::resB"), snap.Resources[3].URN)
|
|
|
|
|
|
|
|
// Run the next case, with "resA" and "resB with no parent and alias to have resA as its parent".
|
|
|
|
mode = 1
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, snap), p.Options, false, p.BackendClient, nil, "1")
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.NoError(t, err)
|
2023-09-06 12:17:02 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Nil(t, snap.VerifyIntegrity())
|
|
|
|
assert.Len(t, snap.Resources, 3)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA::resA"), snap.Resources[1].URN)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA::resB"), snap.Resources[2].URN)
|
|
|
|
assert.Len(t, snap.Resources[2].Aliases, 0)
|
|
|
|
}
|
|
|
|
|
2023-07-13 14:05:50 +00:00
|
|
|
func TestComponentToCustomUpdate(t *testing.T) {
|
|
|
|
// Test for https://github.com/pulumi/pulumi/issues/12550, check that if we change a component resource
|
|
|
|
// into a custom resource the engine handles that best it can. This depends on the provider being able to
|
|
|
|
// cope with the component state being passed as custom state.
|
|
|
|
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
loaders := []*deploytest.ProviderLoader{
|
|
|
|
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) {
|
|
|
|
return &deploytest.Provider{
|
2024-07-26 12:14:45 +00:00
|
|
|
CreateF: func(_ context.Context, req plugin.CreateRequest) (plugin.CreateResponse, error) {
|
2023-07-13 14:05:50 +00:00
|
|
|
id := resource.ID("")
|
2024-07-26 12:14:45 +00:00
|
|
|
if !req.Preview {
|
2023-07-13 14:05:50 +00:00
|
|
|
id = resource.ID("1")
|
|
|
|
}
|
2024-07-26 12:14:45 +00:00
|
|
|
return plugin.CreateResponse{
|
|
|
|
ID: id,
|
|
|
|
Properties: req.Properties,
|
|
|
|
Status: resource.StatusOK,
|
|
|
|
}, nil
|
2023-07-13 14:05:50 +00:00
|
|
|
},
|
2024-07-26 12:14:45 +00:00
|
|
|
DeleteF: func(context.Context, plugin.DeleteRequest) (plugin.DeleteResponse, error) {
|
|
|
|
return plugin.DeleteResponse{}, nil
|
2023-07-13 14:05:50 +00:00
|
|
|
},
|
2024-07-26 12:14:45 +00:00
|
|
|
DiffF: func(context.Context, plugin.DiffRequest) (plugin.DiffResult, error) {
|
2023-07-13 14:05:50 +00:00
|
|
|
return plugin.DiffResult{}, nil
|
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}, deploytest.WithoutGrpc),
|
|
|
|
}
|
|
|
|
|
|
|
|
insA := resource.NewPropertyMapFromMap(map[string]interface{}{
|
|
|
|
"foo": "bar",
|
|
|
|
})
|
|
|
|
createA := func(monitor *deploytest.ResourceMonitor) {
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err := monitor.RegisterResource("prog::myType", "resA", false, deploytest.ResourceOptions{
|
2023-07-13 14:05:50 +00:00
|
|
|
Inputs: insA,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
2023-09-28 21:50:18 +00:00
|
|
|
programF := deploytest.NewLanguageRuntimeF(func(info plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
2023-07-13 14:05:50 +00:00
|
|
|
createA(monitor)
|
|
|
|
return nil
|
|
|
|
})
|
2023-09-28 21:50:18 +00:00
|
|
|
hostF := deploytest.NewPluginHostF(nil, nil, programF, loaders...)
|
2023-07-13 14:05:50 +00:00
|
|
|
|
2024-10-28 11:58:59 +00:00
|
|
|
p := <.TestPlan{
|
|
|
|
Options: lt.TestUpdateOptions{T: t, HostF: hostF},
|
2023-07-13 14:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
project := p.GetProject()
|
|
|
|
|
|
|
|
// Run an update to create the resources
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err := lt.TestOp(Update).RunStep(project, p.GetTarget(t, nil), p.Options, false, p.BackendClient, nil, "0")
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.NoError(t, err)
|
2023-07-13 14:05:50 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Len(t, snap.Resources, 1)
|
|
|
|
assert.Equal(t, tokens.Type("prog::myType"), snap.Resources[0].Type)
|
|
|
|
assert.False(t, snap.Resources[0].Custom)
|
|
|
|
|
|
|
|
// Now update A from a component to custom with an alias
|
|
|
|
createA = func(monitor *deploytest.ResourceMonitor) {
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err := monitor.RegisterResource("pkgA:m:typA", "resA", true, deploytest.ResourceOptions{
|
2023-07-13 14:05:50 +00:00
|
|
|
Inputs: insA,
|
2024-01-26 18:29:22 +00:00
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
makeSpecAlias("", "prog::myType", "", ""),
|
2023-07-13 14:05:50 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, snap), p.Options, false, p.BackendClient, nil, "1")
|
2023-07-13 14:05:50 +00:00
|
|
|
// Assert that A is now a custom
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.NoError(t, err)
|
2023-07-13 14:05:50 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
// Now two because we'll have a provider now
|
|
|
|
assert.Len(t, snap.Resources, 2)
|
|
|
|
assert.Equal(t, tokens.Type("pkgA:m:typA"), snap.Resources[1].Type)
|
|
|
|
assert.True(t, snap.Resources[1].Custom)
|
|
|
|
|
|
|
|
// Now update A back to a component (with an alias)
|
|
|
|
createA = func(monitor *deploytest.ResourceMonitor) {
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err := monitor.RegisterResource("prog::myType", "resA", false, deploytest.ResourceOptions{
|
2023-07-13 14:05:50 +00:00
|
|
|
Inputs: insA,
|
2024-01-26 18:29:22 +00:00
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
makeSpecAlias("", "pkgA:m:typA", "", ""),
|
2023-07-13 14:05:50 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, snap), p.Options, false, p.BackendClient, nil, "2")
|
2023-07-13 14:05:50 +00:00
|
|
|
// Assert that A is now a custom
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.NoError(t, err)
|
2023-07-13 14:05:50 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
// Back to one because the provider should have been cleaned up as well
|
|
|
|
assert.Len(t, snap.Resources, 1)
|
|
|
|
assert.Equal(t, tokens.Type("prog::myType"), snap.Resources[0].Type)
|
|
|
|
assert.False(t, snap.Resources[0].Custom)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestParentAlias(t *testing.T) {
|
|
|
|
// Test for https://github.com/pulumi/pulumi/issues/13324, check that if we change a parent resource which
|
|
|
|
// is also aliased at the same time that we track this correctly.
|
|
|
|
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
loaders := []*deploytest.ProviderLoader{
|
|
|
|
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) {
|
|
|
|
return &deploytest.Provider{
|
2024-07-26 12:14:45 +00:00
|
|
|
CreateF: func(_ context.Context, req plugin.CreateRequest) (plugin.CreateResponse, error) {
|
2023-07-13 14:05:50 +00:00
|
|
|
id := resource.ID("")
|
2024-07-26 12:14:45 +00:00
|
|
|
if !req.Preview {
|
2023-07-13 14:05:50 +00:00
|
|
|
id = resource.ID("1")
|
|
|
|
}
|
2024-07-26 12:14:45 +00:00
|
|
|
return plugin.CreateResponse{
|
|
|
|
ID: id,
|
|
|
|
Properties: req.Properties,
|
|
|
|
Status: resource.StatusOK,
|
|
|
|
}, nil
|
2023-07-13 14:05:50 +00:00
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}, deploytest.WithoutGrpc),
|
|
|
|
}
|
|
|
|
|
|
|
|
firstRun := true
|
2023-09-28 21:50:18 +00:00
|
|
|
programF := deploytest.NewLanguageRuntimeF(func(info plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
2024-04-19 11:08:56 +00:00
|
|
|
respA, err := monitor.RegisterResource(
|
2024-02-08 13:01:47 +00:00
|
|
|
"prog:index:myStandardType", "resA", false, deploytest.ResourceOptions{})
|
2023-07-13 14:05:50 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
if firstRun {
|
2024-04-19 11:08:56 +00:00
|
|
|
respB, err := monitor.RegisterResource("prog:index:myType", "resB", false, deploytest.ResourceOptions{})
|
2023-07-13 14:05:50 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err = monitor.RegisterResource("pkgA:m:typA", "resC", true, deploytest.ResourceOptions{
|
|
|
|
Parent: respB.URN,
|
2023-07-13 14:05:50 +00:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
} else {
|
2024-04-19 11:08:56 +00:00
|
|
|
respB, err := monitor.RegisterResource("prog:index:myType", "resB", false, deploytest.ResourceOptions{
|
|
|
|
Parent: respA.URN,
|
2024-01-26 18:29:22 +00:00
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
makeSpecAliasWithNoParent("", "", "", "", true),
|
2023-07-13 14:05:50 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err = monitor.RegisterResource("pkgA:m:typA", "resC", true, deploytest.ResourceOptions{
|
|
|
|
Parent: respA.URN,
|
2024-01-26 18:29:22 +00:00
|
|
|
Aliases: []*pulumirpc.Alias{
|
2024-04-19 11:08:56 +00:00
|
|
|
makeSpecAliasWithParent("", "", "", "", string(respB.URN)),
|
2023-07-13 14:05:50 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
2023-09-28 21:50:18 +00:00
|
|
|
hostF := deploytest.NewPluginHostF(nil, nil, programF, loaders...)
|
2023-07-13 14:05:50 +00:00
|
|
|
|
2024-10-28 11:58:59 +00:00
|
|
|
p := <.TestPlan{
|
|
|
|
Options: lt.TestUpdateOptions{T: t, HostF: hostF},
|
2023-07-13 14:05:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
project := p.GetProject()
|
|
|
|
|
|
|
|
// Run an update to create the resources
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err := lt.TestOp(Update).RunStep(project, p.GetTarget(t, nil), p.Options, false, p.BackendClient, nil, "0")
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.NoError(t, err)
|
2023-07-13 14:05:50 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Len(t, snap.Resources, 4)
|
|
|
|
|
|
|
|
// Now run again with the rearranged parents, we don't expect to see any replaces
|
|
|
|
firstRun = false
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, snap), p.Options, false, p.BackendClient,
|
2023-07-13 14:05:50 +00:00
|
|
|
func(project workspace.Project, target deploy.Target,
|
2024-05-06 17:34:24 +00:00
|
|
|
entries JournalEntries, events []Event, err error,
|
2023-10-11 14:44:09 +00:00
|
|
|
) error {
|
2023-07-13 14:05:50 +00:00
|
|
|
for _, entry := range entries {
|
|
|
|
assert.Equal(t, deploy.OpSame, entry.Step.Op())
|
|
|
|
}
|
2023-10-11 14:44:09 +00:00
|
|
|
return err
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}, "1")
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.NoError(t, err)
|
2023-07-13 14:05:50 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Len(t, snap.Resources, 4)
|
|
|
|
}
|
2023-09-14 19:52:27 +00:00
|
|
|
|
2024-01-26 18:29:22 +00:00
|
|
|
func TestEmptyParentAlias(t *testing.T) {
|
|
|
|
// Test for backwards compatibility with Python, an alias that sets parent explicitly to "" should be treated the
|
|
|
|
// same as not setting parent at all.
|
|
|
|
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
loaders := []*deploytest.ProviderLoader{
|
|
|
|
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) {
|
|
|
|
return &deploytest.Provider{
|
2024-07-26 12:14:45 +00:00
|
|
|
CreateF: func(_ context.Context, req plugin.CreateRequest) (plugin.CreateResponse, error) {
|
2024-01-26 18:29:22 +00:00
|
|
|
id := resource.ID("")
|
2024-07-26 12:14:45 +00:00
|
|
|
if !req.Preview {
|
2024-01-26 18:29:22 +00:00
|
|
|
id = resource.ID("1")
|
|
|
|
}
|
2024-07-26 12:14:45 +00:00
|
|
|
return plugin.CreateResponse{
|
|
|
|
ID: id,
|
|
|
|
Properties: req.Properties,
|
|
|
|
Status: resource.StatusOK,
|
|
|
|
}, nil
|
2024-01-26 18:29:22 +00:00
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}, deploytest.WithoutGrpc),
|
|
|
|
}
|
|
|
|
|
|
|
|
firstRun := true
|
|
|
|
programF := deploytest.NewLanguageRuntimeF(func(info plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
2024-04-19 11:08:56 +00:00
|
|
|
respA, err := monitor.RegisterResource(
|
2024-02-08 13:01:47 +00:00
|
|
|
"prog:index:myStandardType", "resA", false, deploytest.ResourceOptions{})
|
2024-01-26 18:29:22 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
if firstRun {
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err := monitor.RegisterResource("prog:index:myType", "resB", false, deploytest.ResourceOptions{
|
|
|
|
Parent: respA.URN,
|
2024-01-26 18:29:22 +00:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
} else {
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err := monitor.RegisterResource("prog:index:myType", "resC", false, deploytest.ResourceOptions{
|
|
|
|
Parent: respA.URN,
|
2024-01-26 18:29:22 +00:00
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
makeSpecAliasWithParent("resB", "", "", "", ""),
|
|
|
|
},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
hostF := deploytest.NewPluginHostF(nil, nil, programF, loaders...)
|
|
|
|
|
2024-10-28 11:58:59 +00:00
|
|
|
p := <.TestPlan{
|
|
|
|
Options: lt.TestUpdateOptions{T: t, HostF: hostF},
|
2024-01-26 18:29:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
project := p.GetProject()
|
|
|
|
|
|
|
|
// Run an update to create the resources
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err := lt.TestOp(Update).RunStep(project, p.GetTarget(t, nil), p.Options, false, p.BackendClient, nil, "0")
|
2024-01-26 18:29:22 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Len(t, snap.Resources, 2)
|
|
|
|
|
|
|
|
// Now run again with the rearranged parents, we don't expect to see any replaces
|
|
|
|
firstRun = false
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, snap), p.Options, false, p.BackendClient,
|
2024-01-26 18:29:22 +00:00
|
|
|
func(project workspace.Project, target deploy.Target,
|
2024-05-06 17:34:24 +00:00
|
|
|
entries JournalEntries, events []Event, err error,
|
2024-01-26 18:29:22 +00:00
|
|
|
) error {
|
|
|
|
for _, entry := range entries {
|
|
|
|
assert.Equal(t, deploy.OpSame, entry.Step.Op())
|
|
|
|
}
|
|
|
|
return err
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
}, "1")
|
2024-01-26 18:29:22 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Len(t, snap.Resources, 2)
|
|
|
|
}
|
|
|
|
|
2023-09-14 19:52:27 +00:00
|
|
|
func TestSplitUpdateComponentAliases(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
// This is a test for https://github.com/pulumi/pulumi/issues/13903 to check that if a component is
|
|
|
|
// aliased the internal resources follow it across a split deployment.
|
|
|
|
|
|
|
|
mode := 0
|
|
|
|
loaders := []*deploytest.ProviderLoader{
|
|
|
|
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) {
|
|
|
|
return &deploytest.Provider{
|
2024-07-26 12:14:45 +00:00
|
|
|
CreateF: func(_ context.Context, req plugin.CreateRequest) (plugin.CreateResponse, error) {
|
2023-09-14 19:52:27 +00:00
|
|
|
// We should only create things in the first pass
|
2024-07-26 12:14:45 +00:00
|
|
|
assert.Equal(t, 0, mode, "%s tried to create but should be aliased", req.URN)
|
2023-09-14 19:52:27 +00:00
|
|
|
|
2024-07-26 12:14:45 +00:00
|
|
|
return plugin.CreateResponse{
|
|
|
|
ID: "created-id",
|
|
|
|
Properties: req.Properties,
|
|
|
|
Status: resource.StatusOK,
|
|
|
|
}, nil
|
2023-09-14 19:52:27 +00:00
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}, deploytest.WithoutGrpc),
|
|
|
|
}
|
|
|
|
|
2023-09-28 21:50:18 +00:00
|
|
|
programF := deploytest.NewLanguageRuntimeF(func(info plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
2023-09-14 19:52:27 +00:00
|
|
|
switch mode {
|
|
|
|
case 0:
|
|
|
|
// Default case, make "resA", and "resB" a component with "resA" as its parent and "resC" in the component
|
2024-04-19 11:08:56 +00:00
|
|
|
respA, err := monitor.RegisterResource(
|
2023-09-14 19:52:27 +00:00
|
|
|
"pkgA:m:typA",
|
|
|
|
"resA",
|
|
|
|
true,
|
|
|
|
deploytest.ResourceOptions{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2024-04-19 11:08:56 +00:00
|
|
|
respB, err := monitor.RegisterResource(
|
2023-09-14 19:52:27 +00:00
|
|
|
"pkgA:m:typB",
|
|
|
|
"resB",
|
|
|
|
false,
|
|
|
|
deploytest.ResourceOptions{
|
2024-04-19 11:08:56 +00:00
|
|
|
Parent: respA.URN,
|
2023-09-14 19:52:27 +00:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err = monitor.RegisterResource(
|
2023-09-14 19:52:27 +00:00
|
|
|
"pkgA:m:typC",
|
|
|
|
"resC",
|
|
|
|
true,
|
|
|
|
deploytest.ResourceOptions{
|
2024-04-19 11:08:56 +00:00
|
|
|
Parent: respB.URN,
|
2023-09-14 19:52:27 +00:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
// Delete "resA" and re-parent "resB" to the root but then fail before getting to resC.
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err := monitor.RegisterResource(
|
2023-09-14 19:52:27 +00:00
|
|
|
"pkgA:m:typB",
|
|
|
|
"resB",
|
|
|
|
false,
|
|
|
|
deploytest.ResourceOptions{
|
|
|
|
AliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:m:typA$pkgA:m:typB::resB",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
return errors.New("something went bang")
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
// Update again but this time succeed and register C.
|
2024-04-19 11:08:56 +00:00
|
|
|
respB, err := monitor.RegisterResource(
|
2023-09-14 19:52:27 +00:00
|
|
|
"pkgA:m:typB",
|
|
|
|
"resB",
|
|
|
|
false,
|
|
|
|
deploytest.ResourceOptions{
|
|
|
|
AliasURNs: []resource.URN{
|
|
|
|
"urn:pulumi:test::test::pkgA:m:typA$pkgA:m:typB::resB",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err = monitor.RegisterResource(
|
2023-09-14 19:52:27 +00:00
|
|
|
"pkgA:m:typC",
|
|
|
|
"resC",
|
|
|
|
true,
|
|
|
|
deploytest.ResourceOptions{
|
2024-04-19 11:08:56 +00:00
|
|
|
Parent: respB.URN,
|
2023-09-14 19:52:27 +00:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
2023-09-28 21:50:18 +00:00
|
|
|
hostF := deploytest.NewPluginHostF(nil, nil, programF, loaders...)
|
2023-09-14 19:52:27 +00:00
|
|
|
|
2024-10-28 11:58:59 +00:00
|
|
|
p := <.TestPlan{
|
|
|
|
Options: lt.TestUpdateOptions{T: t, HostF: hostF},
|
2023-09-14 19:52:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
project := p.GetProject()
|
|
|
|
|
|
|
|
// Run an update for initial state with "resA", "resB", and "resC".
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err := lt.TestOp(Update).RunStep(project, p.GetTarget(t, nil), p.Options, false, p.BackendClient, nil, "0")
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.NoError(t, err)
|
2023-09-14 19:52:27 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Nil(t, snap.VerifyIntegrity())
|
|
|
|
assert.Len(t, snap.Resources, 4)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA::resA"), snap.Resources[1].URN)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA$pkgA:m:typB::resB"), snap.Resources[2].URN)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA::resA"), snap.Resources[2].Parent)
|
|
|
|
assert.Equal(t,
|
|
|
|
resource.URN("urn:pulumi:test::test::pkgA:m:typA$pkgA:m:typB$pkgA:m:typC::resC"),
|
|
|
|
snap.Resources[3].URN)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA$pkgA:m:typB::resB"), snap.Resources[3].Parent)
|
|
|
|
|
|
|
|
// Run the next case, resB should be re-parented to the root. A should still be left (because we couldn't
|
|
|
|
// tell it needed to delete due to the error), C should have it's old URN but new parent because it wasn't
|
|
|
|
// registered.
|
|
|
|
mode = 1
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, snap), p.Options, false, p.BackendClient, nil, "1")
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.Error(t, err)
|
2023-09-14 19:52:27 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Nil(t, snap.VerifyIntegrity())
|
|
|
|
assert.Len(t, snap.Resources, 4)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typB::resB"), snap.Resources[0].URN)
|
|
|
|
assert.Equal(t, resource.URN(""), snap.Resources[0].Parent)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA::resA"), snap.Resources[2].URN)
|
|
|
|
// Even though we didn't register C its URN must update to take the re-parenting into account.
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typB$pkgA:m:typC::resC"), snap.Resources[3].URN)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typB::resB"), snap.Resources[3].Parent)
|
|
|
|
|
|
|
|
mode = 2
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, snap), p.Options, false, p.BackendClient, nil, "2")
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.NoError(t, err)
|
2023-09-14 19:52:27 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Nil(t, snap.VerifyIntegrity())
|
|
|
|
assert.Len(t, snap.Resources, 3)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typB::resB"), snap.Resources[0].URN)
|
|
|
|
assert.Equal(t, resource.URN(""), snap.Resources[0].Parent)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typB$pkgA:m:typC::resC"), snap.Resources[2].URN)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typB::resB"), snap.Resources[2].Parent)
|
|
|
|
}
|
2023-09-26 15:18:35 +00:00
|
|
|
|
|
|
|
func TestFailDeleteDuplicateAliases(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
// This is a test for https://github.com/pulumi/pulumi/issues/14041 to check that we don't courrupt state files when
|
|
|
|
// old aliased resources are left in state because they can't delete.
|
|
|
|
//
|
|
|
|
// Imagine the following update flow from an old engine version where we saved aliases to state:
|
|
|
|
//
|
|
|
|
// 1) Creates "resA".
|
|
|
|
//
|
|
|
|
// 2) Makes "resAX" with an alias to "resA" so end up with one resource in the state file "resAX", but it records
|
|
|
|
// it's alias as "resA".
|
|
|
|
//
|
|
|
|
// 3) Tries to destroy "resA" but fails so leaves it in the state file as is, this step doesn't actually seem
|
|
|
|
// important for triggering the error.
|
|
|
|
//
|
|
|
|
// 4) Creates "resA" and again tries to delete "resAX" but again fails, now we try and save the snapshot but before
|
|
|
|
// we save the snapshot we do URN normalisation - That looks at all the resources and sees which ones we're aliased
|
|
|
|
// by looking at the Aliases field on their state - "resAX" still has it's alias recorded from Update 2 so it
|
|
|
|
// registers a URN fixup of "resA" -> "resAX" - We then rewrite all the resources with that rule which means any new
|
|
|
|
// resources created in the update (new resources are always first in the snapshot list) that were either called
|
|
|
|
// resA or tried to use resA as a parent now all rewrite their pointers and URNs to "resAX" which is at the end of
|
|
|
|
// the snapshot list (this explains why we we're seeing child before parent before 3.83, and now see duplicate
|
|
|
|
// resource) - Voila bad snapshot.
|
|
|
|
//
|
|
|
|
// To prevent the above the engine now doesn't save Aliases in state anymore, so when we run update 4 above it
|
|
|
|
// doesn't see any aliases saved for "resAX" and so doesn't do the broken normalisation.
|
|
|
|
|
|
|
|
mode := 0
|
|
|
|
loaders := []*deploytest.ProviderLoader{
|
|
|
|
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) {
|
|
|
|
return &deploytest.Provider{
|
2024-07-26 12:14:45 +00:00
|
|
|
CreateF: func(_ context.Context, req plugin.CreateRequest) (plugin.CreateResponse, error) {
|
2023-09-26 15:18:35 +00:00
|
|
|
// We should only create things in the first and last pass
|
|
|
|
ok := mode == 0 || mode == 2
|
2024-07-26 12:14:45 +00:00
|
|
|
assert.True(t, ok, "%s tried to create but should be aliased", req.URN)
|
2023-09-26 15:18:35 +00:00
|
|
|
|
2024-07-26 12:14:45 +00:00
|
|
|
return plugin.CreateResponse{
|
|
|
|
ID: "created-id",
|
|
|
|
Properties: req.Properties,
|
|
|
|
Status: resource.StatusOK,
|
|
|
|
}, nil
|
2023-09-26 15:18:35 +00:00
|
|
|
},
|
2024-07-26 12:14:45 +00:00
|
|
|
DeleteF: func(_ context.Context, req plugin.DeleteRequest) (plugin.DeleteResponse, error) {
|
2023-09-26 15:18:35 +00:00
|
|
|
// We should only delete things in the last pass
|
|
|
|
ok := mode == 2
|
2024-07-26 12:14:45 +00:00
|
|
|
assert.True(t, ok, "%s tried to delete but should be aliased", req.URN)
|
2023-09-26 15:18:35 +00:00
|
|
|
|
2024-07-26 12:14:45 +00:00
|
|
|
return plugin.DeleteResponse{Status: resource.StatusUnknown}, errors.New("can't delete")
|
2023-09-26 15:18:35 +00:00
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}, deploytest.WithoutGrpc),
|
|
|
|
}
|
|
|
|
|
2023-09-28 21:50:18 +00:00
|
|
|
programF := deploytest.NewLanguageRuntimeF(func(info plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
2023-09-26 15:18:35 +00:00
|
|
|
switch mode {
|
|
|
|
case 0:
|
|
|
|
fallthrough
|
|
|
|
case 2:
|
|
|
|
// Default case, and also the last case make "resA"
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err := monitor.RegisterResource(
|
2023-09-26 15:18:35 +00:00
|
|
|
"pkgA:m:typA",
|
|
|
|
"resA",
|
|
|
|
true,
|
|
|
|
deploytest.ResourceOptions{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
// Rename "resA" to "resAX" with an alias
|
2024-04-19 11:08:56 +00:00
|
|
|
_, err := monitor.RegisterResource(
|
2023-09-26 15:18:35 +00:00
|
|
|
"pkgA:m:typA",
|
|
|
|
"resAX",
|
|
|
|
true,
|
|
|
|
deploytest.ResourceOptions{
|
2024-01-26 18:29:22 +00:00
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
makeSpecAlias("resA", "", "", ""),
|
2023-09-26 15:18:35 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
2023-09-28 21:50:18 +00:00
|
|
|
hostF := deploytest.NewPluginHostF(nil, nil, programF, loaders...)
|
2023-09-26 15:18:35 +00:00
|
|
|
|
2024-10-28 11:58:59 +00:00
|
|
|
p := <.TestPlan{
|
|
|
|
Options: lt.TestUpdateOptions{T: t, HostF: hostF},
|
2023-09-26 15:18:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
project := p.GetProject()
|
|
|
|
|
|
|
|
// Run an update for initial state with "resA"
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err := lt.TestOp(Update).RunStep(project, p.GetTarget(t, nil), p.Options, false, p.BackendClient, nil, "1")
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.NoError(t, err)
|
2023-09-26 15:18:35 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Nil(t, snap.VerifyIntegrity())
|
|
|
|
assert.Len(t, snap.Resources, 2)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA::resA"), snap.Resources[1].URN)
|
|
|
|
|
|
|
|
// Run the next case, resA should be aliased
|
|
|
|
mode = 1
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, snap), p.Options, false, p.BackendClient, nil, "2")
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.NoError(t, err)
|
2023-09-26 15:18:35 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Nil(t, snap.VerifyIntegrity())
|
|
|
|
assert.Len(t, snap.Resources, 2)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA::resAX"), snap.Resources[1].URN)
|
|
|
|
|
|
|
|
// Run the last case, resAX should try to delete and resA should be created. We can't possibly know that resA ==
|
|
|
|
// resAX at this point because we're not being sent aliases.
|
|
|
|
mode = 2
|
2024-10-28 11:58:59 +00:00
|
|
|
snap, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, snap), p.Options, false, p.BackendClient, nil, "3")
|
2023-10-13 09:46:07 +00:00
|
|
|
assert.Error(t, err)
|
2023-09-26 15:18:35 +00:00
|
|
|
assert.NotNil(t, snap)
|
|
|
|
assert.Nil(t, snap.VerifyIntegrity())
|
|
|
|
assert.Len(t, snap.Resources, 3)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA::resA"), snap.Resources[1].URN)
|
|
|
|
assert.Equal(t, resource.URN("urn:pulumi:test::test::pkgA:m:typA::resAX"), snap.Resources[2].URN)
|
|
|
|
}
|
2024-11-05 13:27:11 +00:00
|
|
|
|
|
|
|
// Tests that aliases in provider dependencies are correctly normalized when snapshots are written. That is, if a
|
|
|
|
// resource's provider reference points to a URN that is now an alias for a newly renamed resource, the provider
|
|
|
|
// reference should be updated to the new URN before the snapshot is persisted.
|
|
|
|
func TestAliasesInProvidersAreNormalized(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
p := <.TestPlan{
|
|
|
|
Project: "test-project",
|
|
|
|
Stack: "test-stack",
|
|
|
|
}
|
|
|
|
project := p.GetProject()
|
|
|
|
|
|
|
|
loaders := []*deploytest.ProviderLoader{
|
|
|
|
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) {
|
|
|
|
return &deploytest.Provider{}, nil
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set up the initial program:
|
|
|
|
//
|
|
|
|
// * res0 and res1, which will serve as parents -- res1 initially, then res0 in the second update;
|
|
|
|
// * prov, which will be the child that moves from res1 to res0 and that is aliased in the second update;
|
|
|
|
// * res3, which will have prov as its provider.
|
|
|
|
//
|
|
|
|
// Note: for the URN of prov to change, res0 and res1 must have different types, since only parent types are included
|
|
|
|
// in the URNs of their children. The choice of type0/type1 etc. is thus important in this test.
|
|
|
|
setupProgramF := deploytest.NewLanguageRuntimeF(func(_ plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
|
|
|
_, err := monitor.RegisterResource("pkgA:modA:type0", "res0", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
res1, err := monitor.RegisterResource("pkgA:modA:type1", "res1", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
prov, err := monitor.RegisterResource("pulumi:providers:pkgA", "prov", true, deploytest.ResourceOptions{
|
|
|
|
Parent: res1.URN,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
provRef, err := providers.NewReference(prov.URN, prov.ID)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = monitor.RegisterResource("pkgA:modA:type3", "res3", true, deploytest.ResourceOptions{
|
|
|
|
Provider: provRef.String(),
|
|
|
|
Parent: res1.URN,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
setupHostF := deploytest.NewPluginHostF(nil, nil, setupProgramF, loaders...)
|
|
|
|
setupOpts := lt.TestUpdateOptions{
|
|
|
|
T: t,
|
|
|
|
HostF: setupHostF,
|
|
|
|
}
|
|
|
|
setupSnap, err := lt.TestOp(Update).RunStep(project, p.GetTarget(t, nil), setupOpts, false, p.BackendClient, nil, "0")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// Set up the test program:
|
|
|
|
//
|
|
|
|
// * res0 and res1, which will serve as parents as before;
|
|
|
|
// * prov, which will now be moved to a child of res0, with an alias to its URN when it was a child of res0;
|
|
|
|
// * res3, which will have prov as its provider.
|
|
|
|
reproProgramF := deploytest.NewLanguageRuntimeF(func(_ plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
|
|
|
res0, err := monitor.RegisterResource("pkgA:modA:type0", "res0", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
res1, err := monitor.RegisterResource("pkgA:modA:type1", "res1", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
prov, err := monitor.RegisterResource("pulumi:providers:pkgA", "prov", true, deploytest.ResourceOptions{
|
|
|
|
Parent: res0.URN,
|
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
{
|
|
|
|
Alias: &pulumirpc.Alias_Spec_{
|
|
|
|
Spec: &pulumirpc.Alias_Spec{
|
|
|
|
Parent: &pulumirpc.Alias_Spec_ParentUrn{
|
|
|
|
ParentUrn: string(res1.URN),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
provRef, err := providers.NewReference(prov.URN, prov.ID)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = monitor.RegisterResource("pkgA:modA:type3", "res3", true, deploytest.ResourceOptions{
|
|
|
|
Provider: provRef.String(),
|
|
|
|
Parent: res0.URN,
|
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
{
|
|
|
|
Alias: &pulumirpc.Alias_Spec_{
|
|
|
|
Spec: &pulumirpc.Alias_Spec{
|
|
|
|
Parent: &pulumirpc.Alias_Spec_ParentUrn{
|
|
|
|
ParentUrn: string(res1.URN),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
reproHostF := deploytest.NewPluginHostF(nil, nil, reproProgramF, loaders...)
|
|
|
|
reproOpts := lt.TestUpdateOptions{
|
|
|
|
T: t,
|
|
|
|
HostF: reproHostF,
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, setupSnap), reproOpts, false, p.BackendClient, nil, "1")
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tests that aliases in dependencies are correctly normalized when snapshots are written. That is, if a resource's
|
|
|
|
// dependency list contains to a URN that is now an alias for a newly renamed resource, the reference should be updated
|
|
|
|
// to the new URN before the snapshot is persisted.
|
|
|
|
func TestAliasesInDependenciesAreNormalized(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
p := <.TestPlan{
|
|
|
|
Project: "test-project",
|
|
|
|
Stack: "test-stack",
|
|
|
|
}
|
|
|
|
project := p.GetProject()
|
|
|
|
|
|
|
|
loaders := []*deploytest.ProviderLoader{
|
|
|
|
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) {
|
|
|
|
return &deploytest.Provider{}, nil
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set up the initial program:
|
|
|
|
//
|
|
|
|
// * res0 and res1, which will serve as parents -- res1 initially, then res0 in the second update;
|
|
|
|
// * res2, which will be the child that moves from res1 to res0 and that is aliased in the second update;
|
|
|
|
// * res3, which will depend on res2.
|
|
|
|
//
|
|
|
|
// Note: for the URN of res2 to change, res0 and res1 must have different types, since only parent types are included
|
|
|
|
// in the URNs of their children. The choice of type0/type1 etc. is thus important in this test.
|
|
|
|
setupProgramF := deploytest.NewLanguageRuntimeF(func(_ plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
|
|
|
_, err := monitor.RegisterResource("pkgA:modA:type0", "res0", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
res1, err := monitor.RegisterResource("pkgA:modA:type1", "res1", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
res2, err := monitor.RegisterResource("pkgA:modA:type2", "res2", true, deploytest.ResourceOptions{
|
|
|
|
Parent: res1.URN,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = monitor.RegisterResource("pkgA:modA:type3", "res3", true, deploytest.ResourceOptions{
|
|
|
|
Parent: res1.URN,
|
|
|
|
Dependencies: []resource.URN{res2.URN},
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
setupHostF := deploytest.NewPluginHostF(nil, nil, setupProgramF, loaders...)
|
|
|
|
setupOpts := lt.TestUpdateOptions{
|
|
|
|
T: t,
|
|
|
|
HostF: setupHostF,
|
|
|
|
}
|
|
|
|
setupSnap, err := lt.TestOp(Update).RunStep(project, p.GetTarget(t, nil), setupOpts, false, p.BackendClient, nil, "0")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// Set up the test program:
|
|
|
|
//
|
|
|
|
// * res0 and res1, which will serve as parents as before;
|
|
|
|
// * res2, which will now be moved to a child of res0, with an alias to its URN when it was a child of res1;
|
|
|
|
// * res3, which will depend on res2.
|
|
|
|
reproProgramF := deploytest.NewLanguageRuntimeF(func(_ plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
|
|
|
res0, err := monitor.RegisterResource("pkgA:modA:type0", "res0", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
res1, err := monitor.RegisterResource("pkgA:modA:type1", "res1", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
res2, err := monitor.RegisterResource("pkgA:modA:type2", "res2", true, deploytest.ResourceOptions{
|
|
|
|
Parent: res0.URN,
|
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
{
|
|
|
|
Alias: &pulumirpc.Alias_Spec_{
|
|
|
|
Spec: &pulumirpc.Alias_Spec{
|
|
|
|
Parent: &pulumirpc.Alias_Spec_ParentUrn{
|
|
|
|
ParentUrn: string(res1.URN),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = monitor.RegisterResource("pkgA:modA:type3", "res3", true, deploytest.ResourceOptions{
|
|
|
|
Parent: res0.URN,
|
|
|
|
Dependencies: []resource.URN{res2.URN},
|
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
{
|
|
|
|
Alias: &pulumirpc.Alias_Spec_{
|
|
|
|
Spec: &pulumirpc.Alias_Spec{
|
|
|
|
Parent: &pulumirpc.Alias_Spec_ParentUrn{
|
|
|
|
ParentUrn: string(res1.URN),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
reproHostF := deploytest.NewPluginHostF(nil, nil, reproProgramF, loaders...)
|
|
|
|
reproOpts := lt.TestUpdateOptions{
|
|
|
|
T: t,
|
|
|
|
HostF: reproHostF,
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, setupSnap), reproOpts, false, p.BackendClient, nil, "1")
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tests that aliases in property dependencies are correctly normalized when snapshots are written. That is, if a
|
|
|
|
// resource's property dependency map contains to a URN that is now an alias for a newly renamed resource, the reference
|
|
|
|
// should be updated to the new URN before the snapshot is persisted.
|
|
|
|
func TestAliasesInPropertyDependenciesAreNormalized(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
p := <.TestPlan{
|
|
|
|
Project: "test-project",
|
|
|
|
Stack: "test-stack",
|
|
|
|
}
|
|
|
|
project := p.GetProject()
|
|
|
|
|
|
|
|
loaders := []*deploytest.ProviderLoader{
|
|
|
|
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) {
|
|
|
|
return &deploytest.Provider{}, nil
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set up the initial program:
|
|
|
|
//
|
|
|
|
// * res0 and res1, which will serve as parents -- res1 initially, then res0 in the second update;
|
|
|
|
// * res2, which will be the child that moves from res1 to res0 and that is aliased in the second update;
|
|
|
|
// * res3, which will depend on res2 via a property dependency.
|
|
|
|
//
|
|
|
|
// Note: for the URN of res2 to change, res0 and res1 must have different types, since only parent types are included
|
|
|
|
// in the URNs of their children. The choice of type0/type1 etc. is thus important in this test.
|
|
|
|
setupProgramF := deploytest.NewLanguageRuntimeF(func(_ plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
|
|
|
_, err := monitor.RegisterResource("pkgA:modA:type0", "res0", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
res1, err := monitor.RegisterResource("pkgA:modA:type1", "res1", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
res2, err := monitor.RegisterResource("pkgA:modA:type2", "res2", true, deploytest.ResourceOptions{
|
|
|
|
Parent: res1.URN,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = monitor.RegisterResource("pkgA:modA:type3", "res3", true, deploytest.ResourceOptions{
|
|
|
|
Parent: res1.URN,
|
|
|
|
PropertyDeps: map[resource.PropertyKey][]resource.URN{"propA": {res2.URN}},
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
setupHostF := deploytest.NewPluginHostF(nil, nil, setupProgramF, loaders...)
|
|
|
|
setupOpts := lt.TestUpdateOptions{
|
|
|
|
T: t,
|
|
|
|
HostF: setupHostF,
|
|
|
|
}
|
|
|
|
setupSnap, err := lt.TestOp(Update).RunStep(project, p.GetTarget(t, nil), setupOpts, false, p.BackendClient, nil, "0")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// Set up the test program:
|
|
|
|
//
|
|
|
|
// * res0 and res1, which will serve as parents as before;
|
|
|
|
// * res2, which will now be moved to a child of res0, with an alias to its URN when it was a child of res1;
|
|
|
|
// * res3, which will depend on res2 via a property dependency.
|
|
|
|
reproProgramF := deploytest.NewLanguageRuntimeF(func(_ plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
|
|
|
res0, err := monitor.RegisterResource("pkgA:modA:type0", "res0", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
res1, err := monitor.RegisterResource("pkgA:modA:type1", "res1", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
res2, err := monitor.RegisterResource("pkgA:modA:type2", "res2", true, deploytest.ResourceOptions{
|
|
|
|
Parent: res0.URN,
|
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
{
|
|
|
|
Alias: &pulumirpc.Alias_Spec_{
|
|
|
|
Spec: &pulumirpc.Alias_Spec{
|
|
|
|
Parent: &pulumirpc.Alias_Spec_ParentUrn{
|
|
|
|
ParentUrn: string(res1.URN),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = monitor.RegisterResource("pkgA:modA:type3", "res3", true, deploytest.ResourceOptions{
|
|
|
|
Parent: res0.URN,
|
|
|
|
PropertyDeps: map[resource.PropertyKey][]resource.URN{"propA": {res2.URN}},
|
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
{
|
|
|
|
Alias: &pulumirpc.Alias_Spec_{
|
|
|
|
Spec: &pulumirpc.Alias_Spec{
|
|
|
|
Parent: &pulumirpc.Alias_Spec_ParentUrn{
|
|
|
|
ParentUrn: string(res1.URN),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
reproHostF := deploytest.NewPluginHostF(nil, nil, reproProgramF, loaders...)
|
|
|
|
reproOpts := lt.TestUpdateOptions{
|
|
|
|
T: t,
|
|
|
|
HostF: reproHostF,
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, setupSnap), reproOpts, false, p.BackendClient, nil, "1")
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tests that aliases in deleted-with references are correctly normalized when snapshots are written. That is, if a
|
|
|
|
// resource's deleted-with reference points to to a URN that is now an alias for a newly renamed resource, the reference
|
|
|
|
// should be updated to the new URN before the snapshot is persisted.
|
|
|
|
func TestAliasesInDeletedWithAreNormalized(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
p := <.TestPlan{
|
|
|
|
Project: "test-project",
|
|
|
|
Stack: "test-stack",
|
|
|
|
}
|
|
|
|
project := p.GetProject()
|
|
|
|
|
|
|
|
loaders := []*deploytest.ProviderLoader{
|
|
|
|
deploytest.NewProviderLoader("pkgA", semver.MustParse("1.0.0"), func() (plugin.Provider, error) {
|
|
|
|
return &deploytest.Provider{}, nil
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set up the initial program:
|
|
|
|
//
|
|
|
|
// * res0 and res1, which will serve as parents -- res1 initially, then res0 in the second update;
|
|
|
|
// * res2, which will be the child that moves from res1 to res0 and that is aliased in the second update;
|
|
|
|
// * res3, which will depend on res2 via a deleted-with relationship.
|
|
|
|
//
|
|
|
|
// Note: for the URN of res2 to change, res0 and res1 must have different types, since only parent types are included
|
|
|
|
// in the URNs of their children. The choice of type0/type1 etc. is thus important in this test.
|
|
|
|
setupProgramF := deploytest.NewLanguageRuntimeF(func(_ plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
|
|
|
_, err := monitor.RegisterResource("pkgA:modA:type0", "res0", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
res1, err := monitor.RegisterResource("pkgA:modA:type1", "res1", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
res2, err := monitor.RegisterResource("pkgA:modA:type2", "res2", true, deploytest.ResourceOptions{
|
|
|
|
Parent: res1.URN,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = monitor.RegisterResource("pkgA:modA:type3", "res3", true, deploytest.ResourceOptions{
|
|
|
|
Parent: res1.URN,
|
|
|
|
DeletedWith: res2.URN,
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
setupHostF := deploytest.NewPluginHostF(nil, nil, setupProgramF, loaders...)
|
|
|
|
setupOpts := lt.TestUpdateOptions{
|
|
|
|
T: t,
|
|
|
|
HostF: setupHostF,
|
|
|
|
}
|
|
|
|
setupSnap, err := lt.TestOp(Update).RunStep(project, p.GetTarget(t, nil), setupOpts, false, p.BackendClient, nil, "0")
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// Set up the test program:
|
|
|
|
//
|
|
|
|
// * res0 and res1, which will serve as parents as before;
|
|
|
|
// * res2, which will now be moved to a child of res0, with an alias to its URN when it was a child of res1;
|
|
|
|
// * res3, which will depend on res2 via a deleted-with relationship.
|
|
|
|
reproProgramF := deploytest.NewLanguageRuntimeF(func(_ plugin.RunInfo, monitor *deploytest.ResourceMonitor) error {
|
|
|
|
res0, err := monitor.RegisterResource("pkgA:modA:type0", "res0", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
res1, err := monitor.RegisterResource("pkgA:modA:type1", "res1", false, deploytest.ResourceOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
res2, err := monitor.RegisterResource("pkgA:modA:type2", "res2", true, deploytest.ResourceOptions{
|
|
|
|
Parent: res0.URN,
|
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
{
|
|
|
|
Alias: &pulumirpc.Alias_Spec_{
|
|
|
|
Spec: &pulumirpc.Alias_Spec{
|
|
|
|
Parent: &pulumirpc.Alias_Spec_ParentUrn{
|
|
|
|
ParentUrn: string(res1.URN),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
_, err = monitor.RegisterResource("pkgA:modA:type3", "res3", true, deploytest.ResourceOptions{
|
|
|
|
Parent: res0.URN,
|
|
|
|
DeletedWith: res2.URN,
|
|
|
|
Aliases: []*pulumirpc.Alias{
|
|
|
|
{
|
|
|
|
Alias: &pulumirpc.Alias_Spec_{
|
|
|
|
Spec: &pulumirpc.Alias_Spec{
|
|
|
|
Parent: &pulumirpc.Alias_Spec_ParentUrn{
|
|
|
|
ParentUrn: string(res1.URN),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
reproHostF := deploytest.NewPluginHostF(nil, nil, reproProgramF, loaders...)
|
|
|
|
reproOpts := lt.TestUpdateOptions{
|
|
|
|
T: t,
|
|
|
|
HostF: reproHostF,
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = lt.TestOp(Update).RunStep(project, p.GetTarget(t, setupSnap), reproOpts, false, p.BackendClient, nil, "1")
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|