Files
library-charts/library/common-test/tests/statefulset/metadata_test.yaml
Stavros Kois d8ae55f0d3 chore(labels): adds pod.lifecycle label to pod labels (#660)
**Description**
<!--
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.
-->
⚒️ Fixes  # <!--(issue)-->

**⚙️ Type of change**

- [x] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ Checklist:**

- [x] ⚖️ My code follows the style guidelines of this project
- [x] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [x] ⚠️ My changes generate no new warnings
- [x] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [x] ⬆️ I increased versions for any altered app according to semantic
versioning

** App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🪞 I have opened a PR on
[truecharts/containers](https://github.com/truecharts/containers) adding
the container to TrueCharts mirror repo.
- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._
2023-12-25 16:37:23 +01:00

242 lines
7.3 KiB
YAML

suite: statefulset metadata test
templates:
- common.yaml
chart:
appVersion: &appVer v9.9.9
release:
name: test-release-name
namespace: test-release-namespace
tests:
- it: should pass with statefulset created with labels and annotations
set:
label1: label1
label2: global_label2
annotation1: annotation1
annotation2: global_annotation2
global:
labels:
g_label1: global_label1
g_label2: "{{ .Values.label2 }}"
annotations:
g_annotation1: global_annotation1
g_annotation2: "{{ .Values.annotation2 }}"
workload:
workload-name:
enabled: true
primary: true
type: StatefulSet
labels:
label1: "{{ .Values.label1 }}"
label2: label2
annotations:
annotation1: "{{ .Values.annotation1 }}"
annotation2: annotation2
annotationsList:
- name: some-annotation
value: some-value
labelsList:
- name: some-label
value: some-value
podSpec:
labels:
pod-label1: pod-label1
pod-label2: "{{ .Values.label2 }}"
annotations:
pod-annotation1: pod-annotation1
pod-annotation2: "{{ .Values.annotation2 }}"
asserts:
- documentIndex: &statefulSetDoc 0
isKind:
of: StatefulSet
- documentIndex: *statefulSetDoc
equal:
path: metadata.annotations
value:
annotation1: annotation1
annotation2: annotation2
g_annotation1: global_annotation1
g_annotation2: global_annotation2
some-annotation: some-value
- documentIndex: *statefulSetDoc
equal:
path: metadata.labels
value:
app: common-test-1.0.0
release: test-release-name
helm-revision: "0"
helm.sh/chart: common-test-1.0.0
app.kubernetes.io/name: common-test
app.kubernetes.io/instance: test-release-name
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/version: *appVer
g_label1: global_label1
g_label2: global_label2
label1: label1
label2: label2
some-label: some-value
- documentIndex: *statefulSetDoc
equal:
path: spec.selector.matchLabels
value:
pod.name: workload-name
app.kubernetes.io/name: common-test
app.kubernetes.io/instance: test-release-name
- documentIndex: *statefulSetDoc
equal:
path: spec.template.metadata.labels
value:
pod.name: workload-name
pod.lifecycle: permanent
app: common-test-1.0.0
release: test-release-name
app.kubernetes.io/instance: test-release-name
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-test
app.kubernetes.io/version: v9.9.9
helm-revision: "0"
helm.sh/chart: common-test-1.0.0
g_label1: global_label1
g_label2: global_label2
pod-label1: pod-label1
pod-label2: global_label2
- documentIndex: *statefulSetDoc
matchRegex:
path: spec.template.metadata.annotations.rollme
pattern: '^[0-9a-zA-Z]{5}$'
- it: should pass with 2 daemonset created with correct selector labels
set:
workload:
workload-name:
enabled: true
primary: true
type: StatefulSet
podSpec: {}
other-workload-name:
enabled: true
primary: false
type: StatefulSet
podSpec: {}
asserts:
- documentIndex: *statefulSetDoc
isKind:
of: StatefulSet
- documentIndex: *statefulSetDoc
equal:
path: metadata.name
value: test-release-name-common-test-other-workload-name
- documentIndex: *statefulSetDoc
equal:
path: metadata.namespace
value: test-release-namespace
- documentIndex: *statefulSetDoc
equal:
path: spec.selector.matchLabels
value:
pod.name: other-workload-name
app.kubernetes.io/name: common-test
app.kubernetes.io/instance: test-release-name
- documentIndex: *statefulSetDoc
isSubset:
path: spec.template.metadata.labels
content:
pod.name: other-workload-name
pod.lifecycle: permanent
app.kubernetes.io/instance: test-release-name
app.kubernetes.io/name: common-test
- documentIndex: &otherStatefulSetDoc 1
isKind:
of: StatefulSet
- documentIndex: *otherStatefulSetDoc
equal:
path: metadata.name
value: test-release-name-common-test
- documentIndex: *otherStatefulSetDoc
equal:
path: metadata.namespace
value: test-release-namespace
- documentIndex: *otherStatefulSetDoc
equal:
path: spec.selector.matchLabels
value:
pod.name: workload-name
app.kubernetes.io/name: common-test
app.kubernetes.io/instance: test-release-name
- documentIndex: *otherStatefulSetDoc
isSubset:
path: spec.template.metadata.labels
content:
pod.name: workload-name
pod.lifecycle: permanent
app.kubernetes.io/instance: test-release-name
app.kubernetes.io/name: common-test
- it: should pass with statefulset created with object namespace from tpl
set:
key: some-namespace
workload:
workload-name:
enabled: true
primary: true
type: StatefulSet
namespace: "{{ .Values.key }}"
podSpec: {}
asserts:
- documentIndex: *statefulSetDoc
equal:
path: metadata.namespace
value: some-namespace
- it: should pass with deployment created with global namespace from tpl
set:
key: global-namespace
global:
namespace: "{{ .Values.key }}"
workload:
workload-name:
enabled: true
primary: true
type: StatefulSet
podSpec: {}
asserts:
- documentIndex: *statefulSetDoc
equal:
path: metadata.namespace
value: global-namespace
- it: should pass with deployment created with root namespace from tpl
set:
key: local-namespace
namespace: "{{ .Values.key }}"
global:
namespace: global-namespace
workload:
workload-name:
enabled: true
primary: true
type: StatefulSet
podSpec: {}
asserts:
- documentIndex: *statefulSetDoc
equal:
path: metadata.namespace
value: local-namespace
- it: should pass with deployment created with namespace in TrueNAS SCALE
set:
global:
ixChartContext:
iAmNotEmpty: true
namespace: ix-namespace
workload:
workload-name:
enabled: true
primary: true
type: StatefulSet
podSpec: {}
asserts:
- documentIndex: *statefulSetDoc
equal:
path: metadata.namespace
value: ix-namespace