Skip to content

Commit

Permalink
test: added test cases for endpoint selection for Metrics endpoint (#…
Browse files Browse the repository at this point in the history
…1521)

<!--
Thank you for contributing to New Relic's Helm charts. Before you submit
this PR we'd like to
make sure you are aware of our technical requirements:

*
https://github.com/newrelic-experimental/helm-charts/blob/master/CONTRIBUTING.md#technical-requirements

For a quick overview across what we will look at reviewing your PR,
please read
our review guidelines:

*
https://github.com/newrelic-experimental/helm-charts/blob/master/REVIEW_GUIDELINES.md

Following our best practices right from the start will accelerate the
review process and
help get your PR merged quicker.

When updates to your PR are requested, please add new commits and do not
squash the
history. This will make it easier to identify new changes. The PR will
be squashed
anyways when it is merged. Thanks.

For fast feedback, please @-mention maintainers that are listed in the
Chart.yaml file.

Please make sure you test your changes before you push them. Once
pushed, a Github Action
will run across your changes and do some initial checks and linting.
These checks run
very quickly. Please check the results. We would like these checks to
pass before we
even continue reviewing your changes.
-->
#### Is this a new chart

#### What this PR does / why we need it:

#### Which issue this PR fixes
*(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)`
format, will close that issue when PR gets merged)*
  - fixes #

#### Special notes for your reviewer:

#### Checklist
[Place an '[x]' (no spaces) in all applicable fields. Please remove
unrelated fields.]
- [x] Chart Version bumped
- [ ] Variables are documented in the README.md
- [ ] Title of the PR starts with chart name (e.g. `[mychartname]`)
  • Loading branch information
voorepreethi authored Nov 7, 2024
1 parent 79abdb3 commit 2c95369
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/newrelic-logging/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
description: A Helm chart to deploy New Relic Kubernetes Logging as a DaemonSet, supporting both Linux and Windows nodes and containers
name: newrelic-logging
version: 1.23.4
version: 1.23.5
appVersion: 2.1.0
home: https://github.com/newrelic/kubernetes-logging
icon: https://newrelic.com/assets/newrelic/source/NewRelic-logo-square.svg
Expand Down
113 changes: 113 additions & 0 deletions charts/newrelic-logging/tests/endpoint_region_selection_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,117 @@ tests:
content:
name: ENDPOINT
value: "custom"
template: templates/daemonset-windows.yaml
- it: selects custom metrics endpoint if provided
set:
licenseKey: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaFFFFNRAL
metricsEndpoint: custom-metric-endpoint
enableWindows: true
asserts:
# Linux
- contains:
path: spec.template.spec.containers[0].env
content:
name: METRICS_HOST
value: "custom-metric-endpoint"
template: templates/daemonset.yaml
# Windows
- contains:
path: spec.template.spec.containers[0].env
content:
name: METRICS_HOST
value: "custom-metric-endpoint"
template: templates/daemonset-windows.yaml

- it: selects default endpoints when no conditions match
set:
licenseKey: default
enableWindows: true
asserts:
# Linux
- contains:
path: spec.template.spec.containers[0].env
content:
name: ENDPOINT
value: "https://log-api.newrelic.com/log/v1"
template: templates/daemonset.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: METRICS_HOST
value: "metric-api.newrelic.com"
template: templates/daemonset.yaml
# Windows
- contains:
path: spec.template.spec.containers[0].env
content:
name: ENDPOINT
value: "https://log-api.newrelic.com/log/v1"
template: templates/daemonset-windows.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: METRICS_HOST
value: "metric-api.newrelic.com"
template: templates/daemonset-windows.yaml

- it: fails with invalid license key
set:
licenseKey: invalid
enableWindows: true
asserts:
# Linux
- notContains:
path: spec.template.spec.containers[0].env
content:
name: ENDPOINT
template: templates/daemonset.yaml
- notContains:
path: spec.template.spec.containers[0].env
content:
name: METRICS_HOST
template: templates/daemonset.yaml
# Windows
- notContains:
path: spec.template.spec.containers[0].env
content:
name: ENDPOINT
template: templates/daemonset-windows.yaml
- notContains:
path: spec.template.spec.containers[0].env
content:
name: METRICS_HOST
template: templates/daemonset-windows.yaml

- it: selects endpoints with mixed EU key and custom endpoint
set:
licenseKey: euaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaFFFFNRAL
metricsEndpoint: custom-metric-endpoint
enableWindows: true
asserts:
# Linux
- contains:
path: spec.template.spec.containers[0].env
content:
name: ENDPOINT
value: "https://log-api.eu.newrelic.com/log/v1"
template: templates/daemonset.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: METRICS_HOST
value: "custom-metric-endpoint"
template: templates/daemonset.yaml
# Windows
- contains:
path: spec.template.spec.containers[0].env
content:
name: ENDPOINT
value: "https://log-api.eu.newrelic.com/log/v1"
template: templates/daemonset-windows.yaml
- contains:
path: spec.template.spec.containers[0].env
content:
name: METRICS_HOST
value: "custom-metric-endpoint"
template: templates/daemonset-windows.yaml

0 comments on commit 2c95369

Please sign in to comment.