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

fix MockMonitor reporting DeletedWith wasn't supported #14118

Merged
merged 4 commits into from Oct 9, 2023

Conversation

tgummerer
Copy link
Collaborator

We should support all features in mocks that we are supporting otherwise. We did a similar thing in pulumi-dotnet: pulumi/pulumi-dotnet#93.

However here we're not simply changing hasSupport to true. 1e09626 has a good explanation of why we only support specific values here. However really we only need to disable support for outputValues, and that only if output values are disabled. Originally this was true if PULUMI_ENABLE_OUTPUT_VALUES was set, but that environment variable was later inverted: 3027d01.

This ended up being a little bit more complicated than just passing true, but I think it's more correct this way. I'm also happy to change it back to just passing through true if that's preferred. Once we decided on whether this is the right way to do it vs. just passing true unconditionally I'll also update java and dotnet (if we're going this way) to do the same.

Fixes #13355

Checklist

  • I have run make tidy to update any new dependencies
  • I have run make lint to verify my code passes the lint check
    • I have formatted my code using gofumpt
  • I have added tests that prove my fix is effective or that my feature works
  • I have run make changelog and committed the changelog/pending/<file> documenting my change
  • Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version

@tgummerer tgummerer requested a review from a team October 6, 2023 15:09
@pulumi-bot
Copy link
Contributor

pulumi-bot commented Oct 6, 2023

Changelog

[uncommitted] (2023-10-09)

Bug Fixes

  • [sdk/{go,nodejs,python}] Fix MockMonitor reporting DeletedWith wasn't supported
    #14118

@@ -227,7 +227,7 @@ export class MockMonitor {

// Support for "outputValues" is deliberately disabled for the mock monitor so
// instances of `Output` don't show up in `MockResourceArgs` inputs.
const hasSupport = id === "secrets" || id === "resourceReferences";
const hasSupport = process.env.PULUMI_DISABLE_OUTPUT_VALUES != "true" || id !== "outputValues";
Copy link
Member

Choose a reason for hiding this comment

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

!== here

Frassle
Frassle previously approved these changes Oct 6, 2023
Copy link
Member

@Frassle Frassle left a comment

Choose a reason for hiding this comment

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

I'm not sure anything actually needs this env var anymore, but doesn't look like it'll hurt to check it.
Given we've got no complaints from dotnet about this it's probably fine to leave that as not checking the env var.

cc @justinvp as he might have a better insights to this setting

justinvp
justinvp previously approved these changes Oct 8, 2023
Copy link
Member

@justinvp justinvp left a comment

Choose a reason for hiding this comment

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

I'm not sure anything actually needs this env var anymore

Yeah, no need to check the envvar for these.

LGTM otherwise.

@justinvp
Copy link
Member

justinvp commented Oct 8, 2023

I opened pulumi/pulumi-dotnet#184 to make the .NET SDK consistent with the changes here.

@tgummerer tgummerer added this pull request to the merge queue Oct 9, 2023
@tgummerer tgummerer removed this pull request from the merge queue due to a manual request Oct 9, 2023
We should support all features in mocks that we are supporting
otherwise.  We did a similar thing in pulumi-dotnet:
pulumi/pulumi-dotnet#93.

However here we're not simply changing hasSupport to true.
1e09626
has a good explanation of why we only support specific values here.
However really we only need to disable support for `outputValues`, and
that only if output values are disabled.  Originally this was true
if `PULUMI_ENABLE_OUTPUT_VALUES` was set, but that environment
variable was later inverted: 3027d01.
@@ -494,10 +494,10 @@ func TestRegisterResource_aliasesSpecs(t *testing.T) {
// alias specs.
// So if that's needed, wrap the monitor to claim it
// does.
if tt.supportsAliasSpecs {
if !tt.supportsAliasSpecs {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The changes necessary in this test made me a little bit worried that we'd be breaking some backwards compatibility here, but we're testing internal things here, so maybe it's okay? I'd appreciate some extra eyes here.

Copy link
Member

Choose a reason for hiding this comment

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

Yeh this looks fine

@@ -495,7 +495,7 @@ describe("provider", () => {
it(`deserializes '${test.name}' correctly`, async () => {
pulumi.runtime.setMocks(new TestMocks(), "project", "stack", true);
pulumi.runtime.registerResourceModule("test", "index", new TestModule());
new TestResource("name"); // Create an instance so it can be deserialized.
await new TestResource("name"); // Create an instance so it can be deserialized.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We were previously not awaiting this resource, so when we started resolving aliases during the test because the mock supports that now, things started failing because the resource wasn't fully registered yet by the time we were checking it. Regardless of the other changes in this PR I believe this is the right thing to do.

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK, it is not possible to await a constructor, since it is never async and definitely doesn't return a Promise<T> 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Await the resources URN instead.

Copy link
Collaborator Author

@tgummerer tgummerer Oct 9, 2023

Choose a reason for hiding this comment

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

Interesting, somehow it seemed to work in the test. I don't know a lot about typescript, I think I got it right now? Is 3a8b197 what you meant?

Copy link
Member

Choose a reason for hiding this comment

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

Yup

@tgummerer tgummerer dismissed stale reviews from justinvp and Frassle October 9, 2023 10:07

Would appreciate a double check on the things I commented on.

Zaid-Ajaj added a commit to pulumi/pulumi-java that referenced this pull request Oct 9, 2023
# Description

Make sure the mockmonitor works the same way as the other SDKs as
changed in pulumi/pulumi#14118 and
pulumi/pulumi-dotnet#184.

## Checklist

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have updated the
[CHANGELOG-PENDING](https://github.com/pulumi/pulumi/blob/master/CHANGELOG_PENDING.md)
file with my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Service,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Service API version
<!-- @pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
@tgummerer tgummerer added this pull request to the merge queue Oct 9, 2023
Merged via the queue into master with commit b5077dc Oct 9, 2023
44 checks passed
@tgummerer tgummerer deleted the tg/support-deleted-with branch October 9, 2023 15:02
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.

CLI does not support DeletedWith option in tests
5 participants