-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
option to query metric only on polling interval
Signed-off-by: Zbynek Roubalik <[email protected]>
- Loading branch information
Showing
92 changed files
with
1,334 additions
and
1,155 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
type testData struct { | ||
name string | ||
expectedIdentifier string | ||
soName string | ||
soNamespace string | ||
soKind string | ||
} | ||
|
||
var tests = []testData{ | ||
{ | ||
name: "all lowercase", | ||
expectedIdentifier: "scaledobject.namespace.name", | ||
soName: "name", | ||
soNamespace: "namespace", | ||
soKind: "scaledobject", | ||
}, | ||
{ | ||
name: "all uppercase", | ||
expectedIdentifier: "scaledobject.namespace.name", | ||
soName: "NAME", | ||
soNamespace: "NAMESPACE", | ||
soKind: "SCALEDOBJECT", | ||
}, | ||
{ | ||
name: "camel case", | ||
expectedIdentifier: "scaledobject.namespace.name", | ||
soName: "name", | ||
soNamespace: "namespace", | ||
soKind: "scaledobject", | ||
}, | ||
{ | ||
name: "missing namespace", | ||
expectedIdentifier: "scaledobject..name", | ||
soName: "name", | ||
soKind: "scaledobject", | ||
}, | ||
} | ||
|
||
func TestGeneratedIdentifierForScaledObject(t *testing.T) { | ||
for _, test := range tests { | ||
test := test | ||
t.Run(test.name, func(t *testing.T) { | ||
expectedIdentifier := test.expectedIdentifier | ||
genericIdentifier := GenerateIdentifier(test.soKind, test.soNamespace, test.soName) | ||
|
||
scaledObject := &ScaledObject{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: test.soName, | ||
Namespace: test.soNamespace, | ||
}, | ||
} | ||
scaledObjectIdentifier := scaledObject.GenerateIdentifier() | ||
|
||
withTriggers, err := AsDuckWithTriggers(scaledObject) | ||
if err != nil { | ||
t.Errorf("got error while converting to WithTriggers object: %s", err) | ||
} | ||
withTriggersIdentifier := withTriggers.GenerateIdentifier() | ||
|
||
if expectedIdentifier != genericIdentifier { | ||
t.Errorf("genericIdentifier=%q doesn't equal the expectedIdentifier=%q", genericIdentifier, expectedIdentifier) | ||
} | ||
|
||
if expectedIdentifier != scaledObjectIdentifier { | ||
t.Errorf("scaledObjectIdentifier=%q doesn't equal the expectedIdentifier=%q", scaledObjectIdentifier, expectedIdentifier) | ||
} | ||
|
||
if expectedIdentifier != withTriggersIdentifier { | ||
t.Errorf("withTriggersIdentifier=%q doesn't equal the expectedIdentifier=%q", withTriggersIdentifier, expectedIdentifier) | ||
} | ||
}) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -276,6 +276,8 @@ spec: | |
type: string | ||
type: | ||
type: string | ||
useCachedMetrics: | ||
type: boolean | ||
required: | ||
- metadata | ||
- type | ||
|
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
Oops, something went wrong.