Files
library-charts/library/common-test/tests/externalInterface/validation_test.yaml
Stavros Kois 2fe00ebdd1 replace <> with [] in fail messages (#586)
**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  #584 

**⚙️ Type of change**

- [ ] ⚙️ 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:**

- [ ] ⚖️ My code follows the style guidelines of this project
- [ ] 👀 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
- [ ] ⚠️ My changes generate no new warnings
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [ ] ⬆️ 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-11-12 19:16:09 +01:00

173 lines
5.9 KiB
YAML

suite: external interface validation test
templates:
- common.yaml
release:
name: test-release-name
namespace: test-release-namespace
tests:
- it: should fail with targetSelector not a list
set:
scaleExternalInterface:
- targetSelector: "not a list"
asserts:
- failedTemplate:
errorMessage: External Interface - Expected [targetSelector] to be a [list], but got [string]
- it: should fail with empty hostInterface
set:
scaleExternalInterface:
- hostInterface: ""
asserts:
- failedTemplate:
errorMessage: External Interface - Expected non-empty [hostInterface]
- it: should fail with empty ipam
set:
scaleExternalInterface:
- hostInterface: enp0s3
ipam: {}
asserts:
- failedTemplate:
errorMessage: External Interface - Expected non-empty [ipam]
- it: should fail with empty ipam.type
set:
scaleExternalInterface:
- hostInterface: enp0s3
ipam:
type: ""
asserts:
- failedTemplate:
errorMessage: External Interface - Expected non-empty [ipam.type]
- it: should fail with invalid ipam.type
set:
scaleExternalInterface:
- hostInterface: enp0s3
ipam:
type: invalid
asserts:
- failedTemplate:
errorMessage: External Interface - Expected [ipam.type] to be one of [dhcp, static], but got [invalid]
- it: should fail with non-empty staticIPConfigurations on dhcp
set:
scaleExternalInterface:
- hostInterface: enp0s3
ipam:
type: dhcp
staticIPConfigurations:
- ipAddress: 1.2.3.4
asserts:
- failedTemplate:
errorMessage: External Interface - Expected empty [ipam.staticIPConfigurations] and [ipam.staticRoutes] when [ipam.type] is not [static]
- it: should fail with non-empty staticRoutes on dhcp
set:
scaleExternalInterface:
- hostInterface: enp0s3
ipam:
type: dhcp
staticRoutes:
- gateway: 1.2.3.4
destination: 1.2.3.4
asserts:
- failedTemplate:
errorMessage: External Interface - Expected empty [ipam.staticIPConfigurations] and [ipam.staticRoutes] when [ipam.type] is not [static]
- it: should fail with empty staticIPConfigurations on static
set:
scaleExternalInterface:
- hostInterface: enp0s3
ipam:
type: static
staticIPConfigurations: []
asserts:
- failedTemplate:
errorMessage: External Interface - Expected non-empty [ipam.staticIPConfigurations] when [ipam.type] is [static]
- it: should fail with empty gateway on staticRoutes on static
set:
scaleExternalInterface:
- hostInterface: enp0s3
ipam:
type: static
staticIPConfigurations:
- ipAddress: 1.2.3.4
staticRoutes:
- gateway: ""
destination: 1.2.3.4
asserts:
- failedTemplate:
errorMessage: External Interface - Expected non-empty [gateway] in [ipam.staticRoutes]
- it: should fail with empty destination on staticRoutes on static
set:
scaleExternalInterface:
- hostInterface: enp0s3
ipam:
type: static
staticIPConfigurations:
- ipAddress: 1.2.3.4
staticRoutes:
- gateway: 1.2.3.4
destination: ""
asserts:
- failedTemplate:
errorMessage: External Interface - Expected non-empty [destination] in [ipam.staticRoutes]
- it: should fail with empty ixExternalInterfaceConfigurationNames when interface is defined
set:
# Simulate middleware injection
ixExternalInterfacesConfiguration:
- '{"cniVersion": "0.3.1", "name": "ix-test-release-name-0", "type": "macvlan", "master": "ens3s0", "ipam": {"type": "dhcp"}}'
ixExternalInterfacesConfigurationNames: []
scaleExternalInterface:
- hostInterface: enp0s3
ipam:
type: dhcp
workload:
workload-name1:
enabled: true
primary: true
type: CronJob
schedule: "*/1 * * * *"
podSpec: {}
asserts:
- failedTemplate:
errorMessage: External Interface - Expected non empty [ixExternalInterfaceConfigurationNames]
- it: should fail with namespace longer than 63 characters
set:
# Simulate middleware injection
ixExternalInterfacesConfiguration:
- '{"cniVersion": "0.3.1", "name": "ix-test-release-name-0", "type": "macvlan", "master": "ens3s0", "ipam": {"type": "dhcp"}}'
ixExternalInterfacesConfigurationNames: []
scaleExternalInterface:
- hostInterface: enp0s3
ipam:
type: dhcp
global:
namespace: my-extra-super-duper-long-name-that-is-longer-than-63-characters
asserts:
- failedTemplate:
errorMessage: Network Attachment Definition - Namespace [my-extra-super-duper-long-name-that-is-longer-than-63-characters] is not valid. Must start and end with an alphanumeric lowercase character. It can contain '-'. And must be at most 63 characters.
- it: should fail with namespace not starting with [ix-] in TrueNAS SCALE
set:
global:
namespace: my-namespace
ixChartContext:
iAmNotEmpty: true
# Simulate middleware injection
ixExternalInterfacesConfiguration:
- '{"cniVersion": "0.3.1", "name": "ix-test-release-name-0", "type": "macvlan", "master": "ens3s0", "ipam": {"type": "dhcp"}}'
ixExternalInterfacesConfigurationNames: []
scaleExternalInterface:
- hostInterface: enp0s3
ipam:
type: dhcp
asserts:
- failedTemplate:
errorMessage: Network Attachment Definition - Namespace [my-namespace] expected to have [ix-] prefix when installed in TrueNAS SCALE