Skip to content
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

chore: use binding in keptn metric test #3172

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: ./.github/actions/deploy-prometheus-on-cluster

- name: Install Chainsaw
uses: kyverno/[email protected].7
uses: kyverno/[email protected].8

- name: Run Scheduling Gates Integration Tests
if: inputs.scheduling-gates == 'gates_on' && inputs.allowed-namespaces == 'allowed_ns_off'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ kind: Test
metadata:
name: expose-keptn-metric
spec:
bindings:
- name: service
value: (x_k8s_list($client, 'v1', 'Service', 'keptn-system') | items[?metadata.labels."control-plane" == 'metrics-operator'] | [0])
steps:
- name: step-00
try:
- script:
timeout: 5m
content: |
export NAME=$( echo $NAMESPACE | tr -d -)
export SVCNAME=$( kubectl get svc -n keptn-system -l control-plane=metrics-operator -ojsonpath="{ .items[0].metadata.name }" )
echo "installing first job pointing to ${SVCNAME}"
envsubst < job-no-metric.yaml | kubectl apply -f -
- apply:
template: true
file: job-no-metric.yaml
- wait:
timeout: 5m
resource: job
Expand All @@ -23,13 +22,9 @@ spec:
name: complete
- name: step-01
try:
- script:
timeout: 5m
content: |
export NAME=$( echo $NAMESPACE | tr -d -)
export SVCNAME=$( kubectl get svc -n keptn-system -l control-plane=metrics-operator -ojsonpath="{ .items[0].metadata.name }" )
echo "installing second job pointing to ${SVCNAME}"
envsubst < job-existing-metric.yaml | kubectl apply -f -
- apply:
template: true
file: job-existing-metric.yaml
- wait:
timeout: 5m
resource: job
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
apiVersion: metrics.keptn.sh/v1beta1
kind: KeptnMetric
metadata:
name: $NAME
namespace: $NAMESPACE
name: (replace_all($namespace, '-', ''))
spec:
provider:
name: "provider"
Expand All @@ -12,8 +11,7 @@ spec:
apiVersion: batch/v1
kind: Job
metadata:
name: $NAME-job2
namespace: $NAMESPACE
name: (join('-', [$namespace, 'job2']))
labels:
kind: existing-metric
spec:
Expand All @@ -23,6 +21,11 @@ spec:
containers:
- name: test-prometheus
image: curlimages/curl:8.6.0
env:
- name: NAME
value: (replace_all($namespace, '-', ''))
- name: SVCNAME
value: ($service.metadata.name)
args:
- /bin/sh
- -ec
Expand All @@ -36,6 +39,13 @@ spec:
exit 1
- name: test-api-endpoint
image: curlimages/curl:8.6.0
env:
- name: NAME
value: (replace_all($namespace, '-', ''))
- name: SVCNAME
value: ($service.metadata.name)
- name: NAMESPACE
value: ($namespace)
# yamllint disable rule:line-length
args:
- /bin/sh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
apiVersion: batch/v1
kind: Job
metadata:
name: $NAME-job1
namespace: $NAMESPACE
name: (join('-', [$namespace, 'job1']))
labels:
kind: no-metric
spec:
Expand All @@ -12,6 +11,11 @@ spec:
containers:
- name: test-prometheus
image: curlimages/curl:8.6.0
env:
- name: NAME
value: (replace_all($namespace, '-', ''))
- name: SVCNAME
value: ($service.metadata.name)
args:
- /bin/sh
- -ec
Expand All @@ -23,6 +27,13 @@ spec:
fi
- name: test-api-endpoint
image: curlimages/curl:8.6.0
env:
- name: NAME
value: (replace_all($namespace, '-', ''))
- name: SVCNAME
value: ($service.metadata.name)
- name: NAMESPACE
value: ($namespace)
args:
- /bin/sh
- -ec
Expand Down
Loading