Skip to content

add unit tests for imagePullPolicy #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tools/pytorchjob-generator/chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ customize the Jobs generated by the tool.
| 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). |
| 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) |
| imagePullSecrets | array | `nil` | List of image-pull-secrets to be used for pulling containerImages |
| imagePullPolicy | string | `"IfNotPresent"` | Policy for pulling images (choose from: "IfNotPresent", "Always", or "Never") https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy |
| imagePullPolicy | string | `"IfNotPresent"` | Policy for pulling containerImages (choose from: "IfNotPresent", "Always", or "Never") |

### Resource Requirements

Expand Down
17 changes: 17 additions & 0 deletions tools/pytorchjob-generator/chart/tests/helloworld_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,23 @@ tests:
- matchSnapshot:
path: spec.components[0].template

- it: imagePullPolicy can be set
set:
imagePullPolicy: Always
asserts:
- equal:
path: spec.components[0].template.spec.pytorchReplicaSpecs.Worker.template.spec.containers[0].imagePullPolicy
value: Always
- equal:
path: spec.components[0].template.spec.pytorchReplicaSpecs.Worker.template.spec.containers[0].imagePullPolicy
value: Always

- it: Invalid imagePullPolicies are rejected
set:
imagePullPolicy: Sometimes
asserts:
- failedTemplate: {}

- it: Enabling sshGitConfig injects the envvars, volumes, and volumeMounts
set:
sshGitCloneConfig.secretName: my-git-secret
Expand Down
2 changes: 1 addition & 1 deletion tools/pytorchjob-generator/chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
]},
"imagePullPolicy": { "oneOf": [
{ "type": "null" },
{ "type": "string" }
{ "type": "string", "enum": [ "IfNotPresent", "Always", "Never" ] }
]},
"volumes": { "oneOf": [
{ "type": "null" },
Expand Down
2 changes: 1 addition & 1 deletion tools/pytorchjob-generator/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ imagePullSecrets: # <optional, default=[]>
# - name: secret-one
# - name: secret-two

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

Expand Down