Commit e8cf9e41 authored by Timo Hund's avatar Timo Hund Committed by Markus Kalkbrenner

[TASK] Implement core admin api for solarium (#625)

Resolves: #624
parent 54cad6a0
...@@ -29,6 +29,8 @@ before_script: ...@@ -29,6 +29,8 @@ before_script:
# - pecl install pecl_http # - pecl install pecl_http
- composer require --prefer-source --dev symfony/event-dispatcher:${SYMFONY_VERSION} - composer require --prefer-source --dev symfony/event-dispatcher:${SYMFONY_VERSION}
- solr-${SOLR_VERSION}/bin/solr start -e techproducts - solr-${SOLR_VERSION}/bin/solr start -e techproducts
# make configSet's available for techproducts instance
- cp -R solr-${SOLR_VERSION}/server/solr/configsets solr-${SOLR_VERSION}/example/techproducts/solr/
script: script:
- vendor/bin/phpunit -c phpunit.xml.travis -v - vendor/bin/phpunit -c phpunit.xml.travis -v
......
Core admin queries can be used to administrate cores on your solr server (https://lucene.apache.org/solr/guide/7_4/coreadmin-api.html)
The core admin api on the Apache Solr server has several "actions" available and every action can have a set of arguments.
Building an core admin query
----------------------------
The following example shows how your can build a core admin query that executes the status action:
```php
<?php
require(__DIR__.'/init.php');
htmlHeader();
// create a client instance
$client = new Solarium\Client($config);
// create a core admin query
$coreAdminQuery = $client->createCoreAdmin();
// use the core admin query to build a Status action
$statusAction = $coreAdminQuery->createStatus();
$statusAction->setCore('techproducts');
$coreAdminQuery->setAction($statusAction);
$response = $client->coreAdmin($coreAdminQuery);
$statusResult = $response->getStatusResult();
echo '<b>Core admin status action execution:</b><br/>';
echo 'Uptime of the core ( ' .$statusResult->getCoreName(). ' ): ' . $statusResult->getUptime();
htmlFooter();
```
Beside the **status** action there are several actions available that can be created with the create***ActionName()*** method.
Available actions
-----------------
The api implements the following actions
Create
======
Use to create a new core.
**Available action methods**:
| Name | Arguments | Description |
|-------------------|-------------------------------|---------------------------------------------------------------|
| setAsync | string $async | Identifier for async execution to request the status later |
| setCore | string $core | Name of the core |
| setInstanceDir | string $instanceDir | Instance dir that should be used |
| setConfig | string $config | Name of the config file relative to the instanceDir |
| setSchema | string $schema | Name of the schema file |
| setDataDir | string $dataDir | Name of the dataDir relative to the instance dir |
| setConfigSet | string $configSet | Name of the configSet that should be used |
| setCollection | string $collection | Name of the collection where this core belongs to |
| setShard | string $shard | ShardId that this core represents |
| setCoreProperty | string $name, string $value | Entry for the core.properties file, can be used n times |
MergeIndexes
============
Use to merge cores.
**Available action methods**:
| Name | Arguments | Description |
|-------------------|-------------------------------|---------------------------------------------------------------|
| setAsync | string $async | Identifier for async execution to request the status later |
| setCore | string $core | Name of the core where the data should be merged into |
| setIndexDir | array $indexDir | Array of index directories that should be merged |
| setSrcCore | array $srcCore | Array of source cores that should be merged |
Reload
======
Use to reload a core.
**Available action methods**:
| Name | Arguments | Description |
|-------------------|-------------------------------|---------------------------------------------------------------|
| setCore | string $core | Name of the core that should be reloaded |
Rename
======
Use to rename a core.
**Available action methods**:
| Name | Arguments | Description |
|-------------------|-------------------------------|---------------------------------------------------------------|
| setAsync | string $async | Identifier for async execution to request the status later |
| setCore | string $core | Name of the core that should be renamed |
| setOther | string $otherCoreName | New name of the core |
RequestRecovery
===============
Use to recover a core.
**Note**: Only relevant for solrcloud where cores are shards and a cover can be recovered from the leader (a copy of that core on another node)
**Available action methods**:
| Name | Arguments | Description |
|-------------------|-------------------------------|---------------------------------------------------------------|
| setCore | string $core | Name of the core that should be recovered |
RequestStatus
=============
Use to get the status from an asynchronous request. When you have previously passed an async identifier for another action,
RequestStatus can be used later to retrieve the state for that asynchronous action.
**Available action methods**:
| Name | Arguments | Description |
|-------------------|-------------------------------|---------------------------------------------------------------|
| setRequestId | string $requestId | Id of the asynchronous request that was previously executed. |
Split
=====
Use to split a core.
See also: https://lucene.apache.org/solr/guide/7_4/coreadmin-api.html#coreadmin-split
**Available action methods**:
| Name | Arguments | Description |
|-------------------|-------------------------------|------------------------------------------------------------------|
| setAsync | string $async | Identifier for async execution to request the status later |
| setCore | string $core | Name of the core that should be renamed |
| setPath | array $path | Array of pathes where the parts of the splitted index is written |
| setTargetCore | array $targetCore | Array of target core names that should be used for splitting |
| setRanges | string $ranges | Comma separated list of hash ranges in hexadecimal format |
| setSplitKey | string $splitKey | Key to be used for splitting the index |
Status
======
Use to get the status of one or all cores:
**Note**: When no name is passed the status for all cores will be retrieved.
**Available action methods**:
| Name | Arguments | Description |
|-------------------|-------------------------------|------------------------------------------------------------------|
| setCore | string $core | Optional name of the core where the status should be retrieved |
Swap
====
Use to swap a core.
**Available action methods**:
| Name | Arguments | Description |
|-------------------|-------------------------------|---------------------------------------------------------------|
| setAsync | string $async | Identifier for async execution to request the status later |
| setCore | string $core | Name of the core that should be swap |
| setOther | string $otherCoreName | Target core to swap with |
Unload
======
Use to unload a core.
**Available action methods**:
| Name | Arguments | Description |
|----------------------|-------------------------------|---------------------------------------------------------------|
| setAsync | string $async | Identifier for async execution to request the status later |
| setCore | string $core | Name of the core that should be swap |
| setDeleteIndex | bool $boolean | Deletes the index directory |
| setDeleteDataDir | bool $boolean | Deletes the data directory |
| setDeleteInstanceDir | bool $boolean | Deletes the instance directory |
<?php
require(__DIR__.'/init.php');
htmlHeader();
// create a client instance
$client = new Solarium\Client($config);
// create a core admin query
$coreAdminQuery = $client->createCoreAdmin();
// use the core admin query to build a Status action
$statusAction = $coreAdminQuery->createStatus();
$coreAdminQuery->setAction($statusAction);
$response = $client->coreAdmin($coreAdminQuery);
$statusResults = $response->getStatusResults();
echo '<b>Core admin status action execution:</b><br/>';
foreach($statusResults as $statusResult) {
echo 'Uptime of the core ( ' .$statusResult->getCoreName(). ' ): ' . $statusResult->getUptime();
}
htmlFooter();
\ No newline at end of file
...@@ -90,6 +90,8 @@ ...@@ -90,6 +90,8 @@
<li><a href="2.6-suggester-query.php">2.6 Suggester query</a></li> <li><a href="2.6-suggester-query.php">2.6 Suggester query</a></li>
<li><a href="2.7-extract-query.php">2.7 Extract query</a></li> <li><a href="2.7-extract-query.php">2.7 Extract query</a></li>
<li><a href="2.8-realtime-get-query.php">2.8 Realtime get query</a></li> <li><a href="2.8-realtime-get-query.php">2.8 Realtime get query</a></li>
<li><a href="2.9-server-core-admin-status.php">2.9 Core admin query</a></li>
</ul> </ul>
<li>4. Usage modes</li> <li>4. Usage modes</li>
......
...@@ -72,7 +72,9 @@ class Curl extends Configurable implements AdapterInterface ...@@ -72,7 +72,9 @@ class Curl extends Configurable implements AdapterInterface
public function createHandle($request, $endpoint) public function createHandle($request, $endpoint)
{ {
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$uri = $endpoint->getBaseUri().$request->getUri(); $baseUri = $request->getIsServerRequest() ? $endpoint->getServerUri() : $endpoint->getCoreBaseUri();
$uri = $baseUri.$request->getUri();
$method = $request->getMethod(); $method = $request->getMethod();
$options = $this->createOptions($request, $endpoint); $options = $this->createOptions($request, $endpoint);
......
...@@ -56,9 +56,11 @@ class Guzzle extends Configurable implements AdapterInterface ...@@ -56,9 +56,11 @@ class Guzzle extends Configurable implements AdapterInterface
} }
try { try {
$baseUri = $request->getIsServerRequest() ? $endpoint->getServerUri() : $endpoint->getCoreBaseUri();
$uri = $baseUri.$request->getUri();
$guzzleResponse = $this->getGuzzleClient()->request( $guzzleResponse = $this->getGuzzleClient()->request(
$request->getMethod(), $request->getMethod(),
$endpoint->getBaseUri().$request->getUri(), $uri,
$requestOptions $requestOptions
); );
......
...@@ -31,9 +31,11 @@ class Guzzle3 extends Configurable implements AdapterInterface ...@@ -31,9 +31,11 @@ class Guzzle3 extends Configurable implements AdapterInterface
*/ */
public function execute($request, $endpoint) public function execute($request, $endpoint)
{ {
$baseUri = $request->getIsServerRequest() ? $endpoint->getServerUri() : $endpoint->getCoreBaseUri();
$uri = $baseUri.$request->getUri();
$guzzleRequest = $this->getGuzzleClient()->createRequest( $guzzleRequest = $this->getGuzzleClient()->createRequest(
$request->getMethod(), $request->getMethod(),
$endpoint->getBaseUri().$request->getUri(), $uri,
$this->getRequestHeaders($request), $this->getRequestHeaders($request),
$this->getRequestBody($request), $this->getRequestBody($request),
[ [
......
...@@ -27,7 +27,8 @@ class Http extends Configurable implements AdapterInterface ...@@ -27,7 +27,8 @@ class Http extends Configurable implements AdapterInterface
public function execute($request, $endpoint) public function execute($request, $endpoint)
{ {
$context = $this->createContext($request, $endpoint); $context = $this->createContext($request, $endpoint);
$uri = $endpoint->getBaseUri().$request->getUri(); $baseUri = $request->getIsServerRequest() ? $endpoint->getServerUri() : $endpoint->getCoreBaseUri();
$uri = $baseUri.$request->getUri();
list($data, $headers) = $this->getData($uri, $context); list($data, $headers) = $this->getData($uri, $context);
......
...@@ -63,7 +63,8 @@ class PeclHttp extends Configurable implements AdapterInterface ...@@ -63,7 +63,8 @@ class PeclHttp extends Configurable implements AdapterInterface
*/ */
public function toHttpRequest($request, $endpoint) public function toHttpRequest($request, $endpoint)
{ {
$url = $endpoint->getBaseUri().$request->getUri(); $baseUri = $request->getIsServerRequest() ? $endpoint->getServerUri() : $endpoint->getCoreBaseUri();
$url = $baseUri.$request->getUri();
$httpRequest = new \HttpRequest($url); $httpRequest = new \HttpRequest($url);
$headers = []; $headers = [];
......
...@@ -167,7 +167,9 @@ class Zend2Http extends Configurable implements AdapterInterface ...@@ -167,7 +167,9 @@ class Zend2Http extends Configurable implements AdapterInterface
break; break;
} }
$client->setUri($endpoint->getBaseUri().$request->getHandler()); $baseUri = $request->getIsServerRequest() ? $endpoint->getServerUri() : $endpoint->getCoreBaseUri();
$uri = $baseUri.$request->getUri();
$client->setUri($uri);
$client->setHeaders($request->getHeaders()); $client->setHeaders($request->getHeaders());
$this->timeout = $endpoint->getTimeout(); $this->timeout = $endpoint->getTimeout();
......
...@@ -168,7 +168,9 @@ class ZendHttp extends Configurable implements AdapterInterface ...@@ -168,7 +168,9 @@ class ZendHttp extends Configurable implements AdapterInterface
break; break;
} }
$client->setUri($endpoint->getBaseUri().$request->getHandler()); $baseUri = $request->getIsServerRequest() ? $endpoint->getServerUri() : $endpoint->getCoreBaseUri();
$uri = $baseUri.$request->getUri();
$client->setUri($uri);
$client->setHeaders($request->getHeaders()); $client->setHeaders($request->getHeaders());
$this->timeout = $endpoint->getTimeout(); $this->timeout = $endpoint->getTimeout();
......
...@@ -107,6 +107,11 @@ class Client extends Configurable implements ClientInterface ...@@ -107,6 +107,11 @@ class Client extends Configurable implements ClientInterface
*/ */
const QUERY_REALTIME_GET = 'get'; const QUERY_REALTIME_GET = 'get';
/**
* Querytype cores.
*/
const QUERY_CORE_ADMIN = 'cores';
/** /**
* Default options. * Default options.
* *
...@@ -138,6 +143,7 @@ class Client extends Configurable implements ClientInterface ...@@ -138,6 +143,7 @@ class Client extends Configurable implements ClientInterface
self::QUERY_GRAPH => 'Solarium\QueryType\Graph\Query', self::QUERY_GRAPH => 'Solarium\QueryType\Graph\Query',
self::QUERY_EXTRACT => 'Solarium\QueryType\Extract\Query', self::QUERY_EXTRACT => 'Solarium\QueryType\Extract\Query',
self::QUERY_REALTIME_GET => 'Solarium\QueryType\RealtimeGet\Query', self::QUERY_REALTIME_GET => 'Solarium\QueryType\RealtimeGet\Query',
self::QUERY_CORE_ADMIN => 'Solarium\QueryType\Server\CoreAdmin\Query\Query',
]; ];
/** /**
...@@ -986,6 +992,22 @@ class Client extends Configurable implements ClientInterface ...@@ -986,6 +992,22 @@ class Client extends Configurable implements ClientInterface
return $this->execute($query, $endpoint); return $this->execute($query, $endpoint);
} }
/**
* Execute a CoreAdmin query.
*
* This is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API.
*
* @param QueryInterface|\Solarium\QueryType\Server\CoreAdmin\Query\Query $query
* @param Endpoint|string|null $endpoint
*
* @return \Solarium\QueryType\Server\CoreAdmin\Result\Result
*/
public function coreAdmin(QueryInterface $query, $endpoint = null)
{
return $this->execute($query, $endpoint);
}
/** /**
* Create a query instance. * Create a query instance.
* *
...@@ -1190,6 +1212,18 @@ class Client extends Configurable implements ClientInterface ...@@ -1190,6 +1212,18 @@ class Client extends Configurable implements ClientInterface
return $this->createQuery(self::QUERY_REALTIME_GET, $options); return $this->createQuery(self::QUERY_REALTIME_GET, $options);
} }
/**
* Create a CoreAdmin query instance.
*
* @param mixed $options
*
* @return \Solarium\QueryType\Server\CoreAdmin\Query\Query
*/
public function createCoreAdmin($options = null)
{
return $this->createQuery(self::QUERY_CORE_ADMIN, $options);
}
/** /**
* Initialization hook. * Initialization hook.
*/ */
......
...@@ -482,6 +482,19 @@ interface ClientInterface ...@@ -482,6 +482,19 @@ interface ClientInterface
*/ */
public function realtimeGet(QueryInterface $query, $endpoint = null); public function realtimeGet(QueryInterface $query, $endpoint = null);
/**
* Execute a CoreAdmin query.
*
* @internal this is a convenience method that forwards the query to the
* execute method, thus allowing for an easy to use and clean API
*
* @param QueryInterface|\Solarium\QueryType\Server\CoreAdmin\Query\Query $query
* @param Endpoint|string|null $endpoint
*
* @return \Solarium\QueryType\Server\CoreAdmin\Result\Result
*/
public function coreAdmin(QueryInterface $query, $endpoint = null);
/** /**
* Create a query instance. * Create a query instance.
* *
...@@ -592,4 +605,11 @@ interface ClientInterface ...@@ -592,4 +605,11 @@ interface ClientInterface
* @return \Solarium\QueryType\RealtimeGet\Query * @return \Solarium\QueryType\RealtimeGet\Query
*/ */
public function createRealtimeGet($options = null); public function createRealtimeGet($options = null);
/**
* @param mixed $options
*
* @return \Solarium\QueryType\Server\CoreAdmin\Query\Query
*/
public function createCoreAdmin($options = null);
} }
...@@ -36,7 +36,7 @@ class Endpoint extends Configurable ...@@ -36,7 +36,7 @@ class Endpoint extends Configurable
*/ */
public function __toString() public function __toString()
{ {
$output = __CLASS__.'::__toString'."\n".'base uri: '.$this->getBaseUri()."\n".'host: '.$this->getHost()."\n".'port: '.$this->getPort()."\n".'path: '.$this->getPath()."\n".'core: '.$this->getCore()."\n".'timeout: '.$this->getTimeout()."\n".'authentication: '.print_r($this->getAuthentication(), 1); $output = __CLASS__.'::__toString'."\n".'base uri: '.$this->getCoreBaseUri()."\n".'host: '.$this->getHost()."\n".'port: '.$this->getPort()."\n".'path: '.$this->getPath()."\n".'core: '.$this->getCore()."\n".'timeout: '.$this->getTimeout()."\n".'authentication: '.print_r($this->getAuthentication(), 1);
return $output; return $output;
} }
...@@ -208,11 +208,11 @@ class Endpoint extends Configurable ...@@ -208,11 +208,11 @@ class Endpoint extends Configurable
* *
* @return string * @return string
*/ */
public function getBaseUri() public function getCoreBaseUri()
{ {
$uri = $this->getScheme().'://'.$this->getHost().':'.$this->getPort().$this->getPath().'/'; $uri = $this->getServerUri();
$core = $this->getCore(); $core = $this->getCore();
if (!empty($core)) { if (!empty($core)) {
$uri .= $core.'/'; $uri .= $core.'/';
} }
...@@ -220,6 +220,34 @@ class Endpoint extends Configurable ...@@ -220,6 +220,34 @@ class Endpoint extends Configurable
return $uri; return $uri;
} }
/**
* Get the base url for all requests.
*
* Based on host, path, port and core options.
*
* @deprecated Please use getCoreBaseUri or getServerUri now, will be removed in Solarium 6
*
* @return string
*/
public function getBaseUri()
{
$message = 'Endpoint::getBaseUri is deperacted since Solarium 5, will be removed in Solarium 6 please use '.
'getServerUri or getCoreBaseUri now.';
@trigger_error($message, E_USER_DEPRECATED);
return $this->getCoreBaseUri();
}
/**
* Get the server uri, required for non core/collection specific requests.
*
* @return string
*/
public function getServerUri()
{
return $this->getScheme().'://'.$this->getHost().':'.$this->getPort().$this->getPath().'/';
}
/** /**
* Set HTTP basic auth settings. * Set HTTP basic auth settings.
* *
......
...@@ -290,6 +290,27 @@ class Request extends Configurable implements RequestParamsInterface ...@@ -290,6 +290,27 @@ class Request extends Configurable implements RequestParamsInterface
]; ];
} }
/**
* Execute a request outside of the core context in the global solr context.
*
* @param bool $isServerRequest
*/
public function setIsServerRequest($isServerRequest = false)
{
$this->setOption('isserverrequest', $isServerRequest);
}
/**
* Indicates if a request is core independent and could be executed outside a core context.
* By default a Request is not core independent and must be executed in the context of a core.
*
* @return bool
*/
public function getIsServerRequest(): bool
{
return $this->getOption('isserverrequest') ?? false;
}
/** /**
* Initialization hook. * Initialization hook.
*/ */
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Solarium\Core\Query; namespace Solarium\Core\Query;
use Solarium\Core\Client\Request; use Solarium\Core\Client\Request;
use Solarium\QueryType\Server\AbstractServerQuery;
/** /**
* Class for building Solarium client requests. * Class for building Solarium client requests.
...@@ -32,6 +33,9 @@ abstract class AbstractRequestBuilder implements RequestBuilderInterface ...@@ -32,6 +33,9 @@ abstract class AbstractRequestBuilder implements RequestBuilderInterface
$request->addParam('json.nl', 'flat'); $request->addParam('json.nl', 'flat');
} }
$isServerQuery = ($query instanceof AbstractServerQuery);
$request->setIsServerRequest($isServerQuery);
return $request; return $request;
} }
......
<?php
namespace Solarium\QueryType\Server;
use Solarium\Core\Query\AbstractQuery;
/**
* Base class for all server queries, these query are not executed in the context of a collection or a core.
*/
abstract class AbstractServerQuery extends AbstractQuery
{
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Query\Action;
use Solarium\Core\Configurable;
/**
* CoreAdmin query command base class.
*/
abstract class AbstractAction extends Configurable
{
/**
* Returns command type, for use in adapters.
*
* @return string
*/
abstract public function getType(): string;
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Query\Action;
abstract class AbstractAsyncAction extends AbstractCoreAction
{
/**
* Can be used to set a requestId to track this action with asynchronous processing.
*
* @param string $async
*
* @return self Provides fluent interface
*/
public function setAsync(string $async)
{
return $this->setOption('async', $async);
}
/**
* Get the passed handle for asynchronous processing.
*
* @return string
*/
public function getAsync(): string
{
return (string) $this->getOption('async');
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Query\Action;
abstract class AbstractCoreAction extends AbstractAction
{
/**
* Set the core name that should be reloaded.
*
* @param string $core
*/
public function setCore(string $core)
{
$this->setOption('core', $core);
}
/**
* Get the related core name.
*
* @return string
*/
public function getCore(): string
{
return (string) $this->getOption('core');
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Query\Action;
use Solarium\QueryType\Server\CoreAdmin\Query\Query as CoreAdminQuery;
/**
* Class Create.
*
* @see https://lucene.apache.org/solr/guide/6_6/coreadmin-api.html#CoreAdminAPI-Input.1
*/
class Create extends AbstractAsyncAction
{
/**
* Returns the action type of the core admin action.
*
* @return string
*/
public function getType(): string
{
return CoreAdminQuery::ACTION_CREATE;
}
/**
* Set the core name that should be reloaded.
*
* @param string $core
*/
public function setCore(string $core)
{
// for some reason the core is called "name" in the create action
$this->setOption('name', $core);
}
/**
* Get the related core name.
*
* @return string
*/
public function getCore(): string
{
// for some reason the core is called "name" in the create action
return $this->getOption('name');
}
/**
* Set the instanceDir.
*
* @param string $instanceDir
*
* @return self Provides fluent interface
*/
public function setInstanceDir(string $instanceDir)
{
return $this->setOption('instanceDir', $instanceDir);
}
/**
* Get the instanceDir.
*
* @return string
*/
public function getInstanceDir(): string
{
return (string) $this->getOption('instanceDir');
}
/**
* Set the config.
*
* @param string $config
*
* @return self Provides fluent interface
*/
public function setConfig(string $config)
{
return $this->setOption('config', $config);
}
/**
* Get the config.
*
* @return string
*/
public function getConfig(): string
{
return $this->getOption('config');
}
/**
* Set the schema.
*
* @param string $schema
*
* @return self Provides fluent interface
*/
public function setSchema(string $schema)
{
return $this->setOption('schema', $schema);
}
/**
* Get the schema.
*
* @return string
*/
public function getSchema(): string
{
return (string) $this->getOption('schema');
}
/**
* Set the dataDir.
*
* @param string $dataDir
*
* @return self Provides fluent interface
*/
public function setDataDir(string $dataDir)
{
return $this->setOption('dataDir', $dataDir);
}
/**
* Get the schema.
*
* @return string
*/
public function getDataDir(): string
{
return (string) $this->getOption('dataDir');
}
/**
* Set the configSet.
*
* @param string $configSet
*
* @return self Provides fluent interface
*/
public function setConfigSet(string $configSet)
{
return $this->setOption('configSet', $configSet);
}
/**
* Get the configSet.
*
* @return string
*/
public function getConfigSet(): string
{
return (string) $this->getOption('configSet');
}
/**
* Set the collection.
*
* @param string $collection
*
* @return self Provides fluent interface
*/
public function setCollection(string $collection)
{
return $this->setOption('collection', $collection);
}
/**
* Get the collection.
*
* @return string
*/
public function getCollection(): string
{
return (string) $this->getOption('collection');
}
/**
* Set the shard.
*
* @param string $shard
*
* @return self Provides fluent interface
*/
public function setShard($shard)
{
return $this->setOption('shard', $shard);
}
/**
* Get the collection.
*
* @return string
*/
public function getShard(): string
{
return (string) $this->getOption('shard');
}
/**
* Set the a property in the core.properties file.
*
* @param string $name
* @param string $value
*
* @return self Provides fluent interface
*/
public function setCoreProperty(string $name, string $value)
{
$option = 'property.'.$name;
return $this->setOption($option, $value);
}
/**
* Get a previously added core property.
*
* @return string
*/
public function getCoreProperty($name): string
{
$option = 'property.'.$name;
return (string) $this->getOption($option);
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Query\Action;
use Solarium\QueryType\Server\CoreAdmin\Query\Query as CoreAdminQuery;
class MergeIndexes extends AbstractAsyncAction
{
/**
* Returns the action type of the core admin action.
*
* @return string
*/
public function getType(): string
{
return CoreAdminQuery::ACTION_MERGE_INDEXES;
}
/**
* Directories that should be merged.
*
* @param string[] $indexDir
*
* @return self Provides fluent interface
*/
public function setIndexDir(array $indexDir)
{
return $this->setOption('indexDir', $indexDir);
}
/**
* Get the other core that should be the new name.
*
* @return string[]
*/
public function getIndexDir(): array
{
return (array) $this->getOption('indexDir');
}
/**
* Directories that should be merged.
*
* @param string[] $srcCore
*
* @return self Provides fluent interface
*/
public function setSrcCore(array $srcCore)
{
return $this->setOption('srcCore', $srcCore);
}
/**
* Get the other core that should be the new name.
*
* @return string[]
*/
public function getSrcCore(): array
{
return (array) $this->getOption('srcCore');
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Query\Action;
use Solarium\QueryType\Server\CoreAdmin\Query\Query as CoreAdminQuery;
class Reload extends AbstractCoreAction
{
/**
* Returns the action type of the core admin action.
*
* @return string
*/
public function getType(): string
{
return CoreAdminQuery::ACTION_RELOAD;
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Query\Action;
use Solarium\QueryType\Server\CoreAdmin\Query\Query as CoreAdminQuery;
class Rename extends AbstractAsyncAction
{
/**
* Returns the action type of the core admin action.
*
* @return string
*/
public function getType(): string
{
return CoreAdminQuery::ACTION_RENAME;
}
/**
* Set new name after renaming.
*
* @param string $other
*
* @return self Provides fluent interface
*/
public function setOther($other)
{
return $this->setOption('other', $other);
}
/**
* Get the other core that should be the new name.
*
* @return string
*/
public function getOther(): string
{
return (string) $this->getOption('other');
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Query\Action;
use Solarium\QueryType\Server\CoreAdmin\Query\Query as CoreAdminQuery;
class RequestRecovery extends AbstractCoreAction
{
/**
* Returns the action type of the core admin action.
*
* @return string
*/
public function getType(): string
{
return CoreAdminQuery::ACTION_REQUEST_RECOVERY;
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Query\Action;
use Solarium\QueryType\Server\CoreAdmin\Query\Query as CoreAdminQuery;
/**
* Class RequestStatus.
*
* @see https://lucene.apache.org/solr/guide/6_6/coreadmin-api.html#CoreAdminAPI-REQUESTSTATUS
*/
class RequestStatus extends AbstractAction
{
/**
* Returns the action type of the core admin action.
*
* @return string
*/
public function getType(): string
{
return CoreAdminQuery::ACTION_REQUEST_STATUS;
}
/**
* Set the requestId to get the status from.
*
* @param string $requestId
*
* @return self Provides fluent interface
*/
public function setRequestId($requestId)
{
return $this->setOption('requestid', $requestId);
}
/**
* Get the requestId where that status should be retrieved for.
*
* @return string
*/
public function getRequestId(): string
{
return (string) $this->getOption('requestid');
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Query\Action;
use Solarium\QueryType\Server\CoreAdmin\Query\Query as CoreAdminQuery;
/**
* @see https://lucene.apache.org/solr/guide/6_6/coreadmin-api.html#CoreAdminAPI-SPLIT
*/
class Split extends AbstractAsyncAction
{
/**
* Returns the action type of the core admin action.
*
* @return string
*/
public function getType(): string
{
return CoreAdminQuery::ACTION_SPLIT;
}
/**
* The directories that should be used to split into.
*
* @param string[] $path
*
* @return self Provides fluent interface
*/
public function setPath(array $path)
{
return $this->setOption('path', $path);
}
/**
* Get the pathes that should be used to split into.
*
* @return array
*/
public function getPath(): array
{
return (array) $this->getOption('path');
}
/**
* The target core names to split into.
*
* @param string[] $targetCore
*
* @return self Provides fluent interface
*/
public function setTargetCore(array $targetCore)
{
return $this->setOption('targetCore', $targetCore);
}
/**
* Get the pathes that should be used to split into.
*
* @return array
*/
public function getTargetCore(): array
{
return (array) $this->getOption('targetCore');
}
/**
* Set a comma-separated list of hash ranges in a hexadecimal format.
*
* @param string $ranges
*
* @return self Provides fluent interface
*/
public function setRanges(string $ranges)
{
return $this->setOption('ranges', $ranges);
}
/**
* Get the pathes that should be used to split into.
*
* @return string
*/
public function getRanges(): string
{
return (string) $this->getOption('ranges');
}
/**
* Set a key that should be used for splitting.
*
* @param string $splitKey
*
* @return self Provides fluent interface
*/
public function setSplitKey(string $splitKey)
{
return $this->setOption('split.key', $splitKey);
}
/**
* Returns the key that should be used for splitting.
*
* @return string
*/
public function getSplitKey(): string
{
return (string) $this->getOption('split.key');
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Query\Action;
use Solarium\QueryType\Server\CoreAdmin\Query\Query as CoreAdminQuery;
class Status extends AbstractCoreAction
{
/**
* Returns the action type of the core admin action.
*
* @return string
*/
public function getType(): string
{
return CoreAdminQuery::ACTION_STATUS;
}
/**
* Indicates if the indexInfo should be returned. By default this is the case. Can be set to false
* to improve the request performance if the indexInfo is not required.
*
* @param bool $indexInfo
*
* @return self Provides fluent interface
*/
public function setIndexInfo(bool $indexInfo)
{
return $this->setOption('indexInfo', $indexInfo);
}
/**
* Get if information about the index should be retrieved.
*
* @return bool
*/
public function getIndexInfo(): bool
{
return (string) $this->getOption('indexInfo');
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Query\Action;
use Solarium\QueryType\Server\CoreAdmin\Query\Query as CoreAdminQuery;
class Swap extends AbstractAsyncAction
{
/**
* Returns the action type of the core admin action.
*
* @return string
*/
public function getType(): string
{
return CoreAdminQuery::ACTION_SWAP;
}
/**
* Set core that should be used for swapping.
*
* @param string $other
*
* @return self Provides fluent interface
*/
public function setOther($other)
{
return $this->setOption('other', $other);
}
/**
* Get the other core that should ne used for swapping.
*
* @return string
*/
public function getOther(): string
{
return (string) $this->getOption('other');
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Query\Action;
use Solarium\QueryType\Server\CoreAdmin\Query\Query as CoreAdminQuery;
/**
* @see https://lucene.apache.org/solr/guide/6_6/coreadmin-api.html#CoreAdminAPI-UNLOAD
*/
class Unload extends AbstractAsyncAction
{
/**
* Returns the action type of the core admin action.
*
* @return string
*/
public function getType(): string
{
return CoreAdminQuery::ACTION_UNLOAD;
}
/**
* If set to true the index will be deleted when the core is unloaded.
*
* @param bool $deleteIndex
*
* @return self Provides fluent interface
*/
public function setDeleteIndex(bool $deleteIndex)
{
return $this->setOption('deleteIndex', $deleteIndex);
}
/**
* Indicates if a deletion was forced.
*
* @return bool
*/
public function getDeleteIndex(): bool
{
return (string) $this->getOption('deleteIndex');
}
/**
* If set to true the data dir will be removed when unloading.
*
* @param bool $deleteDataDir
*
* @return self Provides fluent interface
*/
public function setDeleteDataDir(bool $deleteDataDir)
{
return $this->setOption('deleteDataDir', $deleteDataDir);
}
/**
* Indicates if a deletion of the dataDir was forced.
*
* @return bool
*/
public function getDeleteDataDir(): bool
{
return (string) $this->getOption('deleteDataDir');
}
/**
* If set to true the instance dir will be removed when unloading.
*
* @param bool $deleteInstanceDir
*
* @return self Provides fluent interface
*/
public function setDeleteInstanceDir(bool $deleteInstanceDir)
{
return $this->setOption('deleteInstanceDir', $deleteInstanceDir);
}
/**
* Indicates if a deletion of the instanceDir was forced.
*
* @return bool
*/
public function getDeleteInstanceDir(): bool
{
return (string) $this->getOption('deleteInstanceDir');
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Query;
use Solarium\Core\Client\Client;
use Solarium\Exception\InvalidArgumentException;
use Solarium\QueryType\Server\AbstractServerQuery;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\AbstractAction;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Create;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\MergeIndexes;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Reload;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Rename;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\RequestRecovery;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\RequestStatus;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Split;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Status;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Swap;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Unload;
use Solarium\QueryType\Server\CoreAdmin\RequestBuilder;
use Solarium\QueryType\Server\CoreAdmin\ResponseParser;
/**
* CoreAdmin query.
*
* Can be used to perform an action on the core admin endpoint
*/
class Query extends AbstractServerQuery
{
/**
* Create core action.
*/
const ACTION_CREATE = 'CREATE';
/**
* Merge indexes action.
*/
const ACTION_MERGE_INDEXES = 'MERGEINDEXES';
/**
* Reload core action.
*/
const ACTION_RELOAD = 'RELOAD';
/**
* Rename core action.
*/
const ACTION_RENAME = 'RENAME';
/**
* Request the recovery of a core.
*/
const ACTION_REQUEST_RECOVERY = 'REQUESTRECOVERY';
/**
* Request the status of a core.
*/
const ACTION_REQUEST_STATUS = 'REQUESTSTATUS';
/**
* Request a split of a core.
*/
const ACTION_SPLIT = 'SPLIT';
/**
* Request the status of a core.
*/
const ACTION_STATUS = 'STATUS';
/**
* Request the swap of two cores.
*/
const ACTION_SWAP = 'SWAP';
/**
* Request the unload of a core.
*/
const ACTION_UNLOAD = 'UNLOAD';
/**
* Update command types.
*
* @var array
*/
protected $actionTypes = [
self::ACTION_CREATE => 'Solarium\QueryType\Server\CoreAdmin\Query\Action\Create',
self::ACTION_MERGE_INDEXES => 'Solarium\QueryType\Server\CoreAdmin\Query\Action\MergeIndexes',
self::ACTION_RELOAD => 'Solarium\QueryType\Server\CoreAdmin\Query\Action\Reload',
self::ACTION_RENAME => 'Solarium\QueryType\Server\CoreAdmin\Query\Action\Rename',
self::ACTION_REQUEST_RECOVERY => 'Solarium\QueryType\Server\CoreAdmin\Query\Action\RequestRecovery',
self::ACTION_REQUEST_STATUS => 'Solarium\QueryType\Server\CoreAdmin\Query\Action\RequestStatus',
self::ACTION_SPLIT => 'Solarium\QueryType\Server\CoreAdmin\Query\Action\Split',
self::ACTION_STATUS => 'Solarium\QueryType\Server\CoreAdmin\Query\Action\Status',
self::ACTION_SWAP => 'Solarium\QueryType\Server\CoreAdmin\Query\Action\Swap',
self::ACTION_UNLOAD => 'Solarium\QueryType\Server\CoreAdmin\Query\Action\Unload',
];
/**
* Default options.
*
* @var array
*/
protected $options = [
'handler' => 'admin/cores',
'resultclass' => 'Solarium\QueryType\Server\CoreAdmin\Result\Result',
];
/**
* Action that should be performed on the core admin api.
*
* @var AbstractAction
*/
protected $action = null;
/**
* Get type for this query.
*
* @return string
*/
public function getType()
{
return Client::QUERY_CORE_ADMIN;
}
/**
* Get a requestbuilder for this query.
*
* @return RequestBuilder
*/
public function getRequestBuilder()
{
return new RequestBuilder();
}
/**
* Get a response parser for this query.
*
* @return ResponseParser
*/
public function getResponseParser()
{
return new ResponseParser();
}
/**
* @param array $options
*
* @return Create
*/
public function createCreate($options = [])
{
return $this->createAction(self::ACTION_CREATE, $options);
}
/**
* @param array $options
*
* @return MergeIndexes
*/
public function createMergeIndexes($options = [])
{
return $this->createAction(self::ACTION_MERGE_INDEXES, $options);
}
/**
* @param array $options
*
* @return Reload
*/
public function createReload($options = [])
{
return $this->createAction(self::ACTION_RELOAD, $options);
}
/**
* @param array $options
*
* @return Rename
*/
public function createRename($options = [])
{
return $this->createAction(self::ACTION_RENAME, $options);
}
/**
* @param array $options
*
* @return RequestRecovery
*/
public function createRequestRecovery($options = [])
{
return $this->createAction(self::ACTION_REQUEST_RECOVERY, $options);
}
/**
* @param array $options
*
* @return RequestStatus
*/
public function createRequestStatus($options = [])
{
return $this->createAction(self::ACTION_REQUEST_STATUS, $options);
}
/**
* @param array $options
*
* @return Split
*/
public function createSplit($options = [])
{
return $this->createAction(self::ACTION_SPLIT, $options);
}
/**
* @param array $options
*
* @return Status
*/
public function createStatus($options = [])
{
return $this->createAction(self::ACTION_STATUS, $options);
}
/**
* @param array $options
*
* @return Swap
*/
public function createSwap($options = [])
{
return $this->createAction(self::ACTION_SWAP, $options);
}
/**
* @param array $options
*
* @return Unload
*/
public function createUnload($options = [])
{
return $this->createAction(self::ACTION_UNLOAD, $options);
}
/**
* Create a command instance.
*
* @param string $type
* @param mixed $options
*
* @throws InvalidArgumentException
*
* @return AbstractAction
*/
public function createAction($type, $options = null)
{
if (!isset($this->actionTypes[$type])) {
throw new InvalidArgumentException('CoreAdmin action unknown: '.$type);
}
$class = $this->actionTypes[$type];
return new $class($options);
}
/**
* @param AbstractAction $action
*/
public function setAction(AbstractAction $action)
{
$this->action = $action;
}
/**
* Get the active action.
*
* @return AbstractAction
*/
public function getAction()
{
return $this->action;
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin;
use Solarium\Core\Client\Request;
use Solarium\Core\Query\AbstractRequestBuilder as BaseRequestBuilder;
use Solarium\Core\Query\QueryInterface;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\AbstractAction;
use Solarium\QueryType\Server\CoreAdmin\Query\Query as CoreAdminQuery;
/**
* Build an core admin request.
*/
class RequestBuilder extends BaseRequestBuilder
{
/**
* Build request for an update query.
*
* @param QueryInterface|CoreAdminQuery $query
*
* @return Request
*/
public function build(QueryInterface $query)
{
$request = parent::build($query);
$request->setMethod(Request::METHOD_GET);
$request = $this->addOptionsFromAction($query->getAction(), $request);
return $request;
}
protected function addOptionsFromAction(AbstractAction $action, Request $request)
{
$options = ['action' => $action->getType()];
$options += $action->getOptions();
$request->addParams($options);
return $request;
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin;
use Solarium\Core\Query\AbstractResponseParser as ResponseParserAbstract;
use Solarium\Core\Query\ResponseParserInterface;
use Solarium\QueryType\Server\CoreAdmin\Query\Query;
use Solarium\QueryType\Server\CoreAdmin\Result\Result;
use Solarium\QueryType\Server\CoreAdmin\Result\StatusResult;
/**
* Parse update response data.
*/
class ResponseParser extends ResponseParserAbstract implements ResponseParserInterface
{
/**
* Parse response data.
*
* @param Result $result
*
* @return array
*/
public function parse($result)
{
$data = $result->getData();
$data = $this->parseStatus($data, $result);
$data = $this->addHeaderInfo($data, $data);
return $data;
}
/**
* @param array $data
* @param Result $result
*
* @return array
*/
protected function parseStatus(array $data, Result $result)
{
$action = $result->getQuery()->getAction();
$type = $action->getType();
$data['wasSuccessful'] = 200 === $result->getResponse()->getStatusCode();
$data['statusMessage'] = $result->getResponse()->getStatusMessage();
if (Query::ACTION_STATUS !== $type) {
return $data;
}
if (!is_array($data['status'])) {
return $data;
}
$coreStatusResults = [];
$coreStatusResult = null;
foreach ($data['status'] as $coreName => $coreStatusData) {
$status = new StatusResult();
$status->setCoreName($coreName);
$status->setNumberOfDocuments($coreStatusData['index']['numDocs'] ?? 0);
$status->setVersion($coreStatusData['index']['version'] ?? 0);
$status->setUptime($coreStatusData['uptime'] ?? 0);
$startTimeDate = isset($coreStatusData['startTime']) ? new \DateTime($coreStatusData['startTime']) : null;
$status->setStartTime($startTimeDate);
$lastModifiedDate = isset($coreStatusData['index']['lastModified']) ? new \DateTime($coreStatusData['index']['lastModified']) : null;
$status->setLastModified($lastModifiedDate);
$coreStatusResults[] = $status;
// when a core name was set in the action and we have a response we remember it to set a single statusResult
if ($coreName === $action->getCore()) {
$coreStatusResult = $status;
}
}
$data['statusResults'] = $coreStatusResults;
$data['statusResult'] = $coreStatusResult;
return $data;
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Result;
use Solarium\Core\Query\Result\QueryType as BaseResult;
/**
* CoreAdmin result object.
*/
class Result extends BaseResult
{
/**
* StatusResult collection when multiple statuses have been requested.
*
* @var StatusResult[]
*/
protected $statusResults = null;
/**
* Status result when the status only for one core as requested.
*
* @var StatusResult
*/
protected $statusResult = null;
/**
* @var bool
*/
protected $wasSuccessful = false;
/**
* @var string
*/
protected $statusMessage = 'ERROR';
/**
* @return bool
*/
public function getWasSuccessful(): bool
{
$this->parseResponse();
return $this->wasSuccessful;
}
/**
* @return string
*/
public function getStatusMessage(): string
{
$this->parseResponse();
return $this->statusMessage;
}
/**
* Returns the status result objects for all requested core statuses.
*
* @return StatusResult[]|null
*/
public function getStatusResults()
{
$this->parseResponse();
return $this->statusResults;
}
/**
* Retrives the status of the core, only available when the core was filtered to a core in the status action.
*
* @return StatusResult|null
*/
public function getStatusResult()
{
$this->parseResponse();
return $this->statusResult;
}
/**
* @param string $coreName
*
* @return null|StatusResult
*/
public function getStatusResultByCoreName($coreName)
{
return $this->statusResults[$coreName] ?? null;
}
}
<?php
namespace Solarium\QueryType\Server\CoreAdmin\Result;
/**
* Retrieved status information.
*/
class StatusResult
{
/**
* @var string
*/
protected $coreName = '';
/**
* @var int
*/
protected $numberOfDocuments = 0;
/**
* @var int
*/
protected $uptime = 0;
/**
* @var int
*/
protected $version = 0;
/**
* @var \DateTime|null
*/
protected $startTime = null;
/**
* @var \DateTime|null
*/
protected $lastModified = null;
/**
* @return string
*/
public function getCoreName(): string
{
return $this->coreName;
}
/**
* @param string $coreName
*/
public function setCoreName(string $coreName)
{
$this->coreName = $coreName;
}
/**
* @return int
*/
public function getNumberOfDocuments(): int
{
return $this->numberOfDocuments;
}
/**
* @param int $numberOfDocuments
*/
public function setNumberOfDocuments(int $numberOfDocuments)
{
$this->numberOfDocuments = $numberOfDocuments;
}
/**
* @return int
*/
public function getUptime(): int
{
return $this->uptime;
}
/**
* @param int $uptime
*/
public function setUptime(int $uptime)
{
$this->uptime = $uptime;
}
/**
* @return int
*/
public function getVersion(): int
{
return $this->version;
}
/**
* @param int $version
*/
public function setVersion(int $version)
{
$this->version = $version;
}
/**
* @return \DateTime|null
*/
public function getStartTime()
{
return $this->startTime;
}
/**
* @param \DateTime|null $startTime
*/
public function setStartTime($startTime)
{
$this->startTime = $startTime;
}
/**
* @return \DateTime|null
*/
public function getLastModified()
{
return $this->lastModified;
}
/**
* @param \DateTime|null $lastModified
*/
public function setLastModified($lastModified)
{
$this->lastModified = $lastModified;
}
}
...@@ -78,25 +78,46 @@ class EndpointTest extends TestCase ...@@ -78,25 +78,46 @@ class EndpointTest extends TestCase
$this->assertSame('https', $this->endpoint->getScheme()); $this->assertSame('https', $this->endpoint->getScheme());
} }
public function testGetBaseUri() public function testGetCoreBaseUri()
{ {
$this->endpoint->setHost('myserver')->setPath('/mypath')->setPort(123); $this->endpoint->setHost('myserver')->setPath('/mypath')->setPort(123);
$this->assertSame('http://myserver:123/mypath/', $this->endpoint->getBaseUri()); $this->assertSame('http://myserver:123/mypath/', $this->endpoint->getCoreBaseUri());
} }
public function testGetBaseUriWithHttps() public function testGetServerUri()
{
$this->endpoint->setHost('myserver')->setPath('/mypath')->setPort(123);
$this->assertSame('http://myserver:123/mypath/', $this->endpoint->getServerUri());
}
public function testGetCoreBaseUriWithHttps()
{ {
$this->endpoint->setScheme('https')->setHost('myserver')->setPath('/mypath')->setPort(123); $this->endpoint->setScheme('https')->setHost('myserver')->setPath('/mypath')->setPort(123);
$this->assertSame('https://myserver:123/mypath/', $this->endpoint->getBaseUri()); $this->assertSame('https://myserver:123/mypath/', $this->endpoint->getCoreBaseUri());
}
public function testGetServerUriWithHttps()
{
$this->endpoint->setScheme('https')->setHost('myserver')->setPath('/mypath')->setPort(123);
$this->assertSame('https://myserver:123/mypath/', $this->endpoint->getServerUri());
}
public function testGetCoreBaseUriWithCore()
{
$this->endpoint->setHost('myserver')->setPath('/mypath')->setPort(123)->setCore('mycore');
$this->assertSame('http://myserver:123/mypath/mycore/', $this->endpoint->getCoreBaseUri());
} }
public function testGetBaseUriWithCore() public function testServerUriDoesNotContainCoreSegment()
{ {
$this->endpoint->setHost('myserver')->setPath('/mypath')->setPort(123)->setCore('mycore'); $this->endpoint->setHost('myserver')->setPath('/mypath')->setPort(123)->setCore('mycore');
$this->assertSame('http://myserver:123/mypath/mycore/', $this->endpoint->getBaseUri()); $this->assertSame('http://myserver:123/mypath/', $this->endpoint->getServerUri());
} }
public function testGetAndSetAuthentication() public function testGetAndSetAuthentication()
......
...@@ -7,6 +7,7 @@ use Solarium\Component\ComponentAwareQueryInterface; ...@@ -7,6 +7,7 @@ use Solarium\Component\ComponentAwareQueryInterface;
use Solarium\Component\QueryTraits\TermsTrait; use Solarium\Component\QueryTraits\TermsTrait;
use Solarium\Component\Result\Terms\Result; use Solarium\Component\Result\Terms\Result;
use Solarium\Core\Client\ClientInterface; use Solarium\Core\Client\ClientInterface;
use Solarium\Exception\HttpException;
use Solarium\QueryType\Select\Query\Query as SelectQuery; use Solarium\QueryType\Select\Query\Query as SelectQuery;
use Solarium\QueryType\Select\Result\Document; use Solarium\QueryType\Select\Result\Document;
...@@ -492,6 +493,160 @@ abstract class AbstractTechproductsTest extends TestCase ...@@ -492,6 +493,160 @@ abstract class AbstractTechproductsTest extends TestCase
$content = $json->{$fileName}; $content = $json->{$fileName};
$this->assertSame('PDF Test', trim($content), 'Can not extract the plain content from the file'); $this->assertSame('PDF Test', trim($content), 'Can not extract the plain content from the file');
} }
public function testCanReloadCore()
{
$coreAdminQuery = $this->client->createCoreAdmin();
$reloadAction = $coreAdminQuery->createReload();
$reloadAction->setCore('techproducts');
$coreAdminQuery->setAction($reloadAction);
$result = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($result->getWasSuccessful());
// reloading an unexisting core should not be succesful
$this->expectException(HttpException::class);
$reloadAction2 = $coreAdminQuery->createReload();
$reloadAction2->setCore('nonExistingCore');
$coreAdminQuery->setAction($reloadAction2);
$this->client->coreAdmin($coreAdminQuery);
}
public function testCoreAdminStatus()
{
$coreAdminQuery = $this->client->createCoreAdmin();
$statusAction = $coreAdminQuery->createStatus();
$statusAction->setCore('techproducts');
$coreAdminQuery->setAction($statusAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$json = json_decode($response->getResponse()->getBody());
$this->assertTrue($response->getWasSuccessful());
$this->assertGreaterThanOrEqual(0, $json->responseHeader->QTime);
$this->assertNotNull($response->getStatusResult()->getUptime());
$this->assertGreaterThan(0, $response->getStatusResult()->getStartTime()->format('U'));
$this->assertGreaterThan(0, $response->getStatusResult()->getLastModified()->format('U'));
$this->assertSame('techproducts', $response->getStatusResult()->getCoreName());
$statusAction = $coreAdminQuery->createStatus();
$statusAction->setCore('unknowncore');
$coreAdminQuery->setAction($statusAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($response->getWasSuccessful());
$this->assertSame(0, $response->getStatusResult()->getUptime());
$this->assertNull($response->getStatusResult()->getLastModified());
$this->assertNull($response->getStatusResult()->getStartTime());
}
public function testSplitAndMerge()
{
$coreAdminQuery = $this->client->createCoreAdmin();
// create core techproducts_a
$createAction = $coreAdminQuery->createCreate();
$createAction->setCore('techproducts_a');
$createAction->setConfigSet('sample_techproducts_configs');
$coreAdminQuery->setAction($createAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($response->getWasSuccessful());
// create core techproducts_b
$createAction = $coreAdminQuery->createCreate();
$createAction->setCore('techproducts_b');
$createAction->setConfigSet('sample_techproducts_configs');
$coreAdminQuery->setAction($createAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($response->getWasSuccessful());
// split the techproducts core into techproducts_a and techproducts_b
$splitAction = $coreAdminQuery->createSplit();
$splitAction->setCore('techproducts');
$splitAction->setTargetCore(['techproducts_a', 'techproducts_b']);
$coreAdminQuery->setAction($splitAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($response->getWasSuccessful());
// reload core techproducts_a
$reloadAction = $coreAdminQuery->createReload();
$reloadAction->setCore('techproducts_a');
$coreAdminQuery->setAction($reloadAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($response->getWasSuccessful());
// reload core techproducts_b
$reloadAction = $coreAdminQuery->createReload();
$reloadAction->setCore('techproducts_b');
$coreAdminQuery->setAction($reloadAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($response->getWasSuccessful());
// check that we have 32 documents in techproducts 16 in techproducts_a and 16 in techproducts_b
$statusAction = $coreAdminQuery->createStatus();
$statusAction->setCore('techproducts');
$coreAdminQuery->setAction($statusAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($response->getWasSuccessful());
$this->assertSame(32, $response->getStatusResult()->getNumberOfDocuments());
$statusAction = $coreAdminQuery->createStatus();
$statusAction->setCore('techproducts_a');
$coreAdminQuery->setAction($statusAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($response->getWasSuccessful());
$this->assertSame(16, $response->getStatusResult()->getNumberOfDocuments());
$statusAction = $coreAdminQuery->createStatus();
$statusAction->setCore('techproducts_b');
$coreAdminQuery->setAction($statusAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($response->getWasSuccessful());
$this->assertSame(16, $response->getStatusResult()->getNumberOfDocuments());
// now we cleanup the created cores
$unloadAction = $coreAdminQuery->createUnload();
$unloadAction->setCore('techproducts_a');
$unloadAction->setDeleteDataDir(true)->setDeleteIndex(true)->setDeleteInstanceDir(true);
$coreAdminQuery->setAction($unloadAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($response->getWasSuccessful());
$unloadAction = $coreAdminQuery->createUnload();
$unloadAction->setCore('techproducts_b');
$unloadAction->setDeleteDataDir(true)->setDeleteIndex(true)->setDeleteInstanceDir(true);
$coreAdminQuery->setAction($unloadAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($response->getWasSuccessful());
}
public function testGetStatusFromAllCoreWhenNoCoreNameWasSet()
{
$coreAdminQuery = $this->client->createCoreAdmin();
// create core techproducts_new
$createAction = $coreAdminQuery->createCreate();
$createAction->setCore('techproducts_new');
$createAction->setConfigSet('sample_techproducts_configs');
$coreAdminQuery->setAction($createAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($response->getWasSuccessful());
// we now have two cores and when we retrieve the status for all we should have two status objects
$statusAction = $coreAdminQuery->createStatus();
$coreAdminQuery->setAction($statusAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($response->getWasSuccessful());
$statusResults = $response->getStatusResults();
$this->assertSame(2, count($statusResults));
$this->assertGreaterThan(0, $statusResults[0]->getUptime(), 'Can not get uptime of first core');
// now we unload the created core again
$unloadAction = $coreAdminQuery->createUnload();
$unloadAction->setCore('techproducts_new');
$unloadAction->setDeleteDataDir(true)->setDeleteIndex(true)->setDeleteInstanceDir(true);
$coreAdminQuery->setAction($unloadAction);
$response = $this->client->coreAdmin($coreAdminQuery);
$this->assertTrue($response->getWasSuccessful());
}
} }
class TestQuery extends SelectQuery class TestQuery extends SelectQuery
......
<?php
namespace Solarium\Tests\QueryType\Server\CoreAdmin\Query\Action;
use PHPUnit\Framework\TestCase;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Create;
class CreateTest extends TestCase
{
/**
* @var Create
*/
protected $action;
public function setUp()
{
$this->action = new Create();
}
public function testSetCore()
{
$this->action->setCore('myCore');
$this->assertSame('myCore', $this->action->getCore());
}
public function testSetAsync()
{
$this->action->setAsync('fooXyz');
$this->assertSame('fooXyz', $this->action->getAsync());
}
public function testGetType()
{
$this->assertSame('CREATE', $this->action->getType());
}
}
<?php
namespace Solarium\Tests\QueryType\Server\CoreAdmin\Query\Action;
use PHPUnit\Framework\TestCase;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\MergeIndexes;
class MergeIndexesTest extends TestCase
{
/**
* @var MergeIndexes
*/
protected $action;
public function setUp()
{
$this->action = new MergeIndexes();
}
public function testSetSrcCore()
{
$this->action->setSrcCore(['coreA', 'coreB']);
$this->assertSame(['coreA', 'coreB'], $this->action->getSrcCore());
}
public function testSetIndexDir()
{
$this->action->setIndexDir(['/dirA', '/dirB']);
$this->assertSame(['/dirA', '/dirB'], $this->action->getIndexDir());
}
public function testGetType()
{
$this->assertSame('MERGEINDEXES', $this->action->getType());
}
}
<?php
namespace Solarium\Tests\QueryType\Server\CoreAdmin\Query\Action;
use PHPUnit\Framework\TestCase;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Reload;
class ReloadTest extends TestCase
{
/**
* @var Reload
*/
protected $action;
public function setUp()
{
$this->action = new Reload();
}
public function testGetType()
{
$this->assertSame('RELOAD', $this->action->getType());
}
}
<?php
namespace Solarium\Tests\QueryType\Server\CoreAdmin\Query\Action;
use PHPUnit\Framework\TestCase;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Rename;
class RenameTest extends TestCase
{
/**
* @var Rename
*/
protected $action;
public function setUp()
{
$this->action = new Rename();
}
public function testSetOther()
{
$this->action->setOther('newName');
$this->assertSame('newName', $this->action->getOther());
}
public function testGetType()
{
$this->assertSame('RENAME', $this->action->getType());
}
}
<?php
namespace Solarium\Tests\QueryType\Server\CoreAdmin\Query\Action;
use PHPUnit\Framework\TestCase;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\RequestRecovery;
class RequestRecoveryTest extends TestCase
{
/**
* @var RequestRecovery
*/
protected $action;
public function setUp()
{
$this->action = new RequestRecovery();
}
public function testGetType()
{
$this->assertSame('REQUESTRECOVERY', $this->action->getType());
}
}
<?php
namespace Solarium\Tests\QueryType\Server\CoreAdmin\Query\Action;
use PHPUnit\Framework\TestCase;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\RequestStatus;
class RequestStatusTest extends TestCase
{
/**
* @var RequestStatus
*/
protected $action;
public function setUp()
{
$this->action = new RequestStatus();
}
public function testSetRequestId()
{
$this->action->setRequestId('myAsyncId');
$this->assertSame('myAsyncId', $this->action->getRequestId());
}
public function testGetType()
{
$this->assertSame('REQUESTSTATUS', $this->action->getType());
}
}
<?php
namespace Solarium\Tests\QueryType\Server\CoreAdmin\Query\Action;
use PHPUnit\Framework\TestCase;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Split;
class SplitTest extends TestCase
{
/**
* @var Split
*/
protected $action;
public function setUp()
{
$this->action = new Split();
}
public function testSetPath()
{
$this->action->setPath(['/index1', '/index2']);
$this->assertSame(['/index1', '/index2'], $this->action->getPath());
}
public function testSetTargetCore()
{
$this->action->setTargetCore(['targetCoreA', 'targetCoreB']);
$this->assertSame(['targetCoreA', 'targetCoreB'], $this->action->getTargetCore());
}
public function testSetRanges()
{
$this->action->setRanges('0-1f4,1f5-3e8,3e9-5dc');
$this->assertSame('0-1f4,1f5-3e8,3e9-5dc', $this->action->getRanges());
}
public function testSetSplitKey()
{
$this->action->setSplitKey('A!');
$this->assertSame('A!', $this->action->getSplitKey());
}
public function testGetType()
{
$this->assertSame('SPLIT', $this->action->getType());
}
}
<?php
namespace Solarium\Tests\QueryType\Server\CoreAdmin\Query\Action;
use PHPUnit\Framework\TestCase;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Status;
class StatusTest extends TestCase
{
/**
* @var Status
*/
protected $action;
public function setUp()
{
$this->action = new Status();
}
public function testSetPath()
{
$this->action->setIndexInfo(true);
$this->assertTrue($this->action->getIndexInfo());
}
public function testGetType()
{
$this->assertSame('STATUS', $this->action->getType());
}
}
<?php
namespace Solarium\Tests\QueryType\Server\CoreAdmin\Query\Action;
use PHPUnit\Framework\TestCase;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Swap;
class SwapTest extends TestCase
{
/**
* @var Swap
*/
protected $action;
public function setUp()
{
$this->action = new Swap();
}
public function testSetOther()
{
$this->action->setOther('targetCore');
$this->assertSame('targetCore', $this->action->getOther());
}
public function testGetType()
{
$this->assertSame('SWAP', $this->action->getType());
}
}
<?php
namespace Solarium\Tests\QueryType\Server\CoreAdmin\Query\Action;
use PHPUnit\Framework\TestCase;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Unload;
class UnloadTest extends TestCase
{
/**
* @var Unload
*/
protected $action;
public function setUp()
{
$this->action = new Unload();
}
public function testSetDeleteDataDir()
{
$this->action->setDeleteDataDir(true);
$this->assertTrue($this->action->getDeleteDataDir());
}
public function testSetDeleteIndex()
{
$this->action->setDeleteIndex(true);
$this->assertTrue($this->action->getDeleteIndex());
}
public function testSetDeleteInstanceDir()
{
$this->action->setDeleteInstanceDir(true);
$this->assertTrue($this->action->getDeleteInstanceDir());
}
public function testGetType()
{
$this->assertSame('UNLOAD', $this->action->getType());
}
}
<?php
namespace Solarium\Tests\QueryType\Server\CoreAdmin\Query;
use PHPUnit\Framework\TestCase;
use Solarium\Core\Client\Client;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Create;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\MergeIndexes;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Reload;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Rename;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\RequestRecovery;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\RequestStatus;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Split;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Status;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Swap;
use Solarium\QueryType\Server\CoreAdmin\Query\Action\Unload;
use Solarium\QueryType\Server\CoreAdmin\Query\Query;
class QueryTest extends TestCase
{
/**
* @var Query
*/
protected $query;
public function setUp()
{
$this->query = new Query();
}
public function testGetType()
{
$this->assertSame(Client::QUERY_CORE_ADMIN, $this->query->getType());
}
public function testCreateCreate()
{
$action = $this->query->createCreate();
$this->assertInstanceOf(Create::class, $action, 'Can not create create action');
}
public function testCreateMergeIndexes()
{
$action = $this->query->createMergeIndexes();
$this->assertInstanceOf(MergeIndexes::class, $action, 'Can not create mergeindexes action');
}
public function testCreateReload()
{
$action = $this->query->createReload();
$this->assertInstanceOf(Reload::class, $action, 'Can not create reload action');
}
public function testCreateRename()
{
$action = $this->query->createRename();
$this->assertInstanceOf(Rename::class, $action, 'Can not create rename action');
}
public function testCreateRequestRecovery()
{
$action = $this->query->createRequestRecovery();
$this->assertInstanceOf(RequestRecovery::class, $action, 'Can not create request recovery action');
}
public function testCreateRequestStatus()
{
$action = $this->query->createRequestStatus();
$this->assertInstanceOf(RequestStatus::class, $action, 'Can not create request status action');
}
public function testCreateSplit()
{
$action = $this->query->createSplit();
$this->assertInstanceOf(Split::class, $action, 'Can not create split action');
}
public function testCreateStatus()
{
$action = $this->query->createStatus();
$this->assertInstanceOf(Status::class, $action, 'Can not create status action');
}
public function testCreateSwap()
{
$action = $this->query->createSwap();
$this->assertInstanceOf(Swap::class, $action, 'Can not create swap action');
}
public function testCreateUnload()
{
$action = $this->query->createUnload();
$this->assertInstanceOf(Unload::class, $action, 'Can not create unload action');
}
}
<?php
namespace Solarium\Tests\QueryType\Server\CoreAdmin;
use PHPUnit\Framework\TestCase;
use Solarium\Core\Client\Request;
use Solarium\QueryType\Server\CoreAdmin\Query\Query;
use Solarium\QueryType\Server\CoreAdmin\RequestBuilder;
class RequestBuilderTest extends TestCase
{
/**
* @var Query
*/
protected $query;
/**
* @var RequestBuilder
*/
protected $builder;
public function setUp()
{
$this->query = new Query();
$this->builder = new RequestBuilder();
}
public function testBuildParams()
{
$reload = $this->query->createReload();
$reload->setCore('foobar');
$this->query->setAction($reload);
$request = $this->builder->build($this->query);
$this->assertEquals(
[
'core' => 'foobar',
'wt' => 'json',
'json.nl' => 'flat',
'action' => 'RELOAD',
],
$request->getParams()
);
$this->assertSame(Request::METHOD_GET, $request->getMethod());
$this->assertTrue($request->getIsServerRequest());
$this->assertSame('admin/cores?wt=json&json.nl=flat&action=RELOAD&core=foobar', $request->getUri());
}
public function testCreate()
{
$create = $this->query->createCreate();
$create->setCore('myNewCore');
$create->setConfigSet('my_default_configSet');
$create->setCoreProperty('mycustomproperty', 'somethingspecial');
$this->query->setAction($create);
$request = $this->builder->build($this->query);
$this->assertSame(Request::METHOD_GET, $request->getMethod());
$expectedUri = 'admin/cores?wt=json&json.nl=flat&action=CREATE&name=myNewCore&configSet=my_default_configSet&'.
'property.mycustomproperty=somethingspecial';
$this->assertSame($expectedUri, $request->getUri());
}
public function testStatus()
{
$status = $this->query->createStatus();
$status->setCore('statusCore');
$status->setIndexInfo(true);
$this->query->setAction($status);
$request = $this->builder->build($this->query);
$this->assertSame(Request::METHOD_GET, $request->getMethod());
$expectedUri = 'admin/cores?wt=json&json.nl=flat&action=STATUS&core=statusCore&indexInfo=true';
$this->assertSame($expectedUri, $request->getUri());
}
public function testReload()
{
$reload = $this->query->createReload();
$reload->setCore('reloadMe');
$this->query->setAction($reload);
$request = $this->builder->build($this->query);
$this->assertSame(Request::METHOD_GET, $request->getMethod());
$expectedUri = 'admin/cores?wt=json&json.nl=flat&action=RELOAD&core=reloadMe';
$this->assertSame($expectedUri, $request->getUri());
}
public function testRename()
{
$rename = $this->query->createRename();
$rename->setCore('oldCore');
$rename->setOther('newCore');
$this->query->setAction($rename);
$request = $this->builder->build($this->query);
$this->assertSame(Request::METHOD_GET, $request->getMethod());
$expectedUri = 'admin/cores?wt=json&json.nl=flat&action=RENAME&core=oldCore&other=newCore';
$this->assertSame($expectedUri, $request->getUri());
}
public function testSwap()
{
$swap = $this->query->createSwap();
$swap->setCore('swapSource');
$swap->setOther('swapTarget');
$swap->setAsync('myHandle');
$this->query->setAction($swap);
$request = $this->builder->build($this->query);
$this->assertSame(Request::METHOD_GET, $request->getMethod());
$expectedUri = 'admin/cores?wt=json&json.nl=flat&action=SWAP&core=swapSource&other=swapTarget&async=myHandle';
$this->assertSame($expectedUri, $request->getUri());
}
public function testUnload()
{
$unload = $this->query->createUnload();
$unload->setCore('unloadMe');
$unload->setDeleteDataDir(true);
$this->query->setAction($unload);
$request = $this->builder->build($this->query);
$this->assertSame(Request::METHOD_GET, $request->getMethod());
$expectedUri = 'admin/cores?wt=json&json.nl=flat&action=UNLOAD&core=unloadMe&deleteDataDir=true';
$this->assertSame($expectedUri, $request->getUri());
}
public function testMergeIndexesBySrcCore()
{
$mergeIndexes = $this->query->createMergeIndexes();
$mergeIndexes->setCore('targetCore');
$mergeIndexes->setSrcCore(['oldCoreA', 'oldCoreB']);
$this->query->setAction($mergeIndexes);
$request = $this->builder->build($this->query);
$this->assertSame(Request::METHOD_GET, $request->getMethod());
$expectedUri = 'admin/cores?wt=json&json.nl=flat&action=MERGEINDEXES&core=targetCore&srcCore=oldCoreA&srcCore=oldCoreB';
$this->assertSame($expectedUri, $request->getUri());
}
public function testMergeIndexesByIndexDir()
{
$mergeIndexes = $this->query->createMergeIndexes();
$mergeIndexes->setCore('targetCore');
$mergeIndexes->setIndexDir(['/pathA/index', '/pathB/index']);
$this->query->setAction($mergeIndexes);
$request = $this->builder->build($this->query);
$this->assertSame(Request::METHOD_GET, $request->getMethod());
$expectedUri = 'admin/cores?wt=json&json.nl=flat&action=MERGEINDEXES&core=targetCore&indexDir=%2FpathA%2Findex&indexDir=%2FpathB%2Findex';
$this->assertSame($expectedUri, $request->getUri());
}
public function testSplitIntoTargetCore()
{
$split = $this->query->createSplit();
$split->setCore('splitMe');
$split->setTargetCore(['splittedA', 'splittedB']);
$split->setAsync('asyncKey');
$this->query->setAction($split);
$request = $this->builder->build($this->query);
$this->assertSame(Request::METHOD_GET, $request->getMethod());
$expectedUri = 'admin/cores?wt=json&json.nl=flat&action=SPLIT&core=splitMe&targetCore=splittedA&targetCore=splittedB&async=asyncKey';
$this->assertSame($expectedUri, $request->getUri());
}
public function testSplitIntoTargetPath()
{
$split = $this->query->createSplit();
$split->setCore('splitMe');
$split->setPath(['/corea/data', '/coreb/data']);
$split->setAsync('asyncKey');
$this->query->setAction($split);
$request = $this->builder->build($this->query);
$this->assertSame(Request::METHOD_GET, $request->getMethod());
$expectedUri = 'admin/cores?wt=json&json.nl=flat&action=SPLIT&core=splitMe&path=%2Fcorea%2Fdata&path=%2Fcoreb%2Fdata&async=asyncKey';
$this->assertSame($expectedUri, $request->getUri());
}
public function testSplitByKey()
{
$split = $this->query->createSplit();
$split->setCore('splitMe');
$split->setSplitKey('country');
$this->query->setAction($split);
$request = $this->builder->build($this->query);
$this->assertSame(Request::METHOD_GET, $request->getMethod());
$expectedUri = 'admin/cores?wt=json&json.nl=flat&action=SPLIT&core=splitMe&split.key=country';
$this->assertSame($expectedUri, $request->getUri());
}
public function testRequestStatus()
{
$requestStatus = $this->query->createRequestStatus();
$requestStatus->setRequestId('myAsyncIdentifier');
$this->query->setAction($requestStatus);
$request = $this->builder->build($this->query);
$this->assertSame(Request::METHOD_GET, $request->getMethod());
$expectedUri = 'admin/cores?wt=json&json.nl=flat&action=REQUESTSTATUS&requestid=myAsyncIdentifier';
$this->assertSame($expectedUri, $request->getUri());
}
public function testRequestRecovery()
{
$requestRecovery = $this->query->createRequestRecovery();
$requestRecovery->setCore('coreToRecover');
$this->query->setAction($requestRecovery);
$request = $this->builder->build($this->query);
$this->assertSame(Request::METHOD_GET, $request->getMethod());
$expectedUri = 'admin/cores?wt=json&json.nl=flat&action=REQUESTRECOVERY&core=coreToRecover';
$this->assertSame($expectedUri, $request->getUri());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment