-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Kubernetes] Update KSM location to avoid updating all state tests (#…
…37240) * Update KSM loc. * Update KSM loc. * Update KSM loc. * Update KSM loc. * refactor code * Update metricbeat/module/kubernetes/_meta/test/README.md Co-authored-by: Andrew Gizas <andreas.gkizas@elastic.co> * Update metricbeat/module/kubernetes/_meta/test/README.md Co-authored-by: Andrew Gizas <andreas.gkizas@elastic.co> * Update metricbeat/module/kubernetes/_meta/test/README.md Co-authored-by: Andrew Gizas <andreas.gkizas@elastic.co> * Fix testdata path file --------- Co-authored-by: Andrew Gizas <andreas.gkizas@elastic.co>
- Loading branch information
1 parent
aeb8d70
commit dfdd982
Showing
38 changed files
with
191 additions
and
145 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,18 +1,24 @@ | ||
# Kube State Metrics metrics files | ||
|
||
Each KSM metrics files has the **name format `ksm.v<version>.plain`**. **The `<version>` should be compatible with the Kubernetes versions we support**. Check the compatibility in the official repository [here](https://github.com/kubernetes/kube-state-metrics#compatibility-matrix). | ||
Each KSM metrics file used for the tests of each `state_*` metricset can be found inside `KSM` directory. Each `state_*` metricset directory will have corresponding `_meta/test*` subfolder with expected files. | ||
|
||
**These files are being used in the metricsets that fetch these metrics**: all the `state_*` ones. As of the time of this commit (21.feb.2023), there are two folders that are in use for the `test` file present in each metricset: `test` and `testdata`. Both **these folders require these KSM metrics files** to generate the expected ones. You can check the test file by running `go test -data` to generate the expected files, or simply `go test .` to check against the already present generated files. | ||
Each file has the name format `ksm.v<version>.plain`. The `<version>` should be compatible with the Kubernetes versions we support. Check the compatibility in the official repository [here](https://github.com/kubernetes/kube-state-metrics#compatibility-matrix). | ||
|
||
> **_NOTE:_** The expected files inside these two folders are not deleted when running the tests. Remember to delete them if they are from an old version. | ||
**The name of these files needs to end with the suffix `.plain`**. The reason for this is that the `config.yml` file inside each `state_*` metricset `testdata` requires the suffix `.plain` for the metrics files: | ||
It's mandatory for the name of these files to end with the suffix `.plain`. The reason for this is that the `config.yml` file inside each `state_*` metricset `testdata` requires the suffix `.plain` for the metrics files: | ||
|
||
```yaml | ||
type: http | ||
url: "/metrics" | ||
suffix: plain | ||
path: "../_meta/test" | ||
path: "../_meta/test/KSM" | ||
``` | ||
Since all metricsets use a `data.json` file for the documentation - this file contains an example of the metrics fields -, **it is necessary that one of these files has the name `docs.plain`**. This file should have the **same content as one of the metrics file of a KSM version** we support. This means that one of the files is duplicated, for example: `ksm.v2.7.0.plain` has the same content as `docs.plain`. This is not a mistake, as having the `ksm.v2.7.0.plain` tells us the metrics of that specific version. | ||
When you update the KSM directory files, remember to run `go test -data` inside each `state_*` metricset directory to generate the expected files. To check against the expected files already present, you can just run `go test .`. | ||
|
||
> **TIP**: To run tests and generate the expected files for all state metricsets you can run `go test ./state... --data`. Navigate to `/elastic/beats/metricbeat/module/kubernetes/` to run this command. | ||
|
||
> **_NOTE:_** The expected files inside the two folders of each `state_*` mericset (`_meta/test` and `_meta/testdata`) are not deleted when running the tests. Remember to delete them if they are from an old version. | ||
|
||
|
||
Since all metricsets use a `data.json` file for the documentation - this file contains an example of the metrics fields -, it is necessary that one of these files has the name `docs.plain`. This file needs to be inside `kubernetes/_meta/test` directory. This file should have the same content as one of the metrics file of a KSM version we support. |
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
2 changes: 1 addition & 1 deletion
2
metricbeat/module/kubernetes/state_container/_meta/testdata/config.yml
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
type: http | ||
url: "/metrics" | ||
suffix: plain | ||
path: "../_meta/test" | ||
path: "../_meta/test/KSM" |
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
2 changes: 1 addition & 1 deletion
2
metricbeat/module/kubernetes/state_cronjob/_meta/testdata/config.yml
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
type: http | ||
url: "/metrics" | ||
suffix: plain | ||
path: "../_meta/test" | ||
path: "../_meta/test/KSM" |
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
2 changes: 1 addition & 1 deletion
2
metricbeat/module/kubernetes/state_daemonset/_meta/testdata/config.yml
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
type: http | ||
url: "/metrics" | ||
suffix: plain | ||
path: "../_meta/test" | ||
path: "../_meta/test/KSM" |
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
2 changes: 1 addition & 1 deletion
2
metricbeat/module/kubernetes/state_deployment/_meta/testdata/config.yml
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
type: http | ||
url: "/metrics" | ||
suffix: plain | ||
path: "../_meta/test" | ||
path: "../_meta/test/KSM" |
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
2 changes: 1 addition & 1 deletion
2
metricbeat/module/kubernetes/state_job/_meta/testdata/config.yml
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
type: http | ||
url: "/metrics" | ||
suffix: plain | ||
path: "../_meta/test" | ||
path: "../_meta/test/KSM" |
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
2 changes: 1 addition & 1 deletion
2
metricbeat/module/kubernetes/state_namespace/_meta/testdata/config.yml
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
type: http | ||
url: "/metrics" | ||
suffix: plain | ||
path: "../_meta/test" | ||
path: "../_meta/test/KSM" |
Oops, something went wrong.