Files
spark-operator/charts/spark-operator-chart/tests/webhook/mutatingwebhookconfiguration_test.yaml

100 lines
2.5 KiB
YAML

#
# Copyright 2024 The Kubeflow authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
suite: Test mutating webhook configuration
templates:
- webhook/mutatingwebhookconfiguration.yaml
release:
name: spark-operator
namespace: spark-operator
tests:
- it: Should create the mutating webhook configuration by default
asserts:
- containsDocument:
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
name: spark-operator-webhook
- it: Should not create the mutating webhook configuration if `webhook.enable` is `false`
set:
webhook:
enable: false
asserts:
- hasDocuments:
count: 0
- it: Should use the specified webhook port
set:
webhook:
port: 12345
asserts:
- equal:
path: webhooks[*].clientConfig.service.port
value: 12345
- it: Should use the specified failure policy
set:
webhook:
failurePolicy: Fail
asserts:
- equal:
path: webhooks[*].failurePolicy
value: Fail
- it: Should set namespaceSelector if `spark.jobNamespaces` is set with non-empty strings
set:
spark:
jobNamespaces:
- ns1
- ns2
- ns3
asserts:
- equal:
path: webhooks[*].namespaceSelector
value:
matchExpressions:
- key: kubernetes.io/metadata.name
operator: In
values:
- ns1
- ns2
- ns3
- it: Should not set namespaceSelector if `spark.jobNamespaces` contains empty string
set:
spark:
jobNamespaces:
- ""
- ns1
- ns2
- ns3
asserts:
- notExists:
path: webhooks[*].namespaceSelector
- it: Should should use the specified timeoutSeconds
set:
webhook:
timeoutSeconds: 5
asserts:
- equal:
path: webhooks[*].timeoutSeconds
value: 5