github.com/rohankumardubey/aresdb@v0.0.2-0.20190517170215-e54e3ca06b9c/subscriber/config/service_config_test.go (about) 1 // Copyright (c) 2017-2018 Uber Technologies, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package config 16 17 import ( 18 . "github.com/onsi/ginkgo" 19 . "github.com/onsi/gomega" 20 "github.com/uber-go/tally" 21 "github.com/uber/aresdb/utils" 22 "go.uber.org/config" 23 "go.uber.org/zap" 24 ) 25 26 var _ = Describe("service_config", func() { 27 ActiveAresNameSpace = "dev01" 28 ActiveJobNameSpace = "job-test" 29 It("NewServiceConfig normal", func() { 30 cfg, err := config.NewYAMLProviderFromFiles("test.yaml") 31 Ω(err).Should(BeNil()) 32 33 p := Params{ 34 Environment: utils.EnvironmentContext{ 35 Deployment: "test", 36 }, 37 Logger: zap.NewNop(), 38 Scope: tally.NoopScope, 39 Config: cfg, 40 } 41 42 res, err := NewServiceConfig(p) 43 Ω(err).Should(BeNil()) 44 Ω(res).ShouldNot(BeNil()) 45 }) 46 It("NewServiceConfig local", func() { 47 cfg, err := config.NewYAMLProviderFromFiles("test-controller-disable.yaml") 48 Ω(err).Should(BeNil()) 49 50 p := Params{ 51 Environment: utils.EnvironmentContext{ 52 Deployment: "test", 53 }, 54 Logger: zap.NewNop(), 55 Scope: tally.NoopScope, 56 Config: cfg, 57 } 58 59 res, err := NewServiceConfig(p) 60 Ω(err).Should(BeNil()) 61 Ω(res).ShouldNot(BeNil()) 62 }) 63 It("NewServiceConfig ares-ns-empty", func() { 64 cfg, err := config.NewYAMLProviderFromFiles("test-ares-ns-empty.yaml") 65 Ω(err).Should(BeNil()) 66 67 p := Params{ 68 Environment: utils.EnvironmentContext{ 69 Deployment: "test", 70 }, 71 Logger: zap.NewNop(), 72 Scope: tally.NoopScope, 73 Config: cfg, 74 } 75 76 res, err := NewServiceConfig(p) 77 Ω(err).ShouldNot(BeNil()) 78 Ω(res).ShouldNot(BeNil()) 79 80 cfg, err = config.NewYAMLProviderFromFiles("test-ares-cluster-empty.yaml") 81 Ω(err).Should(BeNil()) 82 83 p.Config = cfg 84 85 res, err = NewServiceConfig(p) 86 Ω(err).ShouldNot(BeNil()) 87 Ω(res).ShouldNot(BeNil()) 88 89 cfg, err = config.NewYAMLProviderFromFiles("test-job-empty.yaml") 90 Ω(err).Should(BeNil()) 91 92 p.Config = cfg 93 94 res, err = NewServiceConfig(p) 95 Ω(err).ShouldNot(BeNil()) 96 Ω(res).ShouldNot(BeNil()) 97 98 ActiveAresNameSpace = "dev01-ares" 99 cfg, err = config.NewYAMLProviderFromFiles("test.yaml") 100 Ω(err).Should(BeNil()) 101 102 p.Config = cfg 103 104 res, err = NewServiceConfig(p) 105 Ω(err).ShouldNot(BeNil()) 106 Ω(res).ShouldNot(BeNil()) 107 }) 108 109 It("GetSinkMode", func() { 110 s := SinkConfig{ 111 SinkModeStr: "x", 112 } 113 Ω(s.GetSinkMode()).Should(Equal(Sink_Undefined)) 114 115 s = SinkConfig{ 116 SinkModeStr: "aresDB", 117 } 118 Ω(s.GetSinkMode()).Should(Equal(Sink_AresDB)) 119 120 s = SinkConfig{ 121 SinkModeStr: "kafka", 122 } 123 Ω(s.GetSinkMode()).Should(Equal(Sink_Kafka)) 124 }) 125 })