-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathmanager_appframework_test.go
More file actions
2726 lines (2242 loc) · 163 KB
/
manager_appframework_test.go
File metadata and controls
2726 lines (2242 loc) · 163 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2018-2022 Splunk Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.s
package m4appfw
import (
"context"
"encoding/json"
"fmt"
"path/filepath"
"strings"
"time"
. "github.com/onsi/ginkgo/v2"
"github.com/onsi/ginkgo/v2/types"
. "github.com/onsi/gomega"
enterpriseApi "github.com/splunk/splunk-operator/api/v4"
splcommon "github.com/splunk/splunk-operator/pkg/splunk/common"
"github.com/splunk/splunk-operator/pkg/splunk/enterprise"
testenv "github.com/splunk/splunk-operator/test/testenv"
corev1 "k8s.io/api/core/v1"
)
var _ = Describe("m4appfw test", func() {
var testcaseEnvInst *testenv.TestCaseEnv
var deployment *testenv.Deployment
var uploadedApps []string
var appSourceNameIdxc string
var appSourceNameShc string
var s3TestDirShc string
var s3TestDirIdxc string
var appSourceVolumeNameIdxc string
var appSourceVolumeNameShc string
var s3TestDirShcLocal string
var s3TestDirIdxcLocal string
var s3TestDirShcCluster string
var s3TestDirIdxcCluster string
var filePresentOnOperator bool
ctx := context.TODO()
BeforeEach(func() {
var err error
name := fmt.Sprintf("%s-%s", testenvInstance.GetName(), testenv.RandomDNSName(3))
fmt.Printf("[DEBUG] M4-manager BeforeEach starting, name=%s\n", name)
testcaseEnvInst, err = testenv.NewDefaultTestCaseEnv(testenvInstance.GetKubeClient(), name)
Expect(err).To(Succeed(), "Unable to create testcaseenv")
fmt.Printf("[DEBUG] M4-manager BeforeEach testcaseenv created, namespace=%s\n", testcaseEnvInst.GetName())
deployment, err = testcaseEnvInst.NewDeployment(testenv.RandomDNSName(3))
Expect(err).To(Succeed(), "Unable to create deployment")
// Validate test prerequisites early to fail fast
err = testcaseEnvInst.ValidateTestPrerequisites(ctx, deployment)
Expect(err).To(Succeed(), "Test prerequisites validation failed")
s3TestDirIdxc = "m4appfw-idxc-" + testenv.RandomDNSName(4)
s3TestDirShc = "m4appfw-shc-" + testenv.RandomDNSName(4)
appSourceVolumeNameIdxc = "appframework-test-volume-idxc-" + testenv.RandomDNSName(3)
appSourceVolumeNameShc = "appframework-test-volume-shc-" + testenv.RandomDNSName(3)
fmt.Printf("[DEBUG] M4-manager BeforeEach complete, deployment=%s\n", deployment.GetName())
})
AfterEach(func() {
// When a test spec failed, skip the teardown so we can troubleshoot.
if types.SpecState(CurrentSpecReport().State) == types.SpecStateFailed {
testcaseEnvInst.SkipTeardown = true
}
if deployment != nil {
deployment.Teardown()
}
// Delete files uploaded to S3
if !testcaseEnvInst.SkipTeardown {
testenv.DeleteFilesOnS3(testS3Bucket, uploadedApps)
}
if testcaseEnvInst != nil {
Expect(testcaseEnvInst.Teardown()).ToNot(HaveOccurred())
}
if filePresentOnOperator {
//Delete files from app-directory
opPod := testenv.GetOperatorPodName(testcaseEnvInst)
podDownloadPath := filepath.Join(testenv.AppDownloadVolume, "test_file.img")
testenv.DeleteFilesOnOperatorPod(ctx, deployment, opPod, []string{podDownloadPath})
}
})
Context("Multisite Indexer Cluster with Search Head Cluster (m4) with App Framework", func() {
It("smoke, m4, managerappframeworkm4, appframework: can deploy a M4 SVA with App Framework enabled, install apps and upgrade them", func() {
/* Test Steps
################## SETUP ##################
* Upload V1 apps to S3 for Monitoring Console
* Create app source for Monitoring Console
* Prepare and deploy Monitoring Console CRD with app framework and wait for the pod to be ready
* Upload V1 apps to S3 for Indexer Cluster and Search Head Cluster
* Prepare and deploy M4 CRD with app framework and wait for the pods to be ready
########## INITIAL VERIFICATIONS ##########
* Verify Apps Downloaded in App Deployment Info
* Verify Apps Copied in App Deployment Info
* Verify App Package is deleted from Operator Pod
* Verify Apps Installed in App Deployment Info
* Verify App Package is deleted from Splunk Pod
* Verify bundle push is successful
* Verify apps are copied and installed on Monitoring Console and on Search Heads and Indexers pods
############# UPGRADE APPS ################
* Upgrade apps in app sources
* Wait for Monitoring Console and M4 pod to be ready
########## UPGRADE VERIFICATIONS ##########
* Verify Apps Downloaded in App Deployment Info
* Verify Apps Copied in App Deployment Info
* Verify App Package is deleted from Operator Pod
* Verify Apps Installed in App Deployment Info
* Verify App Package is deleted from Splunk Pod
* Verify bundle push is successful
* Verify apps are copied and upgraded on Monitoring Console and on Search Heads and Indexers pods
*/
//################## SETUP ##################
// Upload V1 apps to S3 for Monitoring Console
appVersion := "V1"
appFileList := testenv.GetAppFileList(appListV1)
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Monitoring Console", appVersion))
s3TestDirMC := "m4appfw-mc-" + testenv.RandomDNSName(4)
uploadedFiles, err := testenv.UploadFilesToS3(testS3Bucket, s3TestDirMC, appFileList, downloadDirV1)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Monitoring Console", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Create App framework Spec for Monitoring Console
appSourceNameMC := "appframework-" + enterpriseApi.ScopeLocal + "mc-" + testenv.RandomDNSName(3)
volumeNameMC := "appframework-test-volume-mc-" + testenv.RandomDNSName(3)
appFrameworkSpecMC := testenv.GenerateAppFrameworkSpec(ctx, testcaseEnvInst, volumeNameMC, enterpriseApi.ScopeLocal, appSourceNameMC, s3TestDirMC, 60)
mcSpec := enterpriseApi.MonitoringConsoleSpec{
CommonSplunkSpec: enterpriseApi.CommonSplunkSpec{
Spec: enterpriseApi.Spec{
ImagePullPolicy: "IfNotPresent",
Image: testcaseEnvInst.GetSplunkImage(),
},
Volumes: []corev1.Volume{},
},
AppFrameworkConfig: appFrameworkSpecMC,
}
// Deploy Monitoring Console
testcaseEnvInst.Log.Info("Deploy Monitoring Console")
mcName := deployment.GetName()
mc, err := deployment.DeployMonitoringConsoleWithGivenSpec(ctx, testcaseEnvInst.GetName(), mcName, mcSpec)
Expect(err).To(Succeed(), "Unable to deploy Monitoring Console")
// Verify Monitoring Console is ready and stays in ready state
testcaseEnvInst.VerifyMonitoringConsoleReady(ctx, deployment, deployment.GetName(), mc)
// Upload V1 apps to S3 for Indexer Cluster
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Indexer Cluster", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirIdxc, appFileList, downloadDirV1)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Indexer Cluster %s", appVersion, testS3Bucket))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Upload V1 apps to S3 for Search Head Cluster
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Search Head Cluster", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirShc, appFileList, downloadDirV1)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Search Head Cluster", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Create App framework Spec for M4
appSourceNameIdxc = "appframework-idxc-" + enterpriseApi.ScopeCluster + testenv.RandomDNSName(3)
appSourceNameShc = "appframework-shc-" + enterpriseApi.ScopeCluster + testenv.RandomDNSName(3)
appFrameworkSpecIdxc := testenv.GenerateAppFrameworkSpec(ctx, testcaseEnvInst, appSourceVolumeNameIdxc, enterpriseApi.ScopeCluster, appSourceNameIdxc, s3TestDirIdxc, 60)
appFrameworkSpecShc := testenv.GenerateAppFrameworkSpec(ctx, testcaseEnvInst, appSourceVolumeNameShc, enterpriseApi.ScopeCluster, appSourceNameShc, s3TestDirShc, 60)
// get revision number of the resource
resourceVersion := testcaseEnvInst.GetResourceVersion(ctx, deployment, mc)
// Deploy M4 CRD
testcaseEnvInst.Log.Info("Deploy Multisite Indexer Cluster with Search Head Cluster")
siteCount := 3
shReplicas := 3
indexersPerSite := 1
cm, _, shc, err := deployment.DeployMultisiteClusterWithSearchHeadAndAppFramework(ctx, deployment.GetName(), indexersPerSite, siteCount, appFrameworkSpecIdxc, appFrameworkSpecShc, true, mcName, "")
Expect(err).To(Succeed(), "Unable to deploy Multisite Indexer Cluster and Search Head Cluster with App framework")
// Ensure that the Cluster Manager goes to Ready phase
testcaseEnvInst.VerifyClusterManagerReady(ctx, deployment)
// Ensure the Indexers of all sites go to Ready phase
testcaseEnvInst.VerifyIndexersReady(ctx, deployment, siteCount)
// Ensure Indexer Cluster configured as Multisite
testcaseEnvInst.VerifyIndexerClusterMultisiteStatus(ctx, deployment, siteCount)
// Ensure Search Head Cluster go to Ready phase
testcaseEnvInst.VerifySearchHeadClusterReady(ctx, deployment)
// Verify RF SF is met
testcaseEnvInst.VerifyRFSFMet(ctx, deployment)
// wait for custom resource resource version to change
testcaseEnvInst.VerifyCustomResourceVersionChanged(ctx, deployment, mc, resourceVersion)
// Verify Monitoring Console is ready and stays in ready state
testcaseEnvInst.VerifyMonitoringConsoleReady(ctx, deployment, deployment.GetName(), mc)
// Get Pod age to check for pod resets later
splunkPodUIDs := testenv.GetPodUIDs(testcaseEnvInst.GetName())
// ############ Verify livenessProbe and readinessProbe config object and scripts############
testcaseEnvInst.Log.Info("Get config map for livenessProbe and readinessProbe")
ConfigMapName := enterprise.GetProbeConfigMapName(testcaseEnvInst.GetName())
_, err = testenv.GetConfigMap(ctx, deployment, testcaseEnvInst.GetName(), ConfigMapName)
Expect(err).To(Succeed(), "Unable to get config map for livenessProbe and readinessProbe", "ConfigMap name", ConfigMapName)
scriptsNames := []string{enterprise.GetLivenessScriptName(), enterprise.GetReadinessScriptName(), enterprise.GetStartupScriptName()}
allPods := testenv.DumpGetPods(testcaseEnvInst.GetName())
testcaseEnvInst.VerifyFilesInDirectoryOnPod(ctx, deployment, allPods, scriptsNames, enterprise.GetProbeMountDirectory(), false, true)
//########## INITIAL VERIFICATIONS ##########
var idxcPodNames, shcPodNames []string
idxcPodNames = testenv.GeneratePodNameSlice(testenv.MultiSiteIndexerPod, deployment.GetName(), 1, true, siteCount)
shcPodNames = testenv.GeneratePodNameSlice(testenv.SearchHeadPod, deployment.GetName(), shReplicas, false, 1)
cmPod := []string{fmt.Sprintf(testenv.ClusterManagerPod, deployment.GetName())}
deployerPod := []string{fmt.Sprintf(testenv.DeployerPod, deployment.GetName())}
mcPod := []string{fmt.Sprintf(testenv.MonitoringConsolePod, deployment.GetName())}
cmAppSourceInfo := testenv.AppSourceInfo{CrKind: cm.Kind, CrName: cm.Name, CrAppSourceName: appSourceNameIdxc, CrAppSourceVolumeName: appSourceVolumeNameIdxc, CrPod: cmPod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeCluster, CrAppList: appListV1, CrAppFileList: appFileList, CrReplicas: indexersPerSite, CrMultisite: true, CrClusterPods: idxcPodNames}
shcAppSourceInfo := testenv.AppSourceInfo{CrKind: shc.Kind, CrName: shc.Name, CrAppSourceName: appSourceNameShc, CrAppSourceVolumeName: appSourceVolumeNameShc, CrPod: deployerPod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeCluster, CrAppList: appListV1, CrAppFileList: appFileList, CrReplicas: shReplicas, CrClusterPods: shcPodNames}
mcAppSourceInfo := testenv.AppSourceInfo{CrKind: mc.Kind, CrName: mc.Name, CrAppSourceName: appSourceNameMC, CrAppSourceVolumeName: appSourceNameMC, CrPod: mcPod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeLocal, CrAppList: appListV1, CrAppFileList: appFileList}
allAppSourceInfo := []testenv.AppSourceInfo{cmAppSourceInfo, shcAppSourceInfo, mcAppSourceInfo}
clusterManagerBundleHash := testcaseEnvInst.VerifyAppFrameworkState(ctx, deployment, allAppSourceInfo, splunkPodUIDs, "")
// Verify no pods reset by checking the pod age
testcaseEnvInst.VerifyNoPodResetByUID(ctx, deployment, splunkPodUIDs, nil)
//############# UPGRADE APPS ################
// Delete apps on S3
testcaseEnvInst.Log.Info(fmt.Sprintf("Delete %s apps on S3", appVersion))
testenv.DeleteFilesOnS3(testS3Bucket, uploadedApps)
uploadedApps = nil
// get revision number of the resource
_ = testcaseEnvInst.GetResourceVersion(ctx, deployment, mc)
// Upload V2 apps to S3 for Indexer Cluster
appVersion = "V2"
appFileList = testenv.GetAppFileList(appListV2)
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Indexer Cluster", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirIdxc, appFileList, downloadDirV2)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Indexer Cluster %s", appVersion, testS3Bucket))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Upload V2 apps to S3 for Search Head Cluster
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Search Head Cluster", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirShc, appFileList, downloadDirV2)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Search Head Cluster", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Upload V2 apps for Monitoring Console
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Monitoring Console", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirMC, appFileList, downloadDirV2)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Monitoring Console", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Check for changes in App phase to determine if next poll has been triggered
testenv.WaitforPhaseChange(ctx, deployment, testcaseEnvInst, deployment.GetName(), cm.Kind, appSourceNameIdxc, appFileList)
// Ensure that the Cluster Manager goes to Ready phase
testcaseEnvInst.VerifyClusterManagerReady(ctx, deployment)
// Ensure the Indexers of all sites go to Ready phase
testcaseEnvInst.VerifyIndexersReady(ctx, deployment, siteCount)
// Ensure cluster configured as Multisite
testcaseEnvInst.VerifyIndexerClusterMultisiteStatus(ctx, deployment, siteCount)
// Ensure Search Head Cluster go to Ready phase
testcaseEnvInst.VerifySearchHeadClusterReady(ctx, deployment)
// Verify RF SF is met
testcaseEnvInst.VerifyRFSFMet(ctx, deployment)
// Verify MC is Ready and stays in ready state
testcaseEnvInst.VerifyMonitoringConsoleReady(ctx, deployment, deployment.GetName(), mc)
// Verify Monitoring Console is Ready and stays in ready state
testcaseEnvInst.VerifyMonitoringConsoleReady(ctx, deployment, deployment.GetName(), mc)
// Get Pod age to check for pod resets later
splunkPodUIDs = testenv.GetPodUIDs(testcaseEnvInst.GetName())
//########## UPGRADE VERIFICATIONS ##########
cmAppSourceInfo.CrAppVersion = appVersion
cmAppSourceInfo.CrAppList = appListV2
cmAppSourceInfo.CrAppFileList = testenv.GetAppFileList(appListV2)
shcAppSourceInfo.CrAppVersion = appVersion
shcAppSourceInfo.CrAppList = appListV2
shcAppSourceInfo.CrAppFileList = testenv.GetAppFileList(appListV2)
mcAppSourceInfo.CrAppVersion = appVersion
mcAppSourceInfo.CrAppList = appListV2
mcAppSourceInfo.CrAppFileList = testenv.GetAppFileList(appListV2)
allAppSourceInfo = []testenv.AppSourceInfo{cmAppSourceInfo, shcAppSourceInfo, mcAppSourceInfo}
testcaseEnvInst.VerifyAppFrameworkState(ctx, deployment, allAppSourceInfo, splunkPodUIDs, clusterManagerBundleHash)
// Verify no pods reset by checking the pod age
testcaseEnvInst.VerifyNoPodResetByUID(ctx, deployment, splunkPodUIDs, nil)
})
})
Context("Multisite Indexer Cluster with Search Head Cluster (m4) with App Framework", func() {
It("integration, m4, managerappframeworkm4, appframework: can deploy a M4 SVA with App Framework enabled, install apps and downgrade them", func() {
/* Test Steps
################## SETUP ##################
* Upload V2 apps to S3 for Monitoring Console
* Create app source for Monitoring Console
* Prepare and deploy Monitoring Console CRD with app framework and wait for the pod to be ready
* Upload V2 apps to S3 for Indexer Cluster and Search Head Cluster
* Prepare and deploy M4 CRD with app framework and wait for the pods to be ready
########## INITIAL VERIFICATIONS ##########
* Verify Apps Downloaded in App Deployment Info
* Verify Apps Copied in App Deployment Info
* Verify App Package is deleted from Operator Pod
* Verify Apps Installed in App Deployment Info
* Verify App Package is deleted from Splunk Pod
* Verify bundle push is successful
* Verify apps are copied and installed on Monitoring Console and on Search Heads and Indexers pods
############ DOWNGRADE APPS ###############
* Downgrade apps in app sources
* Wait for Monitoring Console and M4 to be ready
########## DOWNGRADE VERIFICATIONS ########
* Verify Apps Downloaded in App Deployment Info
* Verify Apps Copied in App Deployment Info
* Verify App Package is deleted from Operator Pod
* Verify Apps Installed in App Deployment Info
* Verify App Package is deleted from Splunk Pod
* Verify bundle push is successful
* Verify apps are copied and downgraded on Monitoring Console and on Search Heads and Indexers pods
*/
//################## SETUP ##################
// Upload V2 version of apps to S3 for Monitoring Console
appVersion := "V2"
appFileList := testenv.GetAppFileList(appListV2)
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Monitoring Console", appVersion))
s3TestDirMC := "m4appfw-mc-" + testenv.RandomDNSName(4)
uploadedFiles, err := testenv.UploadFilesToS3(testS3Bucket, s3TestDirMC, appFileList, downloadDirV2)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Monitoring Console", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Create App framework Spec for Monitoring Console
appSourceNameMC := "appframework-" + enterpriseApi.ScopeLocal + "mc-" + testenv.RandomDNSName(3)
volumeNameMC := "appframework-test-volume-mc-" + testenv.RandomDNSName(3)
appFrameworkSpecMC := testenv.GenerateAppFrameworkSpec(ctx, testcaseEnvInst, volumeNameMC, enterpriseApi.ScopeLocal, appSourceNameMC, s3TestDirMC, 60)
mcSpec := enterpriseApi.MonitoringConsoleSpec{
CommonSplunkSpec: enterpriseApi.CommonSplunkSpec{
Spec: enterpriseApi.Spec{
ImagePullPolicy: "IfNotPresent",
Image: testcaseEnvInst.GetSplunkImage(),
},
Volumes: []corev1.Volume{},
},
AppFrameworkConfig: appFrameworkSpecMC,
}
// Deploy Monitoring Console
testcaseEnvInst.Log.Info("Deploy Monitoring Console")
mcName := deployment.GetName()
mc, err := deployment.DeployMonitoringConsoleWithGivenSpec(ctx, testcaseEnvInst.GetName(), mcName, mcSpec)
Expect(err).To(Succeed(), "Unable to deploy Monitoring Console instance")
// Verify Monitoring Console is ready and stays in ready state
testcaseEnvInst.VerifyMonitoringConsoleReady(ctx, deployment, deployment.GetName(), mc)
// Upload V2 apps to S3 for Indexer Cluster
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Indexer Cluster", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirIdxc, appFileList, downloadDirV2)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Indexer Cluster %s", appVersion, testS3Bucket))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Upload V2 apps to S3 for Search Head Cluster
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Search Head Cluster", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirShc, appFileList, downloadDirV2)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Search Head Cluster", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Create App framework Spec for M4
appSourceNameIdxc = "appframework-idxc-" + enterpriseApi.ScopeCluster + testenv.RandomDNSName(3)
appSourceNameShc = "appframework-shc-" + enterpriseApi.ScopeCluster + testenv.RandomDNSName(3)
appFrameworkSpecIdxc := testenv.GenerateAppFrameworkSpec(ctx, testcaseEnvInst, appSourceVolumeNameIdxc, enterpriseApi.ScopeCluster, appSourceNameIdxc, s3TestDirIdxc, 60)
appFrameworkSpecShc := testenv.GenerateAppFrameworkSpec(ctx, testcaseEnvInst, appSourceVolumeNameShc, enterpriseApi.ScopeCluster, appSourceNameShc, s3TestDirShc, 60)
// Deploy M4 CRD
testcaseEnvInst.Log.Info("Deploy Multisite Indexer Cluster with Search Head Cluster")
siteCount := 3
shReplicas := 3
indexersPerSite := 1
cm, _, shc, err := deployment.DeployMultisiteClusterWithSearchHeadAndAppFramework(ctx, deployment.GetName(), indexersPerSite, siteCount, appFrameworkSpecIdxc, appFrameworkSpecShc, true, mcName, "")
Expect(err).To(Succeed(), "Unable to deploy Multisite Indexer Cluster and Search Head Cluster with App framework")
// Ensure that the Cluster Manager goes to Ready phase
testcaseEnvInst.VerifyClusterManagerReady(ctx, deployment)
// Ensure the Indexers of all sites go to Ready phase
testcaseEnvInst.VerifyIndexersReady(ctx, deployment, siteCount)
// Ensure cluster configured as Multisite
testcaseEnvInst.VerifyIndexerClusterMultisiteStatus(ctx, deployment, siteCount)
// Ensure Search Head Cluster go to Ready phase
testcaseEnvInst.VerifySearchHeadClusterReady(ctx, deployment)
// Verify RF SF is met
testcaseEnvInst.VerifyRFSFMet(ctx, deployment)
// Verify Monitoring Console is Ready and stays in ready state
testcaseEnvInst.VerifyMonitoringConsoleReady(ctx, deployment, deployment.GetName(), mc)
// Get Pod age to check for pod resets later
splunkPodUIDs := testenv.GetPodUIDs(testcaseEnvInst.GetName())
//########## INITIAL VERIFICATIONS ##########
var idxcPodNames, shcPodNames []string
idxcPodNames = testenv.GeneratePodNameSlice(testenv.MultiSiteIndexerPod, deployment.GetName(), 1, true, siteCount)
shcPodNames = testenv.GeneratePodNameSlice(testenv.SearchHeadPod, deployment.GetName(), shReplicas, false, 1)
cmPod := []string{fmt.Sprintf(testenv.ClusterManagerPod, deployment.GetName())}
deployerPod := []string{fmt.Sprintf(testenv.DeployerPod, deployment.GetName())}
mcPod := []string{fmt.Sprintf(testenv.MonitoringConsolePod, deployment.GetName())}
cmAppSourceInfo := testenv.AppSourceInfo{CrKind: cm.Kind, CrName: cm.Name, CrAppSourceName: appSourceNameIdxc, CrAppSourceVolumeName: appSourceVolumeNameIdxc, CrPod: cmPod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeCluster, CrAppList: appListV2, CrAppFileList: appFileList, CrReplicas: indexersPerSite, CrMultisite: true, CrClusterPods: idxcPodNames}
shcAppSourceInfo := testenv.AppSourceInfo{CrKind: shc.Kind, CrName: shc.Name, CrAppSourceName: appSourceNameShc, CrAppSourceVolumeName: appSourceVolumeNameShc, CrPod: deployerPod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeCluster, CrAppList: appListV2, CrAppFileList: appFileList, CrReplicas: shReplicas, CrClusterPods: shcPodNames}
mcAppSourceInfo := testenv.AppSourceInfo{CrKind: mc.Kind, CrName: mc.Name, CrAppSourceName: appSourceNameMC, CrAppSourceVolumeName: appSourceNameMC, CrPod: mcPod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeLocal, CrAppList: appListV2, CrAppFileList: appFileList}
allAppSourceInfo := []testenv.AppSourceInfo{cmAppSourceInfo, shcAppSourceInfo, mcAppSourceInfo}
clusterManagerBundleHash := testcaseEnvInst.VerifyAppFrameworkState(ctx, deployment, allAppSourceInfo, splunkPodUIDs, "")
// Verify no pods reset by checking the pod age
testcaseEnvInst.VerifyNoPodResetByUID(ctx, deployment, splunkPodUIDs, nil)
//############# DOWNGRADE APPS ################
// Delete V2 apps on S3
testcaseEnvInst.Log.Info(fmt.Sprintf("Delete %s apps on S3", appVersion))
testenv.DeleteFilesOnS3(testS3Bucket, uploadedApps)
uploadedApps = nil
// Upload V1 apps to S3 for Indexer Cluster
appVersion = "V1"
appFileList = testenv.GetAppFileList(appListV1)
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Indexer Cluster", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirIdxc, appFileList, downloadDirV1)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Indexer Cluster %s", appVersion, testS3Bucket))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Upload V1 apps to S3 for Search Head Cluster
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Search Head Cluster", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirShc, appFileList, downloadDirV1)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Search Head Cluster", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Upload V1 apps to S3 for Monitoring Console
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Monitoring Console", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirMC, appFileList, downloadDirV1)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Monitoring Console", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Check for changes in App phase to determine if next poll has been triggered
testenv.WaitforPhaseChange(ctx, deployment, testcaseEnvInst, deployment.GetName(), cm.Kind, appSourceNameIdxc, appFileList)
// Ensure that the Cluster Manager goes to Ready phase
testcaseEnvInst.VerifyClusterManagerReady(ctx, deployment)
// Ensure the Indexers of all sites go to Ready phase
testcaseEnvInst.VerifyIndexersReady(ctx, deployment, siteCount)
// Ensure cluster configured as Multisite
testcaseEnvInst.VerifyIndexerClusterMultisiteStatus(ctx, deployment, siteCount)
// Ensure Search Head Cluster go to Ready phase
testcaseEnvInst.VerifySearchHeadClusterReady(ctx, deployment)
// Verify RF SF is met
testcaseEnvInst.VerifyRFSFMet(ctx, deployment)
// Verify Monitoring Console is Ready and stays in ready state
testcaseEnvInst.VerifyMonitoringConsoleReady(ctx, deployment, deployment.GetName(), mc)
// Get Pod age to check for pod resets later
splunkPodUIDs = testenv.GetPodUIDs(testcaseEnvInst.GetName())
//########## DOWNGRADE VERIFICATIONS ########
cmAppSourceInfo.CrAppVersion = appVersion
cmAppSourceInfo.CrAppList = appListV1
cmAppSourceInfo.CrAppFileList = testenv.GetAppFileList(appListV1)
shcAppSourceInfo.CrAppVersion = appVersion
shcAppSourceInfo.CrAppList = appListV1
shcAppSourceInfo.CrAppFileList = testenv.GetAppFileList(appListV1)
mcAppSourceInfo.CrAppVersion = appVersion
mcAppSourceInfo.CrAppList = appListV1
mcAppSourceInfo.CrAppFileList = testenv.GetAppFileList(appListV1)
allAppSourceInfo = []testenv.AppSourceInfo{cmAppSourceInfo, shcAppSourceInfo, mcAppSourceInfo}
testcaseEnvInst.VerifyAppFrameworkState(ctx, deployment, allAppSourceInfo, splunkPodUIDs, clusterManagerBundleHash)
// Verify no pods reset by checking the pod age
testcaseEnvInst.VerifyNoPodResetByUID(ctx, deployment, splunkPodUIDs, nil)
})
})
Context("Multisite Indexer Cluster with Search Head Cluster (m4) with App Framework", func() {
It("integration, m4, managerappframeworkm4, appframework: can deploy a M4 SVA with App Framework enabled, install apps, scale up clusters, install apps on new pods, scale down", func() {
/* Test Steps
################## SETUP ##################
* Upload V1 apps to S3 for M4
* Create app source for M4 SVA (Cluster Manager and Deployer)
* Prepare and deploy M4 CRD with app config and wait for pods to be ready
########### INITIAL VERIFICATIONS #########
* Verify Apps Downloaded in App Deployment Info
* Verify Apps Copied in App Deployment Info
* Verify App Package is deleted from Operator Pod
* Verify Apps Installed in App Deployment Info
* Verify App Package is deleted from Splunk Pod
* Verify bundle push is sucessful
* Verify apps are copied and installed on Monitoring Console and also on Search Heads and Indexers pods
############### SCALING UP ################
* Scale up Indexers and Search Head Cluster
* Wait for Monitoring Console and M4 to be ready
######### SCALING UP VERIFICATIONS ########
* Verify Apps Downloaded in App Deployment Info
* Verify Apps Copied in App Deployment Info
* Verify App Package is deleted from Operator Pod
* Verify Apps Installed in App Deployment Info
* Verify App Package is deleted from Splunk Pod
* Verify bundle push is sucessful
* Verify apps are copied and installed on new Search Heads and Indexers pods
############### SCALING DOWN ##############
* Scale down Indexers and Search Head Cluster
* Wait for Monitoring Console and M4 to be ready
######### SCALING DOWN VERIFICATIONS ######
* Verify Apps Downloaded in App Deployment Info
* Verify Apps Copied in App Deployment Info
* Verify App Package is deleted from Operator Pod
* Verify Apps Installed in App Deployment Info
* Verify App Package is deleted from Splunk Pod
* Verify bundle push is sucessful
* Verify apps are still copied and installed on all Search Heads and Indexers pods
*/
//################## SETUP ##################
// Upload V1 apps to S3 for Indexer Cluster
appVersion := "V1"
appFileList := testenv.GetAppFileList(appListV1)
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Indexer Cluster", appVersion))
uploadedFiles, err := testenv.UploadFilesToS3(testS3Bucket, s3TestDirIdxc, appFileList, downloadDirV1)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Indexer Cluster %s", appVersion, testS3Bucket))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Upload V1 apps to S3 for Search Head Cluster
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Search Head Cluster", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirShc, appFileList, downloadDirV1)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Search Head Cluster", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Create App framework Spec for M4
appSourceNameIdxc = "appframework-idxc-" + enterpriseApi.ScopeCluster + testenv.RandomDNSName(3)
appSourceNameShc = "appframework-shc-" + enterpriseApi.ScopeCluster + testenv.RandomDNSName(3)
appFrameworkSpecIdxc := testenv.GenerateAppFrameworkSpec(ctx, testcaseEnvInst, appSourceVolumeNameIdxc, enterpriseApi.ScopeCluster, appSourceNameIdxc, s3TestDirIdxc, 60)
appFrameworkSpecShc := testenv.GenerateAppFrameworkSpec(ctx, testcaseEnvInst, appSourceVolumeNameShc, enterpriseApi.ScopeCluster, appSourceNameShc, s3TestDirShc, 60)
// Deploy M4 CRD
testcaseEnvInst.Log.Info("Deploy Multisite Indexer Cluster with Search Head Cluster")
siteCount := 3
indexersPerSite := 1
shReplicas := 3
cm, _, shc, err := deployment.DeployMultisiteClusterWithSearchHeadAndAppFramework(ctx, deployment.GetName(), indexersPerSite, siteCount, appFrameworkSpecIdxc, appFrameworkSpecShc, true, "", "")
Expect(err).To(Succeed(), "Unable to deploy Multisite Indexer Cluster with Search Head Cluster")
// Ensure that the Cluster Manager goes to Ready phase
testcaseEnvInst.VerifyClusterManagerReady(ctx, deployment)
// Ensure the Indexers of all sites go to Ready phase
testcaseEnvInst.VerifyIndexersReady(ctx, deployment, siteCount)
// Ensure cluster configured as Multisite
testcaseEnvInst.VerifyIndexerClusterMultisiteStatus(ctx, deployment, siteCount)
// Ensure Search Head Cluster go to Ready phase
testcaseEnvInst.VerifySearchHeadClusterReady(ctx, deployment)
// Verify RF SF is met
testcaseEnvInst.VerifyRFSFMet(ctx, deployment)
// Get Pod age to check for pod resets later
splunkPodUIDs := testenv.GetPodUIDs(testcaseEnvInst.GetName())
// Ingest data on Indexers
for i := 1; i <= siteCount; i++ {
podName := fmt.Sprintf(testenv.MultiSiteIndexerPod, deployment.GetName(), i, 0)
logFile := fmt.Sprintf("test-log-%s.log", testenv.RandomDNSName(3))
testenv.CreateMockLogfile(logFile, 2000)
testenv.IngestFileViaMonitor(ctx, logFile, "main", podName, deployment)
}
// ############ Verify livenessProbe and readinessProbe config object and scripts############
testcaseEnvInst.Log.Info("Get config map for livenessProbe and readinessProbe")
ConfigMapName := enterprise.GetProbeConfigMapName(testcaseEnvInst.GetName())
_, err = testenv.GetConfigMap(ctx, deployment, testcaseEnvInst.GetName(), ConfigMapName)
Expect(err).To(Succeed(), "Unable to get config map for livenessProbe and readinessProbe", "ConfigMap name", ConfigMapName)
//########### INITIAL VERIFICATIONS #########
var idxcPodNames, shcPodNames []string
idxcPodNames = testenv.GeneratePodNameSlice(testenv.MultiSiteIndexerPod, deployment.GetName(), 1, true, siteCount)
shcPodNames = testenv.GeneratePodNameSlice(testenv.SearchHeadPod, deployment.GetName(), shReplicas, false, 1)
cmPod := []string{fmt.Sprintf(testenv.ClusterManagerPod, deployment.GetName())}
deployerPod := []string{fmt.Sprintf(testenv.DeployerPod, deployment.GetName())}
cmAppSourceInfo := testenv.AppSourceInfo{CrKind: cm.Kind, CrName: cm.Name, CrAppSourceName: appSourceNameIdxc, CrAppSourceVolumeName: appSourceVolumeNameIdxc, CrPod: cmPod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeCluster, CrAppList: appListV1, CrAppFileList: appFileList, CrReplicas: indexersPerSite, CrMultisite: true, CrClusterPods: idxcPodNames}
shcAppSourceInfo := testenv.AppSourceInfo{CrKind: shc.Kind, CrName: shc.Name, CrAppSourceName: appSourceNameShc, CrAppSourceVolumeName: appSourceVolumeNameShc, CrPod: deployerPod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeCluster, CrAppList: appListV1, CrAppFileList: appFileList, CrReplicas: shReplicas, CrClusterPods: shcPodNames}
allAppSourceInfo := []testenv.AppSourceInfo{cmAppSourceInfo, shcAppSourceInfo}
testcaseEnvInst.VerifyAppFrameworkState(ctx, deployment, allAppSourceInfo, splunkPodUIDs, "")
// Verify no pods reset by checking the pod age
testcaseEnvInst.VerifyNoPodResetByUID(ctx, deployment, splunkPodUIDs, nil)
//Delete configMap Object
err = testenv.DeleteConfigMap(testcaseEnvInst.GetName(), ConfigMapName)
Expect(err).To(Succeed(), "Unable to delete ConfigMao", "ConfigMap name", ConfigMapName)
//############### SCALING UP ################
// Get instance of current Search Head Cluster CR with latest config
err = deployment.GetInstance(ctx, deployment.GetName()+"-shc", shc)
Expect(err).To(Succeed(), "Failed to get instance of Search Head Cluster")
// Scale up Search Head Cluster
defaultSHReplicas := shc.Spec.Replicas
scaledSHReplicas := defaultSHReplicas + 1
testcaseEnvInst.Log.Info("Scale up Search Head Cluster", "Current Replicas", defaultSHReplicas, "New Replicas", scaledSHReplicas)
// Update Replicas of Search Head Cluster
shc.Spec.Replicas = int32(scaledSHReplicas)
err = deployment.UpdateCR(ctx, shc)
Expect(err).To(Succeed(), "Failed to scale up Search Head Cluster")
// Ensure Search Head Cluster scales up and go to ScalingUp phase
testcaseEnvInst.VerifySearchHeadClusterPhase(ctx, deployment, enterpriseApi.PhaseScalingUp)
// Get instance of current Indexer CR with latest config
idxcName := deployment.GetName() + "-" + "site1"
idxc := &enterpriseApi.IndexerCluster{}
err = deployment.GetInstance(ctx, idxcName, idxc)
Expect(err).To(Succeed(), "Failed to get instance of Indexer Cluster")
defaultIndexerReplicas := idxc.Spec.Replicas
scaledIndexerReplicas := defaultIndexerReplicas + 1
testcaseEnvInst.Log.Info("Scale up Indexer Cluster", "Current Replicas", defaultIndexerReplicas, "New Replicas", scaledIndexerReplicas)
// Update Replicas of Indexer Cluster
idxc.Spec.Replicas = int32(scaledIndexerReplicas)
err = deployment.UpdateCR(ctx, idxc)
Expect(err).To(Succeed(), "Failed to Scale Up Indexer Cluster")
// Ensure Indexer cluster scales up and go to ScalingUp phase
testcaseEnvInst.VerifyIndexerClusterPhase(ctx, deployment, enterpriseApi.PhaseScalingUp, idxcName)
// Ensure Indexer cluster go to Ready phase
testcaseEnvInst.VerifyIndexersReady(ctx, deployment, siteCount)
// Ingest data on new Indexers
podName := fmt.Sprintf(testenv.MultiSiteIndexerPod, deployment.GetName(), 1, 1)
logFile := fmt.Sprintf("test-log-%s.log", testenv.RandomDNSName(3))
testenv.CreateMockLogfile(logFile, 2000)
testenv.IngestFileViaMonitor(ctx, logFile, "main", podName, deployment)
// Ensure Search Head Cluster go to Ready phase
testcaseEnvInst.VerifySearchHeadClusterReady(ctx, deployment)
// Verify RF SF is met
testcaseEnvInst.VerifyRFSFMet(ctx, deployment)
// Search for data on newly added indexer
searchPod := fmt.Sprintf(testenv.SearchHeadPod, deployment.GetName(), 0)
indexerName := fmt.Sprintf(testenv.MultiSiteIndexerPod, deployment.GetName(), 1, 1)
searchString := fmt.Sprintf("index=%s host=%s | stats count by host", "main", indexerName)
searchResultsResp, err := testenv.PerformSearchSync(ctx, searchPod, searchString, deployment)
Expect(err).To(Succeed(), "Failed to execute search '%s' on pod %s", searchPod, searchString)
// Verify result.
searchResponse := strings.Split(searchResultsResp, "\n")[0]
var searchResults map[string]interface{}
jsonErr := json.Unmarshal([]byte(searchResponse), &searchResults)
Expect(jsonErr).To(Succeed(), "Failed to unmarshal JSON Search Results from response '%s'", searchResultsResp)
testcaseEnvInst.Log.Info("Search results :", "searchResults", searchResults["result"])
Expect(searchResults["result"]).ShouldNot(BeNil(), "No results in search response '%s' on pod %s", searchResults, searchPod)
resultLine := searchResults["result"].(map[string]interface{})
testcaseEnvInst.Log.Info("Sync Search results host count:", "count", resultLine["count"].(string), "host", resultLine["host"].(string))
testHostname := strings.Compare(resultLine["host"].(string), indexerName)
Expect(testHostname).To(Equal(0), "Incorrect search result hostname. Expect: %s Got: %s", indexerName, resultLine["host"].(string))
//######### SCALING UP VERIFICATIONS ########
testcaseEnvInst.VerifyAppFrameworkState(ctx, deployment, allAppSourceInfo, splunkPodUIDs, "")
// ############ Verify livenessProbe and readinessProbe config object and scripts############
testcaseEnvInst.Log.Info("Get config map for livenessProbe and readinessProbe")
_, err = testenv.GetConfigMap(ctx, deployment, testcaseEnvInst.GetName(), ConfigMapName)
Expect(err).To(Succeed(), "Unable to get config map for livenessProbe and readinessProbe", "ConfigMap name", ConfigMapName)
scriptsNames := []string{enterprise.GetLivenessScriptName(), enterprise.GetReadinessScriptName(), enterprise.GetStartupScriptName()}
allPods := testenv.DumpGetPods(testcaseEnvInst.GetName())
testcaseEnvInst.VerifyFilesInDirectoryOnPod(ctx, deployment, allPods, scriptsNames, enterprise.GetProbeMountDirectory(), false, true)
// Listing the Search Head cluster pods to exclude them from the 'no pod reset' test as they are expected to be reset after scaling
shcPodNames = []string{fmt.Sprintf(testenv.DeployerPod, deployment.GetName())}
shcPodNames = append(shcPodNames, testenv.GeneratePodNameSlice(testenv.SearchHeadPod, deployment.GetName(), shReplicas, false, 1)...)
// Verify no pods reset by checking the pod age
testcaseEnvInst.VerifyNoPodResetByUID(ctx, deployment, splunkPodUIDs, shcPodNames)
//############### SCALING DOWN ##############
// Get instance of current Search Head Cluster CR with latest config
err = deployment.GetInstance(ctx, deployment.GetName()+"-shc", shc)
Expect(err).To(Succeed(), "Failed to get instance of Search Head Cluster")
// Scale down Search Head Cluster
defaultSHReplicas = shc.Spec.Replicas
scaledSHReplicas = defaultSHReplicas - 1
testcaseEnvInst.Log.Info("Scaling down Search Head Cluster", "Current Replicas", defaultSHReplicas, "New Replicas", scaledSHReplicas)
// Update Replicas of Search Head Cluster
shc.Spec.Replicas = int32(scaledSHReplicas)
err = deployment.UpdateCR(ctx, shc)
Expect(err).To(Succeed(), "Failed to scale down Search Head Cluster")
// Ensure Search Head Cluster scales down and go to ScalingDown phase
testcaseEnvInst.VerifySearchHeadClusterPhase(ctx, deployment, enterpriseApi.PhaseScalingDown)
// Get instance of current Indexer CR with latest config
err = deployment.GetInstance(ctx, idxcName, idxc)
Expect(err).To(Succeed(), "Failed to get instance of Indexer Cluster")
defaultIndexerReplicas = idxc.Spec.Replicas
scaledIndexerReplicas = defaultIndexerReplicas - 1
testcaseEnvInst.Log.Info("Scaling down Indexer Cluster", "Current Replicas", defaultIndexerReplicas, "New Replicas", scaledIndexerReplicas)
// Update Replicas of Indexer Cluster
idxc.Spec.Replicas = int32(scaledIndexerReplicas)
err = deployment.UpdateCR(ctx, idxc)
Expect(err).To(Succeed(), "Failed to Scale down Indexer Cluster")
// Ensure Indexer cluster scales down and go to ScalingDown phase
testcaseEnvInst.VerifyIndexerClusterPhase(ctx, deployment, enterpriseApi.PhaseScalingDown, idxcName)
// Ensure Search Head Cluster go to Ready phase
testcaseEnvInst.VerifySearchHeadClusterReady(ctx, deployment)
// Ensure Indexer cluster go to Ready phase
testcaseEnvInst.VerifyIndexersReady(ctx, deployment, siteCount)
// Verify RF SF is met
testcaseEnvInst.VerifyRFSFMet(ctx, deployment)
// Search for data from removed indexer
searchString = fmt.Sprintf("index=%s host=%s | stats count by host", "main", indexerName)
searchResultsResp, err = testenv.PerformSearchSync(ctx, searchPod, searchString, deployment)
Expect(err).To(Succeed(), "Failed to execute search '%s' on pod %s", searchPod, searchString)
// Verify result.
searchResponse = strings.Split(searchResultsResp, "\n")[0]
jsonErr = json.Unmarshal([]byte(searchResponse), &searchResults)
Expect(jsonErr).To(Succeed(), "Failed to unmarshal JSON Search Results from response '%s'", searchResultsResp)
testcaseEnvInst.Log.Info("Search results :", "searchResults", searchResults["result"])
Expect(searchResults["result"]).ShouldNot(BeNil(), "No results in search response '%s' on pod %s", searchResults, searchPod)
resultLine = searchResults["result"].(map[string]interface{})
testcaseEnvInst.Log.Info("Sync Search results host count:", "count", resultLine["count"].(string), "host", resultLine["host"].(string))
testHostname = strings.Compare(resultLine["host"].(string), indexerName)
Expect(testHostname).To(Equal(0), "Incorrect search result hostname. Expect: %s Got: %s", indexerName, resultLine["host"].(string))
//######### SCALING DOWN VERIFICATIONS ######
testcaseEnvInst.VerifyAppFrameworkState(ctx, deployment, allAppSourceInfo, splunkPodUIDs, "")
// Verify no pods reset by checking the pod age
testcaseEnvInst.VerifyNoPodResetByUID(ctx, deployment, splunkPodUIDs, shcPodNames)
})
})
Context("Multi Site Indexer Cluster with Search Head Cluster (m4) with App Framework", func() {
It("integration, m4, managerappframeworkm4, appframework: can deploy a M4 SVA and have apps installed locally on Cluster Manager and Deployer", func() {
/* Test Steps
################## SETUP ####################
* Upload V1 apps to S3
* Create app source with local scope for M4 SVA (Cluster Manager and Deployer)
* Prepare and deploy M4 CRD with app framework and wait for pods to be ready
########## INITIAL VERIFICATION #############
* Verify Apps Downloaded in App Deployment Info
* Verify Apps Copied in App Deployment Info
* Verify App Package is deleted from Operator Pod
* Verify Apps Installed in App Deployment Info
* Verify App Package is deleted from Splunk Pod
* Verify apps are installed locally on Cluster Manager and Deployer
############### UPGRADE APPS ################
* Upgrade apps in app sources
* Wait for pods to be ready
########## UPGRADE VERIFICATIONS ############
* Verify Apps Downloaded in App Deployment Info
* Verify Apps Copied in App Deployment Info
* Verify App Package is deleted from Operator Pod
* Verify Apps Installed in App Deployment Info
* Verify App Package is deleted from Splunk Pod
* Verify apps are copied, installed and upgraded on Cluster Manager and Deployer
*/
//################## SETUP ####################
// Upload V1 apps to S3 for Indexer Cluster
appVersion := "V1"
appFileList := testenv.GetAppFileList(appListV1)
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Indexer Cluster", appVersion))
uploadedFiles, err := testenv.UploadFilesToS3(testS3Bucket, s3TestDirIdxc, appFileList, downloadDirV1)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Indexer Cluster %s", appVersion, testS3Bucket))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Upload V1 apps to S3 for Search Head Cluster
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Search Head Cluster", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirShc, appFileList, downloadDirV1)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Search Head Cluster", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Create App framework Spec
appSourceNameIdxc = "appframework-idxc-" + enterpriseApi.ScopeLocal + testenv.RandomDNSName(3)
appSourceNameShc = "appframework-shc-" + enterpriseApi.ScopeLocal + testenv.RandomDNSName(3)
appFrameworkSpecIdxc := testenv.GenerateAppFrameworkSpec(ctx, testcaseEnvInst, appSourceVolumeNameIdxc, enterpriseApi.ScopeLocal, appSourceNameIdxc, s3TestDirIdxc, 60)
appFrameworkSpecShc := testenv.GenerateAppFrameworkSpec(ctx, testcaseEnvInst, appSourceVolumeNameShc, enterpriseApi.ScopeLocal, appSourceNameShc, s3TestDirShc, 60)
// Deploy Multisite Cluster and Search Head Cluster, with App Framework enabled on Cluster Manager and Deployer
siteCount := 3
indexersPerSite := 1
shReplicas := 3
testcaseEnvInst.Log.Info("Deploy Multisite Indexer Cluster with Search Head Cluster")
cm, _, shc, err := deployment.DeployMultisiteClusterWithSearchHeadAndAppFramework(ctx, deployment.GetName(), indexersPerSite, siteCount, appFrameworkSpecIdxc, appFrameworkSpecShc, true, "", "")
Expect(err).To(Succeed(), "Unable to deploy Multisite Indexer Cluster with Search Head Cluster")
// Ensure that the Cluster Manager goes to Ready phase
testcaseEnvInst.VerifyClusterManagerReady(ctx, deployment)
// Ensure the Indexers of all sites go to Ready phase
testcaseEnvInst.VerifyIndexersReady(ctx, deployment, siteCount)
// Ensure Search Head Cluster go to Ready phase
testcaseEnvInst.VerifySearchHeadClusterReady(ctx, deployment)
// Get Pod age to check for pod resets later
splunkPodUIDs := testenv.GetPodUIDs(testcaseEnvInst.GetName())
//########## INITIAL VERIFICATION #############
var idxcPodNames, shcPodNames []string
idxcPodNames = testenv.GeneratePodNameSlice(testenv.MultiSiteIndexerPod, deployment.GetName(), 1, true, siteCount)
shcPodNames = testenv.GeneratePodNameSlice(testenv.SearchHeadPod, deployment.GetName(), shReplicas, false, 1)
cmPod := []string{fmt.Sprintf(testenv.ClusterManagerPod, deployment.GetName())}
deployerPod := []string{fmt.Sprintf(testenv.DeployerPod, deployment.GetName())}
cmAppSourceInfo := testenv.AppSourceInfo{CrKind: cm.Kind, CrName: cm.Name, CrAppSourceName: appSourceNameIdxc, CrAppSourceVolumeName: appSourceVolumeNameIdxc, CrPod: cmPod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeLocal, CrAppList: appListV1, CrAppFileList: appFileList, CrReplicas: indexersPerSite, CrMultisite: true, CrClusterPods: idxcPodNames}
shcAppSourceInfo := testenv.AppSourceInfo{CrKind: shc.Kind, CrName: shc.Name, CrAppSourceName: appSourceNameShc, CrAppSourceVolumeName: appSourceVolumeNameShc, CrPod: deployerPod, CrAppVersion: appVersion, CrAppScope: enterpriseApi.ScopeLocal, CrAppList: appListV1, CrAppFileList: appFileList, CrReplicas: shReplicas, CrClusterPods: shcPodNames}
allAppSourceInfo := []testenv.AppSourceInfo{cmAppSourceInfo, shcAppSourceInfo}
testcaseEnvInst.VerifyAppFrameworkState(ctx, deployment, allAppSourceInfo, splunkPodUIDs, "")
// Verify no pods reset by checking the pod age
testcaseEnvInst.VerifyNoPodResetByUID(ctx, deployment, splunkPodUIDs, nil)
//############### UPGRADE APPS ################
// Delete V1 apps on S3
testcaseEnvInst.Log.Info(fmt.Sprintf("Delete %s apps on S3", appVersion))
testenv.DeleteFilesOnS3(testS3Bucket, uploadedApps)
uploadedApps = nil
// Upload V2 apps to S3 for Indexer Cluster
appVersion = "V2"
appFileList = testenv.GetAppFileList(appListV2)
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Indexer Cluster", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirIdxc, appFileList, downloadDirV2)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Indexer Cluster %s", appVersion, testS3Bucket))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Upload V2 apps to S3 for Search Head Cluster
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Search Head Cluster", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirShc, appFileList, downloadDirV2)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Search Head Cluster", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Check for changes in App phase to determine if next poll has been triggered
testenv.WaitforPhaseChange(ctx, deployment, testcaseEnvInst, deployment.GetName(), cm.Kind, appSourceNameIdxc, appFileList)
// Ensure that the Cluster Manager goes to Ready phase
testcaseEnvInst.VerifyClusterManagerReady(ctx, deployment)
// Ensure the Indexers of all sites go to Ready phase
testcaseEnvInst.VerifyIndexersReady(ctx, deployment, siteCount)
// Ensure Search Head Cluster go to Ready phase
testcaseEnvInst.VerifySearchHeadClusterReady(ctx, deployment)
// Get Pod age to check for pod resets later
splunkPodUIDs = testenv.GetPodUIDs(testcaseEnvInst.GetName())
//########## UPGRADE VERIFICATIONS ############
cmAppSourceInfo.CrAppVersion = appVersion
cmAppSourceInfo.CrAppList = appListV2
cmAppSourceInfo.CrAppFileList = testenv.GetAppFileList(appListV2)
shcAppSourceInfo.CrAppVersion = appVersion
shcAppSourceInfo.CrAppList = appListV2
shcAppSourceInfo.CrAppFileList = testenv.GetAppFileList(appListV2)
allAppSourceInfo = []testenv.AppSourceInfo{cmAppSourceInfo, shcAppSourceInfo}
testcaseEnvInst.VerifyAppFrameworkState(ctx, deployment, allAppSourceInfo, splunkPodUIDs, "")
// Verify no pods reset by checking the pod age
testcaseEnvInst.VerifyNoPodResetByUID(ctx, deployment, splunkPodUIDs, nil)
})
})
Context("Multi Site Indexer Cluster with Search Head Cluster (m4) with App Framework", func() {
It("integration, m4, managerappframeworkm4, appframework: can deploy a M4 SVA with App Framework enabled for manual poll", func() {
/* Test Steps
################## SETUP ####################
* Upload V1 apps to S3 for Monitoring Console
* Create app source for Monitoring Console
* Prepare and deploy Monitoring Console with app framework and wait for the pod to be ready
* Upload V1 apps to S3
* Create app source with manaul poll for M4 SVA (Cluster Manager and Deployer)
* Prepare and deploy M4 CRD with app framework and wait for pods to be ready
########## INITIAL VERIFICATION #############
* Verify Apps Downloaded in App Deployment Info
* Verify Apps Copied in App Deployment Info
* Verify App Package is deleted from Operator Pod
* Verify Apps Installed in App Deployment Info
* Verify App Package is deleted from Splunk Pod
* Verify apps are installed locally on Cluster Manager and Deployer
############### UPGRADE APPS ################
* Upgrade apps in app sources
* Wait for pods to be ready
############ VERIFICATION APPS ARE NOT UPDATED BEFORE ENABLING MANUAL POLL ############
* Verify Apps are not updated
############ ENABLE MANUAL POLL ############
* Verify Manual Poll disabled after the check
############## UPGRADE VERIFICATIONS ############
* Verify Apps Downloaded in App Deployment Info
* Verify Apps Copied in App Deployment Info
* Verify App Package is deleted from Operator Pod
* Verify Apps Installed in App Deployment Info
* Verify App Package is deleted from Splunk Pod
* Verify App Directory in under splunk path
* Verify apps are installed locally on Cluster Manager and Deployer
*/
// ################## SETUP ####################
// Upload V1 apps to S3 for Monitoring Console
appVersion := "V1"
appFileList := testenv.GetAppFileList(appListV1)
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Monitoring Console", appVersion))
s3TestDirMC := "m4appfw-mc-" + testenv.RandomDNSName(4)
uploadedFiles, err := testenv.UploadFilesToS3(testS3Bucket, s3TestDirMC, appFileList, downloadDirV1)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Monitoring Console", appVersion))
uploadedApps = append(uploadedApps, uploadedFiles...)
// Create App framework Spec for Monitoring Console
appSourceNameMC := "appframework-" + enterpriseApi.ScopeLocal + "mc-" + testenv.RandomDNSName(3)
volumeNameMC := "appframework-test-volume-mc-" + testenv.RandomDNSName(3)
appFrameworkSpecMC := testenv.GenerateAppFrameworkSpec(ctx, testcaseEnvInst, volumeNameMC, enterpriseApi.ScopeLocal, appSourceNameMC, s3TestDirMC, 0)
mcSpec := enterpriseApi.MonitoringConsoleSpec{
CommonSplunkSpec: enterpriseApi.CommonSplunkSpec{
Spec: enterpriseApi.Spec{
ImagePullPolicy: "IfNotPresent",
Image: testcaseEnvInst.GetSplunkImage(),
},
Volumes: []corev1.Volume{},
},
AppFrameworkConfig: appFrameworkSpecMC,
}
// Deploy Monitoring Console
testcaseEnvInst.Log.Info("Deploy Monitoring Console")
mcName := deployment.GetName()
mc, err := deployment.DeployMonitoringConsoleWithGivenSpec(ctx, testcaseEnvInst.GetName(), mcName, mcSpec)
Expect(err).To(Succeed(), "Unable to deploy Monitoring Console")
// Verify Monitoring Console is ready and stays in ready state
testcaseEnvInst.VerifyMonitoringConsoleReady(ctx, deployment, deployment.GetName(), mc)
// Upload V1 apps to S3 for Indexer Cluster
testcaseEnvInst.Log.Info(fmt.Sprintf("Upload %s apps to S3 for Indexer Cluster", appVersion))
uploadedFiles, err = testenv.UploadFilesToS3(testS3Bucket, s3TestDirIdxc, appFileList, downloadDirV1)
Expect(err).To(Succeed(), fmt.Sprintf("Unable to upload %s apps to S3 test directory for Indexer Cluster %s", appVersion, testS3Bucket))