Skip to content

Commit a49e621

Browse files
committed
CSPL-3775 Making some improvements
1 parent 64cf023 commit a49e621

15 files changed

Lines changed: 235 additions & 270 deletions

test/monitoring_console/monitoring_console_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
. "github.com/onsi/ginkgo/v2"
2121
. "github.com/onsi/gomega"
22+
"sigs.k8s.io/controller-runtime/pkg/client"
2223

2324
enterpriseApiV3 "github.com/splunk/splunk-operator/api/v3"
2425
enterpriseApi "github.com/splunk/splunk-operator/api/v4"
@@ -39,7 +40,7 @@ var masterManagerMCConfigs = []testenv.MCVersionConfig{
3940
DeployM4WithMC: func(ctx context.Context, d *testenv.Deployment, name string, replicas int, siteCount int, mcRef string, shc bool) error {
4041
return d.DeployMultisiteClusterMasterWithMonitoringConsole(ctx, name, replicas, siteCount, mcRef, shc)
4142
},
42-
NewCMObject: func() interface{} { return &enterpriseApiV3.ClusterMaster{} },
43+
NewCMObject: func() client.Object { return &enterpriseApiV3.ClusterMaster{} },
4344
VerifyCMReady: func(ctx context.Context, d *testenv.Deployment, te *testenv.TestCaseEnv) error {
4445
return te.VerifyClusterMasterReady(ctx, d)
4546
},
@@ -56,7 +57,7 @@ var masterManagerMCConfigs = []testenv.MCVersionConfig{
5657
DeployM4WithMC: func(ctx context.Context, d *testenv.Deployment, name string, replicas int, siteCount int, mcRef string, shc bool) error {
5758
return d.DeployMultisiteClusterWithMonitoringConsole(ctx, name, replicas, siteCount, mcRef, shc)
5859
},
59-
NewCMObject: func() interface{} { return &enterpriseApi.ClusterManager{} },
60+
NewCMObject: func() client.Object { return &enterpriseApi.ClusterManager{} },
6061
VerifyCMReady: func(ctx context.Context, d *testenv.Deployment, te *testenv.TestCaseEnv) error {
6162
return te.VerifyClusterManagerReady(ctx, d)
6263
},

test/smartstore/smartstore_test_shared.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
// RunS1MultipleIndexesTest runs the standard S1 multiple indexes SmartStore test workflow
2929
func RunS1MultipleIndexesTest(ctx context.Context, deployment *testenv.Deployment, testcaseEnvInst *testenv.TestCaseEnv, waitTimeout time.Duration) {
3030
volName := "test-volume-" + testenv.RandomDNSName(3)
31+
// Each key is unique at runtime because RandomDNSName generates distinct suffixes.
3132
indexVolumeMap := map[string]string{
3233
"test-index-" + testenv.RandomDNSName(3): volName,
3334
"test-index-" + testenv.RandomDNSName(3): volName,
@@ -128,19 +129,19 @@ func RunS1DefaultVolumesTest(ctx context.Context, deployment *testenv.Deployment
128129
serverConfPath := "/opt/splunk/etc/apps/splunk-operator/local/server.conf"
129130

130131
// Validate MaxCacheSizeMB
131-
Expect(testcaseEnvInst.VerifyConfOnPod(podName, serverConfPath, "max_cache_size", fmt.Sprint(cacheManagerSmartStoreSpec.MaxCacheSizeMB))).To(Succeed(), "MaxCacheSizeMB mismatch")
132+
Expect(testcaseEnvInst.VerifyConfOnPod(ctx, podName, serverConfPath, "max_cache_size", fmt.Sprint(cacheManagerSmartStoreSpec.MaxCacheSizeMB))).To(Succeed(), "MaxCacheSizeMB mismatch")
132133

133134
// Validate EvictionPaddingSizeMB
134-
Expect(testcaseEnvInst.VerifyConfOnPod(podName, serverConfPath, "eviction_padding", fmt.Sprint(cacheManagerSmartStoreSpec.EvictionPaddingSizeMB))).To(Succeed(), "EvictionPaddingSizeMB mismatch")
135+
Expect(testcaseEnvInst.VerifyConfOnPod(ctx, podName, serverConfPath, "eviction_padding", fmt.Sprint(cacheManagerSmartStoreSpec.EvictionPaddingSizeMB))).To(Succeed(), "EvictionPaddingSizeMB mismatch")
135136

136137
// Validate MaxConcurrentDownloads
137-
Expect(testcaseEnvInst.VerifyConfOnPod(podName, serverConfPath, "max_concurrent_downloads", fmt.Sprint(cacheManagerSmartStoreSpec.MaxConcurrentDownloads))).To(Succeed(), "MaxConcurrentDownloads mismatch")
138+
Expect(testcaseEnvInst.VerifyConfOnPod(ctx, podName, serverConfPath, "max_concurrent_downloads", fmt.Sprint(cacheManagerSmartStoreSpec.MaxConcurrentDownloads))).To(Succeed(), "MaxConcurrentDownloads mismatch")
138139

139140
// Validate MaxConcurrentUploads
140-
Expect(testcaseEnvInst.VerifyConfOnPod(podName, serverConfPath, "max_concurrent_uploads", fmt.Sprint(cacheManagerSmartStoreSpec.MaxConcurrentUploads))).To(Succeed(), "MaxConcurrentUploads mismatch")
141+
Expect(testcaseEnvInst.VerifyConfOnPod(ctx, podName, serverConfPath, "max_concurrent_uploads", fmt.Sprint(cacheManagerSmartStoreSpec.MaxConcurrentUploads))).To(Succeed(), "MaxConcurrentUploads mismatch")
141142

142143
// Validate EvictionPolicy
143-
Expect(testcaseEnvInst.VerifyConfOnPod(podName, serverConfPath, "eviction_policy", cacheManagerSmartStoreSpec.EvictionPolicy)).To(Succeed(), "EvictionPolicy mismatch")
144+
Expect(testcaseEnvInst.VerifyConfOnPod(ctx, podName, serverConfPath, "eviction_policy", cacheManagerSmartStoreSpec.EvictionPolicy)).To(Succeed(), "EvictionPolicy mismatch")
144145
}
145146

146147
// RunS1EphemeralStorageTest deploys a Standalone with one ephemeral storage volume configured and verifies it is ready.

test/testenv/appframework_utils.go

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,9 @@ func (testenv *TestCaseEnv) VerifyAppFrameworkState(ctx context.Context, deploym
490490
verifyCtx, cancel := context.WithTimeout(ctx, deployment.GetTimeout())
491491
defer cancel()
492492

493-
testenv.VerifyAppListPhase(verifyCtx, deployment, as.CrName, as.CrKind, as.CrAppSourceName, p, as.CrAppFileList)
493+
if err := testenv.VerifyAppListPhase(verifyCtx, deployment, as.CrName, as.CrKind, as.CrAppSourceName, p, as.CrAppFileList); err != nil {
494+
errChan <- fmt.Errorf("phase %v verification failed for CR %s/%s: %w", p, as.CrKind, as.CrName, err)
495+
}
494496
}(appSourceItem, phase)
495497
}
496498
}
@@ -515,7 +517,9 @@ func (testenv *TestCaseEnv) VerifyAppFrameworkState(ctx context.Context, deploym
515517
for _, appSource := range appSource {
516518
testenv.Log.Info(fmt.Sprintf("Verify apps %s packages are deleted from the operator pod for CR %v with name %v", appSource.CrAppVersion, appSource.CrKind, appSource.CrName))
517519
opPath := filepath.Join(splcommon.AppDownloadVolume, "downloadedApps", testenv.GetName(), appSource.CrKind, deployment.GetName(), appSource.CrAppScope, appSource.CrAppSourceName)
518-
testenv.VerifyAppsPackageDeletedOnOperatorContainer(ctx, deployment, []string{opPod}, appSource.CrAppFileList, opPath)
520+
if err := testenv.VerifyAppsPackageDeletedOnOperatorContainer(ctx, deployment, []string{opPod}, appSource.CrAppFileList, opPath); err != nil {
521+
return "", fmt.Errorf("apps packages not deleted from operator pod for CR %s/%s: %w", appSource.CrKind, appSource.CrName, err)
522+
}
519523
}
520524

521525
// Verify apps 'install' state for all CRs IN PARALLEL
@@ -537,7 +541,9 @@ func (testenv *TestCaseEnv) VerifyAppFrameworkState(ctx context.Context, deploym
537541
verifyCtx, cancel := context.WithTimeout(ctx, deployment.GetTimeout())
538542
defer cancel()
539543

540-
testenv.VerifyAppListPhase(verifyCtx, deployment, as.CrName, as.CrKind, as.CrAppSourceName, enterpriseApi.PhaseInstall, as.CrAppFileList)
544+
if err := testenv.VerifyAppListPhase(verifyCtx, deployment, as.CrName, as.CrKind, as.CrAppSourceName, enterpriseApi.PhaseInstall, as.CrAppFileList); err != nil {
545+
errChan <- fmt.Errorf("install phase verification failed for CR %s/%s: %w", as.CrKind, as.CrName, err)
546+
}
541547
}(appSourceItem)
542548
}
543549

@@ -561,34 +567,46 @@ func (testenv *TestCaseEnv) VerifyAppFrameworkState(ctx context.Context, deploym
561567
podDownloadPath := AppStagingLocOnPod + appSource.CrAppSourceVolumeName
562568
pod := appSource.CrPod
563569
testenv.Log.Info(fmt.Sprintf("Verify %s apps packages are deleted on pod %s", appSource.CrAppVersion, pod))
564-
testenv.VerifyAppsPackageDeletedOnContainer(ctx, deployment, pod, appSource.CrAppFileList, podDownloadPath)
570+
if err := testenv.VerifyAppsPackageDeletedOnContainer(ctx, deployment, pod, appSource.CrAppFileList, podDownloadPath); err != nil {
571+
return "", fmt.Errorf("apps packages not deleted on pod %s for CR %s/%s: %w", pod, appSource.CrKind, appSource.CrName, err)
572+
}
565573
}
566574

567575
// Verify bundle push status
568576
for _, appSource := range appSource {
569577
if (appSource.CrKind == "ClusterManager" || appSource.CrKind == "ClusterMaster") && appSource.CrAppScope == enterpriseApi.ScopeCluster {
570578
testenv.Log.Info(fmt.Sprintf("Verify Cluster Manager bundle push status (%s apps) and compare bundle hash with previous bundle hash", appSource.CrAppVersion))
571-
testenv.VerifyClusterManagerBundlePush(ctx, deployment, appSource.CrReplicas, clusterManagerBundleHash)
579+
if err := testenv.VerifyClusterManagerBundlePush(ctx, deployment, appSource.CrReplicas, clusterManagerBundleHash); err != nil {
580+
return "", fmt.Errorf("cluster manager bundle push verification failed: %w", err)
581+
}
572582
if clusterManagerBundleHash == "" {
573583
clusterManagerBundleHash = GetClusterManagerBundleHash(ctx, deployment, appSource.CrKind)
574584
}
575585
}
576586
if appSource.CrKind == "SearchHeadCluster" && appSource.CrAppScope == enterpriseApi.ScopeCluster {
577587
testenv.Log.Info(fmt.Sprintf("Verify Deployer bundle push status (%s apps)", appSource.CrAppVersion))
578-
testenv.VerifyDeployerBundlePush(ctx, deployment, testenv.GetName(), appSource.CrReplicas)
588+
if err := testenv.VerifyDeployerBundlePush(ctx, deployment, testenv.GetName(), appSource.CrReplicas); err != nil {
589+
return "", fmt.Errorf("deployer bundle push verification failed: %w", err)
590+
}
579591
}
580592
}
581593

582594
// Verify apps are copied to correct location on all CRs
583595
for _, appSource := range appSource {
584596
if appSource.CrAppScope == enterpriseApi.ScopeLocal {
585597
testenv.Log.Info(fmt.Sprintf("Verify %s apps with 'local' scope are copied to /etc/apps/ for CR %s with name %s", appSource.CrAppVersion, appSource.CrKind, appSource.CrName))
586-
testenv.VerifyAppsCopied(ctx, deployment, appSource.CrPod, appSource.CrAppList, true, appSource.CrAppScope)
598+
if err := testenv.VerifyAppsCopied(ctx, deployment, appSource.CrPod, appSource.CrAppList, true, appSource.CrAppScope); err != nil {
599+
return "", fmt.Errorf("local apps not copied for CR %s/%s: %w", appSource.CrKind, appSource.CrName, err)
600+
}
587601
} else {
588602
testenv.Log.Info(fmt.Sprintf("Verify %s apps with 'cluster' scope are NOT copied to /etc/apps/ on %v pod", appSource.CrAppVersion, appSource.CrPod))
589-
testenv.VerifyAppsCopied(ctx, deployment, appSource.CrPod, appSource.CrAppList, false, appSource.CrAppScope)
603+
if err := testenv.VerifyAppsCopied(ctx, deployment, appSource.CrPod, appSource.CrAppList, false, appSource.CrAppScope); err != nil {
604+
return "", fmt.Errorf("cluster apps unexpectedly copied to CR pod for %s/%s: %w", appSource.CrKind, appSource.CrName, err)
605+
}
590606
testenv.Log.Info(fmt.Sprintf("Verify %s apps with 'cluster' scope are copied on %v pods", appSource.CrAppVersion, appSource.CrClusterPods))
591-
testenv.VerifyAppsCopied(ctx, deployment, appSource.CrClusterPods, appSource.CrAppList, true, appSource.CrAppScope)
607+
if err := testenv.VerifyAppsCopied(ctx, deployment, appSource.CrClusterPods, appSource.CrAppList, true, appSource.CrAppScope); err != nil {
608+
return "", fmt.Errorf("cluster apps not copied to cluster pods for %s/%s: %w", appSource.CrKind, appSource.CrName, err)
609+
}
592610
}
593611
}
594612

@@ -598,11 +616,15 @@ func (testenv *TestCaseEnv) VerifyAppFrameworkState(ctx context.Context, deploym
598616
checkUpdated := appSource.CrAppVersion == "V2"
599617
if appSource.CrAppScope == "local" {
600618
testenv.Log.Info(fmt.Sprintf("Verify %s apps with 'local' scope for CR %s with name %s are installed on pod %s", appSource.CrAppVersion, appSource.CrKind, appSource.CrName, allPodNames))
601-
testenv.VerifyAppInstalled(ctx, deployment, testenv.GetName(), allPodNames, appSource.CrAppList, true, "enabled", checkUpdated, false)
619+
if err := testenv.VerifyAppInstalled(ctx, deployment, testenv.GetName(), allPodNames, appSource.CrAppList, true, "enabled", checkUpdated, false); err != nil {
620+
return "", fmt.Errorf("local apps not installed for CR %s/%s: %w", appSource.CrKind, appSource.CrName, err)
621+
}
602622
} else {
603623
allPodNames = appSource.CrClusterPods
604624
testenv.Log.Info(fmt.Sprintf("Verify %s apps with 'cluster' scope for CR %s with name %s are installed on pods %s", appSource.CrAppVersion, appSource.CrKind, appSource.CrName, allPodNames))
605-
testenv.VerifyAppInstalled(ctx, deployment, testenv.GetName(), allPodNames, appSource.CrAppList, true, "enabled", checkUpdated, true)
625+
if err := testenv.VerifyAppInstalled(ctx, deployment, testenv.GetName(), allPodNames, appSource.CrAppList, true, "enabled", checkUpdated, true); err != nil {
626+
return "", fmt.Errorf("cluster apps not installed for CR %s/%s: %w", appSource.CrKind, appSource.CrName, err)
627+
}
606628
}
607629
}
608630
return clusterManagerBundleHash, nil

test/testenv/assertion_helpers.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
enterpriseApiV3 "github.com/splunk/splunk-operator/api/v3"
2222
enterpriseApi "github.com/splunk/splunk-operator/api/v4"
2323
corev1 "k8s.io/api/core/v1"
24+
"sigs.k8s.io/controller-runtime/pkg/client"
2425
)
2526

2627
// ScaleSearchHeadCluster scales a Search Head Cluster to the specified replica count
@@ -64,7 +65,7 @@ func (testcaseenv *TestCaseEnv) ScaleIndexerCluster(ctx context.Context, deploym
6465
}
6566

6667
// UpdateMonitoringConsoleRefAndVerify updates the MonitoringConsoleRef in a CR and waits for the change to apply
67-
func (testcaseenv *TestCaseEnv) UpdateMonitoringConsoleRefAndVerify(ctx context.Context, deployment *Deployment, obj interface{}, instanceName string, newMCName string) error {
68+
func (testcaseenv *TestCaseEnv) UpdateMonitoringConsoleRefAndVerify(ctx context.Context, deployment *Deployment, obj client.Object, instanceName string, newMCName string) error {
6869
// Get current resource version before update
6970
resourceVersion := testcaseenv.GetResourceVersion(ctx, deployment, obj)
7071

@@ -157,17 +158,11 @@ func (testcaseenv *TestCaseEnv) VerifyM1ClusterReady(ctx context.Context, deploy
157158
}
158159

159160
// VerifyM4ClusterReady verifies the cluster coordinator, indexers, multisite status, and SHC are ready.
161+
// It delegates to VerifyM4ComponentsReady, adapting the callback signature.
160162
func (testcaseenv *TestCaseEnv) VerifyM4ClusterReady(ctx context.Context, deployment *Deployment, siteCount int, verifyCoordinator func(context.Context, *Deployment) error) error {
161-
if err := verifyCoordinator(ctx, deployment); err != nil {
162-
return err
163-
}
164-
if err := testcaseenv.VerifyIndexersReady(ctx, deployment, siteCount); err != nil {
165-
return err
166-
}
167-
if err := testcaseenv.VerifyIndexerClusterMultisiteStatus(ctx, deployment, siteCount); err != nil {
168-
return err
169-
}
170-
return testcaseenv.VerifySearchHeadClusterReady(ctx, deployment)
163+
return testcaseenv.VerifyM4ComponentsReady(ctx, deployment, siteCount, func() error {
164+
return verifyCoordinator(ctx, deployment)
165+
})
171166
}
172167

173168
// VerifyM4IndexersAndSHCReady verifies the cluster coordinator, indexers, and SHC are ready (without multisite check).

test/testenv/cmutil.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type ClusterManagerSitesResponse struct {
3333
Entries []ClusterManagerSitesEntry `json:"entry"`
3434
}
3535

36-
// ClusterManagerSitesEntry represents a site of an indexer cluster with its metadata
36+
// ClusterManagerSitesEntry represents a site of an Indexer Cluster with its metadata
3737
type ClusterManagerSitesEntry struct {
3838
Name string `json:"name"`
3939
Content ClusterManagerSitesContent `json:"content"`
@@ -55,7 +55,7 @@ type ClusterManagerHealthResponse struct {
5555
Entries []ClusterManagerHealthEntry `json:"entry"`
5656
}
5757

58-
// ClusterManagerHealthEntry represents a site of an indexer cluster with its metadata
58+
// ClusterManagerHealthEntry represents a site of an Indexer Cluster with its metadata
5959
type ClusterManagerHealthEntry struct {
6060
Name string `json:"name"`
6161
Content ClusterManagerHealthContent `json:"content"`
@@ -129,7 +129,7 @@ type ClusterManagerPeersAndSearchHeadResponse struct {
129129
} `json:"entry"`
130130
}
131131

132-
// GetIndexersOrSearchHeadsOnCM get indexers or search head on Cluster Manager
132+
// GetIndexersOrSearchHeadsOnCM gets Indexers or Search Heads on Cluster Manager
133133
func GetIndexersOrSearchHeadsOnCM(ctx context.Context, deployment *Deployment, endpoint string) ClusterManagerPeersAndSearchHeadResponse {
134134
url := ""
135135
if endpoint == "sh" {
@@ -154,7 +154,7 @@ func GetIndexersOrSearchHeadsOnCM(ctx context.Context, deployment *Deployment, e
154154
return restResponse
155155
}
156156

157-
// CheckIndexerOnCM check given Indexer on cluster manager
157+
// CheckIndexerOnCM checks given Indexer on Cluster Manager
158158
func CheckIndexerOnCM(ctx context.Context, deployment *Deployment, indexerName string) bool {
159159
restResponse := GetIndexersOrSearchHeadsOnCM(ctx, deployment, "peer")
160160
found := false
@@ -168,7 +168,7 @@ func CheckIndexerOnCM(ctx context.Context, deployment *Deployment, indexerName s
168168
return found
169169
}
170170

171-
// CheckSearchHeadOnCM check given search head on cluster manager
171+
// CheckSearchHeadOnCM checks given Search Head on Cluster Manager
172172
func CheckSearchHeadOnCM(ctx context.Context, deployment *Deployment, searchHeadName string) bool {
173173
restResponse := GetIndexersOrSearchHeadsOnCM(ctx, deployment, "sh")
174174
found := false
@@ -182,7 +182,7 @@ func CheckSearchHeadOnCM(ctx context.Context, deployment *Deployment, searchHead
182182
return found
183183
}
184184

185-
// CheckSearchHeadRemoved check if search head is removed from Indexer Cluster
185+
// CheckSearchHeadRemoved checks if Search Head is removed from Indexer Cluster
186186
func CheckSearchHeadRemoved(ctx context.Context, deployment *Deployment) bool {
187187
restResponse := GetIndexersOrSearchHeadsOnCM(ctx, deployment, "sh")
188188
searchHeadRemoved := true

test/testenv/common_test_patterns.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ type ClusterReadinessConfig struct {
162162
// function that returns the appropriate ClusterReadinessConfig.
163163
// This is the standard config type shared by test packages that loop over
164164
// V3 (master) and V4 (manager) variants.
165+
// See also MasterManagerLMTestConfig (in lmutil.go) for the license-manager
166+
// equivalent that returns *LicenseTestConfig instead.
165167
type MasterManagerTestConfig struct {
166168
NamePrefix string
167169
Label string

test/testenv/cr_update_helpers.go

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)