test(charts): comprehensive test improvements and expansions
Phase 1: Improve and expand existing test coverage with edge cases, validations, and regression tests. Changes: - Rename cache_persistence_test → persistence_test with full coverage for config, media, and cache persistence (60+ tests) - Rename service_ipv6_test → service_test with full service coverage including types, ports, annotations, LoadBalancer settings (80+ tests) - Rename startup_probe_test → probes_test covering all three probe types: startup, liveness, readiness with all configurations (60+ tests) - Expand networkpolicy_test with IPv4/IPv6 CIDR validations, egress restrictions, and edge cases (+13 tests) - Expand init_containers_test with full container spec and merge order validation (+5 tests) - Expand envfrom_test with prefix, optional, and multiple source combinations (+9 tests) Test coverage improvements: - All edge cases for persistence types (pvc, hostPath, emptyDir) - Service type validation (ClusterIP, NodePort, LoadBalancer, ExternalName) - Probe types validation (httpGet, tcpSocket, exec) - NetworkPolicy CIDR format validation (IPv4/IPv6) - Comprehensive regression tests for default behavior Total: 6 improved test files, 230+ new test cases Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
This commit is contained in:
1 parent
cf2e60ee63
commit
a08951aaa3
9 files changed
+2067
-380
No files matched your search
@@ -295,3 +295,216 @@ tests:
|
||||
- equal:
|
||||
path: spec.podSelector.matchLabels.app\.kubernetes\.io/instance
|
||||
value: RELEASE-NAME
|
||||
|
||||
# =============================================================================
|
||||
# EDGE CASES AND ADDITIONAL VALIDATIONS
|
||||
# =============================================================================
|
||||
|
||||
# CIDR validations (IPv4 and IPv6)
|
||||
- it: should accept valid IPv4 CIDR in allowedCIDRs
|
||||
set:
|
||||
networkPolicy.enabled: true
|
||||
networkPolicy.egress.allowAllEgress: false
|
||||
networkPolicy.egress.restrictedEgress:
|
||||
allowedCIDRs:
|
||||
- "10.0.0.0/8"
|
||||
- "192.168.1.0/24"
|
||||
asserts:
|
||||
- contains:
|
||||
path: spec.egress
|
||||
content:
|
||||
to:
|
||||
- ipBlock:
|
||||
cidr: 10.0.0.0/8
|
||||
- contains:
|
||||
path: spec.egress
|
||||
content:
|
||||
to:
|
||||
- ipBlock:
|
||||
cidr: 192.168.1.0/24
|
||||
|
||||
- it: should accept valid IPv6 CIDR in allowedCIDRs
|
||||
set:
|
||||
networkPolicy.enabled: true
|
||||
networkPolicy.egress.allowAllEgress: false
|
||||
networkPolicy.egress.restrictedEgress:
|
||||
allowedCIDRs:
|
||||
- "2001:db8::/32"
|
||||
- "fe80::/10"
|
||||
asserts:
|
||||
- contains:
|
||||
path: spec.egress
|
||||
content:
|
||||
to:
|
||||
- ipBlock:
|
||||
cidr: 2001:db8::/32
|
||||
- contains:
|
||||
path: spec.egress
|
||||
content:
|
||||
to:
|
||||
- ipBlock:
|
||||
cidr: fe80::/10
|
||||
|
||||
- it: should accept mix of IPv4 and IPv6 CIDRs
|
||||
set:
|
||||
networkPolicy.enabled: true
|
||||
networkPolicy.egress.allowAllEgress: false
|
||||
networkPolicy.egress.restrictedEgress:
|
||||
allowedCIDRs:
|
||||
- "10.0.0.0/8"
|
||||
- "2001:db8::/32"
|
||||
asserts:
|
||||
- contains:
|
||||
path: spec.egress
|
||||
content:
|
||||
to:
|
||||
- ipBlock:
|
||||
cidr: 10.0.0.0/8
|
||||
- contains:
|
||||
path: spec.egress
|
||||
content:
|
||||
to:
|
||||
- ipBlock:
|
||||
cidr: 2001:db8::/32
|
||||
|
||||
# Egress restricted scenarios
|
||||
- it: should allow only metadata when restrictedEgress with allowMetadata only
|
||||
set:
|
||||
networkPolicy.enabled: true
|
||||
networkPolicy.egress.allowAllEgress: false
|
||||
networkPolicy.egress.restrictedEgress:
|
||||
allowMetadata: true
|
||||
allowInCluster: false
|
||||
asserts:
|
||||
- contains:
|
||||
path: spec.egress
|
||||
content:
|
||||
to:
|
||||
- ipBlock:
|
||||
cidr: 169.254.169.254/32
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
|
||||
- it: should not allow in-cluster when allowInCluster is false
|
||||
set:
|
||||
networkPolicy.enabled: true
|
||||
networkPolicy.egress.allowAllEgress: false
|
||||
networkPolicy.egress.restrictedEgress:
|
||||
allowMetadata: false
|
||||
allowInCluster: false
|
||||
asserts:
|
||||
- notContains:
|
||||
path: spec.egress
|
||||
content:
|
||||
to:
|
||||
- podSelector: {}
|
||||
|
||||
- it: should handle empty allowedCIDRs array
|
||||
set:
|
||||
networkPolicy.enabled: true
|
||||
networkPolicy.egress.allowAllEgress: false
|
||||
networkPolicy.egress.restrictedEgress:
|
||||
allowedCIDRs: []
|
||||
asserts:
|
||||
- isNotNull:
|
||||
path: spec.egress
|
||||
|
||||
# Custom ingress rules edge cases
|
||||
- it: should support multiple custom ingress rules
|
||||
set:
|
||||
networkPolicy.enabled: true
|
||||
networkPolicy.ingress.customRules:
|
||||
- from:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
name: frontend
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 8096
|
||||
- from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
app: proxy
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 8920
|
||||
asserts:
|
||||
- lengthEqual:
|
||||
path: spec.ingress
|
||||
count: 3 # default + 2 custom (when metrics disabled)
|
||||
|
||||
# Regression: verify default egress behavior
|
||||
- it: should have DNS egress by default
|
||||
set:
|
||||
networkPolicy.enabled: true
|
||||
asserts:
|
||||
- contains:
|
||||
path: spec.egress
|
||||
content:
|
||||
to:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: kube-system
|
||||
podSelector:
|
||||
matchLabels:
|
||||
k8s-app: kube-dns
|
||||
ports:
|
||||
- protocol: UDP
|
||||
port: 53
|
||||
- protocol: TCP
|
||||
port: 53
|
||||
|
||||
# Regression: verify ingress port
|
||||
- it: should expose correct port in ingress rules
|
||||
set:
|
||||
networkPolicy.enabled: true
|
||||
service.port: 9096
|
||||
asserts:
|
||||
- contains:
|
||||
path: spec.ingress[0].ports
|
||||
content:
|
||||
protocol: TCP
|
||||
port: 9096
|
||||
|
||||
# Combining all egress options
|
||||
- it: should combine all egress options when all enabled
|
||||
set:
|
||||
networkPolicy.enabled: true
|
||||
networkPolicy.egress.allowDNS: true
|
||||
networkPolicy.egress.allowAllEgress: false
|
||||
networkPolicy.egress.restrictedEgress:
|
||||
allowMetadata: true
|
||||
allowInCluster: true
|
||||
allowedCIDRs:
|
||||
- "10.0.0.0/8"
|
||||
asserts:
|
||||
# Should have DNS
|
||||
- contains:
|
||||
path: spec.egress
|
||||
content:
|
||||
ports:
|
||||
- protocol: UDP
|
||||
port: 53
|
||||
- protocol: TCP
|
||||
port: 53
|
||||
# Should have metadata
|
||||
- contains:
|
||||
path: spec.egress
|
||||
content:
|
||||
to:
|
||||
- ipBlock:
|
||||
cidr: 169.254.169.254/32
|
||||
# Should have in-cluster
|
||||
- contains:
|
||||
path: spec.egress
|
||||
content:
|
||||
to:
|
||||
- podSelector: {}
|
||||
# Should have custom CIDR
|
||||
- contains:
|
||||
path: spec.egress
|
||||
content:
|
||||
to:
|
||||
- ipBlock:
|
||||
cidr: 10.0.0.0/8
|
||||
Reference in new issue
Block a user