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 command to show historical runs of porter #1779

Merged
merged 2 commits into from
Oct 4, 2021

Conversation

phillipahereza
Copy link
Contributor

@phillipahereza phillipahereza commented Sep 25, 2021

What does this change

Adds the command porter installation runs list [NAME] [--namespace NAMESPACE] [--output FORMAT] that lists the historical runs for an installation

Screenshot 2021-09-25 at 15 39 50

What issue does it fix

Closes #1699

Notes for the reviewer

N/A

Checklist

  • Unit Tests
  • Documentation
  • Schema (porter.yaml)

Copy link
Member

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

This looks great! 💯 Once we have the performance concern addressed and a test for the output, it should be good to go.

cmd/porter/installations.go Outdated Show resolved Hide resolved
cmd/porter/installations.go Outdated Show resolved Hide resolved
cmd/porter/installations.go Outdated Show resolved Hide resolved
docs/content/cli/installations_runs_runs.md Outdated Show resolved Hide resolved
pkg/porter/runs.go Outdated Show resolved Hide resolved
pkg/porter/runs.go Outdated Show resolved Hide resolved
pkg/porter/runs.go Outdated Show resolved Hide resolved
pkg/porter/runs.go Show resolved Hide resolved
"testing"
)

func TestPorter_ListInstallationRuns(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

This is a good test. Let's add one more testcase for checking the formatted command output.

The tests for porter installation show in pkg/porter/show_test.go demonstrate how to write a test that checks that the printed output looks the way that you expect. It captures the output from the command, and then compares it against expected output in a file.

The p.CompareGoldenFile function assists with updating the contents of those test files to match the current test output (which is helpful when you intentionally change the output of those commands). Once the test files exist, you can run mage updateTestFiles and all of those test files will be synced with the current output.

The tricky part with those tests is making sure that timestamps do not cause the output to be different every time that you run the test. So the test uses fixed timestamps to make comparing the outputs easier.

i := p.TestClaims.CreateInstallation(claims.NewInstallation("dev", "mywordpress"), p.TestClaims.SetMutableInstallationValues

The SetMutableInstallationValues function (there is also SetMutableRunValues, and SetMutableResultValues) updates the timestamps and IDs so that the tests are reproducible.

Copy link
Member

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

Everything looks great, thanks for improving the performance of that function.

We just need to get the test that checks the command output figured out and it will be all set.

pkg/porter/testdata/runs/expected-output.json Show resolved Hide resolved
Signed-off-by: Phillip Ahereza <pahereza@gmail.com>
@@ -0,0 +1,42 @@
[
Copy link
Member

Choose a reason for hiding this comment

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

Something about how the test is being set up isn't quite right. This file should be the output that someone would see if they ran the command and didn't set the format (i.e. what you see in your screenshot). It shouldn't be json.

Same for the yaml output test case.

Signed-off-by: Phillip Ahereza <pahereza@gmail.com>
Copy link
Member

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

Great, the test looks good. I just built it and ran everything locally and it's working just like we hoped. Thank you for adding this to Porter! 💯

The one failing test (the windows smoke test) is unrelated to your PR and is fixed on the v1 branch, so that can be ignored.

@carolynvs carolynvs merged commit 6b7efb9 into getporter:release/v1 Oct 4, 2021
@phillipahereza phillipahereza deleted the historical_runs branch October 4, 2021 18:20
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.

2 participants