Skip to content

Commit

Permalink
fix: handled review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Hardikl committed Sep 2, 2024
1 parent 1e68385 commit 0cba98a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 48 deletions.
3 changes: 2 additions & 1 deletion cmd/collectors/rest/plugins/quota/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func (q *Quota) handlingQuotaMetrics(instanceMap map[string]*matrix.Instance, me
continue
}
index := quota.GetLabel("index")
volumeUUID := quota.GetLabel("volume_uuid")
uName := quota.GetLabel("userName")
uid := quota.GetLabel("userId")
group := quota.GetLabel("groupName")
Expand All @@ -93,7 +94,7 @@ func (q *Quota) handlingQuotaMetrics(instanceMap map[string]*matrix.Instance, me
for metricName, m := range metricMap {
// set -1 for unlimited
value := -1.0
quotaInstanceKey := index + metricName
quotaInstanceKey := index + volumeUUID + metricName
quotaInstance, err := data.NewInstance(quotaInstanceKey)
if err != nil {
q.Logger.Debug().Msgf("add (%s) instance: %v", metricName, err)
Expand Down
10 changes: 5 additions & 5 deletions cmd/collectors/rest/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var (
func TestMain(m *testing.M) {
conf.TestLoadHarvestConfig("testdata/config.yml")

benchRest = newRest("Volume", "volume.yaml")
benchRest = newRest("Volume", "volume.yaml", "testdata/conf")
fullPollData = collectors.JSONToGson("testdata/volume-1.json.gz", true)
now := time.Now().Truncate(time.Second)
_, _ = benchRest.pollData(now, fullPollData, volumeEndpoints)
Expand Down Expand Up @@ -120,7 +120,7 @@ func Test_pollDataVolume(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

r := newRest("Volume", "volume.yaml")
r := newRest("Volume", "volume.yaml", "testdata/conf")
now := time.Now().Truncate(time.Second)
pollData := collectors.JSONToGson(tt.pollDataPath1, true)

Expand Down Expand Up @@ -149,9 +149,9 @@ func volumeEndpoints(e *EndPoint) ([]gjson.Result, time.Duration, error) {
return gson, 0, nil
}

func newRest(object string, path string) *Rest {
func newRest(object string, path string, confPath string) *Rest {
var err error
opts := options.New(options.WithConfPath("testdata/conf"))
opts := options.New(options.WithConfPath(confPath))
opts.Poller = pollerName
opts.HomePath = "testdata"
opts.IsTest = true
Expand Down Expand Up @@ -441,7 +441,7 @@ func TestFields(t *testing.T) {
}

func TestQuotas(t *testing.T) {
r := newRest("Quota", "quota.yaml")
r := newRest("Quota", "quota.yaml", "../../../conf")
var instanceKeys []string
result, err := collectors.InvokeRestCallWithTestFile(r.Client, "", r.Logger, "testdata/quota.json")
if err != nil {
Expand Down
42 changes: 0 additions & 42 deletions cmd/collectors/rest/testdata/conf/rest/9.12.1/quota.yaml

This file was deleted.

0 comments on commit 0cba98a

Please sign in to comment.