Skip to content

Commit

Permalink
fix: add unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
soniqua committed Apr 12, 2024
1 parent 5b05e0e commit 205b825
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
renders extraPodSpecs CRA:
1: |
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
name: container-registry-agent-broker-RELEASE-NAME
namespace: NAMESPACE
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
template:
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
spec:
containers:
- env:
- name: BROKER_SERVER_URL
value: https://broker.test.snyk.io
- name: BROKER_HEALTHCHECK_PATH
value: /healthcheck
- name: BROKER_SYSTEMCHECK_PATH
value: /systemcheck
- name: BROKER_TOKEN
valueFrom:
secretKeyRef:
key: container-registry-agent-broker-token-key
name: container-registry-agent-broker-token-RELEASE-NAME
- name: CR_AGENT_URL
value: http://cra-service-RELEASE-NAME:8081
- name: CR_TYPE
value: ecr
- name: CR_ROLE_ARN
value: arn:aws-us-gov:iam::123456789012:role
- name: CR_REGION
value: eu-west
- name: CR_EXTERNAL_ID
value: 11111111-1111-1111-1111-111111111111
- name: PORT
value: "8000"
- name: BROKER_CLIENT_URL
value: http://container-registry-agent-broker-service-RELEASE-NAME:8000
- name: BROKER_CLIENT_VALIDATION_URL
value: http://cra-service-RELEASE-NAME:8081/healthcheck
- name: LOG_LEVEL
value: info
- name: LOG_ENABLE_BODY
value: "false"
- name: BROKER_DISPATCHER_BASE_URL
value: https://api.test.snyk.io
image: snyk/broker:container-registry-agent
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
httpGet:
path: /healthcheck
port: 8000
scheme: HTTP
initialDelaySeconds: 3
periodSeconds: 10
timeoutSeconds: 1
name: container-registry-agent-broker-RELEASE-NAME
ports:
- containerPort: 8000
name: http
readinessProbe:
failureThreshold: 3
httpGet:
path: /healthcheck
port: 8000
scheme: HTTP
initialDelaySeconds: 3
periodSeconds: 10
timeoutSeconds: 1
resources:
limits:
cpu: 1
memory: 256Mi
requests:
cpu: 1
memory: 256Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
volumeMounts: null
nodeSelector:
corp.io/node-classification: snyk
securityContext: {}
serviceAccountName: snyk-broker-RELEASE-NAME
tolerations:
- effect: NoSchedule
key: networking/something
operator: Equal
value: internal-pods
volumes: null
2: |
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: RELEASE-NAME-cr-RELEASE-NAME
name: container-registry-agent-cra-RELEASE-NAME
namespace: NAMESPACE
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: RELEASE-NAME-cr-RELEASE-NAME
template:
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: RELEASE-NAME-cr-RELEASE-NAME
spec:
containers:
- env:
- name: SNYK_PORT
value: "8081"
image: snyk/container-registry-agent:latest
imagePullPolicy: Always
name: container-registry-agent-RELEASE-NAME
ports:
- containerPort: 8081
name: http
resources:
limits:
cpu: 1
memory: 2Gi
requests:
cpu: 1
memory: 2Gi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: false
runAsNonRoot: true
runAsUser: 1000
nodeSelector:
corp.io/node-classification: snyk
securityContext: {}
serviceAccountName: snyk-broker-RELEASE-NAME
tolerations:
- effect: NoSchedule
key: networking/something
operator: Equal
value: internal-pods
3: |
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: snyk-broker-RELEASE-NAME
helm.sh/chart: snyk-broker-0.0.0
name: cra-service-RELEASE-NAME
namespace: NAMESPACE
spec:
ports:
- port: 8081
targetPort: 8081
selector:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: RELEASE-NAME-cr-RELEASE-NAME
type: ClusterIP
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
suite: test broker deployment with extraPodSpec
chart:
version: 0.0.0
templates:
- broker_deployment.yaml
- cra_deployment.yaml

tests:
- it: renders extraPodSpecs CRA
values:
- ./fixtures/default_values_cra.yaml
- ./fixtures/extra_pod_spec_values.yaml
asserts:
- matchSnapshot: {}
18 changes: 18 additions & 0 deletions charts/snyk-broker/tests/fixtures/extra_pod_spec_values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

extraPodSpecs:
tolerations:
- key: "networking/something"
operator: "Equal"
value: "internal-pods"
effect: "NoSchedule"
nodeSelector:
corp.io/node-classification: snyk

extraPodSpecsCr:
tolerations:
- key: "networking/something"
operator: "Equal"
value: "internal-pods"
effect: "NoSchedule"
nodeSelector:
corp.io/node-classification: snyk

0 comments on commit 205b825

Please sign in to comment.