Skip to content

Commit

Permalink
[TASK] Remove content stream usage
Browse files Browse the repository at this point in the history
Drops the usage of content streams for Solr queries, this
removes the dependency to SOLR_ENABLE_STREAM_BODY.

Resolves: #3750
  • Loading branch information
dkd-friedrich authored and dkd-kaehm committed May 17, 2024
1 parent 40c0ecf commit e09615e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 54 deletions.
21 changes: 1 addition & 20 deletions Classes/Report/SolrStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,10 @@ protected function getConnectionStatus(Site $site, array $solrConnection): Statu
$pingTime = $this->checkPingTime($solrAdmin);
$configName = $this->checkSolrConfigName($solrAdmin);
$schemaName = $this->checkSolrSchemaName($solrAdmin);
$streamBodySetting = $this->checkStreamBodySetting($solrAdmin);

/** @phpstan-ignore-next-line */
if ($this->responseStatus !== ContextualFeedbackSeverity::OK) {
$header = 'Failed contacting the Solr server or invalid settings found.';
$header = 'Failed contacting the Solr server.';
}

$variables = [
Expand All @@ -136,7 +135,6 @@ protected function getConnectionStatus(Site $site, array $solrConnection): Statu
'configName' => $configName,
'schemaName' => $schemaName,
'accessFilter' => $accessFilter,
'streamBodySetting' => $streamBodySetting,
];

$report = $this->getRenderedReport('SolrStatus.html', $variables);
Expand Down Expand Up @@ -227,23 +225,6 @@ protected function checkSolrSchemaName(SolrAdminService $solrAdminService): stri
return $solrSchemaMessage;
}

protected function checkStreamBodySetting(SolrAdminService $solrAdminService): string
{
$systemProperties = $solrAdminService->getSystemProperties();
if ($systemProperties === null) {
$this->responseStatus = ContextualFeedbackSeverity::ERROR;
return 'Error determining system properties';
}

$streamSetting = (bool)($systemProperties['solr.enableStreamBody'] ?? false);
if (!$streamSetting) {
$this->responseStatus = ContextualFeedbackSeverity::ERROR;
return 'Content Streams not enabled';
}

return 'true';
}

/**
* Formats the Apache Solr server version number. By default, this is going
* to be the simple major.minor.patch-level version. Custom Builds provide
Expand Down
21 changes: 0 additions & 21 deletions Classes/System/Solr/Service/SolrAdminService.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class SolrAdminService extends AbstractSolrService
public const LUKE_SERVLET = 'admin/luke';
public const SYSTEM_SERVLET = 'admin/system';
public const CORES_SERVLET = '../admin/cores';
public const PROPERTY_SERVLET = '../admin/info/properties';
public const FILE_SERVLET = 'admin/file';
public const SCHEMA_SERVLET = 'schema';
public const SYNONYMS_SERVLET = 'schema/analysis/synonyms/';
Expand Down Expand Up @@ -89,26 +88,6 @@ public function system(): ResponseAdapter
return $this->_sendRawGet($this->_constructUrl(self::SYSTEM_SERVLET, ['wt' => 'json']));
}

/**
* Gets system properties
*
* @return array|null
*/
public function getSystemProperties(): ?array
{
$url = $this->_constructUrl(self::PROPERTY_SERVLET, ['wt' => 'json']);
$propertyInformation = $this->_sendRawGet($url);

$parsedPropertyInformation = $propertyInformation->getParsedData();
if ($parsedPropertyInformation === null
|| !property_exists($parsedPropertyInformation, 'system.properties')
) {
return null;
}

return (array)$parsedPropertyInformation->{'system.properties'};
}

/**
* Gets information about the plugins installed in Solr
*
Expand Down
6 changes: 1 addition & 5 deletions Docker/SolrServer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ RUN rm -fR /opt/solr/server/solr/* \
&& groupmod --non-unique --gid "${SOLR_UNIX_GID}" solr \
&& chown -R solr:solr /var/solr /opt/solr \
&& apt update && apt upgrade -y && apt install sudo -y \
&& echo "solr ALL=NOPASSWD: /docker-entrypoint-initdb.d/as-sudo/*" > /etc/sudoers.d/solr \
&& echo "# EXT:solr relevant changes: " >> /etc/default/solr.in.sh \
&& echo "SOLR_ENABLE_REMOTE_STREAMING=true" >> /etc/default/solr.in.sh \
&& echo "SOLR_ENABLE_STREAM_BODY=true" >> /etc/default/solr.in.sh \
&& echo "# END: EXT:solr" >> /etc/default/solr.in.sh
&& echo "solr ALL=NOPASSWD: /docker-entrypoint-initdb.d/as-sudo/*" > /etc/sudoers.d/solr

COPY Docker/SolrServer/docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d
USER solr
Expand Down
1 change: 0 additions & 1 deletion Documentation/Solr/ConfigurationStructures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ When you want to install Solr on your system in another way the following steps
* Install the Solr server
* Copy the configsets into the configset folder (by default $SOLR_HOME/server/solr/configsets)
* Make sure that the solr.xml file ($SOLR_HOME/server/solr/solr.xml) is in place and fits to your Solr version
* Enable Content Streams. EXT:solr uses content streams and requires environment variables SOLR_ENABLE_REMOTE_STREAMING and SOLR_ENABLE_STREAM_BODY to be set, see section `Content Streams in the Reference Guide <https://solr.apache.org/guide/solr/latest/indexing-guide/content-streams.html>`__

* Create an init script that starts Solr on boottime.
* Secure your Solr port from outside.
Expand Down
6 changes: 0 additions & 6 deletions Resources/Private/Templates/Backend/Reports/SolrStatus.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@
<th>Access Filter Plugin</th>
<td>{accessFilter}</td>
</tr>
<tr>
<th>Content Streams<br><small>(SOLR_ENABLE_REMOTE_STREAMING)</small></th>
<td class="{f:if(condition:'{streamBodySetting} !== \'true\'', then: 'warning')}">
{streamBodySetting}
</td>
</tr>
</table>

</html>
13 changes: 12 additions & 1 deletion Tests/Integration/IntegrationTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Http\RequestFactory;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait;
Expand Down Expand Up @@ -100,7 +101,17 @@ protected function cleanUpSolrServerAndAssertEmpty(?string $coreName = 'core_en'
$this->validateTestCoreName($coreName);

// cleanup the solr server
$result = file_get_contents($this->getSolrConnectionUriAuthority() . '/solr/' . $coreName . '/update?stream.body=<delete><query>*:*</query></delete>&commit=true');
$requestFactory = GeneralUtility::makeInstance(RequestFactory::class);
$response = $requestFactory->request(
$this->getSolrConnectionUriAuthority() . '/solr/' . $coreName . '/update',
'POST',
[
'headers' => ['Content-Type' => 'application/xml'],
'body' => '<delete><query>*:*</query></delete>',
]
);
$result = $response->getBody()->getContents();

if (!str_contains($result, '<int name="QTime">')) {
self::fail('Could not empty solr test index');
}
Expand Down

0 comments on commit e09615e

Please sign in to comment.