Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Updated metric_type schema to support custom metrics #404

Merged
merged 2 commits into from
Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions servicebroker/config/catalog.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,8 @@
"description": "The interval between two successive scaling activity"
},
"metric_type": {
"enum": [
"memoryused",
"memoryutil",
"responsetime",
"throughput"
],
"type": "string"
"type": "string",
"pattern": "^[a-zA-Z0-9_]+$"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the metric type can start with a number? such as "999metric".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pradyutsarma @paltanmoy @boyang9527 @cdlliuy
should custom metric name be allowed to start with number ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is fine

},
"operator": {
"enum": [
Expand Down
9 changes: 7 additions & 2 deletions servicebroker/test/routes/catalog_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,16 @@ describe("Validate schema definition",function(){
expect(ajv.validate(catalogSchema,fakePolicy)).to.be.false;
});

it("validate metric_type",function(){
fakePolicy.scaling_rules[0].metric_type = "mymetrictype"
it("validate metric_type with non alphanumeric characters",function(){
fakePolicy.scaling_rules[0].metric_type = "ab cd$"
expect(ajv.validate(catalogSchema,fakePolicy)).to.be.false;
});

it("validate metric_type with underscore",function(){
fakePolicy.scaling_rules[0].metric_type = "my_metric2"
expect(ajv.validate(catalogSchema,fakePolicy)).to.be.true;
});

it("validate operator",function(){
fakePolicy.scaling_rules[0].operator = "$"
expect(ajv.validate(catalogSchema,fakePolicy)).to.be.false;
Expand Down