-
Notifications
You must be signed in to change notification settings - Fork 42
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
MM-56605: Create results file and print to file #729
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c3dce66
MM-56605: Create results file and print to file
DHaussermann bbaabaf
Separate writter into its own function for later
DHaussermann d560e9c
Mofify writeToFile. Passing the file object.
DHaussermann ef54815
implement multiWriter so I can double the writes and then send them …
DHaussermann 00134be
Replace file object with interface.
DHaussermann 4a2e621
- Remove separate function to create file
DHaussermann 65aee47
Draft unti test for PrintResults
DHaussermann d65c7ec
Make test runnable by using LoadTests and Status properly.
DHaussermann a38abb5
- Solve missing use of interface in the initail code chnage
DHaussermann 18ed511
Change expected to allign with the output. This solves failing unit t…
DHaussermann c6113ee
Address most several of the code review feedback point.
DHaussermann 93e4052
Use existing file path that is already being provided to the function.
DHaussermann 5d8cf1b
Address linter complaint about use of `Sprintf` for strings that need…
DHaussermann 90a549f
Address review comments
DHaussermann 21151df
Remove line printing an error as it was redundant.
DHaussermann 128ff74
Update another if block that redundantly prints and returns the same …
DHaussermann 455ccab
Implement missed correction from Alejandro. If block must return the …
DHaussermann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/mattermost/mattermost-load-test-ng/comparison" | ||
"github.com/mattermost/mattermost-load-test-ng/coordinator" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestPrintResults(t *testing.T) { | ||
// Create a buffer to capture the output | ||
buf := &bytes.Buffer{} | ||
|
||
// Prepare test data | ||
results := []comparison.Result{ | ||
{ | ||
Report: "Sample Report", | ||
DashboardURL: "http://example.com/dashboard", | ||
LoadTests: [2]comparison.LoadTestResult{ | ||
{ | ||
Label: "Test1", | ||
Config: comparison.LoadTestConfig{ | ||
Type: "bounded", | ||
DBEngine: "postgres", | ||
NumUsers: 100, | ||
Duration: "10m", | ||
}, | ||
Status: coordinator.Status{ | ||
SupportedUsers: 80, | ||
NumErrors: 2, | ||
}, | ||
}, | ||
{ | ||
Label: "Test2", | ||
Config: comparison.LoadTestConfig{ | ||
Type: "bounded", | ||
DBEngine: "postgres", | ||
NumUsers: 100, | ||
Duration: "10m", | ||
}, | ||
Status: coordinator.Status{ | ||
SupportedUsers: 80, | ||
NumErrors: 2, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
// Call the function with the test data and the buffer | ||
writeResults(results, buf) | ||
|
||
// Verify the output | ||
expectedOutput := `==================================================Comparison result:Report: report_0_postgres_bounded_100.md | ||
Grafana Dashboard: http://example.com/dashboard | ||
Test1: | ||
Type: bounded | ||
DB Engine: postgres | ||
Duration: 10m | ||
Users: 100 | ||
Errors: 2 | ||
Test2: | ||
Type: bounded | ||
DB Engine: postgres | ||
Duration: 10m | ||
Users: 100 | ||
Errors: 2 | ||
================================================== | ||
|
||
` | ||
require.Equal(t, expectedOutput, buf.String()) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Great test!