Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize block values before passing to TF provider #1971

Merged
merged 80 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
5528bab
empty sets cross test
VenelinMartinov May 14, 2024
fba73e1
Toward a fix
t0yv0 May 14, 2024
9c69721
Add additional checks on input cross tests for ResourceData.Get values
VenelinMartinov May 16, 2024
9c998f0
remove debug output
VenelinMartinov May 16, 2024
95aa4ff
compare change vals too
VenelinMartinov May 16, 2024
5eac370
Merge branch 'vvm/cross_test_inputs_compare_get' into vvm/empty_set_c…
VenelinMartinov May 16, 2024
1e6a0c2
revert error formatting
VenelinMartinov May 16, 2024
3458348
Merge branch 'vvm/cross_test_inputs_compare_get' into vvm/empty_set_c…
VenelinMartinov May 16, 2024
3149478
reimplement UpgradeState, handle empty lists in cty coersion
VenelinMartinov May 16, 2024
2e15635
Merge branch 'master' into vvm/empty_set_cross_test
VenelinMartinov May 16, 2024
d57b99c
remove test flag
VenelinMartinov May 16, 2024
341c6ec
don't loose old meta
VenelinMartinov May 16, 2024
fbf7d05
fix cty property test
VenelinMartinov May 16, 2024
21b48c1
update cty test
VenelinMartinov May 16, 2024
3bcc730
remove flags for prev failing cases
VenelinMartinov May 17, 2024
9519c8f
remove formatting diffs
VenelinMartinov May 17, 2024
230b807
remove other mysterious diff
VenelinMartinov May 17, 2024
d9f0d10
formatting diff
VenelinMartinov May 17, 2024
f980f73
simplify array
VenelinMartinov May 17, 2024
f5fa5d3
formatting
VenelinMartinov May 17, 2024
63e2718
normalize collections only in the test values in cty_test
VenelinMartinov May 17, 2024
472692a
add optional computed tests
VenelinMartinov May 20, 2024
b302d77
optional computed list test
VenelinMartinov May 20, 2024
51edfda
make test table driven
VenelinMartinov May 20, 2024
c71da54
add back simple test
VenelinMartinov May 20, 2024
d3aa2e3
provider2 upgrade state rewrite
VenelinMartinov May 20, 2024
8933992
address review comments
VenelinMartinov May 21, 2024
b2b198f
upgrade state tests
VenelinMartinov May 21, 2024
899ba31
towards an integration test
VenelinMartinov May 21, 2024
f726145
remove max items one, add version meta
VenelinMartinov May 21, 2024
2ff4869
add todos
VenelinMartinov May 21, 2024
b2a8a00
unskip cross tests
VenelinMartinov May 21, 2024
4e1741a
Merge branch 'vvm/provider2_upgrade_state_rewrite' into vvm/empty_set…
VenelinMartinov May 21, 2024
31b2c73
revert cty changes, add tests for attr vs blocks
VenelinMartinov May 21, 2024
9bbef27
Merge branch 'master' into vvm/empty_set_cross_test
VenelinMartinov May 21, 2024
96a461d
block normalization
VenelinMartinov May 21, 2024
4339e51
config mode attr test
VenelinMartinov May 21, 2024
7766391
config mode tests, nested block tests
VenelinMartinov May 21, 2024
1327a5a
remove panic
VenelinMartinov May 21, 2024
24556b5
Merge branch 'master' into vvm/empty_set_cross_test
VenelinMartinov May 22, 2024
b8ec8f4
Merge branch 'master' into vvm/empty_set_cross_test
VenelinMartinov May 23, 2024
1ba9170
repro
VenelinMartinov May 23, 2024
0d2aed4
recusrsive block normalization
VenelinMartinov May 23, 2024
41388c5
refactor normalization functions a bit
VenelinMartinov May 23, 2024
7f6c760
handle unkowns, tests for timeouts
VenelinMartinov May 23, 2024
0187e07
fix map handling, additional tests, logging
VenelinMartinov May 23, 2024
2a2aeac
handle unknowns better
VenelinMartinov May 23, 2024
e1e691e
expand config mode attr tests
VenelinMartinov May 23, 2024
dbef575
flatten test cases, add todo
VenelinMartinov May 23, 2024
d94f72d
delete redundant test
VenelinMartinov May 23, 2024
7a5e480
[TEST ONLY] Enable PlanResourceChange by default
VenelinMartinov May 23, 2024
59f174c
Merge branch 'master' into vvm/empty_set_cross_test
VenelinMartinov May 28, 2024
36f24f3
revert unconditional plan resource change
VenelinMartinov May 31, 2024
4f24fa4
Merge branch 'master' into vvm/empty_set_cross_test
VenelinMartinov May 31, 2024
9ebe718
Update pkg/tfshim/sdk-v2/provider2.go
VenelinMartinov May 31, 2024
b8d5a22
whitespace
VenelinMartinov Jun 3, 2024
93bc806
revert formatting change
VenelinMartinov Jun 3, 2024
13e1e8c
remove verbose log
VenelinMartinov Jun 3, 2024
c6d9138
address review
VenelinMartinov Jun 3, 2024
1298707
refactor
VenelinMartinov Jun 3, 2024
4375e50
remove unnecessary function
VenelinMartinov Jun 3, 2024
bb2db02
add unkown handling test
VenelinMartinov Jun 3, 2024
933d5ca
add non-plan resource change test
VenelinMartinov Jun 4, 2024
e6098cd
max items one unknown
VenelinMartinov Jun 4, 2024
7613c39
targeted regression tests
VenelinMartinov Jun 4, 2024
51d9bf4
Merge branch 'master' into vvm/empty_set_cross_test
VenelinMartinov Jun 4, 2024
0215d28
expand unknown tests to cover block props
VenelinMartinov Jun 4, 2024
19c6dc8
typo
VenelinMartinov Jun 4, 2024
b351202
add missing skip
VenelinMartinov Jun 4, 2024
fe9707d
finish unknown test matrix
VenelinMartinov Jun 4, 2024
63a9bff
unknown tests
VenelinMartinov Jun 4, 2024
634d56f
remove tests
VenelinMartinov Jun 4, 2024
4b4e705
unknown tests
VenelinMartinov Jun 4, 2024
11df84b
don't panic on block unknowns
VenelinMartinov Jun 4, 2024
18b286a
Merge branch 'vvm/unknown_tests' into vvm/empty_set_cross_test
VenelinMartinov Jun 4, 2024
8e0fd52
minor refactor
VenelinMartinov Jun 4, 2024
c998809
rename accidentally repeated test name
VenelinMartinov Jun 4, 2024
1c3797a
rename accidentally repeated test name
VenelinMartinov Jun 4, 2024
e99690d
Merge branch 'vvm/unknown_tests' into vvm/empty_set_cross_test
VenelinMartinov Jun 4, 2024
ed56307
Merge branch 'master' into vvm/empty_set_cross_test
VenelinMartinov Jun 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions pkg/tests/cross-tests/input_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ type inputTestCase struct {

Config any
ObjectType *tftypes.Object

SkipCompareRawPlan bool
SkipCompareRawConfig bool
SkipCompareRawState bool
}

