-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: realanna <[email protected]>
- Loading branch information
Showing
4 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
test/integration/analysis-controller-existing-status/00-teststep-template.yaml
This file contains 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,9 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
envsubst < mock-server.yaml | kubectl apply -f - | ||
# substitutes current time and namespace, making sure they are changed to env var first | ||
# to prevent bad files in case of a test interrupt | ||
- script: | | ||
envsubst < install.yaml | kubectl apply -f - |
11 changes: 11 additions & 0 deletions
11
test/integration/analysis-controller-existing-status/01-assert.yaml
This file contains 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,11 @@ | ||
apiVersion: metrics.keptn.sh/v1alpha3 | ||
kind: Analysis | ||
metadata: | ||
name: analysis-sample | ||
spec: | ||
analysisDefinition: | ||
name: ed-my-proj-dev-svc1 | ||
status: | ||
pass: true | ||
# yamllint disable-line rule:line-length | ||
raw: '{"objectiveResults":[{"result":{"failResult":{"operator":{"lessThan":{"fixedValue":"2"}},"fulfilled":false},"warnResult":{"operator":{"lessThan":{"fixedValue":"3"}},"fulfilled":false},"warning":false,"pass":true},"value":4,"score":1}],"totalScore":1,"maximumScore":1,"pass":true,"warning":false}' |
64 changes: 64 additions & 0 deletions
64
test/integration/analysis-controller-existing-status/install.yaml
This file contains 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,64 @@ | ||
apiVersion: metrics.keptn.sh/v1alpha3 | ||
kind: AnalysisValueTemplate | ||
metadata: | ||
name: ready | ||
namespace: $NAMESPACE | ||
spec: | ||
provider: | ||
name: my-mocked-provider | ||
namespace: $NAMESPACE | ||
query: 'sum(kube_pod_container_status_ready{namespace="{{.ns}}"})' | ||
--- | ||
apiVersion: metrics.keptn.sh/v1alpha3 | ||
kind: AnalysisDefinition | ||
metadata: | ||
name: ed-my-proj-dev-svc1 | ||
namespace: $NAMESPACE | ||
spec: | ||
objectives: | ||
- analysisValueTemplateRef: | ||
name: ready | ||
namespace: $NAMESPACE | ||
target: | ||
failure: | ||
lessThan: | ||
fixedValue: 2 | ||
warning: | ||
lessThan: | ||
fixedValue: 3 | ||
weight: 1 | ||
keyObjective: false | ||
totalScore: | ||
passPercentage: 90 | ||
warningPercentage: 75 | ||
--- | ||
apiVersion: metrics.keptn.sh/v1alpha3 | ||
kind: Analysis | ||
metadata: | ||
name: analysis-sample | ||
namespace: $NAMESPACE | ||
spec: | ||
timeframe: | ||
from: 2023-09-14T07:33:19Z | ||
to: 2023-09-14T07:33:19Z | ||
args: | ||
"ns": "keptn-lifecycle-toolkit-system" | ||
analysisDefinition: | ||
name: ed-my-proj-dev-svc1 | ||
namespace: $NAMESPACE | ||
status: | ||
gibberish: | ||
- value: 1 | ||
objective: | ||
name: notready | ||
namespace: $NAMESPACE | ||
|
||
--- | ||
apiVersion: metrics.keptn.sh/v1alpha3 | ||
kind: KeptnMetricsProvider | ||
metadata: | ||
name: my-mocked-provider | ||
namespace: $NAMESPACE | ||
spec: | ||
type: prometheus | ||
targetServer: "http://mockserver.$NAMESPACE.svc.cluster.local:1080" |
143 changes: 143 additions & 0 deletions
143
test/integration/analysis-controller-existing-status/mock-server.yaml
This file contains 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,143 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: mockserver | ||
namespace: $NAMESPACE | ||
spec: | ||
ports: | ||
- name: serviceport | ||
port: 1080 | ||
protocol: TCP | ||
targetPort: serviceport | ||
selector: | ||
app: mockserver | ||
sessionAffinity: None | ||
type: ClusterIP | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: mockserver | ||
name: mockserver | ||
namespace: $NAMESPACE | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: mockserver | ||
template: | ||
metadata: | ||
labels: | ||
app: mockserver | ||
name: mockserver | ||
spec: | ||
containers: | ||
- env: | ||
- name: MOCKSERVER_LOG_LEVEL | ||
value: INFO | ||
- name: SERVER_PORT | ||
value: "1080" | ||
image: mockserver/mockserver:mockserver-5.13.0 | ||
imagePullPolicy: IfNotPresent | ||
livenessProbe: | ||
failureThreshold: 10 | ||
initialDelaySeconds: 10 | ||
periodSeconds: 5 | ||
successThreshold: 1 | ||
tcpSocket: | ||
port: serviceport | ||
timeoutSeconds: 1 | ||
name: mockserver | ||
ports: | ||
- containerPort: 1080 | ||
name: serviceport | ||
protocol: TCP | ||
readinessProbe: | ||
failureThreshold: 10 | ||
initialDelaySeconds: 2 | ||
periodSeconds: 2 | ||
successThreshold: 1 | ||
tcpSocket: | ||
port: serviceport | ||
timeoutSeconds: 1 | ||
volumeMounts: | ||
- mountPath: /config | ||
name: config-volume | ||
- mountPath: /libs | ||
name: libs-volume | ||
terminationGracePeriodSeconds: 30 | ||
volumes: | ||
- configMap: | ||
defaultMode: 420 | ||
name: mockserver-config | ||
optional: true | ||
name: config-volume | ||
- configMap: | ||
defaultMode: 420 | ||
name: mockserver-config | ||
optional: true | ||
name: libs-volume | ||
--- | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: mockserver-config | ||
namespace: $NAMESPACE | ||
data: | ||
initializerJson.json: |- | ||
[ | ||
{ | ||
"httpRequest": { | ||
"path": "/api/v1/query_range", | ||
"method": "POST" | ||
}, | ||
"httpResponse": { | ||
"body": { | ||
"status": "success", | ||
"data": { | ||
"resultType": "matrix", | ||
"result": [ | ||
{ | ||
"metric": { | ||
"__name__": "metric-name", | ||
"job": "", | ||
"instance": "" | ||
}, | ||
"values": [[1669714193.275, "4"]] | ||
} | ||
] | ||
} | ||
}, | ||
"statusCode": 200 | ||
} | ||
} | ||
] | ||
mockserver.properties: |- | ||
############################### | ||
# MockServer & Proxy Settings # | ||
############################### | ||
# Socket & Port Settings | ||
# socket timeout in milliseconds (default 120000) | ||
mockserver.maxSocketTimeout=120000 | ||
# Certificate Generation | ||
# dynamically generated CA key pair (if they don't already exist in | ||
specified directory) | ||
mockserver.dynamicallyCreateCertificateAuthorityCertificate=true | ||
# save dynamically generated CA key pair in working directory | ||
mockserver.directoryToSaveDynamicSSLCertificate=. | ||
# certificate domain name (default "localhost") | ||
mockserver.sslCertificateDomainName=localhost | ||
# comma separated list of ip addresses for Subject Alternative Name domain | ||
names (default empty list) | ||
mockserver.sslSubjectAlternativeNameDomains=www.example.com,www.another.com | ||
# comma separated list of ip addresses for Subject Alternative Name ips | ||
(default empty list) | ||
mockserver.sslSubjectAlternativeNameIps=127.0.0.1 | ||
# CORS | ||
# enable CORS for MockServer REST API | ||
mockserver.enableCORSForAPI=true | ||
# enable CORS for all responses | ||
mockserver.enableCORSForAllResponses=true | ||
# Json Initialization | ||
mockserver.initializationJsonPath=/config/initializerJson.json |