TEST_F(TcpHealthCheckerImplTest, WrongData) {
  InSequence s;

  setupDataDontReuseConnection();
  cluster_->prioritySet().getMockHostSet(0)->hosts_ = {
      makeTestHost(cluster_->info_, "tcp://127.0.0.1:80", simTime())};
  expectSessionCreate();
  expectClientCreate();
  EXPECT_CALL(*connection_, write(_, _));
  EXPECT_CALL(*timeout_timer_, enableTimer(_, _));
  health_checker_->start();

  connection_->raiseEvent(Network::ConnectionEvent::Connected);

  // Not the expected response
  Buffer::OwnedImpl response;
  addUint8(response, 3);
  read_filter_->onData(response, false);

  // These are the expected metric results after testing.
  EXPECT_EQ(0UL, cluster_->info_->stats_store_.counter("health_check.success").value());
  // TODO(lilika): The TCP health checker does generic pattern matching so we can't differentiate
  // between wrong data and not enough data. We could likely do better here and figure out cases in
  // which a match is not possible but that is not done now.
  EXPECT_EQ(0UL, cluster_->info_->stats_store_.counter("health_check.failure").value());
}
TEST_F(TcpHealthCheckerImplTest, WrongData) {
  InSequence s;

  setupDataDontReuseConnection();
  cluster_->prioritySet().getMockHostSet(0)->hosts_ = {
      makeTestHost(cluster_->info_, "tcp://127.0.0.1:80", simTime())};
  expectSessionCreate();
  expectClientCreate();
  EXPECT_CALL(*connection_, write(_, _));
  EXPECT_CALL(*timeout_timer_, enableTimer(_, _));
  health_checker_->start();

  connection_->raiseEvent(Network::ConnectionEvent::Connected);

   
  Buffer::OwnedImpl response;
  addUint8(response, 3);
  read_filter_->onData(response, false);

   
  EXPECT_EQ(0UL, cluster_->info_->stats_store_.counter("health_check.success").value());
   
   
   
  EXPECT_EQ(0UL, cluster_->info_->stats_store_.counter("health_check.failure").value());
}