func FailNotEqual(t T, name string, tfVal, pulVal any) {
Expand Down Expand Up @@ -158,15 +154,7 @@ func runCreateInputCheck(t T, tc inputTestCase) {
assertValEqual(t, k+" Change New", tfChangeValNew, pulChangeValNew)
}

if !tc.SkipCompareRawConfig {
assertCtyValEqual(t, "RawConfig", tfResData.GetRawConfig(), pulResData.GetRawConfig())
}

if !tc.SkipCompareRawPlan {
assertCtyValEqual(t, "RawPlan", tfResData.GetRawPlan(), pulResData.GetRawPlan())
}

if !tc.SkipCompareRawState {
assertCtyValEqual(t, "RawState", tfResData.GetRawState(), pulResData.GetRawState())
}
assertCtyValEqual(t, "RawConfig", tfResData.GetRawConfig(), pulResData.GetRawConfig())
assertCtyValEqual(t, "RawPlan", tfResData.GetRawPlan(), pulResData.GetRawPlan())
assertCtyValEqual(t, "RawState", tfResData.GetRawState(), pulResData.GetRawState())
}
78 changes: 70 additions & 8 deletions pkg/tests/cross-tests/input_cross_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package crosstests

import (
"context"
"fmt"
"testing"
"time"

Expand Down Expand Up @@ -103,6 +104,7 @@ func TestInputsEqualObjectBasic(t *testing.T) {
}

func TestInputsConfigModeEqual(t *testing.T) {
// Regression test for [pulumi/pulumi-terraform-bridge#1762]
skipUnlessLinux(t)
t2 := tftypes.Object{AttributeTypes: map[string]tftypes.Type{
"x": tftypes.String,
Expand Down Expand Up @@ -183,8 +185,7 @@ func TestInputsConfigModeEqual(t *testing.T) {
},
},
},
Config: tc.config,
SkipCompareRawConfig: true,
Config: tc.config,
})
})
}
Expand Down Expand Up @@ -215,7 +216,33 @@ func TestInputsEmptyString(t *testing.T) {
})
}

