-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RBD supports creating rbd images with object size, strip unit and strip count to support striping. This PR adds the support for the same. More details about strip at https://docs.ceph.com/en/quincy/man/8/rbd/#striping fixes: #3124 Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
- Loading branch information
Showing
7 changed files
with
440 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
Copyright 2018 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) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.