-
-
Notifications
You must be signed in to change notification settings - Fork 7
chore: add metrics test for NiFi 2.x #823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
tests/templates/kuttl/smoke_v2/50-install-test-nifi.yaml.j2
This file contains hidden or 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,78 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: test-nifi | ||
labels: | ||
app: test-nifi | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: test-nifi | ||
template: | ||
metadata: | ||
labels: | ||
app: test-nifi | ||
spec: | ||
serviceAccountName: "tls-sa" | ||
securityContext: | ||
fsGroup: 1000 | ||
containers: | ||
- name: test-nifi | ||
image: oci.stackable.tech/sdp/testing-tools:0.2.0-stackable0.0.0-dev | ||
command: ["sleep", "infinity"] | ||
resources: | ||
requests: | ||
memory: "128Mi" | ||
cpu: "100m" | ||
limits: | ||
memory: "128Mi" | ||
cpu: "400m" | ||
volumeMounts: | ||
- name: tls | ||
mountPath: /stackable/tls | ||
volumes: | ||
- name: tls | ||
ephemeral: | ||
volumeClaimTemplate: | ||
metadata: | ||
annotations: | ||
secrets.stackable.tech/class: tls | ||
secrets.stackable.tech/scope: pod | ||
spec: | ||
storageClassName: secrets.stackable.tech | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: "1" | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: tls-sa | ||
{% if test_scenario['values']['openshift'] == 'true' %} | ||
--- | ||
kind: Role | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: use-integration-tests-scc | ||
rules: | ||
- apiGroups: ["security.openshift.io"] | ||
resources: ["securitycontextconstraints"] | ||
resourceNames: ["privileged"] | ||
verbs: ["use"] | ||
--- | ||
kind: RoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: use-integration-tests-scc | ||
subjects: | ||
- kind: ServiceAccount | ||
name: tls-sa | ||
roleRef: | ||
kind: Role | ||
name: use-integration-tests-scc | ||
apiGroup: rbac.authorization.k8s.io | ||
{% endif %} |
This file contains hidden or 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 hidden or 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 hidden or 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,67 @@ | ||
#!/usr/bin/env python | ||
import requests | ||
import time | ||
import argparse | ||
|
||
if __name__ == "__main__": | ||
# Construct an argument parser | ||
all_args = argparse.ArgumentParser() | ||
|
||
# Add arguments to the parser | ||
all_args.add_argument( | ||
"-m", | ||
"--metric", | ||
required=False, | ||
default="nifi_amount_bytes_read", | ||
help="The name of a certain metric to check", | ||
) | ||
all_args.add_argument( | ||
"-n", "--namespace", required=True, help="The namespace the test is running in" | ||
) | ||
all_args.add_argument( | ||
"-p", | ||
"--port", | ||
required=False, | ||
default="8443", | ||
help="The port where metrics are exposed", | ||
) | ||
all_args.add_argument( | ||
"-t", | ||
"--timeout", | ||
required=False, | ||
default="120", | ||
help="The timeout in seconds to wait for the metrics port to be opened", | ||
) | ||
|
||
args = vars(all_args.parse_args()) | ||
metric_name = args["metric"] | ||
namespace = args["namespace"] | ||
port = args["port"] | ||
timeout = int(args["timeout"]) | ||
|
||
url = f"https://nifi-node-default-metrics.{args['namespace']}.svc.cluster.local:{port}/nifi-api/flow/metrics/prometheus" | ||
|
||
# wait for 'timeout' seconds | ||
t_end = time.time() + timeout | ||
while time.time() < t_end: | ||
try: | ||
response = requests.get( | ||
url, | ||
cert=("/stackable/tls/tls.crt", "/stackable/tls/tls.key"), | ||
verify="/stackable/tls/ca.crt", | ||
) | ||
response.raise_for_status() | ||
if metric_name in response.text: | ||
print("Test metrics succeeded!") | ||
exit(0) | ||
else: | ||
print( | ||
f"Could not find metric [{metric_name}] in response:\n {response.text}" | ||
) | ||
time.sleep(timeout) | ||
except ConnectionError: | ||
# NewConnectionError is expected until metrics are available | ||
time.sleep(10) | ||
|
||
print("Test failed") | ||
exit(-1) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.