Skip to content

Commit c354062

Browse files
committed
CSPL-3558 Adding scenario for update and delete
1 parent 4d3865c commit c354062

File tree

4 files changed

+296
-8
lines changed

4 files changed

+296
-8
lines changed

test/index_and_ingestion_separation/index_and_ingestion_separation_suite_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,58 @@ var (
8989
"AWS_ROLE_ARN=arn:aws:iam::",
9090
"AWS_STS_REGIONAL_ENDPOINTS=regional",
9191
}
92+
93+
updateBus = enterpriseApi.PushBusSpec{
94+
Type: "sqs_smartbus",
95+
SQS: enterpriseApi.SQSSpec{
96+
QueueName: "test-queue-updated",
97+
AuthRegion: "us-west-2",
98+
Endpoint: "https://sqs.us-west-2.amazonaws.com",
99+
LargeMessageStoreEndpoint: "https://s3.us-west-2.amazonaws.com",
100+
LargeMessageStorePath: "s3://test-bucket-updated/smartbus-test",
101+
DeadLetterQueueName: "test-dead-letter-queue-updated",
102+
MaxRetriesPerPart: 5,
103+
RetryPolicy: "max",
104+
SendInterval: "4s",
105+
EncodingFormat: "s2s",
106+
},
107+
}
108+
updatePipelineConfig = enterpriseApi.PipelineConfigSpec{
109+
RemoteQueueRuleset: false,
110+
RuleSet: false,
111+
RemoteQueueTyping: false,
112+
RemoteQueueOutput: false,
113+
Typing: true,
114+
IndexerPipe: true,
115+
}
116+
117+
updatedInputs = []string{
118+
"[remote_queue:test-queue-updated]",
119+
"remote_queue.type = sqs_smartbus",
120+
"remote_queue.sqs_smartbus.auth_region = us-west-2",
121+
"remote_queue.sqs_smartbus.dead_letter_queue.name = test-dead-letter-queue-updated",
122+
"remote_queue.sqs_smartbus.endpoint = https://sqs.us-west-2.amazonaws.com",
123+
"remote_queue.sqs_smartbus.large_message_store.endpoint = https://s3.us-west-2.amazonaws.com",
124+
"remote_queue.sqs_smartbus.large_message_store.path = s3://test-bucket-updated/smartbus-test",
125+
"remote_queue.sqs_smartbus.retry_policy = max",
126+
"remote_queue.max.sqs_smartbus.max_retries_per_part = 5"}
127+
updatedOutputs = append(updatedInputs, "remote_queue.sqs_smartbus.encoding_format = s2s", "remote_queue.sqs_smartbus.send_interval = 4s")
128+
updatedDefaultsAll = []string{
129+
"[pipeline:remotequeueruleset]\ndisabled = false",
130+
"[pipeline:ruleset]\ndisabled = false",
131+
"[pipeline:remotequeuetyping]\ndisabled = false",
132+
"[pipeline:remotequeueoutput]\ndisabled = false",
133+
"[pipeline:typing]\ndisabled = true",
134+
}
135+
updatedDefaultsIngest = append(updatedDefaultsAll, "[pipeline:indexerPipe]\ndisabled = true")
136+
137+
inputsShouldNotContain = []string{
138+
"[remote_queue:test-queue]",
139+
"remote_queue.sqs_smartbus.dead_letter_queue.name = test-dead-letter-queue",
140+
"remote_queue.sqs_smartbus.large_message_store.path = s3://test-bucket/smartbus-test",
141+
"remote_queue.sqs_smartbus.retry_policy = max_count",
142+
"remote_queue.max_count.sqs_smartbus.max_retries_per_part = 4"}
143+
outputsShouldNotContain = append(inputs, "remote_queue.sqs_smartbus.send_interval = 5s")
92144
)
93145

94146
// TestBasic is the main entry point

test/index_and_ingestion_separation/index_and_ingestion_separation_test.go

