Skip to content

Commit f8ca040

Browse files
titpetricTit Petric
and
Tit Petric
authored
[TT-10070] Fix/sanitize error logging (TykTechnologies#6817)
### **User description** https://tyktech.atlassian.net/browse/TT-10070 ___ ### **PR Type** Bug fix, Enhancement ___ ### **Description** - Removed unnecessary PID file reading and improved PID handling. - Enhanced Redis connection handling with explicit connect calls. - Improved webhook validation by checking for empty target paths. - Added test adjustments and cleanup for PID-related functionality. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>config.go</strong><dd><code>Add default PID file location configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> config/config.go - Added a default `PIDFileLocation` configuration. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6817/files#diff-fe44f09c4d5977b5f5eaea29170b6a0748819c9d02271746a20d81a5f3efca17">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>server.go</strong><dd><code>Improve Redis connections and PID handling</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> gateway/server.go <li>Added explicit Redis connection calls across multiple instances.<br> <li> Improved PID handling by removing unnecessary file reads.<br> <li> Enhanced storage connection initialization with timeout handling.<br> <li> Refactored PID-related logic for clarity and reliability. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6817/files#diff-4652d1bf175a0be8f5e61ef7177c9666f23e077d8626b73ac9d13358fa8b525b">+41/-26</a>&nbsp; </td> </tr> </table></td></tr><tr><td><strong>Bug fix</strong></td><td><table> <tr> <td> <details> <summary><strong>api_loader.go</strong><dd><code>Skip mTLS warning when running tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> gateway/api_loader.go - Added a check to skip mTLS warning during tests. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6817/files#diff-cdf0b7f176c9d18e1a314b78ddefc2cb3a94b3de66f1f360174692c915734c68">+2/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>event_handler_webhooks.go</strong><dd><code>Improve webhook validation and URL checks</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> gateway/event_handler_webhooks.go <li>Added validation for empty webhook target paths.<br> <li> Ensured URLs are not empty before parsing. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6817/files#diff-6587ad3f2629cfa6c84a71144127acd6cc7824e5141f0b4961848945a87e0198">+4/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Tests</strong></td><td><table> <tr> <td> <details> <summary><strong>server_test.go</strong><dd><code>Update tests for PID handling changes</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> gateway/server_test.go <li>Removed references to <code>readPIDFromFile</code> in tests.<br> <li> Adjusted test setup to align with new PID handling logic. </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/6817/files#diff-d9f006370c9748c09affd99d0a4edeb8f3419057703a67fd70838a764a485696">+6/-6</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > 💡 **PR-Agent usage**: Comment `/help "your question"` on any pull request to receive relevant information --------- Co-authored-by: Tit Petric <tit@tyk.io>
1 parent daf76a8 commit f8ca040

22 files changed

+200
-87
lines changed

config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ var (
5656
Enabled: false,
5757
AllowUnsafe: []string{},
5858
},
59+
PIDFileLocation: "/var/run/tyk/tyk-gateway.pid",
5960
}
6061
)
6162

