Skip to content

Commit fc28db0

Browse files
committed
CSPL-3558 Adding additional tests
1 parent c5a97dc commit fc28db0

File tree

7 files changed

+5770
-174
lines changed

7 files changed

+5770
-174
lines changed

helm-chart/splunk-enterprise/templates/enterprise_v4_indexercluster.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: List
44
items:
5-
{{- range default (default (until 1) .Values.sva.c3.indexerClusters) .Values.sva.m4.indexerClusters }}
5+
{{- range default (default (list (dict "name" .Values.indexerCluster.name)) .Values.sva.c3.indexerClusters) .Values.sva.m4.indexerClusters }}
66
- apiVersion: enterprise.splunk.com/v4
77
kind: IndexerCluster
88
metadata:
@@ -147,7 +147,7 @@ items:
147147
{{ toYaml . | indent 6 }}
148148
{{- end }}
149149
{{- end }}
150-
{{- if and ($.Values.sva.m4.enabled) (.zone) }}
150+
{{- if and ($.Values.sva.m4.enabled) (.name) }}
151151
affinity:
152152
nodeAffinity:
153153
requiredDuringSchedulingIgnoredDuringExecution:
@@ -156,7 +156,7 @@ items:
156156
- key: topology.kubernetes.io/zone
157157
operator: In
158158
values:
159-
- {{ .zone }}
159+
- {{ .name }}
160160
{{- else }}
161161
{{- with $.Values.indexerCluster.affinity }}
162162
affinity:

helm-chart/splunk-operator/crds/enterprise.splunk.com_indexerclusters.yaml

Lines changed: 992 additions & 135 deletions
Large diffs are not rendered by default.

helm-chart/splunk-operator/crds/enterprise.splunk.com_ingestorclusters.yaml

Lines changed: 4637 additions & 0 deletions
Large diffs are not rendered by default.

test/index_and_ingestion_separation/index_and_ingestion_separation_test.go

Lines changed: 94 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ import (
1818
"fmt"
1919
"strings"
2020

21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
2123
"github.com/onsi/ginkgo/types"
2224
. "github.com/onsi/ginkgo/v2"
2325
. "github.com/onsi/gomega"
2426

2527
enterpriseApi "github.com/splunk/splunk-operator/api/v4"
28+
"github.com/splunk/splunk-operator/pkg/splunk/enterprise"
2629

2730
"github.com/splunk/splunk-operator/test/testenv"
2831
)
@@ -33,6 +36,8 @@ var _ = Describe("indingsep test", func() {
3336
var deployment *testenv.Deployment
3437

3538
var cmSpec enterpriseApi.ClusterManagerSpec
39+
var s3TestDir string
40+
var appSourceVolumeName string
3641

3742
ctx := context.TODO()
3843

@@ -54,6 +59,8 @@ var _ = Describe("indingsep test", func() {
5459
},
5560
},
5661
}
62+
s3TestDir = "s1appfw-" + testenv.RandomDNSName(4)
63+
appSourceVolumeName = "appframework-test-volume-" + testenv.RandomDNSName(3)
5764
})
5865

5966
AfterEach(func() {
@@ -118,41 +125,93 @@ var _ = Describe("indingsep test", func() {
118125
})
119126
})
120127

