diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 77a59eba1..b460880a6 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -51,12 +51,12 @@ jobs: ref: branch_8_11 path: lucene-solr - - name: Checkout solr 9.4 + - name: Checkout solr 9.5 if: matrix.solr == 9 uses: actions/checkout@v4 with: repository: apache/solr - ref: branch_9_4 + ref: branch_9_5 path: lucene-solr - name: Start Solr ${{ matrix.solr }} in ${{ matrix.mode }} mode diff --git a/tests/Integration/AbstractTechproductsTestCase.php b/tests/Integration/AbstractTechproductsTestCase.php index 86d3f93e2..747569125 100644 --- a/tests/Integration/AbstractTechproductsTestCase.php +++ b/tests/Integration/AbstractTechproductsTestCase.php @@ -5,7 +5,6 @@ use PHPUnit\Framework\TestCase; use Solarium\Component\ComponentAwareQueryInterface; use Solarium\Component\Highlighting\Highlighting; -use Solarium\Component\QueryInterface; use Solarium\Component\QueryTraits\GroupingTrait; use Solarium\Component\QueryTraits\TermsTrait; use Solarium\Component\Result\Facet\Pivot\PivotItem; @@ -47,8 +46,6 @@ use Solarium\QueryType\Luke\Result\Fields\FieldInfo as LukeFieldInfo; use Solarium\QueryType\Luke\Result\Index\Index as LukeIndexResult; use Solarium\QueryType\Luke\Result\Schema\Schema as LukeSchemaResult; -use Solarium\QueryType\ManagedResources\Query\AbstractQuery as AbstractManagedResourceQuery; -use Solarium\QueryType\ManagedResources\Query\Command\AbstractAdd as AbstractAddCommand; use Solarium\QueryType\ManagedResources\Query\Stopwords as StopwordsQuery; use Solarium\QueryType\ManagedResources\Query\Synonyms as SynonymsQuery; use Solarium\QueryType\ManagedResources\Query\Synonyms\Synonyms; @@ -62,9 +59,6 @@ use Solarium\QueryType\Update\RequestBuilder\Xml as XmlUpdateRequestBuilder; use Solarium\Support\Utility; use Solarium\Tests\Integration\Plugin\EventTimer; -use Solarium\Tests\Integration\Query\CustomQueryInterfaceQuery; -use Solarium\Tests\Integration\Query\CustomSelfQuery; -use Solarium\Tests\Integration\Query\CustomStaticQuery; use Symfony\Contracts\EventDispatcher\Event; use TRegx\PhpUnit\DataProviders\DataProvider; @@ -5179,9 +5173,10 @@ public function testManagedResources() * @see https://issues.apache.org/jira/browse/SOLR-6853 * @see https://github.com/solariumphp/solarium/pull/742 * - * @dataProvider managedResourcesSolr6853Provider + * @testWith ["stopwords"] + * ["synonyms"] */ - public function testManagedResourcesSolr6853(string $resourceType, AbstractManagedResourceQuery $query, AbstractAddCommand $add) + public function testManagedResourcesSolr6853(string $resourceType) { // unique name is necessary for Stopwords to avoid running into SOLR-14268 $uniqid = uniqid(); @@ -5197,10 +5192,36 @@ public function testManagedResourcesSolr6853(string $resourceType, AbstractManag $nameDoubleEncoded = $uniqid.'test-%253A%252F%253F%2523%255B%255D%2540%2525%2520'; } - // unlike name, term can't contain a slash (SOLR-6853) - $term = 'test-:?#[]@% '; - $termSingleEncoded = 'test-%3A%3F%23%5B%5D%40%25%20'; - $termDoubleEncoded = 'test-%253A%253F%2523%255B%255D%2540%2525%2520'; + if (9 <= self::$solrVersion) { + $term = 'test-:/?#[]@% '; + $termSingleEncoded = 'test-%3A%2F%3F%23%5B%5D%40%25%20'; + $termDoubleEncoded = 'test-%253A%252F%253F%2523%255B%255D%2540%2525%2520'; + } else { + // Before Solr 9.4.1, term can't contain a slash (SOLR-6853) + $term = 'test-:?#[]@% '; + $termSingleEncoded = 'test-%3A%3F%23%5B%5D%40%25%20'; + $termDoubleEncoded = 'test-%253A%253F%2523%255B%255D%2540%2525%2520'; + } + + switch ($resourceType) { + case 'stopwords': + $query = new StopwordsQuery(); + $add = $query->createCommand($query::COMMAND_ADD); + $add->setStopwords([$term]); + break; + case 'synonyms': + $query = new SynonymsQuery(); + $add = $query->createCommand($query::COMMAND_ADD); + $synonyms = new Synonyms(); + $synonyms->setTerm($term); + $synonyms->setSynonyms(['foo', 'bar']); + $add->setSynonyms($synonyms); + break; + default: + // PHPStan needs these variables defined even though we never reach this branch + $query = null; + $add = null; + } $compliantRequestBuilder = new CompliantManagedResourceRequestBuilder(); $actualRequestBuilder = new ResourceRequestBuilder(); @@ -5317,29 +5338,6 @@ public function testManagedResourcesSolr6853(string $resourceType, AbstractManag $this->assertFalse($result->getWasSuccessful()); } - public function managedResourcesSolr6853Provider(): array - { - $term = 'test-:?#[]@% '; - $data = []; - - $query = new StopwordsQuery(); - $add = $query->createCommand($query::COMMAND_ADD); - $add->setStopwords([$term]); - - $data['stopwords'] = ['stopwords', $query, $add]; - - $query = new SynonymsQuery(); - $add = $query->createCommand($query::COMMAND_ADD); - $synonyms = new Synonyms(); - $synonyms->setTerm($term); - $synonyms->setSynonyms(['foo', 'bar']); - $add->setSynonyms($synonyms); - - $data['synonyms'] = ['synonyms', $query, $add]; - - return $data; - } - public function testGetBodyOnHttpError() { /** @var \Solarium\Core\Query\Status4xxNoExceptionInterface $query */ @@ -5393,32 +5391,6 @@ public function testEventDispatching() self::$client->removePlugin('eventtimer'); } - - /** - * Test the various return types that are valid for custom query classes that - * override the {@see \Solarium\Component\QueryTrait::setQuery()} method. - * - * If this test throws a fatal error, the return type of the parent might no - * longer be backward compatible with existing code that overrides it. - * - * @see https://github.com/solariumphp/solarium/issues/1097 - * - * @dataProvider customQueryClassProvider - */ - public function testCustomQueryClassSetQueryReturnType(string $queryClass) - { - $query = new $queryClass(); - $this->assertInstanceOf(QueryInterface::class, $query->setQuery('*:*')); - } - - public function customQueryClassProvider(): array - { - return [ - [CustomStaticQuery::class], - [CustomSelfQuery::class], - [CustomQueryInterfaceQuery::class], - ]; - } } class GroupingTestQuery extends SelectQuery diff --git a/tests/Integration/ConnectionReuseTest.php b/tests/Integration/ConnectionReuseTest.php index 9e72308e5..e1c64b1ef 100644 --- a/tests/Integration/ConnectionReuseTest.php +++ b/tests/Integration/ConnectionReuseTest.php @@ -30,6 +30,13 @@ class ConnectionReuseTest extends TestCase */ protected static $isNewLoggingApi; + /** + * Are we running against a v2 logging API with a known bug (SOLR-17176l)? + * + * @var bool + */ + protected static $isBuggyLoggingApi; + /** * Original org.eclipse.jetty.io.AbstractConnection log level to restore after the testcase. * @@ -68,6 +75,7 @@ public static function setUpBeforeClass(): void self::$client = TestClientFactory::createWithPsr18Adapter(self::$config); // determine if we're running against a version of Solr that uses the tweaked v2 logging API (SOLR-16458) + // determine if we're running against a version of Solr with a known bug in the v2 logging API (SOLR-17176l) $query = self::$client->createApi([ 'version' => Request::API_V1, 'handler' => 'admin/info/system', @@ -77,6 +85,7 @@ public static function setUpBeforeClass(): void $solrSpecVersion = $system['lucene']['solr-spec-version']; self::$isNewLoggingApi = version_compare($solrSpecVersion, '9.3', '>='); + self::$isBuggyLoggingApi = version_compare($solrSpecVersion, '9.5', '>='); // get the current log level to restore afterwards to avoid excessive logging in other testcases $query = self::$client->createApi([ @@ -228,16 +237,26 @@ public function testConnectionReuse(string $createFunction, int $expectedCount) $client->execute($query); } - $query = $client->createApi([ - 'version' => Request::API_V2, - 'handler' => self::$isNewLoggingApi ? 'node/logging/messages' : 'node/logging', - ]); + if (self::$isBuggyLoggingApi) { + // fallback to v1 logging API to work around SOLR-17176 + $apiOptions = [ + 'version' => Request::API_V1, + 'handler' => 'admin/info/logging', + ]; + } else { + $apiOptions = [ + 'version' => Request::API_V2, + 'handler' => self::$isNewLoggingApi ? 'node/logging/messages' : 'node/logging', + ]; + } + + $query = $client->createApi($apiOptions); $query->addParam('since', self::$since); $result = $client->execute($query); $data = $result->getData(); self::$since = $data['info']['last']; - $connections = $this->extractConnections(self::$isNewLoggingApi ? $data['history'] : $data['history']['docs']); + $connections = $this->extractConnections(self::$isNewLoggingApi && !self::$isBuggyLoggingApi ? $data['history'] : $data['history']['docs']); // The count is off-by-1 with an additional connection for one of the tests: // - the request for node/logging without reuse is included in the count without reuse in most tests in a workflow; diff --git a/tests/Integration/Proxy/AbstractProxyTestCase.php b/tests/Integration/Proxy/AbstractProxyTestCase.php index dc99b2393..156fadf42 100644 --- a/tests/Integration/Proxy/AbstractProxyTestCase.php +++ b/tests/Integration/Proxy/AbstractProxyTestCase.php @@ -10,6 +10,7 @@ * Abstract test for connecting through a proxy. * * @group integration + * @group proxy */ abstract class AbstractProxyTestCase extends TestCase { diff --git a/tests/Integration/Proxy/CurlTest.php b/tests/Integration/Proxy/CurlTest.php index 26c4cdf0d..3c5cf2cbf 100644 --- a/tests/Integration/Proxy/CurlTest.php +++ b/tests/Integration/Proxy/CurlTest.php @@ -10,6 +10,7 @@ * Test connecting through a proxy with the Curl adapter. * * @group integration + * @group proxy */ class CurlTest extends AbstractProxyTestCase { diff --git a/tests/Integration/Proxy/CustomizedCurlTest.php b/tests/Integration/Proxy/CustomizedCurlTest.php index 03c31fc74..c021c8694 100644 --- a/tests/Integration/Proxy/CustomizedCurlTest.php +++ b/tests/Integration/Proxy/CustomizedCurlTest.php @@ -11,6 +11,7 @@ * Test connecting through a proxy with a customized Curl adapter that sets the proxy options differently. * * @group integration + * @group proxy */ class CustomizedCurlTest extends CurlTest { diff --git a/tests/Integration/Proxy/CustomizedHttpTest.php b/tests/Integration/Proxy/CustomizedHttpTest.php index 23603e7a5..84edba5d3 100644 --- a/tests/Integration/Proxy/CustomizedHttpTest.php +++ b/tests/Integration/Proxy/CustomizedHttpTest.php @@ -11,6 +11,7 @@ * Test connecting through a proxy with a customized Http adapter that sets the proxy options differently. * * @group integration + * @group proxy */ class CustomizedHttpTest extends HttpTest { diff --git a/tests/Integration/Proxy/HttpTest.php b/tests/Integration/Proxy/HttpTest.php index 16b3b4075..7c94acdd5 100644 --- a/tests/Integration/Proxy/HttpTest.php +++ b/tests/Integration/Proxy/HttpTest.php @@ -8,6 +8,7 @@ * Test connecting through a proxy with the Http adapter. * * @group integration + * @group proxy */ class HttpTest extends AbstractProxyTestCase { diff --git a/tests/Integration/Query/CustomQueryClassTest.php b/tests/Integration/Query/CustomQueryClassTest.php new file mode 100644 index 000000000..3595daecc --- /dev/null +++ b/tests/Integration/Query/CustomQueryClassTest.php @@ -0,0 +1,35 @@ +assertInstanceOf(QueryInterface::class, $query->setQuery('*:*')); + } + + public function customQueryClassProvider(): array + { + return [ + [CustomStaticQuery::class], + [CustomSelfQuery::class], + [CustomQueryInterfaceQuery::class], + ]; + } +}