mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-21 20:40:20 +00:00
d02e50aa9b
Existing config maps are now replaced with rados omaps that help store information regarding the requested volume names and the rbd image names backing the same. Further to detect cluster, pool and which image a volume ID refers to, changes to volume ID encoding has been done as per provided design specification in the stateless ceph-csi proposal. Additional changes and updates, - Updated documentation - Updated manifests - Updated Helm chart - Addressed a few csi-test failures Signed-off-by: ShyamsundarR <srangana@redhat.com>
96 lines
2.4 KiB
Go
96 lines
2.4 KiB
Go
/*
|
|
Copyright 2019 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 util
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
type testTuple struct {
|
|
vID CSIIdentifier
|
|
composedVolID string
|
|
wantEnc bool
|
|
wantEncError bool
|
|
wantDec bool
|
|
wantDecError bool
|
|
}
|
|
|
|
// TODO: Add more test tuples to test out other edge conditions
|
|
var testData = []testTuple{
|
|
{
|
|
vID: CSIIdentifier{
|
|
PoolID: 0xffff,
|
|
EncodingVersion: 0xffff,
|
|
ClusterID: "01616094-9d93-4178-bf45-c7eac19e8b15",
|
|
ObjectUUID: "00000000-1111-2222-bbbb-cacacacacaca",
|
|
},
|
|
composedVolID: "ffff-0024-01616094-9d93-4178-bf45-c7eac19e8b15-000000000000ffff-00000000-1111-2222-bbbb-cacacacacaca",
|
|
wantEnc: true,
|
|
wantEncError: false,
|
|
wantDec: true,
|
|
wantDecError: false,
|
|
},
|
|
}
|
|
|
|
func TestComposeDecomposeID(t *testing.T) {
|
|
var (
|
|
err error
|
|
viDecompose CSIIdentifier
|
|
composedVolID string
|
|
)
|
|
|
|
for _, test := range testData {
|
|
if test.wantEnc {
|
|
composedVolID, err = test.vID.ComposeCSIID()
|
|
|
|
if err != nil && !test.wantEncError {
|
|
t.Errorf("Composing failed: want (%#v), got (%#v %#v)",
|
|
test, composedVolID, err)
|
|
}
|
|
|
|
if err == nil && test.wantEncError {
|
|
t.Errorf("Composing failed: want (%#v), got (%#v %#v)",
|
|
test, composedVolID, err)
|
|
}
|
|
|
|
if !test.wantEncError && err == nil && composedVolID != test.composedVolID {
|
|
t.Errorf("Composing failed: want (%#v), got (%#v %#v)",
|
|
test, composedVolID, err)
|
|
}
|
|
}
|
|
|
|
if test.wantDec {
|
|
err = viDecompose.DecomposeCSIID(test.composedVolID)
|
|
|
|
if err != nil && !test.wantDecError {
|
|
t.Errorf("Decomposing failed: want (%#v), got (%#v %#v)",
|
|
test, viDecompose, err)
|
|
}
|
|
|
|
if err == nil && test.wantDecError {
|
|
t.Errorf("Decomposing failed: want (%#v), got (%#v %#v)",
|
|
test, viDecompose, err)
|
|
}
|
|
|
|
if !test.wantDecError && err == nil && viDecompose != test.vID {
|
|
t.Errorf("Decomposing failed: want (%#v), got (%#v %#v)",
|
|
test, viDecompose, err)
|
|
}
|
|
}
|
|
}
|
|
}
|