121-
// Context("Ingestor and Indexer deployment", func() {
122-
// It("indingsep, smoke, indingsep: Splunk Operator can deploy Ingestors and Indexers with additional configurations", func() {
123-
// // Create Service Account
124-
// testcaseEnvInst.Log.Info("Create Service Account")
125-
// testcaseEnvInst.CreateServiceAccount(serviceAccountName)
126-
127-
// // Deploy Ingestor Cluster
128-
// testcaseEnvInst.Log.Info("Deploy Ingestor Cluster")
129-
// _, err := deployment.DeployIngestorCluster(ctx, deployment.GetName()+"-ingest", 3, bus, pipelineConfig, serviceAccountName)
130-
// Expect(err).To(Succeed(), "Unable to deploy Ingestor Cluster")
131-
132-
// // Deploy Cluster Manager
133-
// testcaseEnvInst.Log.Info("Deploy Cluster Manager")
134-
// _, err = deployment.DeployClusterManagerWithGivenSpec(ctx, deployment.GetName(), cmSpec)
135-
// Expect(err).To(Succeed(), "Unable to deploy Cluster Manager")
136-
137-
// // Deploy Indexer Cluster
138-
// testcaseEnvInst.Log.Info("Deploy Indexer Cluster")
139-
// _, err = deployment.DeployIndexerCluster(ctx, deployment.GetName()+"-idxc", "", 3, deployment.GetName(), "", bus, pipelineConfig, serviceAccountName)
140-
// Expect(err).To(Succeed(), "Unable to deploy Indexer Cluster")
141-
142-
// // Ensure that Ingestor Cluster is in Ready phase
143-
// testcaseEnvInst.Log.Info("Ensure that Ingestor Cluster is in Ready phase")
144-
// testenv.IngestorReady(ctx, deployment, testcaseEnvInst)
145-
146-
// // Ensure that Cluster Manager is in Ready phase
147-
// testcaseEnvInst.Log.Info("Ensure that Cluster Manager is in Ready phase")
148-
// testenv.ClusterManagerReady(ctx, deployment, testcaseEnvInst)
149-
150-
// // Ensure that Indexer Cluster is in Ready phase
151-
// testcaseEnvInst.Log.Info("Ensure that Indexer Cluster is in Ready phase")
152-
// testenv.SingleSiteIndexersReady(ctx, deployment, testcaseEnvInst)
153-
154-
// })
155-
// })
128+
Context("Ingestor and Indexer deployment", func() {
129+
It("indingsep, smoke, indingsep: Splunk Operator can deploy Ingestors and Indexers with additional configurations", func() {
130+
// Create Service Account
131+
testcaseEnvInst.Log.Info("Create Service Account")
132+
testcaseEnvInst.CreateServiceAccount(serviceAccountName)
133+
134+
// Deploy Ingestor Cluster with additional configurations (similar to standalone app framework test)
135+
appSourceName := "appframework-" + enterpriseApi.ScopeLocal + testenv.RandomDNSName(3)
136+
appFrameworkSpec := testenv.GenerateAppFrameworkSpec(ctx, testcaseEnvInst, appSourceVolumeName, enterpriseApi.ScopeLocal, appSourceName, s3TestDir, 60)
137+
appFrameworkSpec.MaxConcurrentAppDownloads = uint64(5)
138+
ic := &enterpriseApi.IngestorCluster{
139+
ObjectMeta: metav1.ObjectMeta{
140+
Name: deployment.GetName() + "-ingest",
141+
Namespace: testcaseEnvInst.GetName(),
142+
},
143+
Spec: enterpriseApi.IngestorClusterSpec{
144+
CommonSplunkSpec: enterpriseApi.CommonSplunkSpec{
145+
ServiceAccount: serviceAccountName,
146+
LivenessInitialDelaySeconds: 600,
147+
ReadinessInitialDelaySeconds: 50,
148+
StartupProbe: &enterpriseApi.Probe{
149+
InitialDelaySeconds: 40,
150+
TimeoutSeconds: 30,
151+
PeriodSeconds: 30,
152+
FailureThreshold: 12,
153+
},
154+
LivenessProbe: &enterpriseApi.Probe{
155+
InitialDelaySeconds: 400,
156+
TimeoutSeconds: 30,
157+
PeriodSeconds: 30,
158+
FailureThreshold: 12,
159+
},
160+
ReadinessProbe: &enterpriseApi.Probe{
161+
InitialDelaySeconds: 20,
162+
TimeoutSeconds: 30,
163+
PeriodSeconds: 30,
164+
FailureThreshold: 12,
165+
},
166+
Spec: enterpriseApi.Spec{
167+
ImagePullPolicy: "Always",
168+
Image: testcaseEnvInst.GetSplunkImage(),
169+
},
170+
},
171+
PushBus: bus,
172+
PipelineConfig: pipelineConfig,
173+
Replicas: 3,
174+
AppFrameworkConfig: appFrameworkSpec,
175+
},
176+
}
177+
178+
testcaseEnvInst.Log.Info("Deploy Ingestor Cluster with additional configurations")
179+
_, err := deployment.DeployIngestorClusterWithAdditionalConfiguration(ctx, ic)
180+
Expect(err).To(Succeed(), "Unable to deploy Ingestor Cluster")
181+
182+
// Ensure that Ingestor Cluster is in Ready phase
183+
testcaseEnvInst.Log.Info("Ensure that Ingestor Cluster is in Ready phase")
184+
testenv.IngestorReady(ctx, deployment, testcaseEnvInst)
185+
186+
// Verify Ingestor Cluster Pods have apps installed
187+
testcaseEnvInst.Log.Info("Verify Ingestor Cluster Pods have apps installed")
188+
ingestorPod := []string{fmt.Sprintf(testenv.IngestorPod, deployment.GetName()+"-ingest", 0)}
189+
ingestorAppSourceInfo := testenv.AppSourceInfo{
190+
CrKind: ic.Kind,
191+
CrName: ic.Name,
192+
CrAppSourceName: appSourceName,
193+
CrPod: ingestorPod,
194+
CrAppVersion: "V1",
195+
CrAppScope: enterpriseApi.ScopeLocal,
196+
CrAppList: testenv.BasicApps,
197+
CrAppFileList: testenv.GetAppFileList(testenv.BasicApps),
198+
CrReplicas: 3,
199+
}
200+
allAppSourceInfo := []testenv.AppSourceInfo{ingestorAppSourceInfo}
201+
splunkPodAge := testenv.GetPodsStartTime(testcaseEnvInst.GetName())
202+
testenv.AppFrameWorkVerifications(ctx, deployment, testcaseEnvInst, allAppSourceInfo, splunkPodAge, "")
203+
204+
// Verify probe configuration
205+
testcaseEnvInst.Log.Info("Get config map for probes")
206+
ConfigMapName := enterprise.GetProbeConfigMapName(testcaseEnvInst.GetName())
207+
_, err = testenv.GetConfigMap(ctx, deployment, testcaseEnvInst.GetName(), ConfigMapName)
208+
Expect(err).To(Succeed(), "Unable to get config map for probes", "ConfigMap", ConfigMapName)
209+
testcaseEnvInst.Log.Info("Verify probe configurations on Ingestor pods")
210+
scriptsNames := []string{enterprise.GetLivenessScriptName(), enterprise.GetReadinessScriptName(), enterprise.GetStartupScriptName()}
211+
allPods := testenv.DumpGetPods(testcaseEnvInst.GetName())
212+
testenv.VerifyFilesInDirectoryOnPod(ctx, deployment, testcaseEnvInst, testcaseEnvInst.GetName(), allPods, scriptsNames, enterprise.GetProbeMountDirectory(), false, true)
213+
})
214+
})
156215

