Skip to content

Commit

Permalink
cover all in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nadavbuc committed Apr 15, 2024
1 parent d2d48f0 commit 491d490
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 8 deletions.
2 changes: 1 addition & 1 deletion charts/karpenter_nodes/templates/nodepool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
spec:
nodeClassRef:
{{- if hasKey $v "nodeClassRef" }}
{{ $v.nodeClassRef | toYaml | nindent 8 }}
{{- $v.nodeClassRef | toYaml | nindent 8 }}
{{- else }}
name: {{ $k }}-{{ $v.instances.architecture | default $.Values.instances.architecture }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
suite: test nodepool - nodes-default
templates:
- nodepool.yaml

values:
- values.yaml

Expand Down
88 changes: 88 additions & 0 deletions charts/karpenter_nodes/tests/nodepool_nodes_noclass_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
suite: test nodepool - nodes-noclass
templates:
- nodepool.yaml
values:
- values.yaml

tests:
- it: Verify nodes-noclass metadata
documentIndex: 1
asserts:
- isKind:
of: NodePool
- equal:
path: metadata.name
value: nodes-noclass-amd64
- equal:
path: spec.template.metadata.labels.cluster
value: eks-dev
- equal:
path: spec.template.metadata.labels.nodegroup
value: nodes-noclass
- equal:
path: spec.template.spec.nodeClassRef.name
value: default

- it: Verify nodes-noclass requirements
documentIndex: 1
asserts:
- equal:
path: spec.template.spec.requirements[0].key
value: "karpenter.k8s.aws/instance-category"
- notContains:
path: spec.template.spec.requirements[0].values
content: t
- equal:
path: spec.template.spec.requirements[0].values[0]
value: m
- equal:
path: spec.template.spec.requirements[0].values[2]
value: c
- equal:
path: spec.template.spec.requirements[1].key
value: "karpenter.k8s.aws/instance-cpu"
- equal:
path: spec.template.spec.requirements[1].values[0]
value: "4"
- equal:
path: spec.template.spec.requirements[1].values[2]
value: "16"
- equal:
path: spec.template.spec.requirements[2].key
value: "karpenter.k8s.aws/instance-generation"
- equal:
path: spec.template.spec.requirements[2].operator
value: "Gt"
- equal:
path: spec.template.spec.requirements[2].values[0]
value: "4"
- equal:
path: spec.template.spec.requirements[3].key
value: "topology.kubernetes.io/zone"
- equal:
path: spec.template.spec.requirements[3].values[0]
value: "eu-west-1a"
- equal:
path: spec.template.spec.requirements[3].values[2]
value: "eu-west-1c"
- equal:
path: spec.template.spec.requirements[4].key
value: "kubernetes.io/arch"
- equal:
path: spec.template.spec.requirements[4].values[0]
value: "amd64"
- equal:
path: spec.template.spec.requirements[5].key
value: "karpenter.sh/capacity-type"
- equal:
path: spec.template.spec.requirements[5].values[0]
value: "spot"
- equal:
path: spec.template.spec.requirements[5].values[1]
value: "on-demand"
- equal:
path: spec.template.spec.requirements[6].key
value: "kubernetes.io/os"
- equal:
path: spec.template.spec.requirements[6].values[0]
value: "linux"
9 changes: 4 additions & 5 deletions charts/karpenter_nodes/tests/nodepool_nodes_workers_test.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
suite: test nodepool - nodes-workers
templates:
- nodepool.yaml

values:
- values.yaml

tests:
- it: Verify nodes-workers metadata
documentIndex: 1
documentIndex: 2
asserts:
- isKind:
of: NodePool
Expand Down Expand Up @@ -51,7 +50,7 @@ tests:
value: noSchedule

- it: Verify nodes-workers requirements
documentIndex: 1
documentIndex: 2
asserts:
- equal:
path: spec.template.spec.requirements[0].key
Expand Down Expand Up @@ -153,7 +152,7 @@ tests:


- it: Verify nodes-workers kubelet
documentIndex: 1
documentIndex: 2
asserts:
- equal:
path: spec.template.spec.kubelet.systemReserved.cpu
Expand All @@ -169,7 +168,7 @@ tests:
value: "2.2.2.2"

- it: Verify nodes-workers Options
documentIndex: 1
documentIndex: 2
asserts:
- equal:
path: spec.disruption.expireAfter
Expand Down
6 changes: 5 additions & 1 deletion charts/karpenter_nodes/tests/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ nodeGroups:
excludeFamilies:
- c6a

nodes-noclass:
instances: {}
nodeClassRef:
name: default

nodes-workers:
additionalNodeTags:
testtag1: tag1
Expand Down Expand Up @@ -76,7 +81,6 @@ nodeGroups:
environment: test
- name: my-ami
- id: ami-123

instances:
architecture: "arm64"
minGeneration: 5
Expand Down

0 comments on commit 491d490

Please sign in to comment.