Skip to content

Commit

Permalink
Disable accurate previews for PF tests (#2752)
Browse files Browse the repository at this point in the history
This change disables accurate previews for the PF tests as accurate
preview rollout for PF is blocked on
#2660

The first commit here are the code changes and the second one is test
recordings.
  • Loading branch information
VenelinMartinov authored Dec 16, 2024
1 parent 731e5a1 commit bf5a600
Show file tree
Hide file tree
Showing 326 changed files with 1,105 additions and 896 deletions.
4 changes: 1 addition & 3 deletions dynamic/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ func TestStacktraceDisplayed(t *testing.T) {
}

func TestPrimitiveTypes(t *testing.T) {
t.Parallel()
skipWindows(t)
// TODO[pulumi/pulumi-terraform-bridge#2517]: fix once accurate bridge previews are enabled by default
t.Setenv("PULUMI_TF_BRIDGE_ACCURATE_BRIDGE_PREVIEW", "true")

ctx := context.Background()

grpc := grpcTestServer(ctx, t)
Expand Down
20 changes: 1 addition & 19 deletions dynamic/testdata/TestPrimitiveTypes/diff(all).golden
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
{
"changes": "DIFF_SOME",
"detailedDiff": {
"attrBoolRequired": {
"kind": "UPDATE"
},
"attrIntRequired": {
"kind": "UPDATE"
},
"attrNumberComputed": {},
"attrNumberRequired": {
"kind": "UPDATE"
},
"attrStringDefault": {},
"attrStringDefaultOverridden": {},
"attrStringRequired": {
"kind": "UPDATE"
}
},
"diffs": [
"attrBoolRequired",
"attrIntRequired",
Expand All @@ -25,6 +8,5 @@
"attrStringDefault",
"attrStringDefaultOverridden",
"attrStringRequired"
],
"hasDetailedDiff": true
]
}
14 changes: 1 addition & 13 deletions dynamic/testdata/TestPrimitiveTypes/diff(some).golden
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
{
"changes": "DIFF_SOME",
"detailedDiff": {
"attrNumberComputed": {},
"attrNumberRequired": {
"kind": "DELETE"
},
"attrStringDefault": {},
"attrStringDefaultOverridden": {},
"attrStringRequired": {
"kind": "UPDATE"
}
},
"diffs": [
"attrNumberComputed",
"attrNumberRequired",
"attrStringDefault",
"attrStringDefaultOverridden",
"attrStringRequired"
],
"hasDetailedDiff": true
]
}
4 changes: 3 additions & 1 deletion pkg/pf/tests/diff_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ func TestDetailedDiffList(t *testing.T) {
})

diff := crosstests.Diff(
t, res, map[string]cty.Value{"key": initialValue}, map[string]cty.Value{"key": changeValue})
t, res, map[string]cty.Value{"key": initialValue}, map[string]cty.Value{"key": changeValue},
crosstests.DisableAccurateBridgePreview(),
)