157216
Context("Ingestor and Indexer deployment", func() {
158217
It("indingsep, integration, indingsep: Splunk Operator can deploy Ingestors and Indexers with correct setup", func() {

test/testenv/appframework_utils.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,28 @@ func GetAppDeploymentInfoStandalone(ctx context.Context, deployment *Deployment,
250250
return appDeploymentInfo, err
251251
}
252252

253+
// GetAppDeploymentInfoIngestorCluster returns AppDeploymentInfo for given IngestorCluster, appSourceName and appName
254+
func GetAppDeploymentInfoIngestorCluster(ctx context.Context, deployment *Deployment, testenvInstance *TestCaseEnv, name string, appSourceName string, appName string) (enterpriseApi.AppDeploymentInfo, error) {
255+
ingestor := &enterpriseApi.IngestorCluster{}
256+
appDeploymentInfo := enterpriseApi.AppDeploymentInfo{}
257+
err := deployment.GetInstance(ctx, name, ingestor)
258+
if err != nil {
259+
testenvInstance.Log.Error(err, "Failed to get CR ", "CR Name", name)
260+
return appDeploymentInfo, err
261+
}
262+
appInfoList := ingestor.Status.AppContext.AppsSrcDeployStatus[appSourceName].AppDeploymentInfoList
263+
for _, appInfo := range appInfoList {
264+
testenvInstance.Log.Info("Checking Ingestor AppInfo Struct", "App Name", appName, "App Source", appSourceName, "Ingestor Name", name, "AppDeploymentInfo", appInfo)
265+
if strings.Contains(appName, appInfo.AppName) {
266+
testenvInstance.Log.Info("App Deployment Info found.", "App Name", appName, "App Source", appSourceName, "Ingestor Name", name, "AppDeploymentInfo", appInfo)
267+
appDeploymentInfo = appInfo
268+
return appDeploymentInfo, nil
269+
}
270+
}
271+
testenvInstance.Log.Info("App Info not found in App Info List", "App Name", appName, "App Source", appSourceName, "Ingestor Name", name, "App Info List", appInfoList)
272+
return appDeploymentInfo, err
273+
}
274+
253275
// GetAppDeploymentInfoMonitoringConsole returns AppDeploymentInfo for given Monitoring Console, appSourceName and appName
254276
func GetAppDeploymentInfoMonitoringConsole(ctx context.Context, deployment *Deployment, testenvInstance *TestCaseEnv, name string, appSourceName string, appName string) (enterpriseApi.AppDeploymentInfo, error) {
255277
mc := &enterpriseApi.MonitoringConsole{}
@@ -345,6 +367,8 @@ func GetAppDeploymentInfo(ctx context.Context, deployment *Deployment, testenvIn
345367
switch crKind {
346368
case "Standalone":
347369
appDeploymentInfo, err = GetAppDeploymentInfoStandalone(ctx, deployment, testenvInstance, name, appSourceName, appName)
370+
case "IngestorCluster":
371+
appDeploymentInfo, err = GetAppDeploymentInfoIngestorCluster(ctx, deployment, testenvInstance, name, appSourceName, appName)
348372
case "MonitoringConsole":
349373
appDeploymentInfo, err = GetAppDeploymentInfoMonitoringConsole(ctx, deployment, testenvInstance, name, appSourceName, appName)
350374
case "SearchHeadCluster":

test/testenv/deployment.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,21 @@ func (d *Deployment) DeployIngestorCluster(ctx context.Context, name string, cou
460460
return deployed.(*enterpriseApi.IngestorCluster), err
461461
}
462462

463+
// DeployIngestorClusterWithAdditionalConfiguration deploys the ingestor cluster with additional configuration
464+
func (d *Deployment) DeployIngestorClusterWithAdditionalConfiguration(ctx context.Context, ic *enterpriseApi.IngestorCluster) (*enterpriseApi.IngestorCluster, error) {
465+
d.testenv.Log.Info("Deploying ingestor cluster with additional configuration", "name", ic.Name)
466+
467+
pdata, _ := json.Marshal(ic)
468+
469+
d.testenv.Log.Info("ingestor cluster spec", "cr", string(pdata))
470+
deployed, err := d.deployCR(ctx, ic.Name, ic)
471+
if err != nil {
472+
return nil, err
473+
}
474+
475+
return deployed.(*enterpriseApi.IngestorCluster), err
476+
}
477+
463478
// DeploySearchHeadCluster deploys a search head cluster
464479
func (d *Deployment) DeploySearchHeadCluster(ctx context.Context, name, ClusterManagerRef, LicenseManagerName string, ansibleConfig string, mcRef string) (*enterpriseApi.SearchHeadCluster, error) {
465480
d.testenv.Log.Info("Deploying search head cluster", "name", name)

test/testenv/testenv.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ import (
2020
"fmt"
2121
"net"
2222
"os"
23-
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
2423
"time"
2524

25+
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
26+
2627
enterpriseApiV3 "github.com/splunk/splunk-operator/api/v3"
2728
enterpriseApi "github.com/splunk/splunk-operator/api/v4"
2829

@@ -77,6 +78,9 @@ const (
7778
// LicenseMasterPod Template String for standalone pod
7879
LicenseMasterPod = "splunk-%s-" + splcommon.LicenseManager + "-%d"
7980

81+
// IngestorPod Template String for ingestor pod
82+
IngestorPod = "splunk-%s-ingestor-%d"
83+
8084
// IndexerPod Template String for indexer pod
8185
IndexerPod = "splunk-%s-idxc-indexer-%d"
8286

0 commit comments

Comments
 (0)