Skip to content

Commit

Permalink
Update integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jlandowner committed Apr 9, 2024
1 parent d8c6926 commit 119f07c
Show file tree
Hide file tree
Showing 12 changed files with 487 additions and 13 deletions.
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,22 @@ test:
HELM_PLUGIN_PATH := $(shell helm env | grep HELM_PLUGINS | cut -d= -f2)

.PHONY: integ-test
integ-test: debug-plugin
-helm chartsnap --chart example/app1 $(ARGS)
-helm chartsnap --chart example/app1 -f example/app1/test/test_ingress_enabled.yaml $(ARGS)
-helm chartsnap --chart example/app1 -f example/app1/test/ $(ARGS)
integ-test: install-dev-bin
helm chartsnap --chart example/app1 -f example/app1/test/test_ingress_enabled.yaml --namespace default $(ARGS)
helm chartsnap --chart example/app1 -f example/app1/test/ --namespace default $(ARGS)

.PHONY: integ-test-fail
integ-test-fail: install-dev-bin
-helm chartsnap --chart example/app1 --namespace default $(ARGS)
-helm chartsnap --chart example/app1 --namespace default -f example/app1/testfail/test_ingress_enabled.yaml $(ARGS)
-helm chartsnap --chart example/app1 --namespace default -f example/app1/testfail/ $(ARGS)

.PHONY: update-versions
update-versions:
sed -i.bk 's/version: .*/version: $(VERSION)/' plugin.yaml

.PHONY: debug-plugin
debug-plugin: build
.PHONY: install-dev-bin
install-dev-bin: build
-helm plugin install https://github.com/jlandowner/helm-chartsnap
cp ./dist/chartsnap_*/chartsnap $(HELM_PLUGIN_PATH)/helm-chartsnap/bin/
helm chartsnap --version
Expand Down
6 changes: 3 additions & 3 deletions example/app1/test/__snapshots__/test_certmanager_enabled.snap
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ SnapShot = """
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
name: app1-cert
namespace: code-server
namespace: default
spec:
dnsNames:
- chartsnap-app1.code-server.svc
- chartsnap-app1.code-server.svc.cluster.local
- chartsnap-app1.default.svc
- chartsnap-app1.default.svc.cluster.local
issuerRef:
kind: Issuer
name: nameOfClusterIssuer
Expand Down
2 changes: 1 addition & 1 deletion example/app1/test/__snapshots__/test_hpa_enabled.snap
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ SnapShot = """
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
name: app1-cert
namespace: code-server
namespace: default
type: kubernetes.io/tls
- object:
apiVersion: v1
Expand Down
6 changes: 3 additions & 3 deletions example/app1/test/__snapshots__/test_ingress_enabled.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SnapShot = """
helm.sh/chart: app1-0.1.0
spec:
containers:
- image: nginx:1.15.0
- image: nginx:1.16.0
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
Expand Down Expand Up @@ -71,7 +71,7 @@ SnapShot = """
port:
number: 80
path: /
pathType: Prefix
pathType: ImplementationSpecific
tls:
- hosts:
- chart-example.local
Expand Down Expand Up @@ -113,7 +113,7 @@ SnapShot = """
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
name: app1-cert
namespace: code-server
namespace: default
type: kubernetes.io/tls
- object:
apiVersion: v1
Expand Down
10 changes: 10 additions & 0 deletions example/app1/test/test_ingress_enabled.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
testSpec:
dynamicFields:
- apiVersion: v1
kind: Secret
name: app1-cert
jsonPath:
- /data/ca.crt
- /data/tls.crt
- /data/tls.key

ingress:
enabled: true
className: "nginx"
Expand Down
9 changes: 9 additions & 0 deletions example/app1/testfail/.chartsnap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file define common behavior of the chart snapshots in the test directory.
dynamicFields:
- apiVersion: v1
kind: Secret
name: app1-cert
jsonPath:
- /data/ca.crt
- /data/tls.crt
- /data/tls.key
124 changes: 124 additions & 0 deletions example/app1/testfail/__snapshots__/test_certmanager_enabled.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
[test_certmanager_enabled]
SnapShot = """
- object:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: app1
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
name: chartsnap-app1
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/name: app1
template:
metadata:
labels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: app1
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
spec:
containers:
- image: nginx:1.16.0
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /
port: http
name: app1
ports:
- containerPort: 80
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /
port: http
resources: {}
securityContext: {}
securityContext: {}
serviceAccountName: chartsnap-app1
- object:
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
labels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: app1
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
name: app1-cert
namespace: code-server
spec:
dnsNames:
- chartsnap-app1.code-server.svc
- chartsnap-app1.code-server.svc.cluster.local
issuerRef:
kind: Issuer
name: nameOfClusterIssuer
secretName: app1-cert
- object:
apiVersion: v1
kind: Pod
metadata:
annotations:
helm.sh/hook: test
labels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: app1
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
name: chartsnap-app1-test-connection
spec:
containers:
- args:
- chartsnap-app1:80
command:
- wget
image: busybox
name: wget
restartPolicy: Never
- object:
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: app1
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
name: chartsnap-app1
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: http
selector:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/name: app1
type: ClusterIP
- object:
apiVersion: v1
automountServiceAccountToken: true
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: app1
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
name: chartsnap-app1
"""
145 changes: 145 additions & 0 deletions example/app1/testfail/__snapshots__/test_hpa_enabled.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
[test_hpa_enabled]
SnapShot = """
- object:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: app1
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
name: chartsnap-app1
spec:
selector:
matchLabels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/name: app1
template:
metadata:
labels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: app1
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
spec:
containers:
- image: nginx:1.16.0
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
path: /
port: http
name: app1
ports:
- containerPort: 80
name: http
protocol: TCP
readinessProbe:
httpGet:
path: /
port: http
resources: {}
securityContext: {}
securityContext: {}
serviceAccountName: chartsnap-app1
- object:
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
labels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: app1
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
name: chartsnap-app1
spec:
maxReplicas: 10
metrics:
- resource:
name: cpu
target:
averageUtilization: 65
type: Utilization
type: Resource
minReplicas: 1
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: chartsnap-app1
- object:
apiVersion: v1
kind: Pod
metadata:
annotations:
helm.sh/hook: test
labels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: app1
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
name: chartsnap-app1-test-connection
spec:
containers:
- args:
- chartsnap-app1:80
command:
- wget
image: busybox
name: wget
restartPolicy: Never
- object:
apiVersion: v1
data:
ca.crt: '###DYNAMIC_FIELD###'
tls.crt: '###DYNAMIC_FIELD###'
tls.key: '###DYNAMIC_FIELD###'
kind: Secret
metadata:
labels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: app1
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
name: app1-cert
namespace: code-server
type: kubernetes.io/tls
- object:
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: app1
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
name: chartsnap-app1
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: http
selector:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/name: app1
type: ClusterIP
- object:
apiVersion: v1
automountServiceAccountToken: true
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/instance: chartsnap
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: app1
app.kubernetes.io/version: 1.16.0
helm.sh/chart: app1-0.1.0
name: chartsnap-app1
"""
Loading

0 comments on commit 119f07c

Please sign in to comment.