Skip to content

Commit

Permalink
chore: use binding in kptn metric test
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
eddycharly committed Mar 4, 2024
1 parent 1804716 commit 3225b76
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:

- name: Install Chainsaw
uses: kyverno/[email protected]
with:
release: v0.1.8-alpha.1

- name: Run Scheduling Gates Integration Tests
if: inputs.scheduling-gates == 'gates_on' && inputs.allowed-namespaces == 'allowed_ns_off'
Expand Down
23 changes: 9 additions & 14 deletions test/chainsaw/integration/expose-keptn-metric/chainsaw-test.yaml
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
15 changes: 13 additions & 2 deletions test/chainsaw/integration/expose-keptn-metric/job-no-metric.yaml
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

0 comments on commit 3225b76

Please sign in to comment.