-
Couldn't load subscription status.
- Fork 87
PMM-1772 Use stable instances for tests. #34
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
Conversation
| // set explicit keys to first instance to test grouping | ||
| cfg.Instances[0].AWSAccessKey = os.Getenv("AWS_ACCESS_KEY") | ||
| cfg.Instances[0].AWSSecretKey = os.Getenv("AWS_SECRET_KEY") | ||
| if cfg.Instances[0].AWSAccessKey == "" || cfg.Instances[0].AWSSecretKey == "" { |
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.
only one cuddle assignment allowed before if statement (from wsl)
| if am56s == p10s { | ||
| assert.Fail(t, "autotest-aurora-mysql-56 and autotest-psql-10 should not share session - different keys (implicit and explicit)") | ||
| } | ||
| if p10s == m57s { |
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.
if statements should only be cuddled with assignments (from wsl)
| } | ||
| if a1s != m56s { | ||
| assert.Fail(t, "rds-aurora1 and rds-mysql56 should share session") | ||
| if m57s != ap11s { |
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.
if statements should only be cuddled with assignments (from wsl)
| } | ||
| if m57s != nil { | ||
| assert.Fail(t, "rds-mysql57 should be skipped") | ||
| if ns != nil { |
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.
if statements should only be cuddled with assignments (from wsl)
| Swap swap `json:"swap"` | ||
| Tasks tasks `json:"tasks"` | ||
|
|
||
| // TODO Handle this: https://jira.percona.com/browse/PMM-3835 |
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.
enhanced/metrics.go:41: Line contains TODO/BUG/FIXME: "TODO Handle this: https://jira.percona.c..." (from godox)
| TGID int `json:"tgid" help:"The thread group identifier, which is a number representing the process ID to which a thread belongs. This identifier is used to group threads from the same process."` | ||
| VSS int `json:"vss" help:"The amount of virtual memory allocated to the process, in kilobytes."` | ||
|
|
||
| // TODO Handle this. |
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.
enhanced/metrics.go:140: Line contains TODO/BUG/FIXME: "TODO Handle this." (from godox)
| func parseOSMetrics(b []byte) (*osMetrics, error) { | ||
| func parseOSMetrics(b []byte, disallowUnknownFields bool) (*osMetrics, error) { | ||
| d := json.NewDecoder(bytes.NewReader(b)) | ||
| if disallowUnknownFields { |
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.
if statements should only be cuddled with assignments used in the if statement itself (from wsl)
| for i := 0; i < t.NumField(); i++ { | ||
| tags := t.Field(i).Tag | ||
| name, help := tags.Get("json"), tags.Get("help") | ||
| if help == "-" { |
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.
only one cuddle assignment allowed before if statement (from wsl)
|
|
||
| var ( | ||
| golden = flag.Bool("golden", false, "update both golden .json and .txt files") | ||
| goldenTXT = flag.Bool("golden-txt", false, "update golden .txt files") |
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.
var goldenTXT is unused (from unused)
| goldenTXT = flag.Bool("golden-txt", false, "update golden .txt files") | ||
| ) | ||
|
|
||
| func readTestDataJSON(t *testing.T, instance string) []byte { |
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.
func readTestDataJSON is unused (from unused)
| require.NoError(t, err) | ||
| } | ||
|
|
||
| func readTestDataMetrics(t *testing.T, instance string) []string { |
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.
func readTestDataMetrics is unused (from unused)
| ) | ||
|
|
||
| var ( | ||
| golden = flag.Bool("golden", false, "update both golden .json and .txt files") |
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.
var golden is unused (from unused)
| return bytes.TrimSpace(b) | ||
| } | ||
|
|
||
| func writeTestDataJSON(t *testing.T, instance string, b []byte) { |
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.
func writeTestDataJSON is unused (from unused)
| if allMessages[instance.ResourceID] == nil { | ||
| allMessages[instance.ResourceID] = make(map[time.Time]string) | ||
| } | ||
| allMessages[instance.ResourceID][timestamp] = *event.Message |
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.
assignments should only be cuddled with other assignments (from wsl)
| resMessages[resourceID] = allMessages[resourceID][timestamp] | ||
| } | ||
| return res | ||
| return resMetrics, resMessages |
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.
return statements should not be cuddled if block has more than two lines (from wsl)
|
|
||
| b, err := ioutil.ReadFile(filepath.Join("testdata", instance+".json")) //nolint:gosec | ||
| require.NoError(t, err) | ||
| return bytes.TrimSpace(b) |
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.
return statements should not be cuddled if block has more than two lines (from wsl)
|
|
||
| b, err := ioutil.ReadFile(filepath.Join("testdata", instance+".txt")) //nolint:gosec | ||
| require.NoError(t, err) | ||
| return strings.Split(string(bytes.TrimSpace(b)), "\n") |
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.
return statements should not be cuddled if block has more than two lines (from wsl)
| // if JSON was updated, update metrics too | ||
| if !t.Failed() && *golden { | ||
| *goldenTXT = true | ||
| TestParse(t) |
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.
only cuddled expressions if assigning variable or using from line above (from wsl)
| return strings.Split(string(bytes.TrimSpace(b)), "\n") | ||
| } | ||
|
|
||
| func writeTestDataMetrics(t *testing.T, metrics []string) { |
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.
func writeTestDataMetrics is unused (from unused)
|
|
||
| var ( | ||
| golden = flag.Bool("golden", false, "does nothing; exists only for compatibility with other packages") | ||
| goldenTXT = flag.Bool("golden-txt", false, "does nothing; exists only for compatibility with other packages") |
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.
var goldenTXT is unused (from unused)
|
|
||
| var ( | ||
| golden = flag.Bool("golden", false, "does nothing; exists only for compatibility with other packages") | ||
| goldenTXT = flag.Bool("golden-txt", false, "update golden .txt files") |
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.
var goldenTXT is unused (from unused)
| func getCollector(t *testing.T) *Collector { | ||
| t.Helper() | ||
|
|
||
| func TestCollector(t *testing.T) { |
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.
func TestCollector is unused (from unused)
| ) | ||
|
|
||
| var ( | ||
| golden = flag.Bool("golden", false, "does nothing; exists only for compatibility with other packages") |
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.
var golden is unused (from unused)
| goldenTXT = flag.Bool("golden-txt", false, "update golden .txt files") | ||
| ) | ||
|
|
||
| func readTestDataMetrics(t *testing.T) []string { |
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.
func readTestDataMetrics is unused (from unused)
| ) | ||
|
|
||
| var ( | ||
| golden = flag.Bool("golden", false, "does nothing; exists only for compatibility with other packages") |
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.
var golden is unused (from unused)
Codecov Report
@@ Coverage Diff @@
## master #34 +/- ##
=========================================
Coverage ? 81.59%
=========================================
Files ? 9
Lines ? 739
Branches ? 0
=========================================
Hits ? 603
Misses ? 118
Partials ? 18
Continue to review full report at Codecov.
|
|
|
||
| b, err := ioutil.ReadFile(filepath.Join("testdata", "all.txt")) //nolint:gosec | ||
| require.NoError(t, err) | ||
| return strings.Split(string(bytes.TrimSpace(b)), "\n") |
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.
return statements should not be cuddled if block has more than two lines (from wsl)
| for _, m := range actualMetrics { | ||
| m.Value = 0 | ||
| } | ||
| actualLines = helpers.Format(helpers.WriteMetrics(actualMetrics)) |
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.
assignments should only be cuddled with other assignments (from wsl)
| metrics = append(metrics, *helpers.ReadMetric(m)) | ||
| expectedMetrics := helpers.ReadMetrics(helpers.Parse(readTestDataMetrics(t))) | ||
| sort.Slice(expectedMetrics, func(i, j int) bool { return expectedMetrics[i].Less(expectedMetrics[j]) }) | ||
| for _, m := range expectedMetrics { |
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.
only one cuddle assignment allowed before range statement (from wsl)
| for _, m := range expectedMetrics { | ||
| m.Value = 0 | ||
| } | ||
| expectedLines := helpers.Format(helpers.WriteMetrics(expectedMetrics)) |
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.
assignments should only be cuddled with other assignments (from wsl)
| osMetrics, err := parseOSMetrics([]byte(*event.Message), s.testDisallowUnknownFields) | ||
| if err != nil { | ||
| // only for tests | ||
| if s.testDisallowUnknownFields { |
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.
why do we need it? How can it help with tests?
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.
This field is set to true in tests. When there are new metrics in CloudWatch Logs, tests will fail.
See discussion at https://jira.percona.com/browse/PMM-3835 for some more background.
| t.Run(fmt.Sprint(instances), func(t *testing.T) { | ||
| // test that there are no new metrics | ||
| s := newScraper(session, instances) | ||
| s.testDisallowUnknownFields = true |
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.
@BupycHuk there
No description provided.