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

TestFaceting.testFacets senseless

    XMLWordPrintableJSON

Details

    • Test
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • None
    • 5.1, 6.0
    • faceting
    • None

    Description

      Hi, I am new to Solr sources and I was digging in facet tests.
      I found unreasonable block of code in TestFaceting.testFacets:

      ... ( 1st document is added and assertion is done) 
      
        // test gaps that take more than one byte
          sb = new StringBuilder();
          sb.append(t(0)).append(' ');
          sb.append(t(150)).append(' ');
          sb.append(t(301)).append(' ');
          sb.append(t(453)).append(' ');
          sb.append(t(606)).append(' ');
          sb.append(t(1000)).append(' ');
          sb.append(t(2010)).append(' ');
          sb.append(t(3050)).append(' ');
          sb.append(t(4999)).append(' ');
          assertU(adoc("id", "2", "many_ws", sb.toString()));
          assertQ("check many tokens",
                  req(**"q", "id:1"**,"indent","true"
                      ,"facet", "true", "facet.method","fc"
                      ,"facet.field", "many_ws"
                      ,"facet.limit", "-1"
                      )
                  ,"*[count(//lst[@name='many_ws']/int)=5000]"
                  ,"//lst[@name='many_ws']/int[@name='" + t(0) + "'][.='1']"
                  ,"//lst[@name='many_ws']/int[@name='" + t(150) + "'][.='1']"
                  ,"//lst[@name='many_ws']/int[@name='" + t(301) + "'][.='1']"
                  ,"//lst[@name='many_ws']/int[@name='" + t(453) + "'][.='1']"
                  ,"//lst[@name='many_ws']/int[@name='" + t(606) + "'][.='1']"
                  ,"//lst[@name='many_ws']/int[@name='" + t(1000) + "'][.='1']"
                  ,"//lst[@name='many_ws']/int[@name='" + t(2010) + "'][.='1']"
                  ,"//lst[@name='many_ws']/int[@name='" + t(3055) + "'][.='1']"
                  ,"//lst[@name='many_ws']/int[@name='" + t(4999) + "'][.='1']"
                    );
      

      This code adds second document, never commits and executes second query with q=id:1 again.

      So test will pass even if:
      1) Change assertions to ID's not related to 2nd document (like 2001)
      2) Add commit after 2nd document added (still filter is set to id:1)
      3) Remove at all creating 2nd document.

      Patch changes test flow to fallowing:
      1) add document1 and commit
      2) assert facets to query :
      3) add document2 and commit
      5) assert query : to have facetes with values 1 and 2 when expected

      Attachments

        1. testfaceting.patch
          3 kB
          Michal Kroliczek

        Activity

          People

            shalin Shalin Shekhar Mangar
            kroliczek Michal Kroliczek
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: