@@ -35,21 +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 {
48- Resources : k8score.VolumeResourceRequirements {
49- Requests : map [k8score.ResourceName ]resource.Quantity {
50- k8score .ResourceStorage : resource .MustParse ("5Gi" ),
51- },
56+ AccessModes : []k8score.PersistentVolumeAccessMode {
57+ k8score .ReadWriteOnce ,
5258 },
59+ StorageClassName : stringPtr ("standard" ),
5360 },
5461 },
5562 expectError : false ,
@@ -108,6 +115,17 @@ func TestGetWorkspacePVC(t *testing.T) {
108115 },
109116 expectError : false ,
110117 },
118+ {
119+ name : "default workspace missing required fields should fail" ,
120+ workspace : & pipelinespec.WorkspaceConfig {
121+ Size : "10Gi" ,
122+ },
123+ opts : & argocompiler.Options {
124+ DefaultWorkspace : & k8score.PersistentVolumeClaimSpec {},
125+ },
126+ expectedPVC : k8score.PersistentVolumeClaim {},
127+ expectError : true ,
128+ },
111129 {
112130 name : "workspace with Kubernetes PVC spec patch" ,
113131 workspace : & pipelinespec.WorkspaceConfig {
@@ -160,6 +178,24 @@ func TestGetWorkspacePVC(t *testing.T) {
160178 expectedPVC : k8score.PersistentVolumeClaim {},
161179 expectError : true ,
162180 },
181+ {
182+ name : "workspace patch missing accessModes should fail" ,
183+ workspace : & pipelinespec.WorkspaceConfig {
184+ Size : "20Gi" ,
185+ Kubernetes : & pipelinespec.KubernetesWorkspaceConfig {
186+ PvcSpecPatch : & structpb.Struct {
187+ Fields : map [string ]* structpb.Value {
188+ "storageClassName" : structpb .NewStringValue ("fast-ssd" ),
189+ },
190+ },
191+ },
192+ },
193+ opts : & argocompiler.Options {
194+ DefaultWorkspace : & k8score.PersistentVolumeClaimSpec {},
195+ },
196+ expectedPVC : k8score.PersistentVolumeClaim {},
197+ expectError : true ,
198+ },
163199 {
164200 name : "workspace with invalid PVC spec patch" ,
165201 workspace : & pipelinespec.WorkspaceConfig {
@@ -221,50 +257,6 @@ func TestGetWorkspacePVC(t *testing.T) {
221257 },
222258 expectError : false ,
223259 },
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- },
268260 }
269261
270262 for _ , tt := range tests {
@@ -299,17 +291,41 @@ func TestGetWorkspacePVC_EdgeCases(t *testing.T) {
299291 name : "workspace with very large size" ,
300292 workspace : & pipelinespec.WorkspaceConfig {
301293 Size : "1000Ti" ,
294+ Kubernetes : & pipelinespec.KubernetesWorkspaceConfig {
295+ PvcSpecPatch : & structpb.Struct {
296+ Fields : map [string ]* structpb.Value {
297+ "accessModes" : structpb .NewListValue (& structpb.ListValue {
298+ Values : []* structpb.Value {
299+ structpb .NewStringValue ("ReadWriteOnce" ),
300+ },
301+ }),
302+ "storageClassName" : structpb .NewStringValue ("gp2" ),
303+ },
304+ },
305+ },
302306 },
303307 opts : nil ,
304- expectError : false , // should be valid
308+ expectError : false ,
305309 },
306310 {
307311 name : "workspace with decimal size" ,
308312 workspace : & pipelinespec.WorkspaceConfig {
309313 Size : "1.5Gi" ,
314+ Kubernetes : & pipelinespec.KubernetesWorkspaceConfig {
315+ PvcSpecPatch : & structpb.Struct {
316+ Fields : map [string ]* structpb.Value {
317+ "accessModes" : structpb .NewListValue (& structpb.ListValue {
318+ Values : []* structpb.Value {
319+ structpb .NewStringValue ("ReadWriteOnce" ),
320+ },
321+ }),
322+ "storageClassName" : structpb .NewStringValue ("standard" ),
323+ },
324+ },
325+ },
310326 },
311327 opts : nil ,
312- expectError : false , // should be valid
328+ expectError : false ,
313329 },
314330 {
315331 name : "workspace with invalid size format" ,
0 commit comments