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 negative stopwatch times #11631

Merged
merged 2 commits into from Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,4 @@
changes:
- type: fix
scope: cli/display
description: Fixes negative durations on update display.
3 changes: 3 additions & 0 deletions pkg/backend/display/progress.go
Expand Up @@ -862,6 +862,9 @@ func (display *ProgressDisplay) processNormalEvent(event engine.Event) {
// and time elapsed.
display.opStopwatch.start[step.URN] = time.Now()

// Clear out potential event end timings for prior operations on the same resource.
delete(display.opStopwatch.end, step.URN)

row.SetStep(step)
} else if event.Type == engine.ResourceOutputsEvent {
isRefresh := display.getStepOp(row.Step()) == deploy.OpRefresh
Expand Down
28 changes: 28 additions & 0 deletions tests/integration/integration_nodejs_test.go
Expand Up @@ -1166,6 +1166,34 @@ func TestESMTSCompiled(t *testing.T) {
})
}

// Test that the resource stopwatch doesn't contain a negative time.
func TestNoNegativeTimingsOnRefresh(t *testing.T) {
if runtime.GOOS == WindowsOS {
t.Skip("Skip on windows because we lack yarn")
}
t.Parallel()

dir := filepath.Join("empty", "nodejs")
e := ptesting.NewEnvironment(t)
defer func() {
if !t.Failed() {
e.DeleteEnvironment()
}
}()
e.ImportDirectory(dir)

e.RunCommand("yarn", "link", "@pulumi/pulumi")
e.RunCommand("yarn", "install")
e.RunCommand("pulumi", "login", "--cloud-url", e.LocalURL())
e.RunCommand("pulumi", "stack", "init", "negative-timings")
e.RunCommand("pulumi", "stack", "select", "negative-timings")
e.RunCommand("pulumi", "up", "--yes")
stdout, _ := e.RunCommand("pulumi", "destroy", "--skip-preview", "--refresh=true")
// Assert there are no negative times in the output.
assert.NotContainsf(t, stdout, " (-",
"`pulumi destroy --skip-preview --refresh=true` contains a negative time")
}

// Test that the about command works as expected. Because about parses the
// results of each runtime independently, we have an integration test in each
// language.
Expand Down