@@ -186,87 +186,6 @@ func TestHealthWatcherService_health(t *testing.T) {
186186 }
187187}
188188
189- //func TestHealthWatcherService_health2(t *testing.T) {
190- // ctx := context.Background()
191- // agentConfig := types.AgentConfig()
192- // healthWatcher := NewHealthWatcherService(agentConfig)
193- // ossInstance := protos.NginxOssInstance([]string{})
194- // plusInstance := protos.NginxPlusInstance([]string{})
195- // unspecifiedInstance := protos.UnsupportedInstance()
196- //
197- // fakeOSSHealthOp := healthfakes.FakeHealthWatcherOperator{}
198- // fakeOSSHealthOp.HealthReturns(protos.HealthyInstanceHealth(), nil)
199- //
200- // fakePlusHealthOp := healthfakes.FakeHealthWatcherOperator{}
201- // fakePlusHealthOp.HealthReturns(protos.UnhealthyInstanceHealth(), nil)
202- //
203- // fakeUnspecifiedHealthOp := healthfakes.FakeHealthWatcherOperator{}
204- // fakeUnspecifiedHealthOp.HealthReturns(nil, errors.New("unable to determine health"))
205- //
206- // healthWatcher.watcher = &fakePlusHealthOp
207- //
208- // expected := []*mpi.InstanceHealth{
209- // protos.HealthyInstanceHealth(),
210- // protos.UnhealthyInstanceHealth(),
211- // protos.UnspecifiedInstanceHealth(),
212- // }
213- //
214- // healthWatcher.UpdateHealthWatcher([]*mpi.Instance{
215- // ossInstance,
216- // plusInstance,
217- // unspecifiedInstance,
218- // })
219- //
220- // tests := []struct {
221- // cache map[string]*mpi.InstanceHealth
222- // name string
223- // isHealthDiff bool
224- // }{
225- // {
226- // name: "Test 1: Status Changed",
227- // cache: map[string]*mpi.InstanceHealth{
228- // ossInstance.GetInstanceMeta().GetInstanceId(): protos.HealthyInstanceHealth(),
229- // plusInstance.GetInstanceMeta().GetInstanceId(): {
230- // InstanceId: plusInstance.GetInstanceMeta().GetInstanceId(),
231- // InstanceHealthStatus: mpi.InstanceHealth_INSTANCE_HEALTH_STATUS_HEALTHY,
232- // },
233- // unspecifiedInstance.GetInstanceMeta().GetInstanceId(): protos.UnspecifiedInstanceHealth(),
234- // },
235- // isHealthDiff: true,
236- // },
237- // {
238- // name: "Test 2: Status Not Changed",
239- // cache: map[string]*mpi.InstanceHealth{
240- // ossInstance.GetInstanceMeta().GetInstanceId(): protos.HealthyInstanceHealth(),
241- // plusInstance.GetInstanceMeta().GetInstanceId(): protos.UnhealthyInstanceHealth(),
242- // unspecifiedInstance.GetInstanceMeta().GetInstanceId(): protos.UnspecifiedInstanceHealth(),
243- // },
244- // isHealthDiff: false,
245- // },
246- // {
247- // name: "Test 3: Less Instances",
248- // cache: map[string]*mpi.InstanceHealth{
249- // ossInstance.GetInstanceMeta().GetInstanceId(): {
250- // InstanceId: ossInstance.GetInstanceMeta().GetInstanceId(),
251- // InstanceHealthStatus: mpi.InstanceHealth_INSTANCE_HEALTH_STATUS_UNHEALTHY,
252- // },
253- // unspecifiedInstance.GetInstanceMeta().GetInstanceId(): protos.UnspecifiedInstanceHealth(),
254- // },
255- // isHealthDiff: true,
256- // },
257- // }
258- //
259- // for _, test := range tests {
260- // t.Run(test.name, func(tt *testing.T) {
261- // healthWatcher.updateCache(test.cache)
262- // instanceHealth, healthDiff := healthWatcher.health(ctx)
263- // assert.Equal(t, test.isHealthDiff, healthDiff)
264- //
265- // reflect.DeepEqual(instanceHealth, expected)
266- // })
267- // }
268- //}
269-
270189func TestHealthWatcherService_compareCache (t * testing.T ) {
271190 ossInstance := protos .NginxOssInstance ([]string {})
272191 plusInstance := protos .NginxPlusInstance ([]string {})
0 commit comments