Skip to content

Commit

Permalink
changed order first search and then index
Browse files Browse the repository at this point in the history
Signed-off-by: vivekr-splunk <[email protected]>
  • Loading branch information
vivekr-splunk committed Jan 10, 2024
1 parent 64c5925 commit 898f2c8
Show file tree
Hide file tree
Showing 17 changed files with 382 additions and 368 deletions.
1 change: 0 additions & 1 deletion pkg/splunk/enterprise/clustermanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func ApplyClusterManager(ctx context.Context, client splcommon.ControllerClient,
reqLogger := log.FromContext(ctx)
scopedLog := reqLogger.WithName("ApplyClusterManager")
eventPublisher, _ := newK8EventPublisher(client, cr)
cr.Kind = "ClusterManager"

if cr.Status.ResourceRevMap == nil {
cr.Status.ResourceRevMap = make(map[string]string)
Expand Down
17 changes: 16 additions & 1 deletion pkg/splunk/enterprise/clustermanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func TestApplyClusterManager(t *testing.T) {
}
c := spltest.NewMockClient()
_ = errors.New(splcommon.Rerr)
current.Kind = "ClusterManager"
_, err := ApplyClusterManager(ctx, c, &current)
if err == nil {
t.Errorf("Expected error")
Expand Down Expand Up @@ -204,6 +205,7 @@ func TestApplyClusterManager(t *testing.T) {
},
}

current.Kind = "ClusterManager"
_, err = ApplyClusterManager(ctx, c, &current)
if err == nil {
t.Errorf("Expected error")
Expand All @@ -220,6 +222,7 @@ func TestApplyClusterManager(t *testing.T) {
current.Spec.SmartStore.VolList[0].SecretRef = "s3-secret"
current.Status.SmartStore.VolList[0].SecretRef = "s3-secret"
current.Status.ResourceRevMap["s3-secret"] = "v2"
current.Kind = "ClusterManager"
_, err = ApplyClusterManager(ctx, c, &current)
if err == nil {
t.Errorf("Expected error")
Expand All @@ -234,6 +237,7 @@ func TestApplyClusterManager(t *testing.T) {
c.Create(ctx, &cmap)
current.Spec.SmartStore.VolList[0].SecretRef = ""
current.Spec.SmartStore.Defaults.IndexAndGlobalCommonSpec.VolName = "msos_s2s3_vol"
current.Kind = "ClusterManager"
_, err = ApplyClusterManager(ctx, c, &current)
if err != nil {
t.Errorf("Don't expected error here")
Expand Down Expand Up @@ -290,6 +294,7 @@ func TestApplyClusterManager(t *testing.T) {
},
},
}
current.Kind = "ClusterManager"
_, err = ApplyClusterManager(ctx, c, &current)
if err == nil {
t.Errorf("Expected error")
Expand All @@ -307,6 +312,7 @@ func TestApplyClusterManager(t *testing.T) {
}
rerr := errors.New(splcommon.Rerr)
c.InduceErrorKind[splcommon.MockClientInduceErrorGet] = rerr
current.Kind = "ClusterManager"
_, err = ApplyClusterManager(ctx, c, &current)
if err == nil {
t.Errorf("Expected error")
Expand Down Expand Up @@ -583,6 +589,7 @@ func TestApplyClusterManagerWithSmartstore(t *testing.T) {
}

// Without S3 keys, ApplyClusterManager should fail
current.Kind = "ClusterManager"
_, err := ApplyClusterManager(ctx, client, &current)
if err == nil {
t.Errorf("ApplyClusterManager should fail without S3 secrets configured")
Expand Down Expand Up @@ -612,6 +619,7 @@ func TestApplyClusterManagerWithSmartstore(t *testing.T) {
revised := current.DeepCopy()
revised.Spec.Image = "splunk/test"
reconcile := func(c *spltest.MockClient, cr interface{}) error {
current.Kind = "ClusterManager"
_, err := ApplyClusterManager(context.Background(), c, cr.(*enterpriseApi.ClusterManager))
return err
}
Expand Down Expand Up @@ -639,6 +647,7 @@ func TestApplyClusterManagerWithSmartstore(t *testing.T) {
spltest.ReconcileTesterWithoutRedundantCheck(t, "TestApplyClusterManagerWithSmartstore-0", &current, revised, createCalls, updateCalls, reconcile, true, secret, &smartstoreConfigMap, ss, pod)

current.Status.BundlePushTracker.NeedToPushManagerApps = true
current.Kind = "ClusterManager"
if _, err = ApplyClusterManager(context.Background(), client, &current); err != nil {
t.Errorf("ApplyClusterManager() should not have returned error")
}
Expand Down Expand Up @@ -866,6 +875,7 @@ func TestAppFrameworkApplyClusterManagerShouldNotFail(t *testing.T) {
t.Errorf(err.Error())
}

cm.Kind = "ClusterManager"
_, err = ApplyClusterManager(context.Background(), client, &cm)
if err != nil {
t.Errorf("ApplyClusterManager should not have returned error here.")
Expand Down Expand Up @@ -960,7 +970,7 @@ func TestApplyClusterManagerDeletion(t *testing.T) {
if err != nil {
t.Errorf("Unable to create download directory for apps :%s", splcommon.AppDownloadVolume)
}

cm.Kind = "ClusterManager"
_, err = ApplyClusterManager(ctx, c, &cm)
if err != nil {
t.Errorf("ApplyClusterManager should not have returned error here.")
Expand Down Expand Up @@ -1456,6 +1466,7 @@ func TestIsClusterManagerReadyForUpgrade(t *testing.T) {
},
}

cm.Kind = "ClusterManager"
err = client.Create(ctx, &cm)
_, err = ApplyClusterManager(ctx, client, &cm)
if err != nil {
Expand Down Expand Up @@ -1586,6 +1597,7 @@ func TestChangeClusterManagerAnnotations(t *testing.T) {
return extraEnv, err
}

cm.Kind = "ClusterManager"
client.Create(ctx, cm)
_, err = ApplyClusterManager(ctx, client, cm)
if err != nil {
Expand Down Expand Up @@ -1725,6 +1737,7 @@ func TestClusterManagerWitReadyState(t *testing.T) {
// simulate create stateful set
c.Create(ctx, statefulset)

clustermanager.Kind = "ClusterManager"
// simulate create clustermanager instance before reconcilation
c.Create(ctx, clustermanager)

Expand Down Expand Up @@ -1770,6 +1783,7 @@ func TestClusterManagerWitReadyState(t *testing.T) {
}

// call reconciliation
clustermanager.Kind = "ClusterManager"
_, err = ApplyClusterManager(ctx, c, clustermanager)
if err != nil {
t.Errorf("Unexpected error while running reconciliation for cluster manager with app framework %v", err)
Expand Down Expand Up @@ -1888,6 +1902,7 @@ func TestClusterManagerWitReadyState(t *testing.T) {
}

// call reconciliation
clustermanager.Kind = "ClusterManager"
_, err = ApplyClusterManager(ctx, c, clustermanager)
if err != nil {
t.Errorf("Unexpected error while running reconciliation for cluster manager with app framework %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/splunk/enterprise/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ ClusterManager:
if licenseManagerRef.Name == "" {
return true, nil
}
namespacedName := types.NamespacedName {
namespacedName := types.NamespacedName{
Namespace: cr.GetNamespace(),
Name: GetSplunkStatefulsetName(SplunkClusterManager, cr.GetName()),
}
Expand Down
Loading

0 comments on commit 898f2c8

Please sign in to comment.