forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collect bulk indexing stats for Elasticsearch metricsets (elastic#17992…
…) (elastic#18229) * Collecting new index_stats bulk metrics * Collecting new indices_stats bulk metrics * Collecting new node_stats bulk metrics * Adding CHANGELOG entry * Request bulk stats * Request bulk metrics only if supported * Fixing code and tests * Fixing code so only service URI path is replaced * Updating unit tests
- Loading branch information
1 parent
2deccde
commit 2c4bf42
Showing
7 changed files
with
142 additions
and
3 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
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,70 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package index | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
"testing/quick" | ||
|
||
"github.com/elastic/beats/v7/libbeat/common" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestGetServiceURI(t *testing.T) { | ||
tests := map[string]struct { | ||
esVersion *common.Version | ||
expectedPath string | ||
}{ | ||
"bulk_stats_unavailable": { | ||
esVersion: common.MustNewVersion("7.7.0"), | ||
expectedPath: statsPath, | ||
}, | ||
"bulk_stats_available": { | ||
esVersion: common.MustNewVersion("7.8.0"), | ||
expectedPath: strings.Replace(statsPath, statsMetrics, statsMetrics+",bulk", 1), | ||
}, | ||
} | ||
|
||
for name, test := range tests { | ||
t.Run(name, func(t *testing.T) { | ||
newURI, err := getServicePath(*test.esVersion) | ||
require.NoError(t, err) | ||
require.Equal(t, test.expectedPath, newURI) | ||
}) | ||
} | ||
} | ||
|
||
func TestGetServiceURIMultipleCalls(t *testing.T) { | ||
err := quick.Check(func(r uint) bool { | ||
numCalls := 2 + (r % 10) // between 2 and 11 | ||
|
||
var uri string | ||
var err error | ||
for i := uint(0); i < numCalls; i++ { | ||
uri, err = getServicePath(*common.MustNewVersion("7.8.0")) | ||
if err != nil { | ||
return false | ||
} | ||
} | ||
|
||
return err == nil && uri == strings.Replace(statsPath, statsMetrics, statsMetrics+",bulk", 1) | ||
}, nil) | ||
require.NoError(t, err) | ||
} |
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