2017-12-29 00:33:36 -08:00
|
|
|
/*
|
|
|
|
|
Copyright 2016 The Rook Authors. All rights reserved.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-19 01:10:50 -07:00
|
|
|
package integration
|
2017-09-06 23:36:13 -07:00
|
|
|
|
|
|
|
|
import (
|
2020-10-09 16:58:25 +00:00
|
|
|
"path/filepath"
|
2017-09-06 23:36:13 -07:00
|
|
|
"testing"
|
|
|
|
|
|
2020-07-10 16:40:16 -06:00
|
|
|
"github.com/rook/rook/pkg/daemon/ceph/client"
|
2017-09-06 23:36:13 -07:00
|
|
|
"github.com/rook/rook/tests/framework/clients"
|
|
|
|
|
"github.com/rook/rook/tests/framework/installer"
|
|
|
|
|
"github.com/rook/rook/tests/framework/utils"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
|
)
|
|
|
|
|
|
2020-05-13 06:14:57 +09:00
|
|
|
const (
|
|
|
|
|
localPathPVCmd = "tests/scripts/localPathPV.sh"
|
|
|
|
|
)
|
|
|
|
|
|
2017-10-26 17:49:18 -07:00
|
|
|
// *************************************************************
|
|
|
|
|
// *** Major scenarios tested by the MultiClusterDeploySuite ***
|
|
|
|
|
// Setup
|
|
|
|
|
// - Two clusters started in different namespaces via the CRD
|
|
|
|
|
// Monitors
|
|
|
|
|
// - One mon in each cluster
|
|
|
|
|
// OSDs
|
2020-05-06 00:44:31 +09:00
|
|
|
// - Bluestore running on a raw block device
|
2017-10-26 17:49:18 -07:00
|
|
|
// Block
|
|
|
|
|
// - Create a pool in each cluster
|
|
|
|
|
// - Mount/unmount a block device through the dynamic provisioner
|
|
|
|
|
// File system
|
2018-03-16 08:31:34 -07:00
|
|
|
// - Create a file system via the CRD
|
2017-10-26 17:49:18 -07:00
|
|
|
// Object
|
|
|
|
|
// - Create the object store via the CRD
|
|
|
|
|
// *************************************************************
|
2019-07-17 23:23:01 -06:00
|
|
|
func TestCephMultiClusterDeploySuite(t *testing.T) {
|
2017-11-10 12:03:43 -08:00
|
|
|
s := new(MultiClusterDeploySuite)
|
|
|
|
|
defer func(s *MultiClusterDeploySuite) {
|
2021-03-09 22:52:21 -07:00
|
|
|
HandlePanics(recover(), s.TearDownSuite, s.T)
|
2017-11-10 12:03:43 -08:00
|
|
|
}(s)
|
|
|
|
|
suite.Run(t, s)
|
2017-09-06 23:36:13 -07:00
|
|
|
}
|
|
|
|
|
|
2017-10-26 17:49:18 -07:00
|
|
|
type MultiClusterDeploySuite struct {
|
2017-09-06 23:36:13 -07:00
|
|
|
suite.Suite
|
2021-03-09 22:52:21 -07:00
|
|
|
testClient *clients.TestClient
|
|
|
|
|
k8sh *utils.K8sHelper
|
|
|
|
|
settings *installer.TestCephSettings
|
|
|
|
|
externalManifests installer.CephManifests
|
|
|
|
|
installer *installer.CephInstaller
|
|
|
|
|
coreToolbox string
|
|
|
|
|
externalToolbox string
|
|
|
|
|
poolName string
|
2017-09-06 23:36:13 -07:00
|
|
|
}
|
|
|
|
|
|
2018-10-14 12:10:08 +02:00
|
|
|
// Deploy Multiple Rook clusters
|
2021-03-09 22:52:21 -07:00
|
|
|
func (s *MultiClusterDeploySuite) SetupSuite() {
|
|
|
|
|
s.poolName = "multi-cluster-pool1"
|
|
|
|
|
coreNamespace := "multi-core"
|
|
|
|
|
s.settings = &installer.TestCephSettings{
|
2023-11-24 12:05:24 +05:30
|
|
|
ClusterName: "multi-cluster",
|
|
|
|
|
Namespace: coreNamespace,
|
|
|
|
|
OperatorNamespace: installer.SystemNamespace(coreNamespace),
|
|
|
|
|
StorageClassName: "manual",
|
|
|
|
|
UsePVC: installer.UsePVC(),
|
|
|
|
|
Mons: 1,
|
|
|
|
|
MultipleMgrs: true,
|
|
|
|
|
RookVersion: installer.LocalBuildTag,
|
|
|
|
|
CephVersion: installer.QuincyVersion,
|
|
|
|
|
RequireMsgr2: true,
|
2020-03-03 15:31:57 -07:00
|
|
|
}
|
2021-03-15 20:47:38 -06:00
|
|
|
s.settings.ApplyEnvVars()
|
2021-03-09 22:52:21 -07:00
|
|
|
externalSettings := &installer.TestCephSettings{
|
|
|
|
|
IsExternal: true,
|
|
|
|
|
ClusterName: "test-external",
|
|
|
|
|
Namespace: "multi-external",
|
|
|
|
|
OperatorNamespace: s.settings.OperatorNamespace,
|
|
|
|
|
RookVersion: s.settings.RookVersion,
|
2023-11-14 09:05:27 -07:00
|
|
|
CephVersion: installer.QuincyVersion,
|
2020-02-04 18:26:31 +05:30
|
|
|
}
|
2021-03-15 20:47:38 -06:00
|
|
|
externalSettings.ApplyEnvVars()
|
2021-03-09 22:52:21 -07:00
|
|
|
s.externalManifests = installer.NewCephManifests(externalSettings)
|
2017-11-21 00:37:46 -05:00
|
|
|
|
2021-03-09 22:52:21 -07:00
|
|
|
// Start the core storage cluster
|
|
|
|
|
s.setupMultiClusterCore()
|
|
|
|
|
s.createPools()
|
2017-11-21 00:37:46 -05:00
|
|
|
|
2021-03-09 22:52:21 -07:00
|
|
|
// Start the external cluster that will connect to the core cluster
|
2020-01-24 14:21:07 +01:00
|
|
|
// create an external cluster
|
2021-03-09 22:52:21 -07:00
|
|
|
s.startExternalCluster()
|
2019-06-17 15:44:33 -06:00
|
|
|
|
|
|
|
|
logger.Infof("finished starting clusters")
|
2017-11-21 00:37:46 -05:00
|
|
|
}
|
|
|
|
|
|
2021-03-09 22:52:21 -07:00
|
|
|
func (s *MultiClusterDeploySuite) AfterTest(suiteName, testName string) {
|
|
|
|
|
s.installer.CollectOperatorLog(suiteName, testName)
|
2017-11-21 00:37:46 -05:00
|
|
|
}
|
|
|
|
|
|
2021-03-09 22:52:21 -07:00
|
|
|
func (s *MultiClusterDeploySuite) createPools() {
|
|
|
|
|
// create a test pool in each cluster so that we get some PGs
|
|
|
|
|
logger.Infof("Creating pool %s", s.poolName)
|
|
|
|
|
err := s.testClient.PoolClient.Create(s.poolName, s.settings.Namespace, 1)
|
|
|
|
|
require.Nil(s.T(), err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *MultiClusterDeploySuite) deletePools() {
|
|
|
|
|
// create a test pool in each cluster so that we get some PGs
|
2021-11-18 15:22:56 -07:00
|
|
|
clusterInfo := client.AdminTestClusterInfo(s.settings.Namespace)
|
2021-03-09 22:52:21 -07:00
|
|
|
if err := s.testClient.PoolClient.DeletePool(s.testClient.BlockClient, clusterInfo, s.poolName); err != nil {
|
|
|
|
|
logger.Errorf("failed to delete pool %q. %v", s.poolName, err)
|
|
|
|
|
} else {
|
|
|
|
|
logger.Infof("deleted pool %q", s.poolName)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *MultiClusterDeploySuite) TearDownSuite() {
|
|
|
|
|
s.deletePools()
|
2021-05-06 12:55:46 -06:00
|
|
|
s.installer.UninstallRookFromMultipleNS(s.externalManifests, s.installer.Manifests)
|
2021-03-09 22:52:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test to make sure all rook components are installed and Running
|
|
|
|
|
func (s *MultiClusterDeploySuite) TestInstallingMultipleRookClusters() {
|
|
|
|
|
// Check if Rook cluster 1 is deployed successfully
|
|
|
|
|
client.RunAllCephCommandsInToolboxPod = s.coreToolbox
|
2022-07-26 15:05:39 -06:00
|
|
|
checkIfRookClusterIsInstalled(&s.Suite, s.k8sh, s.settings.OperatorNamespace, s.settings.Namespace, 1)
|
|
|
|
|
checkIfRookClusterIsHealthy(&s.Suite, s.testClient, s.settings.Namespace)
|
2021-03-09 22:52:21 -07:00
|
|
|
|
|
|
|
|
// Check if Rook external cluster is deployed successfully
|
|
|
|
|
// Checking health status is enough to validate the connection
|
|
|
|
|
client.RunAllCephCommandsInToolboxPod = s.externalToolbox
|
2022-07-26 15:05:39 -06:00
|
|
|
checkIfRookClusterIsHealthy(&s.Suite, s.testClient, s.externalManifests.Settings().Namespace)
|
2021-03-09 22:52:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Setup is wrapper for setting up multiple rook clusters.
|
|
|
|
|
func (s *MultiClusterDeploySuite) setupMultiClusterCore() {
|
|
|
|
|
root, err := utils.FindRookRoot()
|
|
|
|
|
require.NoError(s.T(), err, "failed to get rook root")
|
|
|
|
|
cmdArgs := utils.CommandArgs{Command: filepath.Join(root, localPathPVCmd),
|
|
|
|
|
CmdArgs: []string{installer.TestScratchDevice()}}
|
|
|
|
|
cmdOut := utils.ExecuteCommand(cmdArgs)
|
|
|
|
|
require.NoError(s.T(), cmdOut.Err)
|
|
|
|
|
|
2021-09-16 17:48:29 -06:00
|
|
|
s.installer, s.k8sh = StartTestCluster(s.T, s.settings)
|
2021-03-09 22:52:21 -07:00
|
|
|
s.testClient = clients.CreateTestClient(s.k8sh, s.installer.Manifests)
|
|
|
|
|
s.coreToolbox = client.RunAllCephCommandsInToolboxPod
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *MultiClusterDeploySuite) startExternalCluster() {
|
|
|
|
|
err := s.installer.CreateRookExternalCluster(s.externalManifests)
|
2019-07-22 13:13:18 -06:00
|
|
|
if err != nil {
|
2021-03-09 22:52:21 -07:00
|
|
|
s.T().Fail()
|
|
|
|
|
s.installer.GatherAllRookLogs(s.T().Name(), s.externalManifests.Settings().Namespace)
|
|
|
|
|
require.NoError(s.T(), err)
|
2017-11-21 00:37:46 -05:00
|
|
|
}
|
|
|
|
|
|
2021-03-09 22:52:21 -07:00
|
|
|
s.externalToolbox = client.RunAllCephCommandsInToolboxPod
|
|
|
|
|
logger.Infof("succeeded starting external cluster %s", s.externalManifests.Settings().Namespace)
|
2020-01-24 14:21:07 +01:00
|
|
|
}
|