Skip to content

Commit

Permalink
PWX-32409: Adding Upgrade test
Browse files Browse the repository at this point in the history
    This test case verifies that btrfs  datastores stays on upgrade on a
    testbed that qualifies for dmthin.
    TestStorageClusterDMthinUpgrade upgrades PX to 3.1 from 3.0 and 2.13
    over two iterations. It'll also verify that btrfs was installed.

Signed-off-by: Naveen Revanna <nrevanna@purestorage.com>
  • Loading branch information
nrevanna committed Aug 16, 2023
1 parent 2efec6b commit e56a649
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions test/integration_test/basic_dmthin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import (
"testing"

"github.com/hashicorp/go-version"
"github.com/libopenstorage/operator/drivers/storage/portworx"
corev1 "github.com/libopenstorage/operator/pkg/apis/core/v1"
k8sutil "github.com/libopenstorage/operator/pkg/util/k8s"
"github.com/libopenstorage/operator/test/integration_test/types"
ci_utils "github.com/libopenstorage/operator/test/integration_test/utils"
"github.com/portworx/sched-ops/k8s/operator"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -131,6 +134,38 @@ func generateTestCases(opt OptionsArr, idx uint) map[string]types.TestCase {
return retVal
}

var testDmthinCases = []types.TestCase{
{
TestName: "BasicUpgradeStorageClusterDmthinWithAllComponents",
TestrailCaseIDs: []string{"C50241"},
TestSpec: func(t *testing.T) interface{} {
objects, err := ci_utils.ParseSpecs("storagecluster/storagecluster-with-all-components.yaml")
provider := cloud_provider.GetCloudProvider()
require.NoError(t, err)
cluster, ok := objects[0].(*corev1.StorageCluster)
require.True(t, ok)
cluster.Name = "test-stc"
cluster.Namespace = "kube-system"
cloudSpec := &corev1.CloudStorageSpec{}
cloudSpec.DeviceSpecs = provider.GetDefaultDataDrives()
cloudSpec.SystemMdDeviceSpec = provider.GetDefaultMetadataDrive()
cluster.Spec.CloudStorage = cloudSpec
cluster.Spec.Monitoring.Prometheus.AlertManager.Enabled = false
return cluster
},
ShouldSkip: func(tc *types.TestCase) bool {
if len(ci_utils.PxUpgradeHopsURLList) == 0 {
logrus.Info("--px-upgrade-hops-url-list is empty, cannot run BasicUpgradeStorageClusterDmthinWithAllComponents test")
return true
}
k8sVersion, _ := k8sutil.GetVersion()
pxVersion := ci_utils.GetPxVersionFromSpecGenURL(ci_utils.PxUpgradeHopsURLList[0])
return k8sVersion.GreaterThanOrEqual(k8sutil.K8sVer1_22) && pxVersion.LessThan(pxVer2_9)
},
TestFunc: BasicUpgradeStorageClusterDmthin,
},
}

func TestStorageClusterDmthinWithoutPxStoreV2Option(t *testing.T) {
opt := OptionsArr{}
basicInstallTestCases := generateTestCases(opt, 1)
Expand All @@ -148,6 +183,12 @@ func TestStorageClusterDmthinWithPxStoreV2Option(t *testing.T) {
}
}

func TestStorageClusterDMthinUpgrade(t *testing.T) {
for _, testCase := range testDmthinCases {
testCase.RunTest(t)
}
}

func getTotalNodes(t *testing.T, cluster *corev1.StorageCluster) uint {
allNodes, err := test.GetExpectedPxNodeList(cluster)
require.NoError(t, err, "Could not get expected px node list")
Expand Down Expand Up @@ -290,3 +331,46 @@ func BasicInstallDmthin(tc *types.TestCase) func(*testing.T) {
UninstallPX(t, cluster)
}
}

// PxUpgradeHopsURLList is interpreted differently in this test as compared to the original intent
// Each member of the hop list serves as the base PX version to upgrade from to the latest release version.
func BasicUpgradeStorageClusterDmthin(tc *types.TestCase) func(*testing.T) {
return func(t *testing.T) {
for _, hopURL := range ci_utils.PxUpgradeHopsURLList {
pxVersion := ci_utils.GetPxVersionFromSpecGenURL(ci_utils.PxUpgradeHopsURLList[0])
lessThanOrEqualV3_0_0 := pxVersion.LessThanOrEqual(pxVer3_0_0)
require.True(t, lessThanOrEqualV3_0_0, "Update this test for hop URL > 3.0.0")
// Get versions from URL
specImages, err := test.GetImagesFromVersionURL(hopURL, ci_utils.K8sVersion)
require.NoError(t, err)

logrus.Infof("Installing PX version %v", specImages)
cluster := installAndValidate(t, tc, hopURL, specImages)
pxStoreV2 := isPxStoreV2(t, cluster)
require.False(t, pxStoreV2)

// Get live StorageCluster
cluster, err = operator.Instance().GetStorageCluster(cluster.Name, cluster.Namespace)
require.NoError(t, err)

logrus.Infof("Upgrading PX to %v", ci_utils.PxSpecImages)
err = ci_utils.ConstructStorageCluster(cluster, ci_utils.PxSpecGenURL, ci_utils.PxSpecImages)
require.NoError(t, err)

// Set defaults
k8sVersion, _ := version.NewVersion(ci_utils.K8sVersion)
portworx.SetPortworxDefaults(cluster, k8sVersion)

// Update live StorageCluster
cluster, err = ci_utils.UpdateStorageCluster(cluster)
require.NoError(t, err)
logrus.Infof("Validate upgraded StorageCluster %s", cluster.Name)
err = test.ValidateStorageCluster(ci_utils.PxSpecImages, cluster, ci_utils.DefaultValidateUpgradeTimeout, ci_utils.DefaultValidateUpgradeRetryInterval, true, "")
require.NoError(t, err)

pxStoreV2 = isPxStoreV2(t, cluster)
require.False(t, pxStoreV2)
UninstallPX(t, cluster)
}
}
}

0 comments on commit e56a649

Please sign in to comment.