Lines changed: 226 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@ var _ = Describe("indingsep test", func() {
101101
// Ensure that Indexer Cluster is in Ready phase
102102
testcaseEnvInst.Log.Info("Ensure that Indexer Cluster is in Ready phase")
103103
testenv.SingleSiteIndexersReady(ctx, deployment, testcaseEnvInst)
104+
105+
// Delete the Indexer Cluster
106+
idxc := &enterpriseApi.IndexerCluster{}
107+
err = deployment.GetInstance(ctx, deployment.GetName()+"-idxc", idxc)
108+
Expect(err).To(Succeed(), "Unable to get Indexer Cluster instance", "Indexer Cluster Name", idxc)
109+
err = deployment.DeleteCR(ctx, idxc)
110+
Expect(err).To(Succeed(), "Unable to delete Indexer Cluster instance", "Indexer Cluster Name", idxc)
111+
112+
// Delete the Ingestor Cluster
113+
ingest := &enterpriseApi.IngestorCluster{}
114+
err = deployment.GetInstance(ctx, deployment.GetName()+"-ingest", ingest)
115+
Expect(err).To(Succeed(), "Unable to get Ingestor Cluster instance", "Ingestor Cluster Name", ingest)
116+
err = deployment.DeleteCR(ctx, ingest)
117+
Expect(err).To(Succeed(), "Unable to delete Ingestor Cluster instance", "Ingestor Cluster Name", ingest)
104118
})
105119
})
106120

