mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-04 20:20:19 +00:00
4b57cc3ec5
RBD supports creating rbd images with object size, stripe unit and stripe count to support striping. This PR adds the support for the same. More details about striping at https://docs.ceph.com/en/quincy/man/8/rbd/#striping fixes: #3124 Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
89 lines
2.0 KiB
Go
89 lines
2.0 KiB
Go
/*
|
|
Copyright 2022 The Ceph-CSI Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package rbd
|
|
|
|
import "testing"
|
|
|
|
func TestValidateStriping(t *testing.T) {
|
|
t.Parallel()
|
|
tests := []struct {
|
|
name string
|
|
parameters map[string]string
|
|
wantErr bool
|
|
}{
|
|
{
|
|
name: "when stripeUnit is not specified",
|
|
parameters: map[string]string{
|
|
"stripeUnit": "",
|
|
"stripeCount": "10",
|
|
"objectSize": "2",
|
|
},
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "when stripeCount is not specified",
|
|
parameters: map[string]string{
|
|
"stripeUnit": "4096",
|
|
"stripeCount": "",
|
|
"objectSize": "2",
|
|
},
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "when objectSize is not power of 2",
|
|
parameters: map[string]string{
|
|
"stripeUnit": "4096",
|
|
"stripeCount": "8",
|
|
"objectSize": "3",
|
|
},
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "when objectSize is 0",
|
|
parameters: map[string]string{
|
|
"stripeUnit": "4096",
|
|
"stripeCount": "8",
|
|
"objectSize": "0",
|
|
},
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "when valid stripe parameters are specified",
|
|
parameters: map[string]string{
|
|
"stripeUnit": "4096",
|
|
"stripeCount": "8",
|
|
"objectSize": "131072",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "when no stripe parameters are specified",
|
|
parameters: map[string]string{},
|
|
wantErr: false,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
ts := tt
|
|
t.Run(ts.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
if err := validateStriping(ts.parameters); (err != nil) != ts.wantErr {
|
|
t.Errorf("validateStriping() error = %v, wantErr %v", err, ts.wantErr)
|
|
}
|
|
})
|
|
}
|
|
}
|