From d8b2671c79a48307437bc0dccd042549de718c5b Mon Sep 17 00:00:00 2001 From: Kyle Dixler Date: Mon, 12 Dec 2022 11:02:23 -0800 Subject: [PATCH 1/2] created initial test --- tests/integration/integration_nodejs_test.go | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/integration/integration_nodejs_test.go b/tests/integration/integration_nodejs_test.go index 559077da88e5..7034b4c693f2 100644 --- a/tests/integration/integration_nodejs_test.go +++ b/tests/integration/integration_nodejs_test.go @@ -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. From a66cceab423604ab291652faa47330a4ffa1ea56 Mon Sep 17 00:00:00 2001 From: Kyle Dixler Date: Mon, 12 Dec 2022 12:15:35 -0800 Subject: [PATCH 2/2] fix negative durations in update display --- ...i-display--fixes-negative-durations-on-update-display.yaml | 4 ++++ pkg/backend/display/progress.go | 3 +++ 2 files changed, 7 insertions(+) create mode 100644 changelog/pending/20221212--cli-display--fixes-negative-durations-on-update-display.yaml diff --git a/changelog/pending/20221212--cli-display--fixes-negative-durations-on-update-display.yaml b/changelog/pending/20221212--cli-display--fixes-negative-durations-on-update-display.yaml new file mode 100644 index 000000000000..52e79cdf1d34 --- /dev/null +++ b/changelog/pending/20221212--cli-display--fixes-negative-durations-on-update-display.yaml @@ -0,0 +1,4 @@ +changes: +- type: fix + scope: cli/display + description: Fixes negative durations on update display. diff --git a/pkg/backend/display/progress.go b/pkg/backend/display/progress.go index 89296a03b11c..f1bac6d3d749 100644 --- a/pkg/backend/display/progress.go +++ b/pkg/backend/display/progress.go @@ -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