func TestInputsUnspecifiedMaxItemsOne(t *testing.T) {
// Regression test for [pulumi/pulumi-terraform-bridge#1767]
skipUnlessLinux(t)
runCreateInputCheck(t, inputTestCase{
Resource: &schema.Resource{
Schema: map[string]*schema.Schema{
"f0": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"x": {Optional: true, Type: schema.TypeString},
},
},
},
},
},
Config: tftypes.NewValue(
tftypes.Object{},
map[string]tftypes.Value{},
),
})
}

func TestOptionalSetNotSpecified(t *testing.T) {
// Regression test for [pulumi/pulumi-terraform-bridge#1970] and [pulumi/pulumi-terraform-bridge#1964]
skipUnlessLinux(t)
runCreateInputCheck(t, inputTestCase{
Resource: &schema.Resource{
Expand All @@ -231,11 +258,48 @@ func TestOptionalSetNotSpecified(t *testing.T) {
},
},
},
Config: tftypes.NewValue(tftypes.Object{}, map[string]tftypes.Value{}),
SkipCompareRawConfig: true,
Config: tftypes.NewValue(tftypes.Object{}, map[string]tftypes.Value{}),
VenelinMartinov marked this conversation as resolved.
Show resolved Hide resolved
})
}

func TestInputsEqualEmptyList(t *testing.T) {
// Regression test for [pulumi/pulumi-terraform-bridge#1915]
skipUnlessLinux(t)
for _, maxItems := range []int{0, 1} {
name := fmt.Sprintf("MaxItems: %v", maxItems)
t.Run(name, func(t *testing.T) {
t1 := tftypes.List{ElementType: tftypes.String}
t0 := tftypes.Object{
AttributeTypes: map[string]tftypes.Type{
"f0": t1,
},
}
runCreateInputCheck(t, inputTestCase{
Resource: &schema.Resource{
Schema: map[string]*schema.Schema{
"f0": {
Optional: true,
Type: schema.TypeList,
MaxItems: maxItems,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"x": {Optional: true, Type: schema.TypeString},
},
},
},
},
},
Config: tftypes.NewValue(
t0,
map[string]tftypes.Value{
"f0": tftypes.NewValue(t1, []tftypes.Value{}),
},
),
})
})
}
}

func TestExplicitNilList(t *testing.T) {
skipUnlessLinux(t)
t0 := tftypes.Map{ElementType: tftypes.Number}
Expand Down Expand Up @@ -323,8 +387,7 @@ func TestInputsEmptyCollections(t *testing.T) {
},
},
},
Config: config,
SkipCompareRawConfig: true,
Config: config,
})
})
}
Expand Down Expand Up @@ -417,8 +480,7 @@ func TestInputsNestedBlocksEmpty(t *testing.T) {
},
},
},
Config: tc.config,
SkipCompareRawConfig: true,
Config: tc.config,
})
})
}
Expand Down
Loading