From 0f56fab8f8fde14ea44103730819ec59f71a74df Mon Sep 17 00:00:00 2001 From: David Grove Date: Thu, 17 Apr 2025 11:06:02 -0400 Subject: [PATCH] add unit tests for imagePullPolicy --- tools/pytorchjob-generator/chart/README.md | 2 +- .../chart/tests/helloworld_test.yaml | 17 +++++++++++++++++ .../chart/values.schema.json | 2 +- tools/pytorchjob-generator/chart/values.yaml | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/pytorchjob-generator/chart/README.md b/tools/pytorchjob-generator/chart/README.md index e8f87dd..e5bfa56 100644 --- a/tools/pytorchjob-generator/chart/README.md +++ b/tools/pytorchjob-generator/chart/README.md @@ -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 diff --git a/tools/pytorchjob-generator/chart/tests/helloworld_test.yaml b/tools/pytorchjob-generator/chart/tests/helloworld_test.yaml index 33d28f9..83aa908 100644 --- a/tools/pytorchjob-generator/chart/tests/helloworld_test.yaml +++ b/tools/pytorchjob-generator/chart/tests/helloworld_test.yaml @@ -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 diff --git a/tools/pytorchjob-generator/chart/values.schema.json b/tools/pytorchjob-generator/chart/values.schema.json index 0ff8271..9bebe8f 100644 --- a/tools/pytorchjob-generator/chart/values.schema.json +++ b/tools/pytorchjob-generator/chart/values.schema.json @@ -71,7 +71,7 @@ ]}, "imagePullPolicy": { "oneOf": [ { "type": "null" }, - { "type": "string" } + { "type": "string", "enum": [ "IfNotPresent", "Always", "Never" ] } ]}, "volumes": { "oneOf": [ { "type": "null" }, diff --git a/tools/pytorchjob-generator/chart/values.yaml b/tools/pytorchjob-generator/chart/values.yaml index 2c1e642..0b60656 100644 --- a/tools/pytorchjob-generator/chart/values.yaml +++ b/tools/pytorchjob-generator/chart/values.yaml @@ -38,7 +38,7 @@ imagePullSecrets: # # - 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