@@ -32,7 +32,8 @@ import (
3232 appsv1 "k8s.io/api/apps/v1"
3333 corev1 "k8s.io/api/core/v1"
3434 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
35- "k8s.io/apimachinery/pkg/types"
35+ "k8s.io/apimachinery/pkg/runtime"
36+ "sigs.k8s.io/controller-runtime/pkg/client/fake"
3637)
3738
3839func init () {
@@ -55,7 +56,11 @@ func TestApplyIngestorCluster(t *testing.T) {
5556
5657 ctx := context .TODO ()
5758
58- c := spltest .NewMockClient ()
59+ scheme := runtime .NewScheme ()
60+ _ = enterpriseApi .AddToScheme (scheme )
61+ _ = corev1 .AddToScheme (scheme )
62+ _ = appsv1 .AddToScheme (scheme )
63+ c := fake .NewClientBuilder ().WithScheme (scheme ).Build ()
5964
6065 // Object definitions
6166 provider := "sqs_smartbus"
@@ -81,7 +86,7 @@ func TestApplyIngestorCluster(t *testing.T) {
8186 }
8287 c .Create (ctx , bus )
8388
84- lms := enterpriseApi.LargeMessageStore {
89+ lms := & enterpriseApi.LargeMessageStore {
8590 TypeMeta : metav1.TypeMeta {
8691 Kind : "LargeMessageStore" ,
8792 APIVersion : "enterprise.splunk.com/v4" ,
@@ -98,7 +103,7 @@ func TestApplyIngestorCluster(t *testing.T) {
98103 },
99104 },
100105 }
101- c .Create (ctx , & lms )
106+ c .Create (ctx , lms )
102107
103108 cr := & enterpriseApi.IngestorCluster {
104109 TypeMeta : metav1.TypeMeta {
@@ -112,7 +117,8 @@ func TestApplyIngestorCluster(t *testing.T) {
112117 Spec : enterpriseApi.IngestorClusterSpec {
113118 Replicas : 3 ,
114119 CommonSplunkSpec : enterpriseApi.CommonSplunkSpec {
115- Mock : true ,
120+ Mock : true ,
121+ ServiceAccount : "sa" ,
116122 },
117123 BusRef : corev1.ObjectReference {
118124 Name : bus .Name ,
@@ -242,29 +248,6 @@ func TestApplyIngestorCluster(t *testing.T) {
242248 assert .True (t , result .Requeue )
243249 assert .NotEqual (t , enterpriseApi .PhaseError , cr .Status .Phase )
244250
245- // Ensure stored StatefulSet status reflects readiness after any reconcile modifications
246- fetched := & appsv1.StatefulSet {}
247- _ = c .Get (ctx , types.NamespacedName {Name : "splunk-test-ingestor" , Namespace : "test" }, fetched )
248- fetched .Status .Replicas = replicas
249- fetched .Status .ReadyReplicas = replicas
250- fetched .Status .UpdatedReplicas = replicas
251- if fetched .Status .UpdateRevision == "" {
252- fetched .Status .UpdateRevision = "v1"
253- }
254- c .Update (ctx , fetched )
255-
256- // Guarantee all pods have matching revision label
257- for _ , pn := range []string {"splunk-test-ingestor-0" , "splunk-test-ingestor-1" , "splunk-test-ingestor-2" } {
258- p := & corev1.Pod {}
259- if err := c .Get (ctx , types.NamespacedName {Name : pn , Namespace : "test" }, p ); err == nil {
260- if p .Labels == nil {
261- p .Labels = map [string ]string {}
262- }
263- p .Labels ["controller-revision-hash" ] = fetched .Status .UpdateRevision
264- c .Update (ctx , p )
265- }
266- }
267-
268251 // outputs.conf
269252 origNew := newIngestorClusterPodManager
270253 mockHTTPClient := & spltest.MockHTTPClient {}
@@ -280,6 +263,7 @@ func TestApplyIngestorCluster(t *testing.T) {
280263 defer func () { newIngestorClusterPodManager = origNew }()
281264
282265 propertyKVList := [][]string {
266+ {"remote_queue.type" , provider },
283267 {fmt .Sprintf ("remote_queue.%s.encoding_format" , provider ), "s2s" },
284268 {fmt .Sprintf ("remote_queue.%s.auth_region" , provider ), bus .Spec .SQS .Region },
285269 {fmt .Sprintf ("remote_queue.%s.endpoint" , provider ), bus .Spec .SQS .Endpoint },
@@ -318,6 +302,13 @@ func TestApplyIngestorCluster(t *testing.T) {
318302 }
319303 }
320304
305+ for i := 0 ; i < int (cr .Status .ReadyReplicas ); i ++ {
306+ podName := fmt .Sprintf ("splunk-test-ingestor-%d" , i )
307+ baseURL := fmt .Sprintf ("https://%s.splunk-%s-ingestor-headless.%s.svc.cluster.local:8089/services/server/control/restart" , podName , cr .GetName (), cr .GetNamespace ())
308+ req , _ := http .NewRequest ("POST" , baseURL , nil )
309+ mockHTTPClient .AddHandler (req , 200 , "" , nil )
310+ }
311+
321312 // Second reconcile should now yield Ready
322313 cr .Status .TelAppInstalled = true
323314 result , err = ApplyIngestorCluster (ctx , c , cr )
0 commit comments