@@ -171,33 +185,240 @@ var _ = Describe("indingsep test", func() {
171185
outputsPath := "opt/splunk/etc/system/local/outputs.conf"
172186
outputsConf, err := testenv.GetConfFile(pod, outputsPath, deployment.GetName())
173187
Expect(err).To(Succeed(), "Failed to get outputs.conf from Ingestor Cluster pod")
174-
testenv.ValidateConfFileContent(outputsConf, outputs)
188+
testenv.ValidateContent(outputsConf, outputs, true)
189+
190+
// Verify default-mode.conf
191+
testcaseEnvInst.Log.Info("Verify default-mode.conf")
192+
defaultsPath := "opt/splunk/etc/system/local/default-mode.conf"
193+
defaultsConf, err := testenv.GetConfFile(pod, defaultsPath, deployment.GetName())
194+
Expect(err).To(Succeed(), "Failed to get default-mode.conf from Ingestor Cluster pod")
195+
testenv.ValidateContent(defaultsConf, defaultsAll, true)
196+
197+
// Verify AWS env variables
198+
testcaseEnvInst.Log.Info("Verify AWS env variables")
199+
envVars, err := testenv.GetAWSEnv(pod, deployment.GetName())
200+
Expect(err).To(Succeed(), "Failed to get AWS env variables from Ingestor Cluster pod")
201+
testenv.ValidateContent(envVars, awsEnvVars, true)
202+
}
203+
204+
if strings.Contains(pod, "ingest") {
205+
// Verify default-mode.conf
206+
testcaseEnvInst.Log.Info("Verify default-mode.conf")
207+
testenv.ValidateContent(defaultsConf, defaultsIngest, true)
208+
} else if strings.Contains(pod, "idxc") {
209+
// Verify inputs.conf
210+
testcaseEnvInst.Log.Info("Verify inputs.conf")
211+
inputsPath := "opt/splunk/etc/system/local/inputs.conf"
212+
inputsConf, err := testenv.GetConfFile(pod, inputsPath, deployment.GetName())
213+
Expect(err).To(Succeed(), "Failed to get inputs.conf from Indexer Cluster pod")
214+
testenv.ValidateContent(inputsConf, inputs, true)
215+
}
216+
}
217+
})
218+
})
219+
220+
Context("Ingestor and Indexer deployment", func() {
221+
It("indingsep, integration, indingsep: Splunk Operator can update Ingestors and Indexers with correct setup", func() {
222+
// Create Service Account
223+
testcaseEnvInst.Log.Info("Create Service Account")
224+
testcaseEnvInst.CreateServiceAccount(serviceAccountName)
225+
226+
// Deploy Ingestor Cluster
227+
testcaseEnvInst.Log.Info("Deploy Ingestor Cluster")
228+
_, err := deployment.DeployIngestorCluster(ctx, deployment.GetName()+"-ingest", 3, bus, pipelineConfig, serviceAccountName)
229+
Expect(err).To(Succeed(), "Unable to deploy Ingestor Cluster")
230+
231+
// Deploy Cluster Manager
232+
testcaseEnvInst.Log.Info("Deploy Cluster Manager")
233+
_, err = deployment.DeployClusterManagerWithGivenSpec(ctx, deployment.GetName(), cmSpec)
234+
Expect(err).To(Succeed(), "Unable to deploy Cluster Manager")
235+
236+
// Deploy Indexer Cluster
237+
testcaseEnvInst.Log.Info("Deploy Indexer Cluster")
238+
_, err = deployment.DeployIndexerCluster(ctx, deployment.GetName()+"-idxc", "", 3, deployment.GetName(), "", bus, pipelineConfig, serviceAccountName)
239+
Expect(err).To(Succeed(), "Unable to deploy Indexer Cluster")
240+
241+
// Ensure that Ingestor Cluster is in Ready phase
242+
testcaseEnvInst.Log.Info("Ensure that Ingestor Cluster is in Ready phase")
243+
testenv.IngestorReady(ctx, deployment, testcaseEnvInst)
244+
245+
// Ensure that Cluster Manager is in Ready phase
246+
testcaseEnvInst.Log.Info("Ensure that Cluster Manager is in Ready phase")
247+
testenv.ClusterManagerReady(ctx, deployment, testcaseEnvInst)
248+
249+
// Ensure that Indexer Cluster is in Ready phase
250+
testcaseEnvInst.Log.Info("Ensure that Indexer Cluster is in Ready phase")
251+
testenv.SingleSiteIndexersReady(ctx, deployment, testcaseEnvInst)
252+
253+
// Get instance of current Ingestor Cluster CR with latest config
254+
testcaseEnvInst.Log.Info("Get instance of current Ingestor Cluster CR with latest config")
255+
ingest := &enterpriseApi.IngestorCluster{}
256+
err = deployment.GetInstance(ctx, deployment.GetName()+"-ingest", ingest)
257+
Expect(err).To(Succeed(), "Failed to get instance of Ingestor Cluster")
258+
259+
// Update instance of Ingestor Cluster CR with new pushbus config
260+
testcaseEnvInst.Log.Info("Update instance of Ingestor Cluster CR with new pushbus config")
261+
ingest.Spec.PushBus = updateBus
262+
err = deployment.UpdateCR(ctx, ingest)
263+
Expect(err).To(Succeed(), "Unable to deploy Ingestor Cluster with updated CR")
264+
265+
// Verify Ingestor Cluster Status
266+
testcaseEnvInst.Log.Info("Verify Ingestor Cluster Status")
267+
Expect(ingest.Status.PushBus).To(Equal(updateBus), "Ingestor PushBus status is not the same as provided as input")
268+
Expect(ingest.Status.PipelineConfig).To(Equal(pipelineConfig), "Ingestor PipelineConfig status is not the same as provided as input")
269+
270+
// Ensure that Ingestor Cluster has not been restarted
271+
testcaseEnvInst.Log.Info("Ensure that Ingestor Cluster has not been restarted")
272+
testenv.IngestorReady(ctx, deployment, testcaseEnvInst)
273+
274+
// Get instance of current Indexer Cluster CR with latest config
275+
testcaseEnvInst.Log.Info("Get instance of current Indexer Cluster CR with latest config")
276+
index := &enterpriseApi.IndexerCluster{}
277+
err = deployment.GetInstance(ctx, deployment.GetName()+"-idxc", index)
278+
Expect(err).To(Succeed(), "Failed to get instance of Indexer Cluster")
279+
280+
// Update instance of Indexer Cluster CR with new pullbus config
281+
testcaseEnvInst.Log.Info("Update instance of Indexer Cluster CR with new pullbus config")
282+
index.Spec.PullBus = updateBus
283+
err = deployment.UpdateCR(ctx, index)
284+
Expect(err).To(Succeed(), "Unable to deploy Indexer Cluster with updated CR")
285+
286+
// Verify Indexer Cluster Status
287+
testcaseEnvInst.Log.Info("Verify Indexer Cluster Status")
288+
Expect(index.Status.PullBus).To(Equal(updateBus), "Indexer PullBus status is not the same as provided as input")
289+
Expect(index.Status.PipelineConfig).To(Equal(pipelineConfig), "Indexer PipelineConfig status is not the same as provided as input")
290+
291+
// Ensure that Indexer Cluster has not been restarted
292+
testcaseEnvInst.Log.Info("Ensure that Indexer Cluster has not been restarted")
293+
testenv.SingleSiteIndexersReady(ctx, deployment, testcaseEnvInst)
294+
295+
// Verify conf files
296+
testcaseEnvInst.Log.Info("Verify conf files")
297+
pods := testenv.DumpGetPods(deployment.GetName())
298+
for _, pod := range pods {
299+
defaultsConf := ""
300+
301+
if strings.Contains(pod, "ingest") || strings.Contains(pod, "idxc") {
302+
// Verify outputs.conf
303+
testcaseEnvInst.Log.Info("Verify outputs.conf")
304+
outputsPath := "opt/splunk/etc/system/local/outputs.conf"
305+
outputsConf, err := testenv.GetConfFile(pod, outputsPath, deployment.GetName())
306+
Expect(err).To(Succeed(), "Failed to get outputs.conf from Ingestor Cluster pod")
307+
testenv.ValidateContent(outputsConf, updatedOutputs, true)
308+
testenv.ValidateContent(outputsConf, outputsShouldNotContain, false)
309+
310+
// Verify default-mode.conf
311+
testcaseEnvInst.Log.Info("Verify default-mode.conf")
312+
defaultsPath := "opt/splunk/etc/system/local/default-mode.conf"
313+
defaultsConf, err := testenv.GetConfFile(pod, defaultsPath, deployment.GetName())
314+
Expect(err).To(Succeed(), "Failed to get default-mode.conf from Ingestor Cluster pod")
315+
testenv.ValidateContent(defaultsConf, defaultsAll, true)
316+
317+
// Verify AWS env variables
318+
testcaseEnvInst.Log.Info("Verify AWS env variables")
319+
envVars, err := testenv.GetAWSEnv(pod, deployment.GetName())
320+
Expect(err).To(Succeed(), "Failed to get AWS env variables from Ingestor Cluster pod")
321+
testenv.ValidateContent(envVars, awsEnvVars, true)
322+
}
323+
324+
if strings.Contains(pod, "ingest") {
325+
// Verify default-mode.conf
326+
testcaseEnvInst.Log.Info("Verify default-mode.conf")
327+
testenv.ValidateContent(defaultsConf, defaultsIngest, true)
328+
} else if strings.Contains(pod, "idxc") {
329+
// Verify inputs.conf
330+
testcaseEnvInst.Log.Info("Verify inputs.conf")
331+
inputsPath := "opt/splunk/etc/system/local/inputs.conf"
332+
inputsConf, err := testenv.GetConfFile(pod, inputsPath, deployment.GetName())
333+
Expect(err).To(Succeed(), "Failed to get inputs.conf from Indexer Cluster pod")
334+
testenv.ValidateContent(inputsConf, updatedInputs, true)
335+
testenv.ValidateContent(inputsConf, inputsShouldNotContain, false)
336+
}
337+
}
338+
339+
// Get instance of current Ingestor Cluster CR with latest config
340+
testcaseEnvInst.Log.Info("Get instance of current Ingestor Cluster CR with latest config")
341+
ingest = &enterpriseApi.IngestorCluster{}
342+
err = deployment.GetInstance(ctx, deployment.GetName()+"-ingest", ingest)
343+
Expect(err).To(Succeed(), "Failed to get instance of Ingestor Cluster")
344+
345+
// Update instance of Ingestor Cluster CR with new pipelineconfig config
346+
testcaseEnvInst.Log.Info("Update instance of Ingestor Cluster CR with new pipelineconfig config")
347+
ingest.Spec.PipelineConfig = updatePipelineConfig
348+
err = deployment.UpdateCR(ctx, ingest)
349+
Expect(err).To(Succeed(), "Unable to deploy Ingestor Cluster with updated CR")
350+
351+
// Verify Ingestor Cluster Status
352+
testcaseEnvInst.Log.Info("Verify Ingestor Cluster Status")
353+
Expect(ingest.Status.PushBus).To(Equal(updateBus), "Ingestor PushBus status is not the same as provided as input")
354+
Expect(ingest.Status.PipelineConfig).To(Equal(updatePipelineConfig), "Ingestor PipelineConfig status is not the same as provided as input")
355+
356+
// Ensure that Ingestor Cluster has not been restarted
357+
testcaseEnvInst.Log.Info("Ensure that Ingestor Cluster has not been restarted")
358+
testenv.IngestorReady(ctx, deployment, testcaseEnvInst)
359+
360+
// Get instance of current Indexer Cluster CR with latest config
361+
testcaseEnvInst.Log.Info("Get instance of current Indexer Cluster CR with latest config")
362+
index = &enterpriseApi.IndexerCluster{}
363+
err = deployment.GetInstance(ctx, deployment.GetName()+"-idxc", index)
364+
Expect(err).To(Succeed(), "Failed to get instance of Indexer Cluster")
365+
366+
// Update instance of Indexer Cluster CR with new pipelineconfig config
367+
testcaseEnvInst.Log.Info("Update instance of Indexer Cluster CR with new pipelineconfig config")
368+
index.Spec.PipelineConfig = updatePipelineConfig
369+
err = deployment.UpdateCR(ctx, index)
370+
Expect(err).To(Succeed(), "Unable to deploy Indexer Cluster with updated CR")
371+
372+
// Verify Indexer Cluster Status
373+
testcaseEnvInst.Log.Info("Verify Indexer Cluster Status")
374+
Expect(index.Status.PullBus).To(Equal(updateBus), "Indexer PullBus status is not the same as provided as input")
375+
Expect(index.Status.PipelineConfig).To(Equal(updatePipelineConfig), "Indexer PipelineConfig status is not the same as provided as input")
376+
377+
// Ensure that Indexer Cluster has not been restarted
378+
testcaseEnvInst.Log.Info("Ensure that Indexer Cluster has not been restarted")
379+
testenv.SingleSiteIndexersReady(ctx, deployment, testcaseEnvInst)
380+
381+
// Verify conf files
382+
testcaseEnvInst.Log.Info("Verify conf files")
383+
pods = testenv.DumpGetPods(deployment.GetName())
384+
for _, pod := range pods {
385+
defaultsConf := ""
386+
387+
if strings.Contains(pod, "ingest") || strings.Contains(pod, "idxc") {
388+
// Verify outputs.conf
389+
testcaseEnvInst.Log.Info("Verify outputs.conf")
390+
outputsPath := "opt/splunk/etc/system/local/outputs.conf"
391+
outputsConf, err := testenv.GetConfFile(pod, outputsPath, deployment.GetName())
392+
Expect(err).To(Succeed(), "Failed to get outputs.conf from Ingestor Cluster pod")
393+
testenv.ValidateContent(outputsConf, updatedOutputs, true)
394+
testenv.ValidateContent(outputsConf, outputsShouldNotContain, false)
175395

176396
// Verify default-mode.conf
177397
testcaseEnvInst.Log.Info("Verify default-mode.conf")
178398
defaultsPath := "opt/splunk/etc/system/local/default-mode.conf"
179399
defaultsConf, err := testenv.GetConfFile(pod, defaultsPath, deployment.GetName())
180400
Expect(err).To(Succeed(), "Failed to get default-mode.conf from Ingestor Cluster pod")
181-
testenv.ValidateConfFileContent(defaultsConf, defaultsAll)
401+
testenv.ValidateContent(defaultsConf, updatedDefaultsAll, true)
182402

183403
// Verify AWS env variables
184404
testcaseEnvInst.Log.Info("Verify AWS env variables")
185405
envVars, err := testenv.GetAWSEnv(pod, deployment.GetName())
186406
Expect(err).To(Succeed(), "Failed to get AWS env variables from Ingestor Cluster pod")
187-
testenv.ValidateConfFileContent(envVars, awsEnvVars)
407+
testenv.ValidateContent(envVars, awsEnvVars, true)
188408
}
189409

190410
if strings.Contains(pod, "ingest") {
191411
// Verify default-mode.conf
192412
testcaseEnvInst.Log.Info("Verify default-mode.conf")
193-
testenv.ValidateConfFileContent(defaultsConf, defaultsIngest)
413+
testenv.ValidateContent(defaultsConf, updatedDefaultsIngest, true)
194414
} else if strings.Contains(pod, "idxc") {
195415
// Verify inputs.conf
196416
testcaseEnvInst.Log.Info("Verify inputs.conf")
197417
inputsPath := "opt/splunk/etc/system/local/inputs.conf"
198418
inputsConf, err := testenv.GetConfFile(pod, inputsPath, deployment.GetName())
199419
Expect(err).To(Succeed(), "Failed to get inputs.conf from Indexer Cluster pod")
200-
testenv.ValidateConfFileContent(inputsConf, inputs)
420+
testenv.ValidateContent(inputsConf, updatedInputs, true)
421+
testenv.ValidateContent(inputsConf, inputsShouldNotContain, false)
201422
}
202423
}
203424
})

test/testenv/deployment.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,15 @@ func (d *Deployment) UpdateCR(ctx context.Context, cr client.Object) error {
592592
ucr := cr.(*enterpriseApi.IndexerCluster)
593593
current.Spec = ucr.Spec
594594
cobject = current
595+
case "IngestorCluster":
596+
current := &enterpriseApi.IngestorCluster{}
597+
err = d.testenv.GetKubeClient().Get(ctx, namespacedName, current)
598+
if err != nil {
599+
return err
600+
}
601+
ucr := cr.(*enterpriseApi.IngestorCluster)
602+
current.Spec = ucr.Spec
603+
cobject = current
595604
case "ClusterMaster":
596605
current := &enterpriseApiV3.ClusterMaster{}
597606
err = d.testenv.GetKubeClient().Get(ctx, namespacedName, current)

test/testenv/util.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,10 +1252,16 @@ func GetAWSEnv(podName, ns string) (string, error) {
12521252
return string(output), err
12531253
}
12541254

1255-
func ValidateConfFileContent(confFileContent string, listOfStringsForValidation []string) {
1255+
func ValidateContent(confFileContent string, listOfStringsForValidation []string, shouldContain bool) {
12561256
for _, str := range listOfStringsForValidation {
1257-
if !strings.Contains(confFileContent, str) {
1258-
Expect(confFileContent).To(ContainSubstring(str), "Failed to find string "+str+" in conf file")
1257+
if shouldContain {
1258+
if !strings.Contains(confFileContent, str) {
1259+
Expect(confFileContent).To(ContainSubstring(str), "Failed to find string "+str+" in conf file")
1260+
}
1261+
} else {
1262+
if strings.Contains(confFileContent, str) {
1263+
Expect(confFileContent).ToNot(ContainSubstring(str), "Found string "+str+" in conf file, but it should not be there")
1264+
}
12591265
}
12601266
}
12611267
}

0 commit comments

Comments
 (0)