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
Conversation
Changelog[uncommitted] (2024-05-10) |
b35a02b
to
5fc7c92
Compare
e856c07
to
988e557
Compare
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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)?
expectedStdout, err = os.ReadFile(path + "/diff.stdout.txt") | |
expectedStdout, err = os.ReadFile(filepath.Join(path, "diff.stdout.txt")) |
There was a problem hiding this comment.
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.
e6932b6
to
e685cea
Compare
e685cea
to
5849258
Compare
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]>
cbb3647
to
fe79ee0
Compare
41081e2
to
9fb95dd
Compare
9fb95dd
to
74c281e
Compare
74c281e
to
574d0b5
Compare
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?