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

Add display to the engine tests #16050

Merged
merged 8 commits into from May 13, 2024
Merged

Add display to the engine tests #16050

merged 8 commits into from May 13, 2024

Conversation

tgummerer
Copy link
Collaborator

@tgummerer tgummerer commented Apr 24, 2024

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 #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?

@pulumi-bot
Copy link
Contributor

pulumi-bot commented Apr 24, 2024

Changelog

[uncommitted] (2024-05-10)

@tgummerer tgummerer force-pushed the tg/display-tests branch 2 times, most recently from b35a02b to 5fc7c92 Compare April 25, 2024 11:37
@tgummerer tgummerer added the impact/no-changelog-required This issue doesn't require a CHANGELOG update label Apr 25, 2024
@tgummerer tgummerer force-pushed the tg/display-tests branch 3 times, most recently from e856c07 to 988e557 Compare April 29, 2024 15:32
@tgummerer tgummerer marked this pull request as ready for review April 30, 2024 08:24
@tgummerer tgummerer requested a review from a team as a code owner April 30, 2024 08:24
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.

LGTM

@@ -4535,7 +4548,8 @@ func TestResourceNames(t *testing.T) {
})
hostF := deploytest.NewPluginHostF(nil, nil, programF, loaders...)
p := &TestPlan{
Options: TestUpdateOptions{HostF: hostF},
// Displaytests for this are racy
Copy link
Member

Choose a reason for hiding this comment

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

What's this comment for? Was this previously skipped?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I missed cleaning this up. I had started excluding tests from displaytests before I realized we need to do some sorting in the display code to get consistent output.

return nil
}

// TODO: dedup with diff_test.go
Copy link
Member

Choose a reason for hiding this comment

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

In general, any TODO we have in the code should have an associated tracking issue and be linked to from here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for calling this out! It's actually easy enough to just address it rather than leaving a TODO around, so I just did that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I gave that a try and it ends up with an annoying circular dependency that's not easy to fix. Given that, and the fact that this is only used in two places, I don't think it's really worth the effort of factoring it out at this point, so I just removed the TODO.

accept := cmdutil.IsTruthy(os.Getenv("PULUMI_ACCEPT"))
if !accept {
var err error
expectedStdout, err = os.ReadFile(path + "/diff.stdout.txt")
Copy link
Member

Choose a reason for hiding this comment

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

Should this use filepath.Join (applies throughout)?

Suggested change
expectedStdout, err = os.ReadFile(path + "/diff.stdout.txt")
expectedStdout, err = os.ReadFile(filepath.Join(path, "diff.stdout.txt"))

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It definitely should, fixing that now.

@tgummerer tgummerer enabled auto-merge May 9, 2024 09:38
@tgummerer tgummerer added this pull request to the merge queue May 9, 2024
github-merge-queue bot pushed a commit that referenced this pull request May 9, 2024
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 #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 <[email protected]>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 9, 2024
@tgummerer tgummerer enabled auto-merge May 9, 2024 13:15
@tgummerer tgummerer added this pull request to the merge queue May 9, 2024
@tgummerer tgummerer added the ci/test Test CI pipelines on this PR label May 9, 2024
@tgummerer tgummerer removed this pull request from the merge queue due to a manual request May 9, 2024
@tgummerer tgummerer force-pushed the tg/display-tests branch 2 times, most recently from 41081e2 to 9fb95dd Compare May 9, 2024 16:23
@tgummerer tgummerer enabled auto-merge May 9, 2024 16:24
@tgummerer tgummerer added this pull request to the merge queue May 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 9, 2024
@tgummerer tgummerer added this pull request to the merge queue May 13, 2024
Merged via the queue into master with commit fc10da3 May 13, 2024
92 checks passed
@tgummerer tgummerer deleted the tg/display-tests branch May 13, 2024 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/test Test CI pipelines on this PR impact/no-changelog-required This issue doesn't require a CHANGELOG update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants