Skip to content

Commit

Permalink
updated test
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyblasczyk committed Sep 9, 2024
1 parent 40b55f9 commit f0d6aa4
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions controllers/weightsandbiases_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/wandb/operator/pkg/wandb/spec"
"github.com/wandb/operator/pkg/wandb/spec/channel/deployer/deployerfakes"
"github.com/wandb/operator/pkg/wandb/spec/charts"
"github.com/wandb/operator/pkg/wandb/spec/state"
"github.com/wandb/operator/pkg/wandb/spec/state/secrets"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -163,12 +165,21 @@ var _ = Describe("WeightsandbiasesController", func() {
"global": map[string]interface{}{
"host": "https://qa-google.wandb.io",
},
"_releaseId": "0b901113-8135-48ae-bdaf-6fa82b4b2d28",
}},
},
}
err := k8sClient.Create(ctx, &wandb)
Expect(err).ToNot(HaveOccurred())

// Create UserSpec with _releaseId
userSpec := &spec.Spec{
Values: map[string]interface{}{
"_releaseId": "0b901113-8135-48ae-bdaf-6fa82b4b2d28",
},
}
err = state.New(ctx, k8sClient, &wandb, scheme.Scheme, secrets.New(ctx, k8sClient, &wandb, scheme.Scheme)).SetUserInput(userSpec)
Expect(err).ToNot(HaveOccurred())

res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: types.NamespacedName{Name: wandb.Name, Namespace: wandb.Namespace}})
Expect(err).ToNot(HaveOccurred())
Expect(res).To(Equal(ctrl.Result{RequeueAfter: time.Duration(1 * time.Hour)}))
Expand All @@ -189,12 +200,16 @@ var _ = Describe("WeightsandbiasesController", func() {
Expect(err).To(HaveOccurred())
})

It("Should use the specified _releaseId", func() {
It("Should use the specified _releaseId from UserSpec in the final spec", func() {
ctx := context.Background()
wandb := wandbcomv1.WeightsAndBiases{}
err := k8sClient.Get(ctx, types.NamespacedName{Name: "test-release-id", Namespace: "default"}, &wandb)
Expect(err).ToNot(HaveOccurred())
Expect(wandb.Spec.Values.Object["_releaseId"]).To(Equal("0b901113-8135-48ae-bdaf-6fa82b4b2d28"))

specManager := state.New(ctx, k8sClient, &wandb, scheme.Scheme, secrets.New(ctx, k8sClient, &wandb, scheme.Scheme))
activeSpec, err := specManager.GetActive()
Expect(err).ToNot(HaveOccurred())
Expect(activeSpec.Values["_releaseId"]).To(Equal("0b901113-8135-48ae-bdaf-6fa82b4b2d28"))
})
})
Describe("Reconcile and Apply", func() {
Expand Down

0 comments on commit f0d6aa4

Please sign in to comment.