-
Notifications
You must be signed in to change notification settings - Fork 948
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add kernel info to EngineVersion metric
Signed-off-by: KevinBetterQ <1093850932@qq.com>
- Loading branch information
1 parent
9653c63
commit c3e6408
Showing
4 changed files
with
77 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package main | ||
|
||
import ( | ||
"regexp" | ||
|
||
"github.com/alibaba/pouch/pkg/kernel" | ||
"github.com/alibaba/pouch/test/environment" | ||
"github.com/alibaba/pouch/version" | ||
|
||
"github.com/go-check/check" | ||
) | ||
|
||
// APIEngineVersionMetricsSuite is the test suite for EngineVersion metrics API. | ||
type APIEngineVersionMetricsSuite struct{} | ||
|
||
func init() { | ||
check.Suite(&APIEngineVersionMetricsSuite{}) | ||
} | ||
|
||
// SetUpSuite does common setup in the beginning of each suite. | ||
func (suite *APIEngineVersionMetricsSuite) SetUpSuite(c *check.C) { | ||
SkipIfFalse(c, environment.IsLinux) | ||
} | ||
|
||
// TestEngineVersionMetrics tests metrics of EngineVersion. | ||
func (suite *APIEngineVersionMetricsSuite) TestEngineVersionMetrics(c *check.C) { | ||
commitExpected := version.GitCommit | ||
versionExpected := version.Version | ||
kernelVersion, err := kernel.GetKernelVersion() | ||
c.Assert(err, check.IsNil) | ||
kernelExpected := kernelVersion.String() | ||
|
||
key := "engine_daemon_engine_info{" | ||
versionMetrics := GetMetricLine(c, key) | ||
|
||
regularCommit := `^.*commit="(.*?)".*$` | ||
regular := regexp.MustCompile(regularCommit) | ||
params := regular.FindStringSubmatch(versionMetrics) | ||
c.Assert(params[1], check.Equals, commitExpected) | ||
|
||
regularVersion := `^.*version="(.*?)".*$` | ||
regular = regexp.MustCompile(regularVersion) | ||
params = regular.FindStringSubmatch(versionMetrics) | ||
c.Assert(params[1], check.Equals, versionExpected) | ||
|
||
regularKernel := `^.*kernel="(.*?)".*$` | ||
regular = regexp.MustCompile(regularKernel) | ||
params = regular.FindStringSubmatch(versionMetrics) | ||
c.Assert(params[1], check.Equals, kernelExpected) | ||
|
||
} |
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