@@ -35,16 +35,28 @@ func TestGetWorkspacePVC(t *testing.T) {
3535		expectError  bool 
3636	}{
3737		{
38- 			name : "workspace with size specified" ,
38+ 			name : "workspace with size specified and default workspace " ,
3939			workspace : & pipelinespec.WorkspaceConfig {
40- 				Size : "5Gi" ,
40+ 				Size :       "5Gi" ,
41+ 				Kubernetes : nil ,
42+ 			},
43+ 			opts : & argocompiler.Options {
44+ 				DefaultWorkspace : & k8score.PersistentVolumeClaimSpec {
45+ 					AccessModes : []k8score.PersistentVolumeAccessMode {
46+ 						k8score .ReadWriteOnce ,
47+ 					},
48+ 					StorageClassName : stringPtr ("standard" ),
49+ 				},
4150			},
42- 			opts : nil ,
4351			expectedPVC : k8score.PersistentVolumeClaim {
4452				ObjectMeta : k8smeta.ObjectMeta {
4553					Name : "kfp-workspace" ,
4654				},
4755				Spec : k8score.PersistentVolumeClaimSpec {
56+ 					AccessModes : []k8score.PersistentVolumeAccessMode {
57+ 						k8score .ReadWriteOnce ,
58+ 					},
59+ 					StorageClassName : stringPtr ("standard" ),
4860					Resources : k8score.VolumeResourceRequirements {
4961						Requests : map [k8score.ResourceName ]resource.Quantity {
5062							k8score .ResourceStorage : resource .MustParse ("5Gi" ),
@@ -68,7 +80,14 @@ func TestGetWorkspacePVC(t *testing.T) {
6880			workspace : & pipelinespec.WorkspaceConfig {
6981				Size : "" , // no size specified 
7082			},
71- 			opts :        nil , // no options 
83+ 			opts : & argocompiler.Options {
84+ 				DefaultWorkspace : & k8score.PersistentVolumeClaimSpec {
85+ 					AccessModes : []k8score.PersistentVolumeAccessMode {
86+ 						k8score .ReadWriteOnce ,
87+ 					},
88+ 					StorageClassName : stringPtr ("standard" ),
89+ 				},
90+ 			},
7291			expectedPVC : k8score.PersistentVolumeClaim {},
7392			expectError : true ,
7493		},
@@ -108,6 +127,17 @@ func TestGetWorkspacePVC(t *testing.T) {
108127			},
109128			expectError : false ,
110129		},
130+ 		{
131+ 			name : "default workspace missing required fields should fail" ,
132+ 			workspace : & pipelinespec.WorkspaceConfig {
133+ 				Size : "10Gi" ,
134+ 			},
135+ 			opts : & argocompiler.Options {
136+ 				DefaultWorkspace : & k8score.PersistentVolumeClaimSpec {},
137+ 			},
138+ 			expectedPVC : k8score.PersistentVolumeClaim {},
139+ 			expectError : true ,
140+ 		},
111141		{
112142			name : "workspace with Kubernetes PVC spec patch" ,
113143			workspace : & pipelinespec.WorkspaceConfig {
@@ -160,6 +190,24 @@ func TestGetWorkspacePVC(t *testing.T) {
160190			expectedPVC : k8score.PersistentVolumeClaim {},
161191			expectError : true ,
162192		},
193+ 		{
194+ 			name : "workspace patch missing accessModes should fail" ,
195+ 			workspace : & pipelinespec.WorkspaceConfig {
196+ 				Size : "20Gi" ,
197+ 				Kubernetes : & pipelinespec.KubernetesWorkspaceConfig {
198+ 					PvcSpecPatch : & structpb.Struct {
199+ 						Fields : map [string ]* structpb.Value {
200+ 							"storageClassName" : structpb .NewStringValue ("fast-ssd" ),
201+ 						},
202+ 					},
203+ 				},
204+ 			},
205+ 			opts : & argocompiler.Options {
206+ 				DefaultWorkspace : & k8score.PersistentVolumeClaimSpec {},
207+ 			},
208+ 			expectedPVC : k8score.PersistentVolumeClaim {},
209+ 			expectError : true ,
210+ 		},
163211		{
164212			name : "workspace with invalid PVC spec patch" ,
165213			workspace : & pipelinespec.WorkspaceConfig {
@@ -221,50 +269,6 @@ func TestGetWorkspacePVC(t *testing.T) {
221269			},
222270			expectError : false ,
223271		},
224- 		{
225- 			name : "workspace with nil Kubernetes config" ,
226- 			workspace : & pipelinespec.WorkspaceConfig {
227- 				Size :       "30Gi" ,
228- 				Kubernetes : nil ,
229- 			},
230- 			opts : nil ,
231- 			expectedPVC : k8score.PersistentVolumeClaim {
232- 				ObjectMeta : k8smeta.ObjectMeta {
233- 					Name : "kfp-workspace" ,
234- 				},
235- 				Spec : k8score.PersistentVolumeClaimSpec {
236- 					Resources : k8score.VolumeResourceRequirements {
237- 						Requests : map [k8score.ResourceName ]resource.Quantity {
238- 							k8score .ResourceStorage : resource .MustParse ("30Gi" ),
239- 						},
240- 					},
241- 				},
242- 			},
243- 			expectError : false ,
244- 		},
245- 		{
246- 			name : "workspace with empty Kubernetes config" ,
247- 			workspace : & pipelinespec.WorkspaceConfig {
248- 				Size : "40Gi" ,
249- 				Kubernetes : & pipelinespec.KubernetesWorkspaceConfig {
250- 					PvcSpecPatch : nil ,
251- 				},
252- 			},
253- 			opts : nil ,
254- 			expectedPVC : k8score.PersistentVolumeClaim {
255- 				ObjectMeta : k8smeta.ObjectMeta {
256- 					Name : "kfp-workspace" ,
257- 				},
258- 				Spec : k8score.PersistentVolumeClaimSpec {
259- 					Resources : k8score.VolumeResourceRequirements {
260- 						Requests : map [k8score.ResourceName ]resource.Quantity {
261- 							k8score .ResourceStorage : resource .MustParse ("40Gi" ),
262- 						},
263- 					},
264- 				},
265- 			},
266- 			expectError : false ,
267- 		},
268272	}
269273
270274	for  _ , tt  :=  range  tests  {
@@ -299,17 +303,41 @@ func TestGetWorkspacePVC_EdgeCases(t *testing.T) {
299303			name : "workspace with very large size" ,
300304			workspace : & pipelinespec.WorkspaceConfig {
301305				Size : "1000Ti" ,
306+ 				Kubernetes : & pipelinespec.KubernetesWorkspaceConfig {
307+ 					PvcSpecPatch : & structpb.Struct {
308+ 						Fields : map [string ]* structpb.Value {
309+ 							"accessModes" : structpb .NewListValue (& structpb.ListValue {
310+ 								Values : []* structpb.Value {
311+ 									structpb .NewStringValue ("ReadWriteOnce" ),
312+ 								},
313+ 							}),
314+ 							"storageClassName" : structpb .NewStringValue ("gp2" ),
315+ 						},
316+ 					},
317+ 				},
302318			},
303319			opts :        nil ,
304- 			expectError : false ,  // should be valid 
320+ 			expectError : false ,
305321		},
306322		{
307323			name : "workspace with decimal size" ,
308324			workspace : & pipelinespec.WorkspaceConfig {
309325				Size : "1.5Gi" ,
326+ 				Kubernetes : & pipelinespec.KubernetesWorkspaceConfig {
327+ 					PvcSpecPatch : & structpb.Struct {
328+ 						Fields : map [string ]* structpb.Value {
329+ 							"accessModes" : structpb .NewListValue (& structpb.ListValue {
330+ 								Values : []* structpb.Value {
331+ 									structpb .NewStringValue ("ReadWriteOnce" ),
332+ 								},
333+ 							}),
334+ 							"storageClassName" : structpb .NewStringValue ("standard" ),
335+ 						},
336+ 					},
337+ 				},
310338			},
311339			opts :        nil ,
312- 			expectError : false ,  // should be valid 
340+ 			expectError : false ,
313341		},
314342		{
315343			name : "workspace with invalid size format" ,
0 commit comments