Files

218 lines
5.5 KiB
YAML

#
# Copyright 2025 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 hook job
templates:
- hook/job.yaml
release:
name: spark-operator
namespace: spark-operator
tests:
- it: Should not create hook job if `hook.upgradeCrd` is false
set:
hook:
upgradeCrd: false
asserts:
- hasDocuments:
count: 0
- it: Should create hook job if `hook.upgradeCrd` is true
set:
hook:
upgradeCrd: true
asserts:
- containsDocument:
apiVersion: batch/v1
kind: Job
name: spark-operator-hook
- it: Should use the specified image repository
set:
hook:
upgradeCrd: true
image:
registry: test-registry
repository: test-repository
tag: test-tag
asserts:
- equal:
path: spec.template.spec.containers[?(@.name=="spark-operator-hook")].image
value: test-registry/test-repository:test-tag
- it: Should use the specified image pull policy if `image.pullPolicy` is set
set:
image:
pullPolicy: Always
hook:
upgradeCrd: true
asserts:
- equal:
path: spec.template.spec.containers[*].imagePullPolicy
value: Always
- it: Should use the default resources
set:
hook:
upgradeCrd: true
asserts:
- equal:
path: spec.template.spec.containers[?(@.name=="spark-operator-hook")].resources
value:
requests:
cpu: 100m
memory: 64Mi
limits:
cpu: 100m
memory: 64Mi
- it: Should add resources if `hook.resources` is set
set:
hook:
upgradeCrd: true
resources:
requests:
cpu: 200m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
asserts:
- equal:
path: spec.template.spec.containers[?(@.name=="spark-operator-hook")].resources
value:
requests:
cpu: 200m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
- it: Should add nodeSelector if `hook.nodeSelector` is set
set:
hook:
upgradeCrd: true
nodeSelector:
key1: value1
key2: value2
asserts:
- equal:
path: spec.template.spec.nodeSelector.key1
value: value1
- equal:
path: spec.template.spec.nodeSelector.key2
value: value2
- it: Should add affinity if `hook.affinity` is set
set:
hook:
upgradeCrd: true
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: topology.kubernetes.io/zone
operator: In
values:
- antarctica-east1
- antarctica-west1
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: another-node-label-key
operator: In
values:
- another-node-label-value
asserts:
- equal:
path: spec.template.spec.affinity
value:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: topology.kubernetes.io/zone
operator: In
values:
- antarctica-east1
- antarctica-west1
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: another-node-label-key
operator: In
values:
- another-node-label-value
- it: Should add tolerations if `hook.tolerations` is set
set:
hook:
upgradeCrd: true
tolerations:
- key: key1
operator: Equal
value: value1
effect: NoSchedule
- key: key2
operator: Exists
effect: NoSchedule
asserts:
- equal:
path: spec.template.spec.tolerations
value:
- key: key1
operator: Equal
value: value1
effect: NoSchedule
- key: key2
operator: Exists
effect: NoSchedule
- it: Should add annotations to the hook pod if `hook.annotations` is set
set:
hook:
upgradeCrd: true
annotations:
key1: value1
key2: value2
asserts:
- equal:
path: spec.template.metadata.annotations.key1
value: value1
- equal:
path: spec.template.metadata.annotations.key2
value: value2
- it: Should add labels to the hook pod if `hook.labels` is set
set:
hook:
upgradeCrd: true
labels:
key1: value1
key2: value2
asserts:
- equal:
path: spec.template.metadata.labels.key1
value: value1
- equal:
path: spec.template.metadata.labels.key2
value: value2