gateway/api.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -2236,13 +2236,16 @@ func (gw *Gateway) createOauthClient(w http.ResponseWriter, r *http.Request) {
22362236
storageManager := gw.getGlobalMDCBStorageHandler(prefix, false)
22372237
storageManager.Connect()
22382238

2239+
storageDriver := &storage.RedisCluster{KeyPrefix: prefix, HashKeys: false, ConnectionHandler: gw.StorageConnectionHandler}
2240+
storageDriver.Connect()
2241+
22392242
apiSpec.OAuthManager = &OAuthManager{
22402243
OsinServer: gw.TykOsinNewServer(
22412244
&osin.ServerConfig{},
22422245
&RedisOsinStorageInterface{
22432246
storageManager,
22442247
gw.GlobalSessionManager,
2245-
&storage.RedisCluster{KeyPrefix: prefix, HashKeys: false, ConnectionHandler: gw.StorageConnectionHandler},
2248+
storageDriver,
22462249
apiSpec.OrgID,
22472250
gw,
22482251
}),
@@ -2623,12 +2626,16 @@ func (gw *Gateway) getOauthClientDetails(keyName, apiID string) (interface{}, in
26232626
prefix := generateOAuthPrefix(apiSpec.APIID)
26242627
storageManager := gw.getGlobalMDCBStorageHandler(prefix, false)
26252628
storageManager.Connect()
2629+
2630+
storageDriver := &storage.RedisCluster{KeyPrefix: prefix, HashKeys: false, ConnectionHandler: gw.StorageConnectionHandler}
2631+
storageDriver.Connect()
2632+
26262633
apiSpec.OAuthManager = &OAuthManager{
26272634
OsinServer: gw.TykOsinNewServer(&osin.ServerConfig{},
26282635
&RedisOsinStorageInterface{
26292636
storageManager,
26302637
gw.GlobalSessionManager,
2631-
&storage.RedisCluster{KeyPrefix: prefix, HashKeys: false, ConnectionHandler: gw.StorageConnectionHandler},
2638+
storageDriver,
26322639
apiSpec.OrgID,
26332640
gw,
26342641
}),

gateway/api_loader.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,16 @@ type ChainObject struct {
4545

4646
func (gw *Gateway) prepareStorage() generalStores {
4747
var gs generalStores
48+
4849
gs.redisStore = &storage.RedisCluster{KeyPrefix: "apikey-", HashKeys: gw.GetConfig().HashKeys, ConnectionHandler: gw.StorageConnectionHandler}
50+
gs.redisStore.Connect()
51+
4952
gs.redisOrgStore = &storage.RedisCluster{KeyPrefix: "orgkey.", ConnectionHandler: gw.StorageConnectionHandler}
53+
gs.redisOrgStore.Connect()
54+
5055
gs.healthStore = &storage.RedisCluster{KeyPrefix: "apihealth.", ConnectionHandler: gw.StorageConnectionHandler}
56+
gs.healthStore.Connect()
57+
5158
gs.rpcAuthStore = &RPCStorageHandler{KeyPrefix: "apikey-", HashKeys: gw.GetConfig().HashKeys, Gw: gw}
5259
gs.rpcOrgStore = gw.getGlobalMDCBStorageHandler("orgkey.", false)
5360

@@ -56,7 +63,6 @@ func (gw *Gateway) prepareStorage() generalStores {
5663
}
5764

5865
func (gw *Gateway) skipSpecBecauseInvalid(spec *APISpec, logger *logrus.Entry) bool {
59-
6066
switch spec.Protocol {
6167
case "", "http", "https":
6268
if spec.Proxy.ListenPath == "" {
@@ -1064,7 +1070,8 @@ func (gw *Gateway) loadApps(specs []*APISpec) {
10641070

10651071
gwListenPort := gw.GetConfig().ListenPort
10661072
controlApiIsConfigured := (gw.GetConfig().ControlAPIPort != 0 && gw.GetConfig().ControlAPIPort != gwListenPort) || gw.GetConfig().ControlAPIHostname != ""
1067-
if gw.allApisAreMTLS() && !gw.GetConfig().Security.ControlAPIUseMutualTLS && !controlApiIsConfigured {
1073+
1074+
if !gw.isRunningTests() && gw.allApisAreMTLS() && !gw.GetConfig().Security.ControlAPIUseMutualTLS && !controlApiIsConfigured {
10681075
mainLog.Warning("All APIs are protected with mTLS, except for the control API. " +
10691076
"We recommend configuring the control API port or control hostname to ensure consistent security measures")
10701077
}

gateway/coprocess_api.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ import (
1616
// CoProcessDefaultKeyPrefix is used as a key prefix for this CP.
1717
const CoProcessDefaultKeyPrefix = "coprocess-data:"
1818

19-
func getStorageForPython(ctx context.Context) storage.RedisCluster {
19+
func getStorageForPython(ctx context.Context) *storage.RedisCluster {
2020
rc := storage.NewConnectionHandler(ctx)
2121

2222
go rc.Connect(ctx, nil, &config.Config{})
2323
rc.WaitConnect(ctx)
2424

25-
return storage.RedisCluster{KeyPrefix: CoProcessDefaultKeyPrefix, ConnectionHandler: rc}
25+
handler := &storage.RedisCluster{KeyPrefix: CoProcessDefaultKeyPrefix, ConnectionHandler: rc}
26+
handler.Connect()
27+
return handler
2628
}
2729

2830
// TykStoreData is a CoProcess API function for storing data.

gateway/coprocess_id_extractor_test.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,27 @@ const (
3131

3232
func (ts *Test) createSpecTestFrom(tb testing.TB, def *apidef.APIDefinition) *APISpec {
3333
tb.Helper()
34+
3435
loader := APIDefinitionLoader{Gw: ts.Gw}
3536
spec, _ := loader.MakeSpec(&model.MergedAPI{APIDefinition: def}, nil)
3637
tname := tb.Name()
38+
3739
redisStore := &storage.RedisCluster{KeyPrefix: tname + "-apikey.", ConnectionHandler: ts.Gw.StorageConnectionHandler}
40+
redisStore.Connect()
41+
3842
healthStore := &storage.RedisCluster{KeyPrefix: tname + "-apihealth.", ConnectionHandler: ts.Gw.StorageConnectionHandler}
43+
healthStore.Connect()
44+
3945
orgStore := &storage.RedisCluster{KeyPrefix: tname + "-orgKey.", ConnectionHandler: ts.Gw.StorageConnectionHandler}
46+
orgStore.Connect()
47+
4048
spec.Init(redisStore, redisStore, healthStore, orgStore)
4149
return spec
4250
}
4351

44-
func (ts *Test) prepareExtractor(tb testing.TB, extractorSource apidef.IdExtractorSource, extractorType apidef.IdExtractorType,
45-
config map[string]interface{}, disabled bool) (IdExtractor, *APISpec) {
52+
func (ts *Test) prepareExtractor(tb testing.TB, extractorSource apidef.IdExtractorSource, extractorType apidef.IdExtractorType, config map[string]interface{}, disabled bool) (IdExtractor, *APISpec) {
4653
tb.Helper()
54+
4755
def := &apidef.APIDefinition{
4856
OrgID: MockOrgID,
4957
CustomMiddleware: apidef.MiddlewareSection{

gateway/delete_api_cache.go

+2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ import (
88

99
func (gw *Gateway) invalidateAPICache(apiID string) bool {
1010
store := storage.RedisCluster{IsCache: true, ConnectionHandler: gw.StorageConnectionHandler}
11+
store.Connect()
12+
1113
return store.DeleteScanMatch(fmt.Sprintf("cache-%s*", apiID))
1214
}

gateway/event_handler_webhooks.go

+5
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,14 @@ func (w *WebHookHandler) getRequestMethod(m string) WebHookRequestMethod {
161161
}
162162

163163
func (w *WebHookHandler) checkURL(r string) bool {
164+
if r == "" {
165+
return false
166+
}
167+
164168
log.WithFields(logrus.Fields{
165169
"prefix": "webhooks",
166170
}).Debug("Checking URL: ", r)
171+
167172
if _, err := url.ParseRequestURI(r); err != nil {
168173
log.WithFields(logrus.Fields{
169174
"prefix": "webhooks",

gateway/gateway_test.go

+26
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,10 @@ func TestCacheAllSafeRequests(t *testing.T) {
889889
t.Skip() // DeleteScanMatch interferes with other tests.
890890

891891
ts := StartTest(nil)
892+
892893
cache := storage.RedisCluster{KeyPrefix: "cache-", ConnectionHandler: ts.Gw.StorageConnectionHandler}
894+
cache.Connect()
895+
893896
t.Cleanup(func() {
894897
ts.Close()
895898
cache.DeleteScanMatch("*")
@@ -919,7 +922,10 @@ func TestCacheAllSafeRequestsWithCachedHeaders(t *testing.T) {
919922
t.Skip() // DeleteScanMatch interferes with other tests.
920923

921924
ts := StartTest(nil)
925+
922926
cache := storage.RedisCluster{KeyPrefix: "cache-", ConnectionHandler: ts.Gw.StorageConnectionHandler}
927+
cache.Connect()
928+
923929
t.Cleanup(func() {
924930
ts.Close()
925931
cache.DeleteScanMatch("*")
@@ -965,7 +971,10 @@ func TestCacheWithAdvanceUrlRewrite(t *testing.T) {
965971
t.Skip() // DeleteScanMatch interferes with other tests.
966972

967973
ts := StartTest(nil)
974+
968975
cache := storage.RedisCluster{KeyPrefix: "cache-", ConnectionHandler: ts.Gw.StorageConnectionHandler}
976+
cache.Connect()
977+
969978
t.Cleanup(func() {
970979
ts.Close()
971980
cache.DeleteScanMatch("*")
@@ -1024,7 +1033,10 @@ func TestCachePostRequest(t *testing.T) {
10241033
t.Skip() // DeleteScanMatch interferes with other tests.
10251034

10261035
ts := StartTest(nil)
1036+
10271037
cache := storage.RedisCluster{KeyPrefix: "cache-", ConnectionHandler: ts.Gw.StorageConnectionHandler}
1038+
cache.Connect()
1039+
10281040
t.Cleanup(func() {
10291041
ts.Close()
10301042
cache.DeleteScanMatch("*")
@@ -1071,7 +1083,10 @@ func TestAdvanceCachePutRequest(t *testing.T) {
10711083
t.Skip() // DeleteScanMatch interferes with other tests.
10721084

10731085
ts := StartTest(nil)
1086+
10741087
cache := storage.RedisCluster{KeyPrefix: "cache-", ConnectionHandler: ts.Gw.StorageConnectionHandler}
1088+
cache.Connect()
1089+
10751090
t.Cleanup(func() {
10761091
ts.Close()
10771092
cache.DeleteScanMatch("*")
@@ -1164,7 +1179,10 @@ func TestCacheAllSafeRequestsWithAdvancedCacheEndpoint(t *testing.T) {
11641179
t.Skip() // DeleteScanMatch interferes with other tests.
11651180

11661181
ts := StartTest(nil)
1182+
11671183
cache := storage.RedisCluster{KeyPrefix: "cache-", ConnectionHandler: ts.Gw.StorageConnectionHandler}
1184+
cache.Connect()
1185+
11681186
t.Cleanup(func() {
11691187
ts.Close()
11701188
cache.DeleteScanMatch("*")
@@ -1203,7 +1221,9 @@ func TestCacheEtag(t *testing.T) {
12031221
t.Skip() // DeleteScanMatch interferes with other tests.
12041222

12051223
ts := StartTest(nil)
1224+
12061225
cache := storage.RedisCluster{KeyPrefix: "cache-", ConnectionHandler: ts.Gw.StorageConnectionHandler}
1226+
cache.Connect()
12071227

12081228
t.Cleanup(func() {
12091229
ts.Close()
@@ -1258,7 +1278,10 @@ func TestOldCachePlugin(t *testing.T) {
12581278
t.Helper()
12591279

12601280
ts := StartTest(nil)
1281+
12611282
cache := storage.RedisCluster{KeyPrefix: "cache-", ConnectionHandler: ts.Gw.StorageConnectionHandler}
1283+
cache.Connect()
1284+
12621285
t.Cleanup(func() {
12631286
ts.Close()
12641287
cache.DeleteScanMatch("*")
@@ -1287,7 +1310,10 @@ func TestAdvanceCacheTimeoutPerEndpoint(t *testing.T) {
12871310
t.Skip() // DeleteScanMatch interferes with other tests.
12881311

12891312
ts := StartTest(nil)
1313+
12901314
cache := storage.RedisCluster{KeyPrefix: "cache-", ConnectionHandler: ts.Gw.StorageConnectionHandler}
1315+
cache.Connect()
1316+
12911317
t.Cleanup(func() {
12921318
ts.Close()
12931319
cache.DeleteScanMatch("*")

gateway/health_check.go

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func (gw *Gateway) gatherHealthChecks() {
7979
allInfos := SafeHealthCheck{info: make(map[string]HealthCheckItem, 3)}
8080

8181
redisStore := storage.RedisCluster{KeyPrefix: "livenesscheck-", ConnectionHandler: gw.StorageConnectionHandler}
82+
redisStore.Connect()
8283

8384
key := "tyk-liveness-probe"
8485

gateway/host_checker.go

+4
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ func eraseSyncMap(m *sync.Map) {
398398
}
399399

400400
func (h *HostUptimeChecker) Stop() {
401+
if h == nil {
402+
return
403+
}
404+
401405
was := atomic.SwapInt32(&h.isClosed, CLOSED)
402406
if was == OPEN {
403407
eraseSyncMap(h.samples)

gateway/host_checker_manager.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (hc *HostCheckerManager) Init(store storage.Handler) {
8282

8383
func (hc *HostCheckerManager) Start(ctx context.Context) {
8484
// Start loop to check if we are active instance
85-
if hc.Id != "" {
85+
if hc != nil {
8686
go hc.CheckActivePollerLoop(ctx)
8787
}
8888
}
@@ -181,7 +181,6 @@ func (hc *HostCheckerManager) AmIPolling() bool {
181181
}
182182

183183
func (hc *HostCheckerManager) StartPoller(ctx context.Context) {
184-
185184
log.WithFields(logrus.Fields{
186185
"prefix": "host-check-mgr",
187186
}).Debug("---> Initialising checker")
@@ -192,7 +191,8 @@ func (hc *HostCheckerManager) StartPoller(ctx context.Context) {
192191
hc.checker = &HostUptimeChecker{Gw: hc.Gw}
193192
}
194193

195-
hc.checker.Init(hc.Gw.GetConfig().UptimeTests.Config.CheckerPoolSize,
194+
hc.checker.Init(
195+
hc.Gw.GetConfig().UptimeTests.Config.CheckerPoolSize,
196196
hc.Gw.GetConfig().UptimeTests.Config.FailureTriggerSampleSize,
197197
hc.Gw.GetConfig().UptimeTests.Config.TimeWait,
198198
hc.currentHostList,
@@ -207,14 +207,21 @@ func (hc *HostCheckerManager) StartPoller(ctx context.Context) {
207207
log.WithFields(logrus.Fields{
208208
"prefix": "host-check-mgr",
209209
}).Debug("---> Starting checker")
210+
210211
hc.checker.Start(ctx)
212+
211213
log.WithFields(logrus.Fields{
212214
"prefix": "host-check-mgr",
213215
}).Debug("---> Checker started.")
216+
214217
hc.checkerMu.Unlock()
215218
}
216219

217220
func (hc *HostCheckerManager) StopPoller() {
221+
if hc == nil {
222+
return
223+
}
224+
218225
hc.checkerMu.Lock()
219226
hc.checker.Stop()
220227
hc.checkerMu.Unlock()
@@ -536,11 +543,11 @@ func (hc *HostCheckerManager) RecordUptimeAnalytics(report HostHealthReport) err
536543

537544
func (gw *Gateway) InitHostCheckManager(ctx context.Context, store storage.Handler) {
538545
// Already initialized
539-
if gw.GlobalHostChecker.Id != "" {
546+
if gw.GlobalHostChecker != nil {
540547
return
541548
}
542549

543-
gw.GlobalHostChecker = HostCheckerManager{Gw: gw}
550+
gw.GlobalHostChecker = &HostCheckerManager{Gw: gw}
544551
gw.GlobalHostChecker.Init(store)
545552
gw.GlobalHostChecker.Start(ctx)
546553
}

gateway/host_checker_manager_test.go

+17
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ func TestHostCheckerManagerInit(t *testing.T) {
1414
defer ts.Close()
1515

1616
hc := HostCheckerManager{Gw: ts.Gw}
17+
1718
redisStorage := &storage.RedisCluster{KeyPrefix: "host-checker-test:", ConnectionHandler: ts.Gw.StorageConnectionHandler}
19+
redisStorage.Connect()
20+
1821
hc.Init(redisStorage)
1922

2023
if hc.Id == "" {
@@ -46,6 +49,8 @@ func TestAmIPolling(t *testing.T) {
4649
ts.Gw.SetConfig(globalConf)
4750

4851
redisStorage := &storage.RedisCluster{KeyPrefix: "host-checker-test:", ConnectionHandler: ts.Gw.StorageConnectionHandler}
52+
redisStorage.Connect()
53+
4954
hc.Init(redisStorage)
5055
hc2 := HostCheckerManager{Gw: ts.Gw}
5156
hc2.Init(redisStorage)
@@ -74,7 +79,10 @@ func TestAmIPolling(t *testing.T) {
7479

7580
//Testing if the PollerCacheKey doesn't contains the poller_group by default
7681
hc = HostCheckerManager{Gw: ts.Gw}
82+
7783
redisStorage = &storage.RedisCluster{KeyPrefix: "host-checker-test:", ConnectionHandler: ts.Gw.StorageConnectionHandler}
84+
redisStorage.Connect()
85+
7886
hc.Init(redisStorage)
7987
hc.AmIPolling()
8088

@@ -106,7 +114,10 @@ func TestCheckActivePollerLoop(t *testing.T) {
106114
defer ts.Close()
107115

108116
hc := &HostCheckerManager{Gw: ts.Gw}
117+
109118
redisStorage := &storage.RedisCluster{KeyPrefix: "host-checker-test-1:", ConnectionHandler: ts.Gw.StorageConnectionHandler}
119+
redisStorage.Connect()
120+
110121
hc.Init(redisStorage)
111122

112123
go hc.CheckActivePollerLoop(ts.Gw.ctx)
@@ -122,7 +133,10 @@ func TestStartPoller(t *testing.T) {
122133
defer ts.Close()
123134

124135
hc := HostCheckerManager{Gw: ts.Gw}
136+
125137
redisStorage := &storage.RedisCluster{KeyPrefix: "host-checker-TestStartPoller:", ConnectionHandler: ts.Gw.StorageConnectionHandler}
138+
redisStorage.Connect()
139+
126140
hc.Init(redisStorage)
127141

128142
hc.StartPoller(ts.Gw.ctx)
@@ -135,9 +149,12 @@ func TestStartPoller(t *testing.T) {
135149
func TestRecordUptimeAnalytics(t *testing.T) {
136150
ts := StartTest(nil)
137151
defer ts.Close()
152+
138153
hc := &HostCheckerManager{Gw: ts.Gw}
139154

140155
redisStorage := &storage.RedisCluster{KeyPrefix: "host-checker-test-analytics:", ConnectionHandler: ts.Gw.StorageConnectionHandler}
156+
redisStorage.Connect()
157+
141158
hc.Init(redisStorage)
142159

143160
spec := &APISpec{}

0 commit comments

Comments
 (0)