-
Notifications
You must be signed in to change notification settings - Fork 949
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
777292a
commit 579a86e
Showing
4 changed files
with
78 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,52 @@ | ||
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{}) | ||
} | ||
|
||
// SetUpTest does common setup in the beginning of each test. | ||
func (suite *APIEngineVersionMetricsSuite) SetUpTest(c *check.C) { | ||
SkipIfFalse(c, environment.IsLinux) | ||
} | ||
|
||
// SetUpSuite does common setup in the beginning of each suite. | ||
func (suite *APIEngineVersionMetricsSuite) SetUpSuite(c *check.C) { | ||
SkipIfFalse(c, environment.IsLinux) | ||
} | ||
|
||
// TearDownSuite run after each suite to do cleanup work for the whole suite. | ||
func (suite *APIEngineVersionMetricsSuite) TearDownSuite(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) | ||
regularStr := `^.*commit="(.*)",version="(.*)",kernel="(.*)".*$` | ||
regular := regexp.MustCompile(regularStr) | ||
params := regular.FindStringSubmatch(versionMetrics) | ||
c.Assert(params[1], check.Equals, commitExpected) | ||
c.Assert(params[2], check.Equals, versionExpected) | ||
c.Assert(params[3], 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