SOLR-16091 Improve logging for TestContainerPlugin#736
Merged
Conversation
cpoerschke
reviewed
Mar 11, 2022
Contributor
cpoerschke
left a comment
There was a problem hiding this comment.
Thanks for working on this! PR title mentions TestContainerPlugin but scope now also includes TestDistribPackageStore i.e. suggest to revise.
Comment on lines
-186
to
+169
| expectFail( | ||
| () -> | ||
| new V2Request.Builder("/my-random-prefix/their/plugin") | ||
| .forceV2(true) | ||
| .GET() | ||
| .build() | ||
| .process(cluster.getSolrClient())); | ||
| expectFail( | ||
| () -> | ||
| new V2Request.Builder("/my-random-prefix/their/plugin") | ||
| .forceV2(true) | ||
| .GET() | ||
| .build() | ||
| .process(cluster.getSolrClient())); | ||
|
|
||
| // test ClusterSingleton plugin | ||
| plugin.name = "clusterSingleton"; | ||
| plugin.klass = C6.class.getName(); | ||
| req.process(cluster.getSolrClient()); | ||
| version = phaser.awaitAdvanceInterruptibly(version, 10, TimeUnit.SECONDS); | ||
|
|
||
| // just check if the plugin is indeed registered | ||
| readPluginState = new V2Request.Builder("/cluster/plugin").forceV2(true).GET().build(); | ||
| rsp = readPluginState.process(cluster.getSolrClient()); | ||
| assertEquals(C6.class.getName(), rsp._getStr("/plugin/clusterSingleton/class", null)); | ||
|
|
||
| assertTrue("ccProvided", C6.ccProvided); | ||
| assertTrue("startCalled", C6.startCalled); | ||
| assertFalse("stopCalled", C6.stopCalled); | ||
|
|
||
| assertEquals(CConfig.class, ContainerPluginsRegistry.getConfigClass(new CC())); | ||
| assertEquals(CConfig.class, ContainerPluginsRegistry.getConfigClass(new CC1())); | ||
| assertEquals(CConfig.class, ContainerPluginsRegistry.getConfigClass(new CC2())); | ||
|
|
||
| CConfig cfg = new CConfig(); | ||
| cfg.boolVal = Boolean.TRUE; | ||
| cfg.strVal = "Something"; | ||
| cfg.longVal = 1234L; | ||
| PluginMeta p = new PluginMeta(); | ||
| p.name = "hello"; | ||
| p.klass = CC.class.getName(); | ||
| p.config = cfg; | ||
|
|
||
| new V2Request.Builder("/cluster/plugin") | ||
| .forceV2(true) | ||
| .POST() | ||
| .withPayload(singletonMap("add", p)) | ||
| .build() | ||
| .process(cluster.getSolrClient()); | ||
|
|
||
| version = phaser.awaitAdvanceInterruptibly(version, 10, TimeUnit.SECONDS); | ||
|
|
||
| TestDistribPackageStore.assertResponseValues( | ||
| 10, | ||
| () -> | ||
| new V2Request.Builder("hello/plugin") | ||
| .forceV2(true) | ||
| .GET() | ||
| .build() | ||
| .process(cluster.getSolrClient()), | ||
| ImmutableMap.of( | ||
| "/config/boolVal", "true", "/config/strVal", "Something", "/config/longVal", "1234")); | ||
|
|
||
| cfg.strVal = "Something else"; | ||
| new V2Request.Builder("/cluster/plugin") | ||
| .forceV2(true) | ||
| .POST() | ||
| .withPayload(singletonMap("update", p)) | ||
| .build() | ||
| .process(cluster.getSolrClient()); | ||
| version = phaser.awaitAdvanceInterruptibly(version, 10, TimeUnit.SECONDS); | ||
|
|
||
| TestDistribPackageStore.assertResponseValues( | ||
| 10, | ||
| () -> | ||
| new V2Request.Builder("hello/plugin") | ||
| .forceV2(true) | ||
| .GET() | ||
| .build() | ||
| .process(cluster.getSolrClient()), | ||
| ImmutableMap.of( | ||
| "/config/boolVal", "true", "/config/strVal", cfg.strVal, "/config/longVal", "1234")); | ||
|
|
||
| // kill the Overseer leader | ||
| for (JettySolrRunner jetty : cluster.getJettySolrRunners()) { | ||
| if (!jetty.getCoreContainer().getZkController().getOverseer().isClosed()) { | ||
| cluster.stopJettySolrRunner(jetty); | ||
| cluster.waitForJettyToStop(jetty); | ||
| } | ||
| expectError(addPlugin, "path must not have a prefix: collections"); | ||
| assertEquals(1, errors.getCount()); | ||
| } | ||
|
|
||
| plugin.name = "my-random-name"; | ||
| plugin.pathPrefix = "my-random-prefix"; | ||
|
|
||
| addPlugin.process(cluster.getSolrClient()); | ||
| version = phaser.awaitAdvanceInterruptibly(version, 10, TimeUnit.SECONDS); | ||
|
|
||
| // let's test the plugin | ||
| TestDistribPackageStore.assertResponseValues( | ||
| getPlugin("/my-random-name/my/plugin"), Map.of("/method.name", "m1")); | ||
|
|
||
| TestDistribPackageStore.assertResponseValues( | ||
| getPlugin("/my-random-prefix/their/plugin"), Map.of("/method.name", "m2")); | ||
| // now remove the plugin | ||
| new V2Request.Builder("/cluster/plugin") | ||
| .POST() | ||
| .forceV2(true) | ||
| .withPayload("{remove : my-random-name}") | ||
| .build() | ||
| .process(cluster.getSolrClient()); | ||
|
|
||
| version = phaser.awaitAdvanceInterruptibly(version, 10, TimeUnit.SECONDS); | ||
|
|
||
| try (ErrorLogMuter errors = ErrorLogMuter.substring("/my-random-prefix/their/plugin")) { | ||
| expectFail(() -> getPlugin("/my-random-prefix/their/plugin").call()); | ||
| assertEquals(2, errors.getCount()); | ||
| } |
Contributor
There was a problem hiding this comment.
Two calls before (not sure why) but only one call afterwards, could we have a comment re: why two errors for the one call?
Contributor
Author
There was a problem hiding this comment.
I think the two calls before was just a copy-paste bug.
The "two errors" now is because V2Http will log at 146 then log-and-throw at 171. I added some more detail to the test there.
…eStore.java Co-authored-by: Christine Poerschke <cpoerschke@apache.org>
….java Co-authored-by: Christine Poerschke <cpoerschke@apache.org>
cpoerschke
reviewed
Mar 14, 2022
cpoerschke
approved these changes
Mar 14, 2022
madrob
added a commit
that referenced
this pull request
Mar 23, 2022
Improved logging in TestContainerPlugin and TestDistribPackageStore. Switch an instance of System.out to using a logger. Add ErrorLogMute blocks for expected errors. Reduce amount of retries when waiting for state since we have proper expected concurrency hooks in place. Randomize whether the test forces V2 APIs Co-authored-by: Christine Poerschke <cpoerschke@apache.org> (cherry picked from commit 6d64c14)
risdenk
pushed a commit
that referenced
this pull request
Sep 9, 2022
Improved logging in TestContainerPlugin and TestDistribPackageStore. Switch an instance of System.out to using a logger. Add ErrorLogMute blocks for expected errors. Reduce amount of retries when waiting for state since we have proper expected concurrency hooks in place. Randomize whether the test forces V2 APIs Co-authored-by: Christine Poerschke <cpoerschke@apache.org> (cherry picked from commit 6d64c14)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://issues.apache.org/jira/browse/SOLR-16091
I don't think this will actually fix the issue seen by the test, but it will make the logging a little bit easier to follow and hopefully make future failures easier to diagnose.