Files
library-charts/library/common-test/tests/pod/host_users_test.yaml
Stavros Kois 695f3d7e5c fix(nodeSelector, hostUsers): make sure booleans are quoted, respect user defined value over automatic calculation (#827)
**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  #823 
⚒️ Partially #826 

**⚙️ Type of change**

- [ ] ⚙️ Feature/App addition
- [x] 🪛 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
- [x] #️⃣ 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
- [ ] I made sure the title starts with `feat(chart-name):`,
`fix(chart-name):` or `chore(chart-name):`

** App addition**

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

- [ ] 🖼️ 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._
2024-06-07 00:46:25 +02:00

398 lines
10 KiB
YAML

suite: pod hostUsers test
templates:
- common.yaml
release:
name: test-release-name
namespace: test-release-namespace
tests:
- it: should pass with hostUsers enabled from "global"
set:
podOptions:
hostUsers: true
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec: {}
asserts:
- documentIndex: &deploymentDoc 0
isKind:
of: Deployment
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with hostUsers enabled from podSpec
set:
podOptions:
hostUsers: false
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
hostUsers: true
asserts:
- documentIndex: *deploymentDoc
isKind:
of: Deployment
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with enabled hostUsers because of pvc
set:
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec: {}
persistence:
vol1:
enabled: true
type: pvc
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with enabled hostUsers because of hostNet
set:
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
hostNetwork: true
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with enabled hostUsers because of hostPID
set:
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
hostPID: true
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with enabled hostUsers because of hostIPC
set:
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
hostIPC: true
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
# Tests that eq <template> "true" works // bool to string etc.
- it: should pass with disabled hostUsers with host* disabled explicitly
set:
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
hostIPC: false
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: false
- it: should pass with enabled hostUsers because of sysctls
set:
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
securityContext:
sysctls:
- name: some-sysctl
value: some-value
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with enabled hostUsers because of nvidia gpu
set:
resources:
limits:
nvidia.com/gpu: 1
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec: {}
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with enabled hostUsers because of amd gpu
set:
resources:
limits:
amd.com/gpu: 1
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec: {}
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with enabled hostUsers because of intel gpu
set:
resources:
limits:
gpu.intel.com/i915: 1
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec: {}
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with enabled hostUsers because rofs is disabled
set:
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
containers:
container1:
enabled: true
primary: true
probes: &probes
liveness:
enabled: false
readiness:
enabled: false
startup:
enabled: false
securityContext:
readOnlyRootFilesystem: false
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with enabled hostUsers because runAsNonRoot is disabled
set:
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
containers:
container1:
enabled: true
primary: true
probes: *probes
securityContext:
runAsNonRoot: false
# Common will reset to true if runAsUser is not 0
runAsUser: 0
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with enabled hostUsers because privileged is enabled
set:
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
containers:
container1:
enabled: true
primary: true
probes: *probes
securityContext:
privileged: true
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with enabled hostUsers because allowPrivilegeEscalation is enabled
set:
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
containers:
container1:
enabled: true
primary: true
probes: *probes
securityContext:
allowPrivilegeEscalation: true
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with enabled hostUsers because runAsUser is 0
set:
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
containers:
container1:
enabled: true
primary: true
probes: *probes
securityContext:
runAsUser: 0
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with enabled hostUsers because runAsGroup is 0
set:
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
containers:
container1:
enabled: true
primary: true
probes: *probes
securityContext:
runAsGroup: 0
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true
- it: should pass with hostUsers explicitly set on top-level regardless if runAsGroup is 0
set:
podOptions:
hostUsers: false
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
containers:
container1:
enabled: true
primary: true
probes: *probes
securityContext:
runAsGroup: 0
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: false
- it: should pass with hostUsers explicitly set on pod-level regardless if runAsGroup is 0
set:
podOptions:
hostUsers: true
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
hostUsers: false
containers:
container1:
enabled: true
primary: true
probes: *probes
securityContext:
runAsGroup: 0
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: false
- it: should pass with enabled hostUsers because capabilities.add is not empty
set:
workload:
workload-name1:
enabled: true
primary: true
type: Deployment
podSpec:
containers:
container1:
enabled: true
primary: true
probes: *probes
securityContext:
capabilities:
add:
- SYS_ADMIN
asserts:
- documentIndex: *deploymentDoc
equal:
path: spec.template.spec.hostUsers
value: true