Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.3, 7.0
    • Component/s: scripts and tools
    • Security Level: Public (Default Security Level. Issues are Public)
    • Labels:
      None

      Description

      Moving some code from SOLR-7826 over here. This is a new AssertTool which can be used to assert that we are (not) root user and more. Usage:

      usage: bin/solr assert [-m <message>] [-e] [-rR] [-s <url>] [-S <url>] [-u
                      <dir>] [-x <dir>] [-X <dir>]
       -e,--exitcode                 Return an exit code instead of printing
                                     error message on assert fail.
       -m,--message <message>        Exception message to be used in place of
                                     the default error message
       -R,--not-root                 Asserts that we are NOT the root user
       -r,--root                     Asserts that we are the root user
       -S,--not-started <url>        Asserts that Solr is NOT running on a
                                     certain URL. Default timeout is 1000ms
       -s,--started <url>            Asserts that Solr is running on a certain
                                     URL. Default timeout is 1000ms
       -t,--ms <ms>                  Timeout in ms for commands supporting a
                                     timeout
       -u,--same-user <directory>    Asserts that we run as same user that owns
                                     <directory>
       -verbose                      Generate verbose log messages
       -x,--exists <directory>       Asserts that directory <directory> exists
       -X,--not-exists <directory>   Asserts that directory <directory> does NOT
                                     exist
      

      This can then also be used from bin/solr through e.g. run_tool assert -r, or from Java Code static methods such as AssertTool.assertSolrRunning(String url)

      1. SOLR-9610.patch
        11 kB
        Jan Høydahl
      2. SOLR-9610.patch
        7 kB
        Jan Høydahl
      3. SOLR-9610-timeout.patch
        16 kB
        Jan Høydahl
      4. SOLR-9610-timeout.patch
        8 kB
        Jan Høydahl

        Issue Links

          Activity

          Hide
          shalinmangar Shalin Shekhar Mangar added a comment -

          Closing after 6.3.0 release.

          Show
          shalinmangar Shalin Shekhar Mangar added a comment - Closing after 6.3.0 release.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 2ad6de184c9c3a1b4156d963bbe651f7e1f52536 in lucene-solr's branch refs/heads/branch_6x from Jan Høydahl
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=2ad6de1 ]

          SOLR-9610: Fix typo in usage for assertTool timeout option. use --timeout instead of --ms

          (cherry picked from commit fa4e599)

          Show
          jira-bot ASF subversion and git services added a comment - Commit 2ad6de184c9c3a1b4156d963bbe651f7e1f52536 in lucene-solr's branch refs/heads/branch_6x from Jan Høydahl [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=2ad6de1 ] SOLR-9610 : Fix typo in usage for assertTool timeout option. use --timeout instead of --ms (cherry picked from commit fa4e599)
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit b0879c6af2b4d4b0ee36fe80fe29228e158d526a in lucene-solr's branch refs/heads/branch_6_3 from Jan Høydahl
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=b0879c6 ]

          SOLR-9610: Fix typo in usage for assertTool timeout option. use --timeout instead of --ms

          (cherry picked from commit fa4e599)

          Show
          jira-bot ASF subversion and git services added a comment - Commit b0879c6af2b4d4b0ee36fe80fe29228e158d526a in lucene-solr's branch refs/heads/branch_6_3 from Jan Høydahl [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=b0879c6 ] SOLR-9610 : Fix typo in usage for assertTool timeout option. use --timeout instead of --ms (cherry picked from commit fa4e599)
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit fa4e599d1dbedf8093eaddc4091ac0a7b9970928 in lucene-solr's branch refs/heads/master from Jan Høydahl
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=fa4e599 ]

          SOLR-9610: Fix typo in usage for assertTool timeout option. use --timeout instead of --ms

          Show
          jira-bot ASF subversion and git services added a comment - Commit fa4e599d1dbedf8093eaddc4091ac0a7b9970928 in lucene-solr's branch refs/heads/master from Jan Høydahl [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=fa4e599 ] SOLR-9610 : Fix typo in usage for assertTool timeout option. use --timeout instead of --ms
          Hide
          janhoy Jan Høydahl added a comment -

          Resolving (again) after the re-open

          Show
          janhoy Jan Høydahl added a comment - Resolving (again) after the re-open
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit db43bfb0464347143e58e662113a5630224b070e in lucene-solr's branch refs/heads/master from Jan Høydahl
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=db43bfb ]

          SOLR-9610: Add timeout option, abort early on auth failure
          SOLR-9680: Better error messages in SolrCLI when authentication required

          Show
          jira-bot ASF subversion and git services added a comment - Commit db43bfb0464347143e58e662113a5630224b070e in lucene-solr's branch refs/heads/master from Jan Høydahl [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=db43bfb ] SOLR-9610 : Add timeout option, abort early on auth failure SOLR-9680 : Better error messages in SolrCLI when authentication required
          Hide
          janhoy Jan Høydahl added a comment -

          New patch:

          • Using HttpHead request instead of URLConnection in assertSolrNotRunning. Utility method attemptHttpHead
          • Hardened way of detecting auth problems in getJson(). Sending a HEAD request was bad here since even a HEAD request would create a collection when used on collection API URL. Now catching ClientProtocolException instead.
          • Tested with and without authentication for commands create, healthcheck, status, assert & delete
          Show
          janhoy Jan Høydahl added a comment - New patch: Using HttpHead request instead of URLConnection in assertSolrNotRunning. Utility method attemptHttpHead Hardened way of detecting auth problems in getJson(). Sending a HEAD request was bad here since even a HEAD request would create a collection when used on collection API URL. Now catching ClientProtocolException instead. Tested with and without authentication for commands create, healthcheck, status, assert & delete
          Hide
          janhoy Jan Høydahl added a comment -

          Patch SOLR-9610-timeout.patch:

          • Added timeout option -t to change timeout, e.g. -t 180000 for 3 minutes
          • Default timeout for -s and -S is now 1s
          • Added a quick httpcode check to the -S test, to quickly check if nothing is listening
          • Discovered that the StatusTool which we use for the up/down test works badly with Auth/Autz, fixed that by throwing an explicit SolrException with ErrorCode=401/403 in case of auth/autz problems, instead of returning the HTML or retrying/sleeping.
          • Tool will now print a meaningful error if auth/autz fail
          Show
          janhoy Jan Høydahl added a comment - Patch SOLR-9610 -timeout.patch : Added timeout option -t to change timeout, e.g. -t 180000 for 3 minutes Default timeout for -s and -S is now 1s Added a quick httpcode check to the -S test, to quickly check if nothing is listening Discovered that the StatusTool which we use for the up/down test works badly with Auth/Autz, fixed that by throwing an explicit SolrException with ErrorCode=401/403 in case of auth/autz problems, instead of returning the HTML or retrying/sleeping. Tool will now print a meaningful error if auth/autz fail
          Hide
          janhoy Jan Høydahl added a comment -

          Reopening to add configurable timeout for -s and -S

          Show
          janhoy Jan Høydahl added a comment - Reopening to add configurable timeout for -s and -S
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit fd623d4cfdaa934edd7f92b8f72e5899e26a27c3 in lucene-solr's branch refs/heads/branch_6x from Jan Høydahl
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=fd623d4 ]

          SOLR-9610: Bugfix option key for assertTool

          (cherry picked from commit 3488f12)

          Show
          jira-bot ASF subversion and git services added a comment - Commit fd623d4cfdaa934edd7f92b8f72e5899e26a27c3 in lucene-solr's branch refs/heads/branch_6x from Jan Høydahl [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=fd623d4 ] SOLR-9610 : Bugfix option key for assertTool (cherry picked from commit 3488f12)
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 3488f12170a6b035391fda719ce69380dc4b2882 in lucene-solr's branch refs/heads/master from Jan Høydahl
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=3488f12 ]

          SOLR-9610: Bugfix option key for assertTool

          Show
          jira-bot ASF subversion and git services added a comment - Commit 3488f12170a6b035391fda719ce69380dc4b2882 in lucene-solr's branch refs/heads/master from Jan Høydahl [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=3488f12 ] SOLR-9610 : Bugfix option key for assertTool
          Hide
          janhoy Jan Høydahl added a comment -

          Pushed this. I is still not advertised as a tool in main help as it is perhaps not as much for end users as for developers. It would be easy to add the word "assert" to the end of the COMMAND list though.

          Show
          janhoy Jan Høydahl added a comment - Pushed this. I is still not advertised as a tool in main help as it is perhaps not as much for end users as for developers. It would be easy to add the word "assert" to the end of the COMMAND list though.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit df4170629587ff60e10b93dbe16d607ca798e894 in lucene-solr's branch refs/heads/branch_6x from Jan Høydahl
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=df41706 ]

          SOLR-9610: New AssertTool in SolrCLI for easier cross platform assertions from command line

          (cherry picked from commit 6512d0c)

          Show
          jira-bot ASF subversion and git services added a comment - Commit df4170629587ff60e10b93dbe16d607ca798e894 in lucene-solr's branch refs/heads/branch_6x from Jan Høydahl [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=df41706 ] SOLR-9610 : New AssertTool in SolrCLI for easier cross platform assertions from command line (cherry picked from commit 6512d0c)
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 6512d0c62024177cc5d6c8b7086faaa149565dfb in lucene-solr's branch refs/heads/master from Jan Høydahl
          [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=6512d0c ]

          SOLR-9610: New AssertTool in SolrCLI for easier cross platform assertions from command line

          Show
          jira-bot ASF subversion and git services added a comment - Commit 6512d0c62024177cc5d6c8b7086faaa149565dfb in lucene-solr's branch refs/heads/master from Jan Høydahl [ https://git-wip-us.apache.org/repos/asf?p=lucene-solr.git;h=6512d0c ] SOLR-9610 : New AssertTool in SolrCLI for easier cross platform assertions from command line
          Hide
          janhoy Jan Høydahl added a comment -

          New patch:

          • Added -m <message> option for optionally customizing error msg
          • Added -e option for optionally return with exit code only instead of exception/error-msg
          • Added wrapper code in solr.cmd and tested on Windows

          I could not use the default runTool() or runImpl() for the tool since it does not return a status code, so I implemented my own runTool. Should we perhaps add support for any command to return an exit code?

          Show
          janhoy Jan Høydahl added a comment - New patch: Added -m <message> option for optionally customizing error msg Added -e option for optionally return with exit code only instead of exception/error-msg Added wrapper code in solr.cmd and tested on Windows I could not use the default runTool() or runImpl() for the tool since it does not return a status code, so I implemented my own runTool. Should we perhaps add support for any command to return an exit code?
          Hide
          janhoy Jan Høydahl added a comment - - edited

          Patch. I plan to commit this. It just adds the tool. Does not use the assertions anywhere yet. Next step could be to replace some not-root-user or directory-exists checks.

          Currently each assertion throws an exception which by the tool-runner is printed as ERRROR: <msg>. Could be that we want those error messages configurable when using the asserts from Java code. Perhaps also allow a cmdline switch -m <failure message>

          Show
          janhoy Jan Høydahl added a comment - - edited Patch. I plan to commit this. It just adds the tool. Does not use the assertions anywhere yet. Next step could be to replace some not-root-user or directory-exists checks. Currently each assertion throws an exception which by the tool-runner is printed as ERRROR: <msg>. Could be that we want those error messages configurable when using the asserts from Java code. Perhaps also allow a cmdline switch -m <failure message>

            People

            • Assignee:
              janhoy Jan Høydahl
              Reporter:
              janhoy Jan Høydahl
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development