autogold.ExpectFile(t, testOutput{
initialValue: scenario.initialValue,
Expand Down
5 changes: 4 additions & 1 deletion pkg/pf/tests/diff_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ func TestDetailedDiffMap(t *testing.T) {
ResourceSchema: schemaValueMakerPair.schema,
})

diff := crosstests.Diff(t, res, map[string]cty.Value{"key": initialValue}, map[string]cty.Value{"key": changeValue})
diff := crosstests.Diff(
t, res, map[string]cty.Value{"key": initialValue}, map[string]cty.Value{"key": changeValue},
crosstests.DisableAccurateBridgePreview(),
)

autogold.ExpectFile(t, testOutput{
initialValue: scenario.initialValue,
Expand Down
10 changes: 8 additions & 2 deletions pkg/pf/tests/diff_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,10 @@ func TestDetailedDiffObject(t *testing.T) {
res := pb.NewResource(pb.NewResourceArgs{
ResourceSchema: schema.schema,
})
diff := crosstests.Diff(t, res, initialValue, changeValue)
diff := crosstests.Diff(
t, res, initialValue, changeValue,
crosstests.DisableAccurateBridgePreview(),
)
autogold.ExpectFile(t, testOutput{
initialValue: scenario.initialValue,
changeValue: scenario.changeValue,
Expand All @@ -357,7 +360,10 @@ func TestDetailedDiffObject(t *testing.T) {
res := pb.NewResource(pb.NewResourceArgs{
ResourceSchema: schema.schema,
})
diff := crosstests.Diff(t, res, initialValue, changeValue)
diff := crosstests.Diff(
t, res, initialValue, changeValue,
crosstests.DisableAccurateBridgePreview(),
)
autogold.ExpectFile(t, testOutput{
initialValue: scenario.initialValue,
changeValue: scenario.changeValue,
Expand Down
5 changes: 4 additions & 1 deletion pkg/pf/tests/diff_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,10 @@ func TestDetailedDiffSet(t *testing.T) {
initialValue := schemaValueMakerPair.valueMaker(scenario.initialValue)
changeValue := schemaValueMakerPair.valueMaker(scenario.changeValue)

diff := crosstests.Diff(t, schemaValueMakerPair.res, map[string]cty.Value{"key": initialValue}, map[string]cty.Value{"key": changeValue})
diff := crosstests.Diff(
t, schemaValueMakerPair.res, map[string]cty.Value{"key": initialValue}, map[string]cty.Value{"key": changeValue},
crosstests.DisableAccurateBridgePreview(),
)

autogold.ExpectFile(t, testOutput{
initialValue: scenario.initialValue,
Expand Down
2 changes: 1 addition & 1 deletion pkg/pf/tests/genrandom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestGenRandom(t *testing.T) {

t.Run(trace, func(t *testing.T) {
p := testprovider.RandomProvider()
p.EnableAccurateBridgePreview = true
p.EnableAccurateBridgePreview = false
server, err := newProviderServer(t, p)
require.NoError(t, err)
testutils.ReplayFile(t, server, trace)
Expand Down
2 changes: 1 addition & 1 deletion pkg/pf/tests/genupdate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestGenUpdates(t *testing.T) {
trace := "testdata/updateprogram.json"

info := testprovider.SyntheticTestBridgeProvider()
info.EnableAccurateBridgePreview = true
info.EnableAccurateBridgePreview = false
server, err := newProviderServer(t, info)
require.NoError(t, err)
testutils.ReplayFile(t, server, trace)
Expand Down
11 changes: 9 additions & 2 deletions pkg/pf/tests/internal/cross-tests/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ func Diff(t T, res pb.Resource, tfConfig1, tfConfig2 map[string]cty.Value, optio
require.NoError(t, err)
t.Logf("Pulumi.yaml:\n%s", string(bytes))

pt, err := pulcheck.PulCheck(t, bridgedProvider(prov, bridgedProviderOpts{enableAccurateBridgePreview: true}), string(bytes))
pt, err := pulcheck.PulCheck(
t, bridgedProvider(prov, bridgedProviderOpts{enableAccurateBridgePreview: !opts.disableAccurateBridgePreview}), string(bytes))
require.NoError(t, err)
pt.Up(t)

Expand All @@ -133,7 +134,8 @@ func Diff(t T, res pb.Resource, tfConfig1, tfConfig2 map[string]cty.Value, optio
}

type diffOpts struct {
resourceInfo map[string]*info.Schema
resourceInfo map[string]*info.Schema
disableAccurateBridgePreview bool
}

type DiffOption func(*diffOpts)
Expand All @@ -142,3 +144,8 @@ type DiffOption func(*diffOpts)
func DiffProviderInfo(info map[string]*info.Schema) DiffOption {
return func(o *diffOpts) { o.resourceInfo = info }
}

// DisableAccurateBridgePreview disables the accurate bridge preview feature.
func DisableAccurateBridgePreview() DiffOption {
return func(o *diffOpts) { o.disableAccurateBridgePreview = true }
}
20 changes: 4 additions & 16 deletions pkg/pf/tests/provider_diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestEmptyTestresDiff(t *testing.T) {
func TestOptionRemovalTestresDiff(t *testing.T) {
t.Parallel()
info := testprovider.SyntheticTestBridgeProvider()
info.EnableAccurateBridgePreview = true
info.EnableAccurateBridgePreview = false
server, err := newProviderServer(t, info)
require.NoError(t, err)
testCase := `
Expand All @@ -82,13 +82,7 @@ func TestOptionRemovalTestresDiff(t *testing.T) {
"changes": "DIFF_SOME",
"diffs": [
"optionalInputString"
],
"hasDetailedDiff": true,
"detailedDiff": {
"optionalInputString": {
"kind": "DELETE"
}
}
]
}
}
`
Expand Down Expand Up @@ -270,7 +264,7 @@ func TestSetNestedObjectAdded(t *testing.T) {
func TestSetNestedObjectAddedOtherDiff(t *testing.T) {
t.Parallel()
info := testprovider.SyntheticTestBridgeProvider()
info.EnableAccurateBridgePreview = true
info.EnableAccurateBridgePreview = false
server, err := newProviderServer(t, info)
require.NoError(t, err)
testCase := `
Expand Down Expand Up @@ -317,13 +311,7 @@ func TestSetNestedObjectAddedOtherDiff(t *testing.T) {
"diffs": [
"other",
"vlanNames"
],
"hasDetailedDiff": true,
"detailedDiff": {
"other": {
"kind": "UPDATE"
}
}
]
}
}
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"keys[0]": map[string]interface{}{}},
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ Plan: 0 to add, 1 to change, 0 to destroy.
[id=test-id]
[urn=urn:pulumi:test::project::testprovider:index/test:Test::p]
~ keys: [
[0]: "val1"
[1]: "val2"
+ [2]: "val3"
]
Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"keys[2]": map[string]interface{}{}},
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,4 @@ Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{
"keys[0]": map[string]interface{}{"kind": "UPDATE"},
"keys[1]": map[string]interface{}{"kind": "UPDATE"},
"keys[2]": map[string]interface{}{},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@ Plan: 0 to add, 1 to change, 0 to destroy.
[id=test-id]
[urn=urn:pulumi:test::project::testprovider:index/test:Test::p]
~ keys: [
[0]: "val1"
~ [1]: "val3" => "val2"
+ [2]: "val3"
]
Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{
"keys[1]": map[string]interface{}{"kind": "UPDATE"},
"keys[2]": map[string]interface{}{},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"keys": map[string]interface{}{"kind": "DELETE"}},
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"keys[0]": map[string]interface{}{"kind": "UPDATE"}},
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"keys": map[string]interface{}{}},
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ Plan: 0 to add, 1 to change, 0 to destroy.
[id=test-id]
[urn=urn:pulumi:test::project::testprovider:index/test:Test::p]
~ keys: [
[0]: "value"
+ [1]: "value1"
]
Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"keys[1]": map[string]interface{}{}},
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ Plan: 0 to add, 1 to change, 0 to destroy.
[id=test-id]
[urn=urn:pulumi:test::project::testprovider:index/test:Test::p]
~ keys: [
[0]: "value"
- [1]: "value1"
]
Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"keys[1]": map[string]interface{}{"kind": "DELETE"}},
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,30 @@ Plan: 0 to add, 1 to change, 0 to destroy.
[id=test-id]
[urn=urn:pulumi:test::project::testprovider:index/test:Test::p]
~ keys: [
[0]: "value0"
[1]: "value1"
[2]: "value2"
[3]: "value3"
[4]: "value4"
[5]: "value5"
[6]: "value6"
[7]: "value7"
[8]: "value8"
[9]: "value9"
[10]: "value10"
[11]: "value11"
[12]: "value12"
[13]: "value13"
[14]: "value14"
[15]: "value15"
[16]: "value16"
[17]: "value17"
[18]: "value18"
[19]: "value19"
+ [20]: "value20"
]
Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"keys[20]": map[string]interface{}{}},
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,4 @@ Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{
"keys[0]": map[string]interface{}{"kind": "UPDATE"},
"keys[10]": map[string]interface{}{"kind": "UPDATE"},
"keys[11]": map[string]interface{}{"kind": "UPDATE"},
"keys[12]": map[string]interface{}{"kind": "UPDATE"},
"keys[13]": map[string]interface{}{"kind": "UPDATE"},
"keys[14]": map[string]interface{}{"kind": "UPDATE"},
"keys[15]": map[string]interface{}{"kind": "UPDATE"},
"keys[16]": map[string]interface{}{"kind": "UPDATE"},
"keys[17]": map[string]interface{}{"kind": "UPDATE"},
"keys[18]": map[string]interface{}{"kind": "UPDATE"},
"keys[19]": map[string]interface{}{"kind": "UPDATE"},
"keys[1]": map[string]interface{}{"kind": "UPDATE"},
"keys[20]": map[string]interface{}{},
"keys[2]": map[string]interface{}{"kind": "UPDATE"},
"keys[3]": map[string]interface{}{"kind": "UPDATE"},
"keys[4]": map[string]interface{}{"kind": "UPDATE"},
"keys[5]": map[string]interface{}{"kind": "UPDATE"},
"keys[6]": map[string]interface{}{"kind": "UPDATE"},
"keys[7]": map[string]interface{}{"kind": "UPDATE"},
"keys[8]": map[string]interface{}{"kind": "UPDATE"},
"keys[9]": map[string]interface{}{"kind": "UPDATE"},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"keys": map[string]interface{}{"kind": "DELETE"}},
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"keys": map[string]interface{}{}},
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@ Resources:
~ 1 to update
1 unchanged
`,
detailedDiff: map[string]interface{}{"keys[0]": map[string]interface{}{"kind": "DELETE"}},
}
Loading

0 comments on commit bf5a600

Please sign in to comment.