/** * Tests the connect * * @dataProvider connectDataProvider * @test * * @param string $host * @param string $port * @param string $path * @param string $scheme * @param bool $expectsException * @param string $expectedConnectionString * @return void */ public function canConnect($host, $port, $path, $scheme, $expectsException, $expectedConnectionString) { $exceptionOccured = false; try { $solrService = $this->connectionManager->getConnection($host, $port, $path, $scheme); $this->assertEquals($expectedConnectionString, $solrService->__toString()); } catch (\UnexpectedValueException $exception) { $exceptionOccured = true; } $this->assertEquals($expectsException, $exceptionOccured); }
/** * Checks whether a Solr server is available and provides some information. * * @param array $solrConnection Solr connection parameters * @return Status Status of the Solr connection */ protected function getConnectionStatus(array $solrConnection) { $value = 'Your site was unable to contact the Apache Solr server.'; $severity = Status::ERROR; $solr = $this->connectionManager->getConnection($solrConnection['solrHost'], $solrConnection['solrPort'], $solrConnection['solrPath'], $solrConnection['solrScheme']); $message = '<ul>' . '<li style="padding-bottom: 10px;">Site: ' . $solrConnection['label'] . '</li>' . '<li>Scheme: ' . $solr->getScheme() . '</li>' . '<li>Host: ' . $solr->getHost() . '</li>' . '<li>Port: ' . $solr->getPort() . '</li>' . '<li style="padding-bottom: 10px;">Path: ' . $solr->getPath() . '</li>'; $pingQueryTime = $solr->ping(); if ($pingQueryTime !== FALSE) { $severity = Status::OK; $value = 'Your site has contacted the Apache Solr server.'; $solrVersion = $this->formatSolrVersion($solr->getSolrServerVersion()); $message .= '<li>Apache Solr: ' . $solrVersion . '</li>'; $message .= '<li>Ping Query Time: ' . (int) ($pingQueryTime * 1000) . 'ms</li>'; $message .= '<li>schema.xml: ' . $solr->getSchemaName() . '</li>'; $message .= '<li>solrconfig.xml: ' . $solr->getSolrconfigName() . '</li>'; $accessFilterPluginStatus = GeneralUtility::makeInstance('Tx_Solr_Report_AccessFilterPluginInstalledStatus'); $accessFilterPluginVersion = $accessFilterPluginStatus->getInstalledPluginVersion($solr); $message .= '<li>Access Filter Plugin: ' . $accessFilterPluginVersion . '</li>'; } $message .= '</ul>'; return GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', 'Apache Solr', $value, $message, $severity); }
/** * Checks whether a Solr server is available and provides some information. * * @param array $solrConnection Solr connection parameters * @return Status Status of the Solr connection */ protected function getConnectionStatus(array $solrConnection) { $value = 'Your site has contacted the Apache Solr server.'; $this->responseStatus = Status::OK; $solr = $this->connectionManager->getConnection($solrConnection['solrHost'], $solrConnection['solrPort'], $solrConnection['solrPath'], $solrConnection['solrScheme']); $this->responseMessage = $this->getMessageTemplate(); $this->responseMessage = $this->replaceMarkerInResponse($this->responseMessage, 'SITE', $solrConnection['label']); $this->responseMessage = $this->replaceMarkerInResponse($this->responseMessage, 'SCHEME', $solr->getScheme()); $this->responseMessage = $this->replaceMarkerInResponse($this->responseMessage, 'HOST', $solr->getHost()); $this->responseMessage = $this->replaceMarkerInResponse($this->responseMessage, 'PATH', $solr->getPath()); $this->responseMessage = $this->replaceMarkerInResponse($this->responseMessage, 'PORT', $solr->getPort()); $this->checkSolrVersion($solr); $this->checkAccessFilter($solr); $this->checkPingTime($solr); $this->checkSolrConfigName($solr); $this->checkSolrSchemaName($solr); if ($this->responseStatus !== Status::OK) { $value = 'Failed contacting the Solr server.'; } return GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', 'Apache Solr', $value, $this->responseMessage, $this->responseStatus); }