From 6ff5a5b86cf75a3871dfd371b79ef86e81be4188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Miguel=20Olmo=20Mart=C3=ADnez?= Date: Tue, 17 Aug 2021 12:09:05 +0200 Subject: [PATCH] ceph: fix error in test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rook orchestrator is going to use PVs as 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 --- tests/integration/ceph_mgr_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/integration/ceph_mgr_test.go b/tests/integration/ceph_mgr_test.go index 2398b2efa..7017c7c1f 100644 --- a/tests/integration/ceph_mgr_test.go +++ b/tests/integration/ceph_mgr_test.go @@ -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: ") err, output := s.installer.Execute("ceph", []string{"mgr", "module", "enable", "rook", "--force"}, s.namespace)