Skip to content

Commit 745948e

Browse files
committed
Added integration test for snapshots metrics
1 parent 2ac18e9 commit 745948e

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ To disable exporting cluster settings use:
145145
prometheus.cluster.settings: false
146146
```
147147

148+
#### Snapshot metrics
149+
150+
To enable exporting snapshot metrics use:
151+
```
152+
prometheus.snapshots: true
153+
```
154+
155+
148156
#### Nodes filter
149157

150158
Metrics include statistics about individual OpenSearch nodes.

build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.opensearch.gradle.PropertyNormalization
12
import org.opensearch.gradle.test.RestIntegTestTask
23

34
import java.util.regex.Matcher
@@ -124,8 +125,13 @@ tasks.named("check").configure { dependsOn(integTest) }
124125
// Temporary disable task :testingConventions
125126
testingConventions.enabled = false
126127

128+
// Directory for snapshot repository
129+
File repositoryDir = new File(project.buildDir, "shared-repository")
130+
127131
testClusters.all {
128132
numberOfNodes = 2
133+
// Configuring repo path for 'fs' type snapshot repository
134+
setting 'path.repo', "${repositoryDir.absolutePath}", PropertyNormalization.IGNORE_VALUE
129135

130136
// It seems cluster name can not be customized here. It gives an error:
131137
// Testclusters does not allow the following settings to be changed:[cluster.name] for node{::yamlRestTest-0}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
"Verify snapshots metrics enabled":
3+
4+
# Create 'fs' snapshot repository
5+
- do:
6+
snapshot.create_repository:
7+
repository: test_repo_get_1
8+
body:
9+
type: fs
10+
settings:
11+
location: "test_repo_get_1_loc"
12+
13+
- do:
14+
snapshot.get_repository: { }
15+
16+
- is_true: test_repo_get_1
17+
18+
# Enable snapshots metrics
19+
- do:
20+
cluster.put_settings:
21+
body:
22+
persistent:
23+
prometheus.snapshots: "true"
24+
flat_settings: true
25+
26+
- match: { persistent: { prometheus.snapshots: "true" } }
27+
28+
# Create snapshot
29+
- do:
30+
snapshot.create:
31+
repository: test_repo_get_1
32+
snapshot: test_snapshot_1
33+
wait_for_completion: true
34+
35+
- match: { snapshot.snapshot: test_snapshot_1 }
36+
- match: { snapshot.state : SUCCESS }
37+
38+
# Fetch and verify metrics
39+
- do:
40+
prometheus.metrics: {}
41+
42+
- match:
43+
$body: |
44+
/.*
45+
\# \s* HELP \s+ opensearch_min_snapshot_age \s+.*\n
46+
\# \s* TYPE \s+ opensearch_min_snapshot_age \s+ gauge\n
47+
opensearch_min_snapshot_age\{
48+
cluster="yamlRestTest",sm_policy="adhoc",
49+
\}\s+\d+\.\d+\n
50+
.*/

0 commit comments

Comments
 (0)