Skip to content

Commit f5553b9

Browse files
authored
add unit tests for imagePullPolicy (#178)
1 parent ad10c6e commit f5553b9

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

tools/pytorchjob-generator/chart/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ customize the Jobs generated by the tool.
2222
| customLabels | array | `nil` | Optional array of custom labels to add to all the resources created by the Job (the PyTorchJob, the PodGroup, and the AppWrapper). |
2323
| containerImage | string | must be provided by the user | Image used for creating the Job's containers (needs to have all the applications your job may need) |
2424
| imagePullSecrets | array | `nil` | List of image-pull-secrets to be used for pulling containerImages |
25-
| imagePullPolicy | string | `"IfNotPresent"` | Policy for pulling images (choose from: "IfNotPresent", "Always", or "Never") https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy |
25+
| imagePullPolicy | string | `"IfNotPresent"` | Policy for pulling containerImages (choose from: "IfNotPresent", "Always", or "Never") |
2626

2727
### Resource Requirements
2828

tools/pytorchjob-generator/chart/tests/helloworld_test.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ tests:
9393
- matchSnapshot:
9494
path: spec.components[0].template
9595

96+
- it: imagePullPolicy can be set
97+
set:
98+
imagePullPolicy: Always
99+
asserts:
100+
- equal:
101+
path: spec.components[0].template.spec.pytorchReplicaSpecs.Worker.template.spec.containers[0].imagePullPolicy
102+
value: Always
103+
- equal:
104+
path: spec.components[0].template.spec.pytorchReplicaSpecs.Worker.template.spec.containers[0].imagePullPolicy
105+
value: Always
106+
107+
- it: Invalid imagePullPolicies are rejected
108+
set:
109+
imagePullPolicy: Sometimes
110+
asserts:
111+
- failedTemplate: {}
112+
96113
- it: Enabling sshGitConfig injects the envvars, volumes, and volumeMounts
97114
set:
98115
sshGitCloneConfig.secretName: my-git-secret

tools/pytorchjob-generator/chart/values.schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
]},
7272
"imagePullPolicy": { "oneOf": [
7373
{ "type": "null" },
74-
{ "type": "string" }
74+
{ "type": "string", "enum": [ "IfNotPresent", "Always", "Never" ] }
7575
]},
7676
"volumes": { "oneOf": [
7777
{ "type": "null" },

tools/pytorchjob-generator/chart/values.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ imagePullSecrets: # <optional, default=[]>
3838
# - name: secret-one
3939
# - name: secret-two
4040

41-
# -- (string) Policy for pulling images (choose from: "IfNotPresent", "Always", or "Never") https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy
41+
# -- (string) Policy for pulling containerImages (choose from: "IfNotPresent", "Always", or "Never")
4242
# @section -- Job Metadata
4343
imagePullPolicy: IfNotPresent
4444

0 commit comments

Comments
 (0)