From e96009c26dab8d06e6d3e45efe55b9783028b359 Mon Sep 17 00:00:00 2001 From: Satoru Takeuchi Date: Wed, 13 May 2020 06:14:57 +0900 Subject: [PATCH] ceph: prepare PVCs for OSD on PVC test inside the integration test The PVCs for OSD on PVC test is prepared before running the integration test. In addition, users are forced to run this script for this by themselves. To avoid this problem, running this script inside the integration test. Signed-off-by: Satoru Takeuchi --- Jenkinsfile | 3 +-- tests/framework/installer/ceph_installer.go | 6 +----- tests/framework/installer/environment.go | 5 +++++ tests/integration/ceph_multi_cluster_test.go | 10 ++++++++++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 52d64f676..d59dad24c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -198,8 +198,7 @@ def RunIntegrationTest(k, v) { sh "tests/scripts/kubeadm.sh up" sh '''#!/bin/bash export KUBECONFIG=$HOME/admin.conf - tests/scripts/helm.sh up - tests/scripts/localPathPV.sh /dev/xvdc''' + tests/scripts/helm.sh up''' try{ echo "Running full regression" sh '''#!/bin/bash diff --git a/tests/framework/installer/ceph_installer.go b/tests/framework/installer/ceph_installer.go index f92a79f21..01f75aa88 100644 --- a/tests/framework/installer/ceph_installer.go +++ b/tests/framework/installer/ceph_installer.go @@ -802,10 +802,6 @@ func (h *CephInstaller) wipeClusterDisks(namespace string) error { // (non-boot) disks on a node, allowing Ceph to use the disk(s) during its testing. func (h *CephInstaller) GetDiskWipeJob(nodeName, jobName, namespace string) string { // put the wipe job in the cluster namespace so that logs get picked up in failure conditions - scratchDevice := os.Getenv("TEST_SCRATCH_DEVICE") - if scratchDevice == "" { - scratchDevice = "/dev/xvdc" - } return `apiVersion: batch/v1 kind: Job metadata: @@ -869,7 +865,7 @@ spec: done # Wipe the specific disk in the CI that was running in raw mode set +Ee - block=` + scratchDevice + ` + block=` + TestScratchDevice() + ` wipefs --all "$block" dd if=/dev/zero of="$block" bs=1M count=100 oflag=direct,dsync set -Ee diff --git a/tests/framework/installer/environment.go b/tests/framework/installer/environment.go index 6a53353f1..98d902a09 100644 --- a/tests/framework/installer/environment.go +++ b/tests/framework/installer/environment.go @@ -55,6 +55,11 @@ func baseTestDir() string { return val } +// TestScratchDevice get the scratch device to be used for OSD +func TestScratchDevice() string { + return getEnvVarWithDefault("TEST_SCRATCH_DEVICE", "/dev/xvdc") +} + func getEnvVarWithDefault(env, defaultValue string) string { val := os.Getenv(env) if val == "" { diff --git a/tests/integration/ceph_multi_cluster_test.go b/tests/integration/ceph_multi_cluster_test.go index 13512d556..9c6a0f9d8 100644 --- a/tests/integration/ceph_multi_cluster_test.go +++ b/tests/integration/ceph_multi_cluster_test.go @@ -29,6 +29,10 @@ import ( "github.com/stretchr/testify/suite" ) +const ( + localPathPVCmd = "tests/scripts/localPathPV.sh" +) + // ************************************************************* // *** Major scenarios tested by the MultiClusterDeploySuite *** // Setup @@ -150,6 +154,12 @@ func NewMCTestOperations(t func() *testing.T, namespace1 string, namespace2 stri // SetUpRook is wrapper for setting up multiple rook clusters. func (o MCTestOperations) Setup() { var err error + if o.testOverPVC { + cmdArgs := utils.CommandArgs{Command: localPathPVCmd, CmdArgs: []string{installer.TestScratchDevice()}} + cmdOut := utils.ExecuteCommand(cmdArgs) + require.NoError(o.T(), cmdOut.Err) + } + err = o.installer.CreateCephOperator(installer.SystemNamespace(o.namespace1)) require.NoError(o.T(), err)