Skip to content

Commit

Permalink
fix: add custom template (#168)
Browse files Browse the repository at this point in the history
Add custom pod template to e2e tests
  • Loading branch information
ishaansehgal99 authored Nov 15, 2023
1 parent fa60f47 commit b97a288
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/controllers/workspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (c *WorkspaceReconciler) addOrUpdateWorkspace(ctx context.Context, wObj *ka
if wObj.Inference.Preset != nil && strings.Contains(string(wObj.Inference.Preset.Name), "llama") {
useHeadlessService = true
}

if err := c.ensureService(ctx, wObj, useHeadlessService); err != nil {
if updateErr := c.updateStatusConditionIfNotMatch(ctx, wObj, kaitov1alpha1.WorkspaceConditionTypeReady, metav1.ConditionFalse,
"workspaceFailed", err.Error()); updateErr != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/resources/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ func GenerateDeploymentManifestWithPodTemplate(ctx context.Context, workspaceObj
}

templateCopy := workspaceObj.Inference.Template.DeepCopy()

if templateCopy.ObjectMeta.Labels == nil {
templateCopy.ObjectMeta.Labels = make(map[string]string)
}
Expand Down
32 changes: 32 additions & 0 deletions test/e2e/preset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ func createLlama13BWorkspaceWithPresetPrivateMode(registry, registrySecret, imag
return workspaceObj
}

func createCustomWorkspaceWithPresetCustomMode(imageName string, numOfNode int) *kaitov1alpha1.Workspace {
workspaceObj := &kaitov1alpha1.Workspace{}
By("Creating a workspace CR with custom workspace mode", func() {
uniqueID := fmt.Sprint("preset-", rand.Intn(1000))
workspaceObj = utils.GenerateWorkspaceManifest(uniqueID, namespaceName, "",
numOfNode, "Standard_D4s_v3", &metav1.LabelSelector{
MatchLabels: map[string]string{"kaito-workspace": "private-preset-e2e-test"},
}, nil, "", utils.InferenceModeCustomTemplate, nil, utils.GeneratePodTemplate(uniqueID, namespaceName, imageName, nil))

createAndValidateWorkspace(workspaceObj)
})
return workspaceObj
}

func createAndValidateWorkspace(workspaceObj *kaitov1alpha1.Workspace) {
By("Creating workspace", func() {
Eventually(func() error {
Expand Down Expand Up @@ -363,4 +377,22 @@ var _ = Describe("Workspace Preset", func() {
validateWorkspaceReadiness(workspaceObj)
})

It("should create a custom template workspace successfully", func() {
numOfNode := 1
imageName := "nginx:latest"
workspaceObj := createCustomWorkspaceWithPresetCustomMode(imageName, numOfNode)

defer cleanupResources(workspaceObj)

time.Sleep(30 * time.Second)
validateMachineCreation(workspaceObj, numOfNode)
validateResourceStatus(workspaceObj)

time.Sleep(30 * time.Second)

validateInferenceResource(workspaceObj, int32(numOfNode), false)

validateWorkspaceReadiness(workspaceObj)
})

})

0 comments on commit b97a288

Please sign in to comment.