[ 
https://issues.apache.org/jira/browse/SOLR-11028?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17621208#comment-17621208
 ] 

Jason Gerlowski commented on SOLR-11028:
----------------------------------------

If you wanted to write that test, I think that'd be fine and I'd be happy to 
review it (y).

That said, it might be a bit "overkill".  The meat of the REPLACENODE 
functionality isn't new to this commit, and there's already tests to ensure 
that it does its job correctly.  If I was writing the PR, I'd do something more 
narrowly focused on the logic we _are_ writing in this PR: the conversion of 
the v2 input into the format that v1 expects.  Check out 
[V2CollectionsAPIMappingTest.testModifyCollectionAllProperties|https://github.com/apache/solr/blob/a1ee7c1d0de32779109cb8b66a4319a0f8c85037/solr/core/src/test/org/apache/solr/handler/admin/api/V2CollectionAPIMappingTest.java#L89]
 as an example, pasted below for convenience:

{code}
  @Test
  public void testModifyCollectionAllProperties() throws Exception {
    final SolrParams v1Params =
        captureConvertedV1Params(
            "/collections/collName",
            "POST",
            "{ 'modify': {"
                + "'replicationFactor': 123, "
                + "'readOnly': true, "
                + "'config': 'techproducts_config', "
                + "'async': 'requestTrackingId', "
                + "'properties': {"
                + "     'foo': 'bar', "
                + "     'baz': 456 "
                + "}"
                + "}}");

    assertEquals(
        CollectionParams.CollectionAction.MODIFYCOLLECTION.lowerName, 
v1Params.get(ACTION));
    assertEquals("collName", v1Params.get(COLLECTION));
    assertEquals(123, 
v1Params.getPrimitiveInt(ZkStateReader.REPLICATION_FACTOR));
    assertEquals(true, v1Params.getPrimitiveBool(ZkStateReader.READ_ONLY));
    assertEquals("techproducts_config", v1Params.get(COLL_CONF));
    assertEquals("requestTrackingId", v1Params.get(ASYNC));
    assertEquals("bar", v1Params.get("property.foo"));
    assertEquals(456, v1Params.getPrimitiveInt("property.baz"));
  }
{code}

This test starts by using the {{captureConvertedV1Params}} method to submit a 
v2 request with the specified path/verb/request-body.  Under the hood, 
{{captureConvertedV1Params}} passes those values to a {{ModifyCollectionAPI}} 
that's set up to use a 'mock' {{CollectionsHandler}}.  The API class converts 
the params into the v1 format per its code, and then the {{CollectionsHandler}} 
mock (instead of doing any "real" work) just records the v1 params this it 
receives as input.  This lets the remainder of the test validate that the v1 
params look the way they should: e.g. did we add an "action" query-param with 
the right value, did the properties map from the v2 request body get flattened 
out to individual query-params, etc.

IMO this is an example that'd map well onto the REPLACENODE API you're working 
with here.  If you choose to go this route, there's a base class 
(V2APIMappingTest) that gives you access to {{captureConvertedV1Params}} and 
does some other heavy lifting.  You could use that, or even put your test 
method in an existing V2APIMappingTest subclass if there's one that makes sense.

> Create a v2 API equivalent for REPLACENODE API
> ----------------------------------------------
>
>                 Key: SOLR-11028
>                 URL: https://issues.apache.org/jira/browse/SOLR-11028
>             Project: Solr
>          Issue Type: Sub-task
>          Components: SolrCloud, v2 API
>            Reporter: Shalin Shekhar Mangar
>            Priority: Major
>
> The REPLACENODE API is only implemented as part of the v1 collections API. 
> There should be an equivalent call in the v2 paradigm.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to