Solr
  1. Solr
  2. SOLR-7142

TestFaceting.testFacets senseless

    Details

    • Type: Test Test
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.1, 6.0
    • Component/s: faceting
    • Labels:
      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

      1. testfaceting.patch
        3 kB
        Michal Kroliczek

        Activity

        Hide
        Michal Kroliczek added a comment -

        Making test reasonable.

        Show
        Michal Kroliczek added a comment - Making test reasonable.
        Hide
        Shalin Shekhar Mangar added a comment -

        Fixed. Thanks Michal!

        Show
        Shalin Shekhar Mangar added a comment - Fixed. Thanks Michal!
        Hide
        ASF subversion and git services added a comment -

        Commit 1661685 from shalin@apache.org in branch 'dev/trunk'
        [ https://svn.apache.org/r1661685 ]

        SOLR-7142: Fix TestFaceting.testFacets

        Show
        ASF subversion and git services added a comment - Commit 1661685 from shalin@apache.org in branch 'dev/trunk' [ https://svn.apache.org/r1661685 ] SOLR-7142 : Fix TestFaceting.testFacets
        Hide
        ASF subversion and git services added a comment -

        Commit 1661687 from shalin@apache.org in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1661687 ]

        SOLR-7142: Fix TestFaceting.testFacets

        Show
        ASF subversion and git services added a comment - Commit 1661687 from shalin@apache.org in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1661687 ] SOLR-7142 : Fix TestFaceting.testFacets
        Hide
        Timothy Potter added a comment -

        Bulk close after 5.1 release

        Show
        Timothy Potter added a comment - Bulk close after 5.1 release

          People

          • Assignee:
            Shalin Shekhar Mangar
            Reporter:
            Michal Kroliczek
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development