@@ -19,7 +19,6 @@ package feobserver_test
1919import (
2020 "context"
2121 "os"
22- "reflect"
2322 "testing"
2423 "time"
2524
@@ -272,109 +271,3 @@ func TestFeObserver_Ready(t *testing.T) {
272271 })
273272 }
274273}
275-
276- func TestGetFEObserverConfig (t * testing.T ) {
277- type args struct {
278- ctx context.Context
279- observerSpec * srapi.StarRocksFeObserverSpec
280- namespace string
281- }
282- type fields struct {
283- k8sClient client.Client
284- }
285- tests := []struct {
286- name string
287- fields fields
288- args args
289- want map [string ]interface {}
290- wantErr bool
291- }{
292- {
293- name : "get config from ConfigMapInfo" ,
294- fields : fields {
295- k8sClient : fake .NewFakeClient (srapi .Scheme , & corev1.ConfigMap {
296- ObjectMeta : metav1.ObjectMeta {
297- Name : "feobserver-config" ,
298- Namespace : "default" ,
299- },
300- Data : map [string ]string {
301- "fe.conf" : "aa = bb" ,
302- },
303- }),
304- },
305- args : args {
306- ctx : context .Background (),
307- observerSpec : & srapi.StarRocksFeObserverSpec {
308- ComponentSpec : srapi.StarRocksComponentSpec {
309- StarRocksLoadSpec : srapi.StarRocksLoadSpec {
310- ConfigMapInfo : srapi.ConfigMapInfo {
311- ConfigMapName : "feobserver-config" ,
312- ResolveKey : "fe.conf" ,
313- },
314- },
315- },
316- },
317- namespace : "default" ,
318- },
319- want : map [string ]interface {}{
320- "aa" : "bb" ,
321- },
322- },
323- {
324- name : "get config from configMaps with matching subpath" ,
325- fields : fields {
326- k8sClient : fake .NewFakeClient (srapi .Scheme , & corev1.ConfigMap {
327- ObjectMeta : metav1.ObjectMeta {
328- Name : "feobserver-config" ,
329- Namespace : "default" ,
330- },
331- Data : map [string ]string {
332- "fe.conf" : "cc = dd" ,
333- },
334- }),
335- },
336- args : args {
337- ctx : context .Background (),
338- observerSpec : & srapi.StarRocksFeObserverSpec {
339- ComponentSpec : srapi.StarRocksComponentSpec {
340- ConfigMaps : []srapi.ConfigMapReference {
341- {
342- Name : "feobserver-config" ,
343- MountPath : "/opt/starrocks/fe/conf/fe.conf" ,
344- SubPath : "fe.conf" ,
345- },
346- },
347- },
348- },
349- namespace : "default" ,
350- },
351- want : map [string ]interface {}{
352- "cc" : "dd" ,
353- },
354- },
355- {
356- name : "get empty config" ,
357- fields : fields {
358- k8sClient : fake .NewFakeClient (srapi .Scheme ),
359- },
360- args : args {
361- ctx : context .Background (),
362- observerSpec : & srapi.StarRocksFeObserverSpec {},
363- namespace : "default" ,
364- },
365- want : map [string ]interface {}{},
366- },
367- }
368- for _ , tt := range tests {
369- t .Run (tt .name , func (t * testing.T ) {
370- got , err := feobserver .GetFEObserverConfig (tt .args .ctx , tt .fields .k8sClient , tt .args .observerSpec , tt .args .namespace )
371- if (err != nil ) != tt .wantErr {
372- t .Errorf ("GetFEObserverConfig() error = %v, wantErr %v" , err , tt .wantErr )
373- return
374- }
375- if ! reflect .DeepEqual (got , tt .want ) {
376- t .Errorf ("GetFEObserverConfig() got = %v, want %v" , got , tt .want )
377- }
378- })
379- }
380- }
0 commit comments