This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
Current level gauge for FlyteWorkflows #132
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0f74c72
first attempt at adding a collection device
df5a893
revert file
23f4a22
fix
53fb9f4
unit tests
72c9963
Update pkg/controller/controller.go
wild-endeavor 500d655
nits
c9e7611
fix unit test
60dd38b
make goimports
4a20c5d
add missing
88ad163
stupid
8ad7568
more comments
26570d8
move pprof line down
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
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,83 @@ | ||
package controller | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
"github.com/lyft/flyteidl/gen/pb-go/flyteidl/core" | ||
"github.com/lyft/flytepropeller/pkg/apis/flyteworkflow/v1alpha1" | ||
listers "github.com/lyft/flytepropeller/pkg/client/listers/flyteworkflow/v1alpha1" | ||
"github.com/lyft/flytestdlib/promutils" | ||
"github.com/prometheus/client_golang/prometheus/testutil" | ||
"github.com/stretchr/testify/assert" | ||
"k8s.io/apimachinery/pkg/labels" | ||
) | ||
|
||
var wfs = []*v1alpha1.FlyteWorkflow{ | ||
{ | ||
ExecutionID: v1alpha1.ExecutionID{ | ||
WorkflowExecutionIdentifier: &core.WorkflowExecutionIdentifier{ | ||
Project: "proj", | ||
Domain: "dev", | ||
Name: "name", | ||
}, | ||
}, | ||
}, | ||
{ | ||
ExecutionID: v1alpha1.ExecutionID{ | ||
WorkflowExecutionIdentifier: &core.WorkflowExecutionIdentifier{ | ||
Project: "proj", | ||
Domain: "dev", | ||
Name: "name", | ||
}, | ||
}, | ||
}, | ||
{ | ||
ExecutionID: v1alpha1.ExecutionID{ | ||
WorkflowExecutionIdentifier: &core.WorkflowExecutionIdentifier{ | ||
Project: "proj2", | ||
Domain: "dev", | ||
Name: "name", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
func TestNewResourceLevelMonitor(t *testing.T) { | ||
lm := ResourceLevelMonitor{} | ||
res := lm.countList(context.Background(), wfs) | ||
assert.Equal(t, 2, res["proj"]["dev"]) | ||
assert.Equal(t, 1, res["proj2"]["dev"]) | ||
} | ||
|
||
type mockWFLister struct { | ||
listers.FlyteWorkflowLister | ||
} | ||
|
||
func (m mockWFLister) List(_ labels.Selector) (ret []*v1alpha1.FlyteWorkflow, err error) { | ||
return wfs, nil | ||
} | ||
|
||
func TestResourceLevelMonitor_collect(t *testing.T) { | ||
scope := promutils.NewScope("testscope") | ||
g := scope.MustNewGaugeVec("unittest", "testing", "project", "domain") | ||
lm := &ResourceLevelMonitor{ | ||
Scope: scope, | ||
CollectorTimer: scope.MustNewStopWatch("collection_cycle", "Measures how long it takes to run a collection", time.Millisecond), | ||
levels: g, | ||
lister: mockWFLister{}, | ||
} | ||
lm.collect(context.Background()) | ||
|
||
var expected = ` | ||
# HELP testscope:unittest testing | ||
# TYPE testscope:unittest gauge | ||
testscope:unittest{domain="dev",project="proj"} 2 | ||
testscope:unittest{domain="dev",project="proj2"} 1 | ||
` | ||
|
||
err := testutil.CollectAndCompare(g, strings.NewReader(expected)) | ||
assert.NoError(t, err) | ||
} |
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.
:D nit:
missingProject
? or something descriptive