From 9ff075351487b5a20ad3c7073f9b99c6df4cb030 Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Tue, 21 Sep 2021 17:23:24 -0600 Subject: [PATCH] test: run all integration tests against the local build The integration tests must always be run against the local build of rook, and an image should never be pulled from dockerhub. To prevent pulling a release or master tag, the local build will use a tag specific to the build and not ever published elsewhere. Signed-off-by: Travis Nielsen (cherry picked from commit a8a40428b05a20a57c171547f1a1c46a5b75f741) --- tests/framework/installer/ceph_helm_installer.go | 2 +- tests/framework/installer/ceph_installer.go | 10 +++++----- tests/framework/installer/ceph_manifests.go | 2 +- tests/framework/installer/installer.go | 4 ++-- tests/framework/installer/settings.go | 5 ++++- tests/integration/ceph_flex_test.go | 2 +- tests/integration/ceph_helm_test.go | 2 +- tests/integration/ceph_mgr_test.go | 4 ++-- tests/integration/ceph_multi_cluster_test.go | 2 +- tests/integration/ceph_object_test.go | 2 +- tests/integration/ceph_smoke_test.go | 2 +- tests/integration/ceph_upgrade_test.go | 8 ++++---- tests/scripts/github-action-helper.sh | 2 +- 13 files changed, 25 insertions(+), 22 deletions(-) diff --git a/tests/framework/installer/ceph_helm_installer.go b/tests/framework/installer/ceph_helm_installer.go index 234c225ea842..ec0fa60c46df 100644 --- a/tests/framework/installer/ceph_helm_installer.go +++ b/tests/framework/installer/ceph_helm_installer.go @@ -77,7 +77,7 @@ func (h *CephInstaller) CreateRookCephClusterViaHelm(values map[string]interface values["configOverride"] = clusterCustomSettings values["toolbox"] = map[string]interface{}{ "enabled": true, - "image": "rook/ceph:master", + "image": "rook/ceph:" + LocalBuildTag, } values["cephClusterSpec"] = clusterCRD["spec"] diff --git a/tests/framework/installer/ceph_installer.go b/tests/framework/installer/ceph_installer.go index c143edc24c8d..6fef6d02f91e 100644 --- a/tests/framework/installer/ceph_installer.go +++ b/tests/framework/installer/ceph_installer.go @@ -448,7 +448,7 @@ func (h *CephInstaller) installRookOperator() (bool, error) { startDiscovery = true err := h.CreateRookOperatorViaHelm(map[string]interface{}{ "enableDiscoveryDaemon": true, - "image": map[string]interface{}{"tag": "master"}, + "image": map[string]interface{}{"tag": LocalBuildTag}, }) if err != nil { return false, errors.Wrap(err, "failed to configure helm") @@ -479,7 +479,7 @@ func (h *CephInstaller) installRookOperator() (bool, error) { } func (h *CephInstaller) InstallRook() (bool, error) { - if h.settings.RookVersion != VersionMaster { + if h.settings.RookVersion != LocalBuildTag { // make sure we have the images from a previous release locally so the test doesn't hit a timeout assert.NoError(h.T(), h.k8shelper.GetDockerImage("rook/ceph:"+h.settings.RookVersion)) } @@ -499,7 +499,7 @@ func (h *CephInstaller) InstallRook() (bool, error) { if h.settings.UseHelm { err = h.CreateRookCephClusterViaHelm(map[string]interface{}{ - "image": "rook/ceph:master", + "image": "rook/ceph:" + LocalBuildTag, }) if err != nil { return false, errors.Wrap(err, "failed to install ceph cluster using Helm") @@ -901,7 +901,7 @@ spec: restartPolicy: Never containers: - name: rook-cleaner - image: rook/ceph:` + VersionMaster + ` + image: rook/ceph:` + LocalBuildTag + ` securityContext: privileged: true volumeMounts: @@ -931,7 +931,7 @@ spec: restartPolicy: Never containers: - name: rook-cleaner - image: rook/ceph:` + VersionMaster + ` + image: rook/ceph:` + LocalBuildTag + ` securityContext: privileged: true volumeMounts: diff --git a/tests/framework/installer/ceph_manifests.go b/tests/framework/installer/ceph_manifests.go index 4c0704732f3a..5b405230cf89 100644 --- a/tests/framework/installer/ceph_manifests.go +++ b/tests/framework/installer/ceph_manifests.go @@ -56,7 +56,7 @@ type CephManifestsMaster struct { // NewCephManifests gets the manifest type depending on the Rook version desired func NewCephManifests(settings *TestCephSettings) CephManifests { switch settings.RookVersion { - case VersionMaster: + case LocalBuildTag: return &CephManifestsMaster{settings} case Version1_6: return &CephManifestsV1_6{settings} diff --git a/tests/framework/installer/installer.go b/tests/framework/installer/installer.go index 929b10e9097e..719a148a10d0 100644 --- a/tests/framework/installer/installer.go +++ b/tests/framework/installer/installer.go @@ -28,8 +28,8 @@ import ( ) const ( - // VersionMaster tag for the latest manifests - VersionMaster = "master" + // LocalBuildTag tag for the latest manifests + LocalBuildTag = "local-build" // test suite names CassandraTestSuite = "cassandra" diff --git a/tests/framework/installer/settings.go b/tests/framework/installer/settings.go index 033cf957a4f4..7bb7a4c2339f 100644 --- a/tests/framework/installer/settings.go +++ b/tests/framework/installer/settings.go @@ -21,12 +21,15 @@ import ( "io/ioutil" "net/http" "path" + "regexp" "time" "github.com/pkg/errors" "github.com/rook/rook/tests/framework/utils" ) +var imageMatch = regexp.MustCompile(`image: rook\/ceph:[a-z0-9.-]+`) + func readManifest(provider, filename string) string { rootDir, err := utils.FindRookRoot() if err != nil { @@ -38,7 +41,7 @@ func readManifest(provider, filename string) string { if err != nil { panic(errors.Wrapf(err, "failed to read manifest at %s", manifest)) } - return string(contents) + return imageMatch.ReplaceAllString(string(contents), "image: rook/ceph:"+LocalBuildTag) } func readManifestFromGithub(rookVersion, provider, filename string) string { diff --git a/tests/integration/ceph_flex_test.go b/tests/integration/ceph_flex_test.go index d41c1934bc31..3949264cd489 100644 --- a/tests/integration/ceph_flex_test.go +++ b/tests/integration/ceph_flex_test.go @@ -94,7 +94,7 @@ func (s *CephFlexDriverSuite) SetupSuite() { SkipOSDCreation: false, UseCSI: false, DirectMountToolbox: true, - RookVersion: installer.VersionMaster, + RookVersion: installer.LocalBuildTag, CephVersion: installer.OctopusVersion, } s.settings.ApplyEnvVars() diff --git a/tests/integration/ceph_helm_test.go b/tests/integration/ceph_helm_test.go index 46e7fee64032..9fdccf62a390 100644 --- a/tests/integration/ceph_helm_test.go +++ b/tests/integration/ceph_helm_test.go @@ -73,7 +73,7 @@ func (h *HelmSuite) SetupSuite() { SkipOSDCreation: false, EnableAdmissionController: false, EnableDiscovery: true, - RookVersion: installer.VersionMaster, + RookVersion: installer.LocalBuildTag, CephVersion: installer.OctopusVersion, } h.settings.ApplyEnvVars() diff --git a/tests/integration/ceph_mgr_test.go b/tests/integration/ceph_mgr_test.go index 1ae55807fbca..e7c1baebb3f6 100644 --- a/tests/integration/ceph_mgr_test.go +++ b/tests/integration/ceph_mgr_test.go @@ -95,7 +95,7 @@ func (s *CephMgrSuite) SetupSuite() { UseCSI: true, SkipOSDCreation: true, EnableDiscovery: true, - RookVersion: installer.VersionMaster, + RookVersion: installer.LocalBuildTag, CephVersion: installer.MasterVersion, } s.settings.ApplyEnvVars() @@ -224,7 +224,7 @@ func (s *CephMgrSuite) TestStatus() { assert.Equal(s.T(), status, "Backend: rook\nAvailable: Yes") } -func logBytesInfo(bytesSlice []byte){ +func logBytesInfo(bytesSlice []byte) { logger.Infof("---- bytes slice info ---") logger.Infof("bytes: %v\n", bytesSlice) logger.Infof("length: %d\n", len(bytesSlice)) diff --git a/tests/integration/ceph_multi_cluster_test.go b/tests/integration/ceph_multi_cluster_test.go index 9879b8c53000..aa1676e2626e 100644 --- a/tests/integration/ceph_multi_cluster_test.go +++ b/tests/integration/ceph_multi_cluster_test.go @@ -87,7 +87,7 @@ func (s *MultiClusterDeploySuite) SetupSuite() { UseCSI: true, MultipleMgrs: true, EnableAdmissionController: true, - RookVersion: installer.VersionMaster, + RookVersion: installer.LocalBuildTag, CephVersion: installer.NautilusVersion, } s.settings.ApplyEnvVars() diff --git a/tests/integration/ceph_object_test.go b/tests/integration/ceph_object_test.go index f59eb9853db0..0f06e24f69de 100644 --- a/tests/integration/ceph_object_test.go +++ b/tests/integration/ceph_object_test.go @@ -75,7 +75,7 @@ func (s *ObjectSuite) SetupSuite() { UseCSI: true, EnableAdmissionController: true, UseCrashPruner: true, - RookVersion: installer.VersionMaster, + RookVersion: installer.LocalBuildTag, CephVersion: installer.PacificVersion, } s.settings.ApplyEnvVars() diff --git a/tests/integration/ceph_smoke_test.go b/tests/integration/ceph_smoke_test.go index 6eb47fac8d97..ae91f4af93d2 100644 --- a/tests/integration/ceph_smoke_test.go +++ b/tests/integration/ceph_smoke_test.go @@ -99,7 +99,7 @@ func (s *SmokeSuite) SetupSuite() { UseCSI: true, EnableAdmissionController: true, UseCrashPruner: true, - RookVersion: installer.VersionMaster, + RookVersion: installer.LocalBuildTag, CephVersion: installer.PacificVersion, } s.settings.ApplyEnvVars() diff --git a/tests/integration/ceph_upgrade_test.go b/tests/integration/ceph_upgrade_test.go index beb3aec14532..69aea4124d41 100644 --- a/tests/integration/ceph_upgrade_test.go +++ b/tests/integration/ceph_upgrade_test.go @@ -183,7 +183,7 @@ func (s *UpgradeSuite) TestUpgradeToMaster() { s.gatherLogs(s.settings.OperatorNamespace, "_before_master_upgrade") s.upgradeToMaster() - s.verifyOperatorImage(installer.VersionMaster) + s.verifyOperatorImage(installer.LocalBuildTag) s.verifyRookUpgrade(numOSDs) err = s.installer.WaitForToolbox(s.namespace) assert.NoError(s.T(), err) @@ -359,15 +359,15 @@ func (s *UpgradeSuite) verifyFilesAfterUpgrade(fsName, newFileToWrite, messageFo // verify the upgrade but merely starts the upgrade process. func (s *UpgradeSuite) upgradeToMaster() { // Apply the CRDs for the latest master - s.settings.RookVersion = installer.VersionMaster + s.settings.RookVersion = installer.LocalBuildTag m := installer.NewCephManifests(s.settings) require.NoError(s.T(), s.k8sh.ResourceOperation("apply", m.GetCRDs(s.k8sh))) require.NoError(s.T(), s.k8sh.ResourceOperation("apply", m.GetCommon())) require.NoError(s.T(), - s.k8sh.SetDeploymentVersion(s.settings.OperatorNamespace, operatorContainer, operatorContainer, installer.VersionMaster)) + s.k8sh.SetDeploymentVersion(s.settings.OperatorNamespace, operatorContainer, operatorContainer, installer.LocalBuildTag)) require.NoError(s.T(), - s.k8sh.SetDeploymentVersion(s.settings.Namespace, "rook-ceph-tools", "rook-ceph-tools", installer.VersionMaster)) + s.k8sh.SetDeploymentVersion(s.settings.Namespace, "rook-ceph-tools", "rook-ceph-tools", installer.LocalBuildTag)) } diff --git a/tests/scripts/github-action-helper.sh b/tests/scripts/github-action-helper.sh index 83a2e5a60dc8..b3dedaa2bc6a 100755 --- a/tests/scripts/github-action-helper.sh +++ b/tests/scripts/github-action-helper.sh @@ -121,7 +121,7 @@ function build_rook() { tests/scripts/validate_modified_files.sh build docker images if [[ "$build_type" == "build" ]]; then - docker tag "$(docker images | awk '/build-/ {print $1}')" rook/ceph:master + docker tag "$(docker images | awk '/build-/ {print $1}')" rook/ceph:local-build fi }