@@ -30,6 +30,7 @@ import (
30
30
31
31
"github.com/polarismesh/polaris/auth"
32
32
"github.com/polarismesh/polaris/cache"
33
+ cachetypes "github.com/polarismesh/polaris/cache/api"
33
34
commonlog "github.com/polarismesh/polaris/common/log"
34
35
"github.com/polarismesh/polaris/common/utils"
35
36
"github.com/polarismesh/polaris/namespace"
@@ -76,6 +77,7 @@ type EurekaTestSuit struct {
76
77
updateCacheInterval time.Duration
77
78
cancel context.CancelFunc
78
79
storage store.Store
80
+ cacheMgr * cache.CacheManager
79
81
}
80
82
81
83
type options func (cfg * TestConfig )
@@ -117,6 +119,7 @@ func (d *EurekaTestSuit) initialize(t *testing.T, callback func(t *testing.T, s
117
119
if err != nil {
118
120
return err
119
121
}
122
+ d .cacheMgr = cacheMgn
120
123
121
124
// 批量控制器
122
125
namingBatchConfig , err := batch .ParseBatchConfig (d .cfg .Naming .Batch )
@@ -158,8 +161,8 @@ func (d *EurekaTestSuit) initialize(t *testing.T, callback func(t *testing.T, s
158
161
healthCheckServer .SetInstanceCache (cacheMgn .Instance ())
159
162
160
163
// 为 instance 的 cache 添加 健康检查的 Listener
161
- cacheMgn .AddListener (cache . CacheNameInstance , []cache .Listener {cacheProvider })
162
- cacheMgn .AddListener (cache . CacheNameClient , []cache .Listener {cacheProvider })
164
+ cacheMgn .AddListener (cachetypes . CacheInstance , []cachetypes .Listener {cacheProvider })
165
+ cacheMgn .AddListener (cachetypes . CacheClient , []cachetypes .Listener {cacheProvider })
163
166
164
167
d .healthSvr = healthCheckServer
165
168
time .Sleep (5 * time .Second )
@@ -201,11 +204,6 @@ func replaceEnv(configContent string) string {
201
204
202
205
func (d * EurekaTestSuit ) Destroy () {
203
206
d .cancel ()
204
- time .Sleep (5 * time .Second )
205
-
207
+ d .cacheMgr .Close ()
206
208
d .storage .Destroy ()
207
- time .Sleep (5 * time .Second )
208
-
209
- healthcheck .TestDestroy ()
210
- time .Sleep (5 * time .Second )
211
209
}
0 commit comments