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

More unknowns tests for diff #2140

Merged
merged 2 commits into from
Jul 1, 2024
Merged

Conversation

VenelinMartinov
Copy link
Contributor

@VenelinMartinov VenelinMartinov commented Jun 27, 2024

This separates the tests from #2061 to make the effect of the changes obvious.

The tests mostly focus around the way unknowns are displayed in diffs.

Some of the outputs here are very clearly wrong. I've annotated most of them but they are all fixed in 2061

+ prov:index/test:Test: (create)
[urn=urn:pulumi:test::test::prov:index/test:Test::mainRes]
tests : [
[0]: {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an unknown array

[urn=urn:pulumi:test::test::prov:index/test:Test::mainRes]
~ tests: [
~ [0]: {
- testProp: "known_val"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new value is unknown - this just shows us removing the old value.

[urn=urn:pulumi:test::test::prov:index/nestedTest:NestedTest::mainRes]
~ tests: [
~ [0]: {
- nestedProps: [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff here is duplicated?

tests : [
[0]: {
nestedProps: [
[0]: {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unknown array shown as just an array with a single empty object

~ [0]: {
~ nestedProps: [
~ [0]: {
- testProps: [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated diff again

~ nestedProps: [
~ [0]: {
~ testProps: [
~ [0]: "known_val" => output<string>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unknown at the wrong level

@VenelinMartinov VenelinMartinov marked this pull request as ready for review June 27, 2024 14:20
Copy link

codecov bot commented Jun 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 60.63%. Comparing base (8ca6390) to head (3e9a8a8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2140      +/-   ##
==========================================
- Coverage   60.64%   60.63%   -0.01%     
==========================================
  Files         350      350              
  Lines       45898    45898              
==========================================
- Hits        27833    27829       -4     
- Misses      16526    16529       +3     
- Partials     1539     1540       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@iwahbe iwahbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@VenelinMartinov VenelinMartinov merged commit f317dc4 into master Jul 1, 2024
11 checks passed
@VenelinMartinov VenelinMartinov deleted the vvm/more_unknown_tests branch July 1, 2024 12:37
@pulumi-bot
Copy link
Contributor

This PR has been shipped in release v3.86.0.

VenelinMartinov added a commit that referenced this pull request Jul 17, 2024
This changes the bridge to correctly return unknowns for objects and
collections in sdkv2.

fixes #1885
fixes #2032

stacked on #2158

Confirmed that TF sdkv2 supports both unknown blocks and unknown
collections of blocks, so we should be fine to pass these into TF
providers.

The TF sdkv1 does not support unknowns for blocks and collections so we
keep the old behaviour of passing empty/ collection of unknown.

<details>

```hcl
provider "google" {
  region       = "us-central1"
}

resource "google_storage_bucket" "bucket" {
  name     = "example-bucket12312322312"
  location = "US"
}

resource "google_storage_bucket" "bucket1" {
  name     = "example-bucket123123223"
  location = "US"
  dynamic "lifecycle_rule" {
    for_each = google_storage_bucket.bucket.effective_labels
    content {
      action {
        type = lifecycle_rule.value
      }
      condition {
        age = 1
      }
    }
  }
}
```

</details>


This returns `"lifecycle_rule":cty.UnknownVal(cty.List(cty.Object))`


Our handling of collections containing unknowns and unknown collections
is significantly better:

Unknown collections:
before:

```
+ prov:index/test:Test: (create)
  [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes]
  tests     : [
      [0]: {}
  ]
```

after:

```
+ prov:index/test:Test: (create)
  [urn=urn:pulumi:test::test::prov:index/test:Test::mainRes]
  tests     : output<string>
```

Note that the array being output as an `output<string>` is an engine
limitation.

Nested unknown collections:
before:

```
+ prov:index/nestedTest:NestedTest: (create)
  [urn=urn:pulumi:test::test::prov:index/nestedTest:NestedTest::mainRes]
  tests     : [
      [0]: {
          nestedProps: [
              [0]: {
                  testProps : [
                      [0]: output<string>
                  ]
              }
          ]
      }
  ]
```

after:

```
+ prov:index/nestedTest:NestedTest: (create)
    [urn=urn:pulumi:test::test::prov:index/nestedTest:NestedTest::mainRes]
    tests     : [
        [0]: {
            nestedProps: [
                [0]: {
                    testProps : output<string>
                }
            ]
        }
    ]
```

The unknown was being put one level lower than it should be.

Quite a few other very wrong outputs in
#2140, including
diff duplications, missing diffs etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants