ceph: fix error in <ceph orch device ls> test

Rook orchestrator is going to use PVs as <devices> for OSDs.
These PVs must use one storage class present in the cluster and
configured properly in the manager.
With this change we include this new requirement in the Rook manager module test

Signed-off-by: Juan Miguel Olmo Martínez <jolmomar@redhat.com>
This commit is contained in:
Juan Miguel Olmo Martínez committed 2021-08-18 14:19:23 +02:00
1 parent f907e09b8e
commit 6ff5a5b86c
1 file changed
+26
+26
View File
@@ -100,6 +100,7 @@ func (s *CephMgrSuite) SetupSuite() {
s.settings.ApplyEnvVars()
s.installer, s.k8sh = StartTestCluster(s.T, s.settings, cephMasterSuiteMinimalTestVersion)
s.waitForOrchestrationModule()
s.prepareLocalStorageClass("local-storage")
}
func (s *CephMgrSuite) AfterTest(suiteName, testName string) {
@@ -107,6 +108,7 @@ func (s *CephMgrSuite) AfterTest(suiteName, testName string) {
}
func (s *CephMgrSuite) TearDownSuite() {
_ = s.k8sh.DeleteResource("sc", "local-storage")
s.installer.UninstallRook()
}
@@ -115,6 +117,30 @@ func (s *CephMgrSuite) execute(command []string) (error, string) {
return s.installer.Execute("ceph", orchCommand, s.namespace)
}
func (s *CephMgrSuite) prepareLocalStorageClass(storageClassName string) {
// Rook orchestrator use PVs based in this storage class to create OSDs
// It is also needed to list "devices"
localStorageClass := `
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: ` + storageClassName + `
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
`
err := s.k8sh.ResourceOperation("apply", localStorageClass)
if err == nil {
err, _ = s.installer.Execute("ceph", []string{"config", "set", "mgr", "mgr/rook/storage_class", storageClassName}, s.namespace)
if err == nil {
logger.Infof("Storage class %q set in manager config", storageClassName)
} else {
assert.Fail(s.T(), fmt.Sprintf("Error configuring local storage class in manager config: %q", err))
}
} else {
assert.Fail(s.T(), fmt.Sprintf("Error creating local storage class: %q ", err))
}
}
func (s *CephMgrSuite) enableOrchestratorModule() {
logger.Info("Enabling Rook orchestrator module: <ceph mgr module enable rook --force>")
err, output := s.installer.Execute("ceph", []string{"mgr", "module", "enable", "rook", "--force"}, s.namespace)