-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: node metrics analyser The analyser only checks PVC usage at the moment. More analysers can be added on a need to have basis * Add tests * Fix flaky test by waiting for goldpinger pods to start * Fix how outcomes get checked * Fix catch all outcome condition * Fix test * feat: node metrics analyser The analyser only checks PVC usage at the moment. More analysers can be added on a need to have basis * Add tests * Fix flaky test by waiting for goldpinger pods to start * Fix how outcomes get checked * Fix catch all outcome condition * Fix test * Regenerate schemas * Fix failing test --------- Co-authored-by: Dexter Yan <[email protected]>
- Loading branch information
Showing
17 changed files
with
1,303 additions
and
12 deletions.
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
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
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
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,34 @@ | ||
package analyzer | ||
|
||
import "fmt" | ||
|
||
type ComparisonOperator int | ||
|
||
const ( | ||
Unknown ComparisonOperator = iota | ||
Equal | ||
NotEqual | ||
GreaterThan | ||
GreaterThanOrEqual | ||
LessThan | ||
LessThanOrEqual | ||
) | ||
|
||
func ParseComparisonOperator(s string) (ComparisonOperator, error) { | ||
switch s { | ||
case "=", "==", "===": | ||
return Equal, nil | ||
case "!=", "!==": | ||
return NotEqual, nil | ||
case "<": | ||
return LessThan, nil | ||
case ">": | ||
return GreaterThan, nil | ||
case "<=": | ||
return LessThanOrEqual, nil | ||
case ">=": | ||
return GreaterThanOrEqual, nil | ||
} | ||
|
||
return Unknown, fmt.Errorf("unknown operator: %s", s) | ||
} |
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,79 @@ | ||
package analyzer | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParseComparisonOperator(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
input string | ||
want ComparisonOperator | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "equal", | ||
input: "=", | ||
want: Equal, | ||
}, | ||
{ | ||
name: "equal", | ||
input: "==", | ||
want: Equal, | ||
}, | ||
{ | ||
name: "equal", | ||
input: "===", | ||
want: Equal, | ||
}, | ||
{ | ||
name: "not equal", | ||
input: "!=", | ||
want: NotEqual, | ||
}, | ||
{ | ||
name: "not equal", | ||
input: "!==", | ||
want: NotEqual, | ||
}, | ||
{ | ||
name: "less than", | ||
input: "<", | ||
want: LessThan, | ||
}, | ||
{ | ||
name: "greater than", | ||
input: ">", | ||
want: GreaterThan, | ||
}, | ||
{ | ||
name: "less than or equal", | ||
input: "<=", | ||
want: LessThanOrEqual, | ||
}, | ||
{ | ||
name: "greater than or equal", | ||
input: ">=", | ||
want: GreaterThanOrEqual, | ||
}, | ||
{ | ||
name: "invalid operator 1", | ||
input: "", | ||
wantErr: true, | ||
}, | ||
{ | ||
name: "invalid operator 2", | ||
input: "gibberish", | ||
wantErr: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := ParseComparisonOperator(tt.input) | ||
assert.Equal(t, tt.want, got, "ParseOperator() = %v, want %v", got, tt.want) | ||
assert.Equalf(t, tt.wantErr, err != nil, "ParseOperator() error = %v, wantErr %v", err, tt.wantErr) | ||
}) | ||
} | ||
} |
Oops, something went wrong.