Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-11456

HealthCheckHandlerTest.testHealthCheckHandler() asserts nothing useful

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 8.0
    • None
    • None

    Description

      The meat of HealthCheckHandlerTest.testHealthCheckHandler() currently looks like this...

            while (live_nodes.size() == 1 && counter++ < 100) {
              Thread.sleep(100);
              live_nodes = cluster.getSolrClient().getZkStateReader().getClusterState().getLiveNodes();
            }
      
            try {
              req.process(httpSolrClient);
            } catch (HttpSolrClient.RemoteSolrException e) {
              assertTrue(e.getMessage(), e.getMessage().contains("Host Unavailable"));
              assertEquals(SolrException.ErrorCode.SERVICE_UNAVAILABLE.code, e.code());
            }
      
      • nothing actually asserts that live_nodes.size() != 1 – so the loop could just exit after 100 iterations w/o any changes to hte system happening.
      • instead of using expectThrows, the only assertions are inside the catch block – if the code (unexpectedly) succeeds the test will not fail (false positive)

      Attachments

        1. SOLR-11456.patch
          2 kB
          Chris M. Hostetter
        2. SOLR-11456.patch
          5 kB
          Chris M. Hostetter

        Issue Links

          Activity

            People

              hossman Chris M. Hostetter
              hossman Chris M. Hostetter
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: