You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2021/06/18 21:21:54 UTC

[GitHub] [solr] janhoy opened a new pull request #182: SOLR-15484 Redesign integration test, with cluster in local scope variable per test

janhoy opened a new pull request #182:
URL: https://github.com/apache/solr/pull/182


   https://issues.apache.org/jira/browse/SOLR-15484
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [solr] janhoy merged pull request #182: SOLR-15484 Redesign integration test, with cluster in local scope variable per test

Posted by GitBox <gi...@apache.org>.
janhoy merged pull request #182:
URL: https://github.com/apache/solr/pull/182


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [solr] janhoy commented on a change in pull request #182: SOLR-15484 Redesign integration test, with cluster in local scope variable per test

Posted by GitBox <gi...@apache.org>.
janhoy commented on a change in pull request #182:
URL: https://github.com/apache/solr/pull/182#discussion_r654270540



##########
File path: solr/core/src/test/org/apache/solr/security/JWTAuthPluginIntegrationTest.java
##########
@@ -188,11 +181,13 @@ public void infoRequestValidateXSolrAuthHeadersBlockUnknownFalse() throws Except
         "  \"redirect_uris\":[],\n" +
         "  \"authorizationEndpoint\":\"http://acmepaymentscorp/oauth/auz/authorize\",\n" +
         "  \"client_id\":\"solr-cluster\"}", authData);
+    myCluster.shutdown();
   }
 
   @Test
   public void testMetrics() throws Exception {
-    configureClusterStaticKeys("jwt_plugin_jwk_security.json");
+    // Here we use the "global" class-level cluster variable, but not for the other tests

Review comment:
       I combined these two tests into one, using the global "cluster" var, since they both rely on validating metrics (which is bound to the global cluster)

##########
File path: solr/core/src/test/org/apache/solr/security/JWTAuthPluginIntegrationTest.java
##########
@@ -253,45 +239,56 @@ public void createCollectionUpdateAndQueryDistributed() throws Exception {
     result = get(baseUrl + "/" + COLLECTION + "/query?q=*:*", jwtStaticTestToken);
     assertEquals(Integer.valueOf(200), result.second());
     assertAuthMetricsMinimums(10, 10, 0, 0, 0, 0);
-    
+
     // Delete
     assertEquals(200, get(baseUrl + "/admin/collections?action=DELETE&name=" + COLLECTION, jwtStaticTestToken).second().intValue());
     assertAuthMetricsMinimums(11, 11, 0, 0, 0, 0);
     assertPkiAuthMetricsMinimums(4, 4, 0, 0, 0, 0);
+
+    HttpClientUtil.close(cl);
   }
 
+  /**
+   * Configure solr cluster with a security.json talking to MockOAuth2 server
+   * @param numNodes number of nodes in cluster
+   * @param pemFilePath path to PEM file for SSL cert to trust for OAuth2 server
+   * @param timeoutMs how long to wait until the new security.json is applied to the cluster
+   * @return an instance of the created cluster that the test can talk to
+   */
   @SuppressWarnings("BusyWait")
-  private void configureClusterMockOauth(int numNodes, Path pemFilePath, long timeoutMs) throws Exception {
-    configureCluster(numNodes)// nodes
+  private MiniSolrCloudCluster configureClusterMockOauth(int numNodes, Path pemFilePath, long timeoutMs) throws Exception {
+    MiniSolrCloudCluster myCluster = configureCluster(numNodes)// nodes
         .addConfig("conf1", TEST_PATH().resolve("configsets").resolve("cloud-minimal").resolve("conf"))
         .withDefaultClusterProperty("useLegacyReplicaAssignment", "false")
-        .configure();
+        .build();
     String securityJson = createMockOAuthSecurityJson(pemFilePath);
-    cluster.getZkClient().setData("/security.json", securityJson.getBytes(Charset.defaultCharset()), true);
+    myCluster.getZkClient().setData("/security.json", securityJson.getBytes(Charset.defaultCharset()), true);
     RTimer timer = new RTimer();
     do { // Wait timeoutMs time for the security.json change to take effect
       Thread.sleep(200);
       if (timer.getTime() > timeoutMs) {
+        myCluster.shutdown();

Review comment:
       Need to clean up before throwing exception here, since the MiniSolrCloudCluster is already created




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


[GitHub] [solr] janhoy commented on pull request #182: SOLR-15484 Redesign integration test, with cluster in local scope variable per test

Posted by GitBox <gi...@apache.org>.
janhoy commented on pull request #182:
URL: https://github.com/apache/solr/pull/182#issuecomment-863981291


   Or do you think it would be cleaner to create one test class per test-case, and let the cluster init + cleanup happen as usual? I didn't want to create so many new test-classes, but perhaps they could be inner classes, I don't know...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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