diff --git a/.yamllint b/.yamllint index ef4a1972ed..ddb236d18e 100644 --- a/.yamllint +++ b/.yamllint @@ -37,7 +37,7 @@ rules: key-duplicates: enable key-ordering: disable line-length: - max: 150 + max: 155 new-line-at-end-of-file: enable new-lines: enable octal-values: enable diff --git a/Makefile b/Makefile index 54c9e1247b..c6b08e8fd1 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ $(HELMIFY): $(LOCALBIN) test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/keptn/helmify/cmd/helmify@b1da2bb756ec4328bac7645da037a6fb4e6f30cf .PHONY: integration-test #these tests should run on a real cluster! -integration-test: +integration-test: # to run a single test by name use --test eg. --test=expose-keptn-metric kubectl kuttl test --start-kind=false ./test/integration/ --config=kuttl-test.yaml .PHONY: integration-test-local #these tests should run on a real cluster! diff --git a/test/integration/expose-keptn-metric/00-assert.yaml b/test/integration/expose-keptn-metric/00-assert.yaml deleted file mode 100644 index b614812c6c..0000000000 --- a/test/integration/expose-keptn-metric/00-assert.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: test -status: - conditions: - - type: Complete - status: 'True' - succeeded: 1 diff --git a/test/integration/expose-keptn-metric/00-teststep.yaml b/test/integration/expose-keptn-metric/00-teststep.yaml new file mode 100644 index 0000000000..5cccc5605b --- /dev/null +++ b/test/integration/expose-keptn-metric/00-teststep.yaml @@ -0,0 +1,11 @@ +apiVersion: kuttl.dev/v1 +kind: TestStep +commands: # generating job and metric based on namespace to avoid interference between runs + - script: | + export NAME=$( echo $NAMESPACE | tr -d -) + echo "installing first job" + envsubst < job-no-metric.yaml | kubectl apply -f - + - script: | + export NAME=$( echo $NAMESPACE | tr -d -) + echo "asserting first job" + kubectl wait --for=condition=complete job $NAME-job1 -n $NAMESPACE diff --git a/test/integration/expose-keptn-metric/01-assert.yaml b/test/integration/expose-keptn-metric/01-assert.yaml deleted file mode 100644 index 5e9ba728cd..0000000000 --- a/test/integration/expose-keptn-metric/01-assert.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: test2 -status: - conditions: - - type: Complete - status: 'True' - succeeded: 1 diff --git a/test/integration/expose-keptn-metric/01-teststep.yaml b/test/integration/expose-keptn-metric/01-teststep.yaml new file mode 100644 index 0000000000..7e115c93ec --- /dev/null +++ b/test/integration/expose-keptn-metric/01-teststep.yaml @@ -0,0 +1,12 @@ +apiVersion: kuttl.dev/v1 +kind: TestStep +commands: + - script: | # generating job and metric based on namespace to avoid interference between runs + export NAME=$( echo $NAMESPACE | tr -d -) + echo "installing second job" + envsubst < job-existing-metric.yaml | kubectl apply -f - + + - script: | # generating job assertion file + export NAME=$( echo $NAMESPACE | tr -d -) + echo "asserting second job" + kubectl wait --for=condition=complete job $NAME-job2 -n $NAMESPACE diff --git a/test/integration/expose-keptn-metric/02-teststep.yaml b/test/integration/expose-keptn-metric/02-teststep.yaml deleted file mode 100644 index 7db3009193..0000000000 --- a/test/integration/expose-keptn-metric/02-teststep.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: kuttl.dev/v1 -kind: TestStep -commands: - - script: kubectl delete keptnmetric.metrics.keptn.sh/keptnmetric-sample -n keptn-lifecycle-toolkit-system diff --git a/test/integration/expose-keptn-metric/01-install.yaml b/test/integration/expose-keptn-metric/job-existing-metric.yaml similarity index 74% rename from test/integration/expose-keptn-metric/01-install.yaml rename to test/integration/expose-keptn-metric/job-existing-metric.yaml index a0a6695eb5..fadc409bb9 100644 --- a/test/integration/expose-keptn-metric/01-install.yaml +++ b/test/integration/expose-keptn-metric/job-existing-metric.yaml @@ -1,8 +1,8 @@ apiVersion: metrics.keptn.sh/v1alpha2 kind: KeptnMetric metadata: - name: keptnmetric-sample - namespace: keptn-lifecycle-toolkit-system + name: $NAME + namespace: $NAMESPACE spec: provider: name: "provider" @@ -12,7 +12,8 @@ spec: apiVersion: batch/v1 kind: Job metadata: - name: test2 + name: $NAME-job2 + namespace: $NAMESPACE spec: backoffLimit: 5 template: @@ -25,7 +26,8 @@ spec: - -ec - | curl -s metrics-operator-service.keptn-lifecycle-toolkit-system.svc.cluster.local:9999/metrics > ~/out.txt - if grep -Fxq "# HELP keptnmetric_sample keptnmetric-sample" ~/out.txt + echo ~/out.txt + if grep -Fxq "# HELP $NAME $NAME" ~/out.txt then exit 0 fi @@ -37,8 +39,9 @@ spec: - /bin/sh - -ec - | - curl -s metrics-operator-service.keptn-lifecycle-toolkit-system.svc.cluster.local:9999/api/v1/metrics/keptn-lifecycle-toolkit-system/keptnmetric-sample > ~/out.txt - if grep -F "keptnmetric-sample" ~/out.txt + curl -s metrics-operator-service.keptn-lifecycle-toolkit-system.svc.cluster.local:9999/api/v1/metrics/$NAMESPACE/$NAME > ~/out.txt + echo ~/out.txt + if grep -F "$NAME" ~/out.txt then exit 0 fi diff --git a/test/integration/expose-keptn-metric/00-install.yaml b/test/integration/expose-keptn-metric/job-no-metric.yaml similarity index 75% rename from test/integration/expose-keptn-metric/00-install.yaml rename to test/integration/expose-keptn-metric/job-no-metric.yaml index 58cbd947d8..4dd12ce3fd 100644 --- a/test/integration/expose-keptn-metric/00-install.yaml +++ b/test/integration/expose-keptn-metric/job-no-metric.yaml @@ -1,7 +1,8 @@ apiVersion: batch/v1 kind: Job metadata: - name: test + name: $NAME-job1 + namespace: $NAMESPACE spec: backoffLimit: 0 template: @@ -14,7 +15,7 @@ spec: - -ec - | curl -s metrics-operator-service.keptn-lifecycle-toolkit-system.svc.cluster.local:9999/metrics > ~/out.txt - if grep -Fxq "# HELP keptnmetric_sample keptnmetric-sample" ~/out.txt + if grep -Fxq "# HELP $NAME $NAME" ~/out.txt then exit 1 fi @@ -24,8 +25,8 @@ spec: - /bin/sh - -ec - | - curl -s metrics-operator-service.keptn-lifecycle-toolkit-system.svc.cluster.local:9999/api/v1/metrics//keptnmetric-sample > ~/out.txt - if grep -F "keptnmetric-sample" ~/out.txt + curl -s metrics-operator-service.keptn-lifecycle-toolkit-system.svc.cluster.local:9999/api/v1/metrics/$NAMESPACE/$NAME > ~/out.txt + if grep -F "$NAME" ~/out.txt then exit 1 fi