Skip to content

SOLR-16091 Improve logging for TestContainerPlugin#736

Merged
madrob merged 9 commits into
apache:mainfrom
madrob:SOLR-16091-testcontainerplugin
Mar 15, 2022
Merged

SOLR-16091 Improve logging for TestContainerPlugin#736
madrob merged 9 commits into
apache:mainfrom
madrob:SOLR-16091-testcontainerplugin

Conversation

@madrob
Copy link
Copy Markdown
Contributor

@madrob madrob commented Mar 9, 2022

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.

@madrob madrob requested a review from noblepaul March 9, 2022 21:23
Copy link
Copy Markdown
Contributor

@cpoerschke cpoerschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! PR title mentions TestContainerPlugin but scope now also includes TestDistribPackageStore i.e. suggest to revise.

Comment thread solr/core/src/test/org/apache/solr/filestore/TestDistribPackageStore.java Outdated
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());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two calls before (not sure why) but only one call afterwards, could we have a comment re: why two errors for the one call?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java
Comment thread solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java Outdated
madrob and others added 3 commits March 11, 2022 14:54
…eStore.java

Co-authored-by: Christine Poerschke <cpoerschke@apache.org>
….java

Co-authored-by: Christine Poerschke <cpoerschke@apache.org>
Comment thread solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java
Comment thread solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java
Comment thread solr/core/src/test/org/apache/solr/handler/TestContainerPlugin.java
@madrob madrob merged commit 6d64c14 into apache:main Mar 15, 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants