Skip to content

Commit

Permalink
chore: add test for GIT puller job
Browse files Browse the repository at this point in the history
  • Loading branch information
shil committed Aug 5, 2024
1 parent f84b0f2 commit 518908b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/controller/nimcache_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,10 @@ func isModelSelectionDone(nimCache *appsv1alpha1.NIMCache) bool {

func getSelectedProfiles(nimCache *appsv1alpha1.NIMCache) ([]string, error) {
// Return profiles explicitly specified by the user in the spec
if len(nimCache.Spec.Source.NGC.Model.Profiles) > 0 {
if nimCache.Spec.Source.NGC != nil && len(nimCache.Spec.Source.NGC.Model.Profiles) > 0 {
return nimCache.Spec.Source.NGC.Model.Profiles, nil
} else if nimCache.Spec.Source.GIT != nil && len(nimCache.Spec.Source.GIT.Model.Profiles) > 0 {
return nimCache.Spec.Source.GIT.Model.Profiles, nil
} else if isModelSelectionRequired(nimCache) {
// Retrieve the selected profiles from the annotation
var selectedProfiles []string
Expand Down
18 changes: 18 additions & 0 deletions internal/controller/nimcache_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,24 @@ var _ = Describe("NIMCache Controller", func() {
jobName := types.NamespacedName{Name: getJobName(nimCache), Namespace: "default"}
return client.Get(ctx, jobName, job)
}, time.Second*10).Should(Succeed())

nimCache.Spec.Source.NGC = nil
nimCache.Spec.Source.GIT = &appsv1alpha1.GITSource{ModelPuller: "nvcr.io/nim:test-git-puller", PullSecret: "my-secret"}

err = client.Delete(context.TODO(), job)
Expect(err).ToNot(HaveOccurred())

job, err = constructJob(nimCache)
Expect(err).ToNot(HaveOccurred())

err = client.Create(context.TODO(), job)
Expect(err).ToNot(HaveOccurred())

Eventually(func() error {
job := &batchv1.Job{}
jobName := types.NamespacedName{Name: getJobName(nimCache), Namespace: "default"}
return client.Get(ctx, jobName, job)
}, time.Second*10).Should(Succeed())
})

It("should create a ConfigMap with the given model manifest data", func() {
Expand Down

0 comments on commit 518908b

Please sign in to comment.