Skip to content

Commit

Permalink
Add RuntimeClassName as parameter to Tenant creation
Browse files Browse the repository at this point in the history
Increase test coverage of tenant code with RuntimeClassName
  • Loading branch information
allanrogerr committed Jan 11, 2023
1 parent d1aee5d commit 8bb8669
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 13 deletions.
3 changes: 3 additions & 0 deletions models/pool.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions operatorapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions operatorapi/tenants.go
Original file line number Diff line number Diff line change
Expand Up @@ -2270,9 +2270,10 @@ func parseTenantPoolRequest(poolParams *models.Pool) (*miniov2.Pool, error) {
Requests: resourcesRequests,
Limits: resourcesLimits,
},
NodeSelector: poolParams.NodeSelector,
Affinity: affinity,
Tolerations: tolerations,
NodeSelector: poolParams.NodeSelector,
Affinity: affinity,
Tolerations: tolerations,
RuntimeClassName: &poolParams.RuntimeClassName,
}
// if security context for Tenant is present, configure it.
if poolParams.SecurityContext != nil {
Expand Down Expand Up @@ -2501,11 +2502,12 @@ func parseTenantPool(pool *miniov2.Pool) *models.Pool {
Size: size,
StorageClassName: storageClassName,
},
NodeSelector: pool.NodeSelector,
Resources: resources,
Affinity: affinity,
Tolerations: tolerations,
SecurityContext: &securityContext,
NodeSelector: pool.NodeSelector,
Resources: resources,
Affinity: affinity,
Tolerations: tolerations,
SecurityContext: &securityContext,
RuntimeClassName: *pool.RuntimeClassName,
}
return poolModel
}
Expand Down
20 changes: 16 additions & 4 deletions operatorapi/tenants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export MINIO_SECRET_KEY=minio123
}
}

func NoTestTenantInfo(t *testing.T) {
func Test_TenantInfo(t *testing.T) {
testTimeStamp := metav1.Now()
type args struct {
minioTenant *miniov2.Tenant
Expand Down Expand Up @@ -418,6 +418,7 @@ func NoTestTenantInfo(t *testing.T) {
StorageClassName: swag.String("standard"),
},
},
RuntimeClassName: swag.String(""),
},
},

Expand All @@ -436,6 +437,11 @@ func NoTestTenantInfo(t *testing.T) {
Pools: []*models.Pool{
{
Name: "pool1",
SecurityContext: &models.SecurityContext{
RunAsGroup: nil,
RunAsNonRoot: nil,
RunAsUser: nil,
},
Servers: swag.Int64(int64(2)),
VolumesPerServer: swag.Int32(4),
VolumeConfiguration: &models.PoolVolumeConfiguration{
Expand Down Expand Up @@ -483,6 +489,7 @@ func NoTestTenantInfo(t *testing.T) {
StorageClassName: swag.String("standard"),
},
},
RuntimeClassName: swag.String(""),
},
},
Image: "minio/minio:RELEASE.2020-06-14T18-32-17Z",
Expand All @@ -501,6 +508,11 @@ func NoTestTenantInfo(t *testing.T) {
Pools: []*models.Pool{
{
Name: "pool1",
SecurityContext: &models.SecurityContext{
RunAsGroup: nil,
RunAsNonRoot: nil,
RunAsUser: nil,
},
Servers: swag.Int64(int64(2)),
VolumesPerServer: swag.Int32(4),
VolumeConfiguration: &models.PoolVolumeConfiguration{
Expand Down Expand Up @@ -1025,7 +1037,7 @@ func Test_UpdateTenantAction(t *testing.T) {
},
params: operator_api.UpdateTenantParams{
Body: &models.UpdateTenantRequest{
Image: "minio/minio:RELEASE.2020-06-03T22-13-49Z",
Image: "minio/minio:RELEASE.2023-01-06T18-11-18Z",
},
},
},
Expand All @@ -1050,7 +1062,7 @@ func Test_UpdateTenantAction(t *testing.T) {
},
params: operator_api.UpdateTenantParams{
Body: &models.UpdateTenantRequest{
Image: "minio/minio:RELEASE.2020-06-03T22-13-49Z",
Image: "minio/minio:RELEASE.2023-01-06T18-11-18Z",
},
},
},
Expand All @@ -1076,7 +1088,7 @@ func Test_UpdateTenantAction(t *testing.T) {
params: operator_api.UpdateTenantParams{
Tenant: "minio-tenant",
Body: &models.UpdateTenantRequest{
Image: "minio/minio:RELEASE.2020-06-03T22-13-49Z",
Image: "minio/minio:RELEASE.2023-01-06T18-11-18Z",
},
},
},
Expand Down
4 changes: 3 additions & 1 deletion swagger-operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2610,6 +2610,8 @@ definitions:
https://kubernetes.io/docs/concepts/configuration/assign-pod-node/"
affinity:
$ref: "#/definitions/poolAffinity"
runtimeClassName:
type: string
tolerations:
$ref: "#/definitions/poolTolerations"
securityContext:
Expand Down Expand Up @@ -3750,4 +3752,4 @@ definitions:
redirect:
type: string
displayName:
type: string
type: string

0 comments on commit 8bb8669

Please sign in to comment.